diff options
author | furszy <matiasfurszyfer@protonmail.com> | 2023-03-07 18:48:21 -0300 |
---|---|---|
committer | furszy <matiasfurszyfer@protonmail.com> | 2023-03-10 11:29:37 -0300 |
commit | f3221d373a8623fe4808e00c7a92fbb6e0d6419b (patch) | |
tree | f86aab98f730ba398c2061c850f5375a0e784eb6 /test/functional/wallet_create_tx.py | |
parent | acf0119d24c9f8fae825093249a46cd38e4a3a91 (diff) | |
download | bitcoin-f3221d373a8623fe4808e00c7a92fbb6e0d6419b.tar.xz |
test: add wallet too-long-mempool-chain error coverage
Diffstat (limited to 'test/functional/wallet_create_tx.py')
-rwxr-xr-x | test/functional/wallet_create_tx.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/test/functional/wallet_create_tx.py b/test/functional/wallet_create_tx.py index 2d9bb38fcc..11c82e15b7 100755 --- a/test/functional/wallet_create_tx.py +++ b/test/functional/wallet_create_tx.py @@ -32,6 +32,7 @@ class CreateTxWalletTest(BitcoinTestFramework): self.test_anti_fee_sniping() self.test_tx_size_too_large() + self.test_create_too_long_mempool_chain() def test_anti_fee_sniping(self): self.log.info('Check that we have some (old) blocks and that anti-fee-sniping is disabled') @@ -80,6 +81,30 @@ class CreateTxWalletTest(BitcoinTestFramework): ) self.nodes[0].settxfee(0) + def test_create_too_long_mempool_chain(self): + self.log.info('Check too-long mempool chain error') + df_wallet = self.nodes[0].get_wallet_rpc(self.default_wallet_name) + + self.nodes[0].createwallet("too_long") + test_wallet = self.nodes[0].get_wallet_rpc("too_long") + + tx_data = df_wallet.send(outputs=[{test_wallet.getnewaddress(): 25}], options={"change_position": 0}) + txid = tx_data['txid'] + vout = 1 + + options = {"change_position": 0, "add_inputs": False} + for i in range(1, 25): + options['inputs'] = [{'txid': txid, 'vout': vout}] + tx_data = test_wallet.send(outputs=[{test_wallet.getnewaddress(): 25 - i}], options=options) + txid = tx_data['txid'] + + # Sending one more chained transaction will fail + options = {"minconf": 0, "include_unsafe": True, 'add_inputs': True} + assert_raises_rpc_error(-4, "Unconfirmed UTXOs are available, but spending them creates a chain of transactions that will be rejected by the mempool", + test_wallet.send, outputs=[{test_wallet.getnewaddress(): 0.3}], options=options) + + test_wallet.unloadwallet() + if __name__ == '__main__': CreateTxWalletTest().main() |