Skip to content

Commit

Permalink
Fix wallet_conflicts.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Neil committed Oct 29, 2024
1 parent 39a459f commit 23af9aa
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions test/functional/wallet_conflicts.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ def add_options(self, parser):

def set_test_params(self):
self.num_nodes = 3
self.extra_args = [
["-minrelaytxfee=0.00000001"],
["-minrelaytxfee=0.00000001"],
["-minrelaytxfee=0.00000001"],
]

def skip_test_if_missing_module(self):
self.skip_if_no_wallet()
Expand Down Expand Up @@ -49,7 +54,7 @@ def run_test(self):
# | tx2 | -----> | | | |
#
inputs_tx_AB_parent = [{"txid": txid_conflict_from_1, "vout": output_A}, {"txid": txid_conflict_from_2, "vout": output_B}]
tx_AB_parent = self.nodes[0].signrawtransactionwithwallet(self.nodes[0].createrawtransaction(inputs_tx_AB_parent, {self.nodes[0].getnewaddress(): Decimal("19.99998")}))
tx_AB_parent = self.nodes[0].signrawtransactionwithwallet(self.nodes[0].createrawtransaction(inputs_tx_AB_parent, {self.nodes[0].getnewaddress(): Decimal("19.98998")}))

# Secondly, create two transactions: One consuming output_A, and another one consuming output_B
#
Expand All @@ -59,18 +64,18 @@ def run_test(self):
#
inputs_tx_A_1 = [{"txid": txid_conflict_from_1, "vout": output_A}]
inputs_tx_B_1 = [{"txid": txid_conflict_from_2, "vout": output_B}]
tx_A_1 = self.nodes[0].signrawtransactionwithwallet(self.nodes[0].createrawtransaction(inputs_tx_A_1, {self.nodes[0].getnewaddress(): Decimal("9.99998")}))
tx_B_1 = self.nodes[0].signrawtransactionwithwallet(self.nodes[0].createrawtransaction(inputs_tx_B_1, {self.nodes[0].getnewaddress(): Decimal("9.99998")}))
tx_A_1 = self.nodes[0].signrawtransactionwithwallet(self.nodes[0].createrawtransaction(inputs_tx_A_1, {self.nodes[0].getnewaddress(): Decimal("9.98998")}))
tx_B_1 = self.nodes[0].signrawtransactionwithwallet(self.nodes[0].createrawtransaction(inputs_tx_B_1, {self.nodes[0].getnewaddress(): Decimal("9.98998")}))

self.log.info("Broadcast conflicted transaction")
txid_AB_parent = self.nodes[0].sendrawtransaction(tx_AB_parent["hex"])
self.generate(self.nodes[0], 1, sync_fun=self.no_op)

# Now that 'AB_parent_tx' was broadcast, build 'Child_Tx'
output_c = self.get_utxo_of_value(from_tx_id=txid_AB_parent, search_value=19.99998)
output_c = self.get_utxo_of_value(from_tx_id=txid_AB_parent, search_value=19.98998)
inputs_tx_C_child = [({"txid": txid_AB_parent, "vout": output_c})]

tx_C_child = self.nodes[0].signrawtransactionwithwallet(self.nodes[0].createrawtransaction(inputs_tx_C_child, {self.nodes[0].getnewaddress() : Decimal("19.99996")}))
tx_C_child = self.nodes[0].signrawtransactionwithwallet(self.nodes[0].createrawtransaction(inputs_tx_C_child, {self.nodes[0].getnewaddress() : Decimal("19.98996")}))
tx_C_child_txid = self.nodes[0].sendrawtransaction(tx_C_child["hex"])
self.generate(self.nodes[0], 1, sync_fun=self.no_op)

Expand Down Expand Up @@ -121,7 +126,7 @@ def run_test(self):
self.sync_blocks()
former_conflicted = self.nodes[0].gettransaction(txid_AB_parent)
assert_equal(former_conflicted["confirmations"], 1)
assert_equal(former_conflicted["blockheight"], 217)
assert_equal(former_conflicted["blockheight"], 2117)

if __name__ == '__main__':
TxConflicts().main()

0 comments on commit 23af9aa

Please sign in to comment.