Skip to content

Commit f3221d3

Browse files
committed
test: add wallet too-long-mempool-chain error coverage
1 parent acf0119 commit f3221d3

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

test/functional/wallet_create_tx.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ def run_test(self):
3232

3333
self.test_anti_fee_sniping()
3434
self.test_tx_size_too_large()
35+
self.test_create_too_long_mempool_chain()
3536

3637
def test_anti_fee_sniping(self):
3738
self.log.info('Check that we have some (old) blocks and that anti-fee-sniping is disabled')
@@ -80,6 +81,30 @@ def test_tx_size_too_large(self):
8081
)
8182
self.nodes[0].settxfee(0)
8283

84+
def test_create_too_long_mempool_chain(self):
85+
self.log.info('Check too-long mempool chain error')
86+
df_wallet = self.nodes[0].get_wallet_rpc(self.default_wallet_name)
87+
88+
self.nodes[0].createwallet("too_long")
89+
test_wallet = self.nodes[0].get_wallet_rpc("too_long")
90+
91+
tx_data = df_wallet.send(outputs=[{test_wallet.getnewaddress(): 25}], options={"change_position": 0})
92+
txid = tx_data['txid']
93+
vout = 1
94+
95+
options = {"change_position": 0, "add_inputs": False}
96+
for i in range(1, 25):
97+
options['inputs'] = [{'txid': txid, 'vout': vout}]
98+
tx_data = test_wallet.send(outputs=[{test_wallet.getnewaddress(): 25 - i}], options=options)
99+
txid = tx_data['txid']
100+
101+
# Sending one more chained transaction will fail
102+
options = {"minconf": 0, "include_unsafe": True, 'add_inputs': True}
103+
assert_raises_rpc_error(-4, "Unconfirmed UTXOs are available, but spending them creates a chain of transactions that will be rejected by the mempool",
104+
test_wallet.send, outputs=[{test_wallet.getnewaddress(): 0.3}], options=options)
105+
106+
test_wallet.unloadwallet()
107+
83108

84109
if __name__ == '__main__':
85110
CreateTxWalletTest().main()

0 commit comments

Comments
 (0)