Merge #18753: test: Fix intermittent failure in wallet_importmulti

fa8b9b5d1f48ad95eecf47ebbd7bf374777fc621 test: Fix intermittent failure in wallet_importmulti (MarcoFalke)

Pull request description:

  The wallet is async, so after generating a block, we must call `syncwithvalidationinterfacequeue`. Otherwise the timestamp will be of the previous block.

  https://travis-ci.org/github/bitcoin/bitcoin/jobs/677685073#L2648

ACKs for top commit:
  promag:
    ACK fa8b9b5d1f48ad95eecf47ebbd7bf374777fc621.

Tree-SHA512: c21f9912aabbe22019d4ac9d0da06d6e46ef7f2a84d2781110e04c9836eb0ecf90a22cf2bae7f608be611670d17b20600135d1c5e5404aa1e762839816285fb4
This commit is contained in:
MarcoFalke 2020-04-26 10:47:31 -04:00 committed by Pasta
parent b330a1adbd
commit 1c3be8f61b
No known key found for this signature in database
GPG Key ID: 52527BEDABE87984

View File

@ -52,6 +52,7 @@ Multisig = namedtuple('Multisig', ['privkeys',
'p2sh_addr', 'p2sh_addr',
'redeem_script']) 'redeem_script'])
class ImportMultiTest(BitcoinTestFramework): class ImportMultiTest(BitcoinTestFramework):
def set_test_params(self): def set_test_params(self):
self.num_nodes = 2 self.num_nodes = 2
@ -97,7 +98,7 @@ class ImportMultiTest(BitcoinTestFramework):
result = self.nodes[1].importmulti([req]) result = self.nodes[1].importmulti([req])
observed_warnings = [] observed_warnings = []
if 'warnings' in result[0]: if 'warnings' in result[0]:
observed_warnings = result[0]['warnings'] observed_warnings = result[0]['warnings']
assert_equal("\n".join(sorted(warnings)), "\n".join(sorted(observed_warnings))) assert_equal("\n".join(sorted(warnings)), "\n".join(sorted(observed_warnings)))
assert_equal(result[0]['success'], success) assert_equal(result[0]['success'], success)
if error_code is not None: if error_code is not None:
@ -119,6 +120,7 @@ class ImportMultiTest(BitcoinTestFramework):
self.nodes[0].generate(1) self.nodes[0].generate(1)
self.nodes[1].generate(1) self.nodes[1].generate(1)
timestamp = self.nodes[1].getblock(self.nodes[1].getbestblockhash())['mediantime'] timestamp = self.nodes[1].getblock(self.nodes[1].getbestblockhash())['mediantime']
self.nodes[1].syncwithvalidationinterfacequeue()
node0_address1 = self.nodes[0].getaddressinfo(self.nodes[0].getnewaddress()) node0_address1 = self.nodes[0].getaddressinfo(self.nodes[0].getnewaddress())
@ -312,6 +314,7 @@ class ImportMultiTest(BitcoinTestFramework):
self.nodes[1].sendtoaddress(multisig.p2sh_addr, 10.00) self.nodes[1].sendtoaddress(multisig.p2sh_addr, 10.00)
self.nodes[1].generate(1) self.nodes[1].generate(1)
timestamp = self.nodes[1].getblock(self.nodes[1].getbestblockhash())['mediantime'] timestamp = self.nodes[1].getblock(self.nodes[1].getbestblockhash())['mediantime']
self.nodes[1].syncwithvalidationinterfacequeue()
self.log.info("Should import a p2sh") self.log.info("Should import a p2sh")
self.test_importmulti({"scriptPubKey": {"address": multisig.p2sh_addr}, self.test_importmulti({"scriptPubKey": {"address": multisig.p2sh_addr},
@ -331,6 +334,7 @@ class ImportMultiTest(BitcoinTestFramework):
self.nodes[1].sendtoaddress(multisig.p2sh_addr, 10.00) self.nodes[1].sendtoaddress(multisig.p2sh_addr, 10.00)
self.nodes[1].generate(1) self.nodes[1].generate(1)
timestamp = self.nodes[1].getblock(self.nodes[1].getbestblockhash())['mediantime'] timestamp = self.nodes[1].getblock(self.nodes[1].getbestblockhash())['mediantime']
self.nodes[1].syncwithvalidationinterfacequeue()
self.log.info("Should import a p2sh with respective redeem script") self.log.info("Should import a p2sh with respective redeem script")
self.test_importmulti({"scriptPubKey": {"address": multisig.p2sh_addr}, self.test_importmulti({"scriptPubKey": {"address": multisig.p2sh_addr},
@ -350,6 +354,7 @@ class ImportMultiTest(BitcoinTestFramework):
self.nodes[1].sendtoaddress(multisig.p2sh_addr, 10.00) self.nodes[1].sendtoaddress(multisig.p2sh_addr, 10.00)
self.nodes[1].generate(1) self.nodes[1].generate(1)
timestamp = self.nodes[1].getblock(self.nodes[1].getbestblockhash())['mediantime'] timestamp = self.nodes[1].getblock(self.nodes[1].getbestblockhash())['mediantime']
self.nodes[1].syncwithvalidationinterfacequeue()
self.log.info("Should import a p2sh with respective redeem script and private keys") self.log.info("Should import a p2sh with respective redeem script and private keys")
self.test_importmulti({"scriptPubKey": {"address": multisig.p2sh_addr}, self.test_importmulti({"scriptPubKey": {"address": multisig.p2sh_addr},
@ -374,6 +379,7 @@ class ImportMultiTest(BitcoinTestFramework):
self.nodes[1].sendtoaddress(multisig.p2sh_addr, 10.00) self.nodes[1].sendtoaddress(multisig.p2sh_addr, 10.00)
self.nodes[1].generate(1) self.nodes[1].generate(1)
timestamp = self.nodes[1].getblock(self.nodes[1].getbestblockhash())['mediantime'] timestamp = self.nodes[1].getblock(self.nodes[1].getbestblockhash())['mediantime']
self.nodes[1].syncwithvalidationinterfacequeue()
self.log.info("Should import a p2sh with respective redeem script and private keys") self.log.info("Should import a p2sh with respective redeem script and private keys")
self.test_importmulti({"scriptPubKey": {"address": multisig.p2sh_addr}, self.test_importmulti({"scriptPubKey": {"address": multisig.p2sh_addr},
@ -561,5 +567,6 @@ class ImportMultiTest(BitcoinTestFramework):
iswatchonly=False) iswatchonly=False)
if __name__ == '__main__': if __name__ == '__main__':
ImportMultiTest().main() ImportMultiTest().main()