test: run mempool_spend_coinbase.py even with wallet disabled #20385
pull mjdietzx wants to merge 1 commits into bitcoin:master from mjdietzx:mempool-tests-to-miniwallet changing 2 files +30 −15-
mjdietzx commented at 10:57 pm on November 13, 2020: contributorRun the mempool spend coinbase test even when the wallet was not compiled, as proposed in #20078.
-
fanquake added the label Tests on Nov 13, 2020
-
in test/functional/mempool_spend_coinbase.py:38 in ca75db9c66 outdated
40+ # too immature to spend. 41 b = [self.nodes[0].getblockhash(n) for n in range(101, 103)] 42 coinbase_txids = [self.nodes[0].getblock(h)['tx'][0] for h in b] 43- spends_raw = [create_raw_transaction(self.nodes[0], txid, node0_address, amount=49.99) for txid in coinbase_txids] 44+ utxo_101 = next(filter(lambda utxo: coinbase_txids[0] == utxo['txid'], wallet._utxos)) 45+ utxo_102 = next(filter(lambda utxo: coinbase_txids[1] == utxo['txid'], wallet._utxos))
MarcoFalke commented at 8:47 am on November 14, 2020:_utxos is a private member, so you can’t read it directly. It needs to be accessed via a getter method that also marks the utxo as spent (pops it)
mjdietzx commented at 3:41 pm on November 14, 2020:Good point. What do you think of this approach? https://github.com/bitcoin/bitcoin/pull/20385/commits/650ba88013ff0fb8cf08b00d5e7c674cf5b16a22 -
in test/functional/mempool_spend_coinbase.py:45 in ca75db9c66 outdated
49 50 # coinbase at height 102 should be too immature to spend 51- assert_raises_rpc_error(-26,"bad-txns-premature-spend-of-coinbase", self.nodes[0].sendrawtransaction, spends_raw[1]) 52+ assert_raises_rpc_error(-26, 53+ "bad-txns-premature-spend-of-coinbase", 54+ lambda utxo: wallet.send_self_transfer(from_node=self.nodes[0], utxo_to_spend=utxo),
MarcoFalke commented at 8:48 am on November 14, 2020:0 lambda: wallet.send_self_transfer(from_node=self.nodes[0], utxo_to_spend=utxo_102),
-
MarcoFalke approved
-
MarcoFalke commented at 8:48 am on November 14, 2020: memberApproach ACK
-
promag commented at 11:08 am on November 14, 2020: memberConcept ACK.
-
in test/functional/test_framework/wallet.py:43 in 650ba88013 outdated
39@@ -40,9 +40,20 @@ def generate(self, num_blocks): 40 self._utxos.append({'txid': cb_tx['txid'], 'vout': 0, 'value': cb_tx['vout'][0]['value']}) 41 return blocks 42 43- def get_utxo(self): 44- """Return the last utxo. Can be used to get the change output immediately after a send_self_transfer""" 45- return self._utxos.pop() 46+ def get_utxo(self, txid=''):
MarcoFalke commented at 5:55 pm on November 15, 2020:0 def get_utxo(self, *, txid=''):
please force named arguments for this
mjdietzx commented at 6:22 pm on November 15, 2020:done -
MarcoFalke approved
-
MarcoFalke commented at 5:55 pm on November 15, 2020: memberACK. Could squash and rebase
-
mjdietzx force-pushed on Nov 15, 2020
-
MarcoFalke commented at 7:18 am on November 16, 2020: memberPlease squash your commits according to https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#squashing-commits
-
test: run mempool_spend_coinbase.py even with wallet disabled 21f2433601
-
mjdietzx force-pushed on Nov 16, 2020
-
mjdietzx commented at 3:58 pm on November 16, 2020: contributorI squashed the commits as requested. Going forward with these
MiniWallet
test “refactors”, should I continue to make one PR per test file rewrite, or should I batch multiple test file rewrites in each PR? -
laanwj commented at 3:39 pm on November 19, 2020: memberACK 21f24336019d438e225c7bd6653871119883a4ee
-
laanwj merged this on Nov 19, 2020
-
laanwj closed this on Nov 19, 2020
-
MarcoFalke commented at 3:47 pm on November 19, 2020: member
should I continue to make one PR per test file rewrite, or should I batch multiple test file rewrites in each PR?
Whatever makes more sense to you
-
sidhujag referenced this in commit a705f27e5e on Nov 19, 2020
-
mjdietzx deleted the branch on Nov 19, 2020
-
deadalnix referenced this in commit 452c543ebc on Jan 11, 2022
-
DrahtBot locked this on Feb 15, 2022
mjdietzx
MarcoFalke
promag
laanwj
Labels
Tests