66from test_framework .test_framework import BitcoinTestFramework
77from test_framework .util import (
88 connect_nodes_bi ,
9- disconnect_nodes ,
109 get_auth_cookie ,
1110 get_datadir_path ,
1211 rpc_port ,
@@ -538,6 +537,7 @@ def run_test(self):
538537 # Watch the address so we can get tx without txindex
539538 parent .importaddress (mainchain_addr )
540539 claim_block = parent .generatetoaddress (50 , mainchain_addr )[0 ]
540+ self .sync_all (self .node_groups )
541541 block_coinbase = parent .getblock (claim_block , 2 )["tx" ][0 ]
542542 claim_txid = block_coinbase ["txid" ]
543543 claim_tx = block_coinbase ["hex" ]
@@ -553,11 +553,13 @@ def run_test(self):
553553
554554 # 50 more blocks to allow wallet to make it succeed by relay and consensus
555555 parent .generatetoaddress (50 , parent .getnewaddress ())
556+ self .sync_all (self .node_groups )
556557 # Wallet still doesn't want to for 2 more confirms
557558 assert_equal (sidechain .createrawpegin (claim_tx , claim_proof )["mature" ], False )
558559 # But we can just shoot it off
559560 claim_txid = sidechain .sendrawtransaction (signed_pegin )
560561 sidechain .generatetoaddress (1 , sidechain .getnewaddress ())
562+ self .sync_all (self .node_groups )
561563 assert_equal (sidechain .gettransaction (claim_txid )["confirmations" ], 1 )
562564
563565 # Test a confidential pegin.
@@ -569,6 +571,7 @@ def run_test(self):
569571 txid_fund = parent .sendtoaddress (pegin_addr , 10 )
570572 # 10+2 confirms required to get into mempool and confirm
571573 parent .generate (11 )
574+ self .sync_all (self .node_groups )
572575 proof = parent .gettxoutproof ([txid_fund ])
573576 raw = parent .gettransaction (txid_fund )["hex" ]
574577 raw_pegin = sidechain .createrawpegin (raw , proof )['hex' ]
@@ -579,6 +582,8 @@ def run_test(self):
579582 blind_addr = sidechain .getnewaddress ("" , "blech32" )
580583 sidechain .sendtoaddress (blind_addr , 15 )
581584 sidechain .generate (6 )
585+ # Make sure sidechain2 knows about the same input
586+ self .sync_all (self .node_groups )
582587 unspent = [u for u in sidechain .listunspent (6 , 6 ) if u ["amount" ] == 15 ][0 ]
583588 assert (unspent ["spendable" ])
584589 assert ("amountcommitment" in unspent )
@@ -615,23 +620,14 @@ def run_test(self):
615620 assert (final_decoded ["vout" ][1 ]["commitmentnonce_fully_valid" ])
616621 assert ("value" in final_decoded ["vout" ][2 ])
617622 assert ("asset" in final_decoded ["vout" ][2 ])
618- # check that it is accepted in the mempool
623+ # check that it is accepted in either mempool
619624 accepted = sidechain .testmempoolaccept ([pegin_signed ["hex" ]])[0 ]
625+ if not accepted ["allowed" ]:
626+ raise Exception (accepted ["reject-reason" ])
627+ accepted = sidechain2 .testmempoolaccept ([pegin_signed ["hex" ]])[0 ]
620628 if not accepted ["allowed" ]:
621629 raise Exception (accepted ["reject-reason" ])
622630 print ("Blinded transaction looks ok!" ) # need this print to distinguish failures in for loop
623- # check if they get mined; since we're trying to mine two double spends, disconnect the nodes
624- disconnect_nodes (sidechain , 3 )
625- disconnect_nodes (sidechain2 , 2 )
626- txid1 = sidechain .sendrawtransaction (pegin_signed1 ["hex" ])
627- blocks = sidechain .generate (3 )
628- assert_equal (sidechain .getrawtransaction (txid1 , True , blocks [0 ])["confirmations" ], 3 )
629- txid2 = sidechain2 .sendrawtransaction (pegin_signed2 ["hex" ])
630- blocks = sidechain2 .generate (3 )
631- assert_equal (sidechain2 .getrawtransaction (txid2 , True , blocks [0 ])["confirmations" ], 3 )
632- # reconnect in case we extend the test
633- connect_nodes_bi (self .nodes , 2 , 3 )
634- sidechain .generate (10 )
635631
636632 print ('Success!' )
637633
0 commit comments