Run the mempool spend coinbase test even when the wallet was not compiled, as proposed in #20078.
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: contributor
- 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:lambda: wallet.send_self_transfer(from_node=self.nodes[0], utxo_to_spend=utxo_102),MarcoFalke approvedMarcoFalke 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:def get_utxo(self, *, txid=''):please force named arguments for this
mjdietzx commented at 6:22 PM on November 15, 2020:done
MarcoFalke approvedMarcoFalke commented at 5:55 PM on November 15, 2020: memberACK. Could squash and rebase
mjdietzx force-pushed on Nov 15, 2020MarcoFalke 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 21f2433601mjdietzx force-pushed on Nov 16, 2020mjdietzx commented at 3:58 PM on November 16, 2020: contributorI squashed the commits as requested. Going forward with these
MiniWallettest "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, 2020laanwj closed this on Nov 19, 2020MarcoFalke commented at 3:47 PM on November 19, 2020: membershould 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, 2020mjdietzx deleted the branch on Nov 19, 2020deadalnix referenced this in commit 452c543ebc on Jan 11, 2022DrahtBot locked this on Feb 15, 2022ContributorsLabels
This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-20 18:14 UTC
More mirrored repositories can be found on mirror.b10c.me