@@ -32,6 +32,7 @@ def run_test(self):
32
32
33
33
self .test_anti_fee_sniping ()
34
34
self .test_tx_size_too_large ()
35
+ self .test_create_too_long_mempool_chain ()
35
36
36
37
def test_anti_fee_sniping (self ):
37
38
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):
80
81
)
81
82
self .nodes [0 ].settxfee (0 )
82
83
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
+
83
108
84
109
if __name__ == '__main__' :
85
110
CreateTxWalletTest ().main ()
0 commit comments