@@ -165,23 +165,36 @@ def test_truc_replacement(self):
165165 def test_truc_reorg (self ):
166166 node = self .nodes [0 ]
167167 self .log .info ("Test that, during a reorg, TRUC rules are not enforced" )
168- tx_v2_block = self .wallet .send_self_transfer (from_node = node , version = 2 )
169- tx_v3_block = self .wallet .send_self_transfer (from_node = node , version = 3 )
170- tx_v3_block2 = self .wallet .send_self_transfer (from_node = node , version = 3 )
171- self .check_mempool ([tx_v3_block ["txid" ], tx_v2_block ["txid" ], tx_v3_block2 ["txid" ]])
168+ self .check_mempool ([])
169+
170+ # Testing 2<-3 versions allowed
171+ tx_v2_block = self .wallet .create_self_transfer (version = 2 )
172+
173+ # Testing 3<-2 versions allowed
174+ tx_v3_block = self .wallet .create_self_transfer (version = 3 )
175+
176+ # Testing overly-large child size
177+ tx_v3_block2 = self .wallet .create_self_transfer (version = 3 )
178+
179+ # Also create a linear chain of 3 TRUC transactions that will be directly mined, followed by one v2 in-mempool after block is made
180+ tx_chain_1 = self .wallet .create_self_transfer (version = 3 )
181+ tx_chain_2 = self .wallet .create_self_transfer (utxo_to_spend = tx_chain_1 ["new_utxo" ], version = 3 )
182+ tx_chain_3 = self .wallet .create_self_transfer (utxo_to_spend = tx_chain_2 ["new_utxo" ], version = 3 )
183+
184+ 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" ]]
185+ block = self .generateblock (node , output = "raw(42)" , transactions = tx_to_mine )
172186
173- block = self .generate (node , 1 )
174187 self .check_mempool ([])
175188 tx_v2_from_v3 = self .wallet .send_self_transfer (from_node = node , utxo_to_spend = tx_v3_block ["new_utxo" ], version = 2 )
176189 tx_v3_from_v2 = self .wallet .send_self_transfer (from_node = node , utxo_to_spend = tx_v2_block ["new_utxo" ], version = 3 )
177190 tx_v3_child_large = self .wallet .send_self_transfer (from_node = node , utxo_to_spend = tx_v3_block2 ["new_utxo" ], target_vsize = 1250 , version = 3 )
178191 assert_greater_than (node .getmempoolentry (tx_v3_child_large ["txid" ])["vsize" ], TRUC_CHILD_MAX_VSIZE )
179- self .check_mempool ([tx_v2_from_v3 ["txid" ], tx_v3_from_v2 ["txid" ], tx_v3_child_large ["txid" ]])
180- node .invalidateblock (block [0 ])
181- 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" ]])
182- # This is needed because generate() will create the exact same block again.
183- node .reconsiderblock (block [0 ])
192+ tx_chain_4 = self .wallet .send_self_transfer (from_node = node , utxo_to_spend = tx_chain_3 ["new_utxo" ], version = 2 )
193+ self .check_mempool ([tx_v2_from_v3 ["txid" ], tx_v3_from_v2 ["txid" ], tx_v3_child_large ["txid" ], tx_chain_4 ["txid" ]])
184194
195+ # Reorg should have all block transactions re-accepted, ignoring TRUC enforcement
196+ node .invalidateblock (block ["hash" ])
197+ 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" ]])
185198
186199 @cleanup (extra_args = ["-limitdescendantsize=10" ])
187200 def test_nondefault_package_limits (self ):
0 commit comments