test: Add sync_all points after block generation to RPC tests

Previously we only required synchronization points where blocks were
sent between nodes; now we need them between action and query operations
on the same node, because wallet notification of mined blocks no longer
occurs in real-time.
This commit is contained in:
Jack Grigg 2019-12-18 14:34:39 -06:00
parent 8af85a0d10
commit f7eaf921bc
No known key found for this signature in database
GPG Key ID: 9E8255172BBF9898
9 changed files with 14 additions and 0 deletions

View File

@ -56,6 +56,7 @@ class MempoolCoinbaseTest(BitcoinTestFramework):
spends2_id = [ self.nodes[0].sendrawtransaction(tx) for tx in spends2_raw ]
blocks.extend(self.nodes[0].generate(1))
self.sync_all()
# mempool should be empty, all txns confirmed
assert_equal(set(self.nodes[0].getrawmempool()), set())
@ -76,6 +77,8 @@ class MempoolCoinbaseTest(BitcoinTestFramework):
# Generate another block, they should all get mined
self.nodes[0].generate(1)
self.sync_all()
# mempool should be empty, all txns confirmed
assert_equal(set(self.nodes[0].getrawmempool()), set())
for txid in spends1_id+spends2_id:

View File

@ -62,6 +62,7 @@ class MergeToAddressHelper:
do_not_shield_taddr = test.nodes[0].getnewaddress()
test.nodes[0].generate(4)
test.sync_all()
walletinfo = test.nodes[0].getwalletinfo()
assert_equal(walletinfo['immature_balance'], 50)
assert_equal(walletinfo['balance'], 0)

View File

@ -37,6 +37,7 @@ class PaymentDisclosureTest (BitcoinTestFramework):
print "Mining blocks..."
self.nodes[0].generate(4)
self.sync_all()
walletinfo = self.nodes[0].getwalletinfo()
assert_equal(walletinfo['immature_balance'], 40)
assert_equal(walletinfo['balance'], 0)

View File

@ -32,6 +32,7 @@ class WalletTest (BitcoinTestFramework):
print "Mining blocks..."
self.nodes[0].generate(4)
self.sync_all()
walletinfo = self.nodes[0].getwalletinfo()
assert_equal(walletinfo['immature_balance'], 40)

View File

@ -48,6 +48,7 @@ class Wallet1941RegressionTest (BitcoinTestFramework):
self.nodes[0].setmocktime(starttime)
self.nodes[0].generate(101)
self.sync_all()
mytaddr = get_coinbase_address(self.nodes[0])
myzaddr = self.nodes[0].z_getnewaddress('sprout')
@ -66,6 +67,7 @@ class Wallet1941RegressionTest (BitcoinTestFramework):
self.nodes[0].generate(1)
self.nodes[0].setmocktime(starttime + 9000)
self.nodes[0].generate(1)
self.sync_all()
# Confirm the balance on node 0.
resp = self.nodes[0].z_getbalance(myzaddr)

View File

@ -29,6 +29,7 @@ class WalletAnchorForkTest (BitcoinTestFramework):
def run_test (self):
print "Mining blocks..."
self.nodes[0].generate(4)
self.sync_all()
walletinfo = self.nodes[0].getwalletinfo()
assert_equal(walletinfo['immature_balance'], 40)

View File

@ -39,6 +39,7 @@ class WalletShieldCoinbaseTest (BitcoinTestFramework):
self.nodes[0].generate(1)
self.nodes[0].generate(4)
self.sync_all()
walletinfo = self.nodes[0].getwalletinfo()
assert_equal(walletinfo['immature_balance'], 50)
assert_equal(walletinfo['balance'], 0)

View File

@ -93,6 +93,7 @@ class WalletBackupTest(BitcoinTestFramework):
# Must sync mempools before mining.
sync_mempools(self.nodes)
self.nodes[3].generate(1)
self.sync_all()
# As above, this mirrors the original bash test.
def start_three(self):

View File

@ -32,6 +32,7 @@ class JoinSplitTest(BitcoinTestFramework):
shield_tx = self.nodes[0].signrawtransaction(joinsplit_result["rawtxn"])
self.nodes[0].sendrawtransaction(shield_tx["hex"])
self.nodes[0].generate(1)
self.sync_all()
receive_result = self.nodes[0].zcrawreceive(zcsecretkey, joinsplit_result["encryptednote1"])
assert_equal(receive_result["exists"], True)
@ -41,6 +42,7 @@ class JoinSplitTest(BitcoinTestFramework):
addrtest = self.nodes[0].getnewaddress()
for xx in range(0,10):
self.nodes[0].generate(1)
self.sync_all()
for x in range(0,50):
self.nodes[0].sendtoaddress(addrtest, 0.01);
@ -49,6 +51,7 @@ class JoinSplitTest(BitcoinTestFramework):
self.nodes[0].sendrawtransaction(joinsplit_result["rawtxn"])
self.nodes[0].generate(1)
self.sync_all()
print "Done!"
receive_result = self.nodes[0].zcrawreceive(zcsecretkey, joinsplit_result["encryptednote1"])