@@ -191,23 +191,36 @@ def test_truc_bip125(self):
191191 def test_truc_reorg (self ):
192192 node = self .nodes [0 ]
193193 self .log .info ("Test that, during a reorg, TRUC rules are not enforced" )
194- tx_v2_block = self .wallet .send_self_transfer (from_node = node , version = 2 )
195- tx_v3_block = self .wallet .send_self_transfer (from_node = node , version = 3 )
196- tx_v3_block2 = self .wallet .send_self_transfer (from_node = node , version = 3 )
197- self .check_mempool ([tx_v3_block ["txid" ], tx_v2_block ["txid" ], tx_v3_block2 ["txid" ]])
194+ self .check_mempool ([])
195+
196+ # Testing 2<-3 versions allowed
197+ tx_v2_block = self .wallet .create_self_transfer (version = 2 )
198+
199+ # Testing 3<-2 versions allowed
200+ tx_v3_block = self .wallet .create_self_transfer (version = 3 )
201+
202+ # Testing overly-large child size
203+ tx_v3_block2 = self .wallet .create_self_transfer (version = 3 )
204+
205+ # Also create a linear chain of 3 TRUC transactions that will be directly mined, followed by one v2 in-mempool after block is made
206+ tx_chain_1 = self .wallet .create_self_transfer (version = 3 )
207+ tx_chain_2 = self .wallet .create_self_transfer (utxo_to_spend = tx_chain_1 ["new_utxo" ], version = 3 )
208+ tx_chain_3 = self .wallet .create_self_transfer (utxo_to_spend = tx_chain_2 ["new_utxo" ], version = 3 )
209+
210+ tx_to_mine = [tx_v3_block ["hex" ], tx_v2_block ["hex" ], tx_v3_block2 ["hex" ], tx_chain_1 ["hex" ], tx_chain_2 ["hex" ], tx_chain_3 ["hex" ]]
211+ block = self .generateblock (node , output = "raw(42)" , transactions = tx_to_mine )
198212
199- block = self .generate (node , 1 )
200213 self .check_mempool ([])
201214 tx_v2_from_v3 = self .wallet .send_self_transfer (from_node = node , utxo_to_spend = tx_v3_block ["new_utxo" ], version = 2 )
202215 tx_v3_from_v2 = self .wallet .send_self_transfer (from_node = node , utxo_to_spend = tx_v2_block ["new_utxo" ], version = 3 )
203216 tx_v3_child_large = self .wallet .send_self_transfer (from_node = node , utxo_to_spend = tx_v3_block2 ["new_utxo" ], target_weight = 5000 , version = 3 )
204217 assert_greater_than (node .getmempoolentry (tx_v3_child_large ["txid" ])["vsize" ], 1000 )
205- self .check_mempool ([tx_v2_from_v3 ["txid" ], tx_v3_from_v2 ["txid" ], tx_v3_child_large ["txid" ]])
206- node .invalidateblock (block [0 ])
207- self .check_mempool ([tx_v3_block ["txid" ], tx_v2_block ["txid" ], tx_v3_block2 ["txid" ], tx_v2_from_v3 ["txid" ], tx_v3_from_v2 ["txid" ], tx_v3_child_large ["txid" ]])
208- # This is needed because generate() will create the exact same block again.
209- node .reconsiderblock (block [0 ])
218+ tx_chain_4 = self .wallet .send_self_transfer (from_node = node , utxo_to_spend = tx_chain_3 ["new_utxo" ], version = 2 )
219+ self .check_mempool ([tx_v2_from_v3 ["txid" ], tx_v3_from_v2 ["txid" ], tx_v3_child_large ["txid" ], tx_chain_4 ["txid" ]])
210220
221+ # Reorg should have all block transactions re-accepted, ignoring TRUC enforcement
222+ node .invalidateblock (block ["hash" ])
223+ self .check_mempool ([tx_v3_block ["txid" ], tx_v2_block ["txid" ], tx_v3_block2 ["txid" ], tx_v2_from_v3 ["txid" ], tx_v3_from_v2 ["txid" ], tx_v3_child_large ["txid" ], tx_chain_1 ["txid" ], tx_chain_2 ["txid" ], tx_chain_3 ["txid" ], tx_chain_4 ["txid" ]])
211224
212225 @cleanup (extra_args = ["-limitdescendantsize=10" , "-datacarriersize=40000" ])
213226 def test_nondefault_package_limits (self ):
0 commit comments