test: Pass at most one node group to sync_all
This commit is contained in:
parent
fa4680ed09
commit
fafe008cb4
5 changed files with 28 additions and 29 deletions
test/functional
|
@ -33,7 +33,7 @@ class WalletTest(BitcoinTestFramework):
|
|||
connect_nodes_bi(self.nodes, 0, 1)
|
||||
connect_nodes_bi(self.nodes, 1, 2)
|
||||
connect_nodes_bi(self.nodes, 0, 2)
|
||||
self.sync_all([self.nodes[0:3]])
|
||||
self.sync_all(self.nodes[0:3])
|
||||
|
||||
def check_fee_amount(self, curr_balance, balance_with_fee, fee_per_byte, tx_size):
|
||||
"""Return curr_balance after asserting the fee was in range"""
|
||||
|
@ -58,9 +58,9 @@ class WalletTest(BitcoinTestFramework):
|
|||
assert_equal(walletinfo['immature_balance'], 50)
|
||||
assert_equal(walletinfo['balance'], 0)
|
||||
|
||||
self.sync_all([self.nodes[0:3]])
|
||||
self.sync_all(self.nodes[0:3])
|
||||
self.nodes[1].generate(101)
|
||||
self.sync_all([self.nodes[0:3]])
|
||||
self.sync_all(self.nodes[0:3])
|
||||
|
||||
assert_equal(self.nodes[0].getbalance(), 50)
|
||||
assert_equal(self.nodes[1].getbalance(), 50)
|
||||
|
@ -107,7 +107,7 @@ class WalletTest(BitcoinTestFramework):
|
|||
|
||||
# Have node0 mine a block, thus it will collect its own fee.
|
||||
self.nodes[0].generate(1)
|
||||
self.sync_all([self.nodes[0:3]])
|
||||
self.sync_all(self.nodes[0:3])
|
||||
|
||||
# Exercise locking of unspent outputs
|
||||
unspent_0 = self.nodes[2].listunspent()[0]
|
||||
|
@ -143,7 +143,7 @@ class WalletTest(BitcoinTestFramework):
|
|||
|
||||
# Have node1 generate 100 blocks (so node0 can recover the fee)
|
||||
self.nodes[1].generate(100)
|
||||
self.sync_all([self.nodes[0:3]])
|
||||
self.sync_all(self.nodes[0:3])
|
||||
|
||||
# node0 should end up with 100 btc in block rewards plus fees, but
|
||||
# minus the 21 plus fees sent to node2
|
||||
|
@ -172,7 +172,7 @@ class WalletTest(BitcoinTestFramework):
|
|||
|
||||
# Have node1 mine a block to confirm transactions:
|
||||
self.nodes[1].generate(1)
|
||||
self.sync_all([self.nodes[0:3]])
|
||||
self.sync_all(self.nodes[0:3])
|
||||
|
||||
assert_equal(self.nodes[0].getbalance(), 0)
|
||||
assert_equal(self.nodes[2].getbalance(), 94)
|
||||
|
@ -187,14 +187,14 @@ class WalletTest(BitcoinTestFramework):
|
|||
self.nodes[2].settxfee(fee_per_byte * 1000)
|
||||
txid = self.nodes[2].sendtoaddress(address, 10, "", "", False)
|
||||
self.nodes[2].generate(1)
|
||||
self.sync_all([self.nodes[0:3]])
|
||||
self.sync_all(self.nodes[0:3])
|
||||
node_2_bal = self.check_fee_amount(self.nodes[2].getbalance(), Decimal('84'), fee_per_byte, self.get_vsize(self.nodes[2].gettransaction(txid)['hex']))
|
||||
assert_equal(self.nodes[0].getbalance(), Decimal('10'))
|
||||
|
||||
# Send 10 BTC with subtract fee from amount
|
||||
txid = self.nodes[2].sendtoaddress(address, 10, "", "", True)
|
||||
self.nodes[2].generate(1)
|
||||
self.sync_all([self.nodes[0:3]])
|
||||
self.sync_all(self.nodes[0:3])
|
||||
node_2_bal -= Decimal('10')
|
||||
assert_equal(self.nodes[2].getbalance(), node_2_bal)
|
||||
node_0_bal = self.check_fee_amount(self.nodes[0].getbalance(), Decimal('20'), fee_per_byte, self.get_vsize(self.nodes[2].gettransaction(txid)['hex']))
|
||||
|
@ -202,7 +202,7 @@ class WalletTest(BitcoinTestFramework):
|
|||
# Sendmany 10 BTC
|
||||
txid = self.nodes[2].sendmany('', {address: 10}, 0, "", [])
|
||||
self.nodes[2].generate(1)
|
||||
self.sync_all([self.nodes[0:3]])
|
||||
self.sync_all(self.nodes[0:3])
|
||||
node_0_bal += Decimal('10')
|
||||
node_2_bal = self.check_fee_amount(self.nodes[2].getbalance(), node_2_bal - Decimal('10'), fee_per_byte, self.get_vsize(self.nodes[2].gettransaction(txid)['hex']))
|
||||
assert_equal(self.nodes[0].getbalance(), node_0_bal)
|
||||
|
@ -210,7 +210,7 @@ class WalletTest(BitcoinTestFramework):
|
|||
# Sendmany 10 BTC with subtract fee from amount
|
||||
txid = self.nodes[2].sendmany('', {address: 10}, 0, "", [address])
|
||||
self.nodes[2].generate(1)
|
||||
self.sync_all([self.nodes[0:3]])
|
||||
self.sync_all(self.nodes[0:3])
|
||||
node_2_bal -= Decimal('10')
|
||||
assert_equal(self.nodes[2].getbalance(), node_2_bal)
|
||||
node_0_bal = self.check_fee_amount(self.nodes[0].getbalance(), node_0_bal + Decimal('10'), fee_per_byte, self.get_vsize(self.nodes[2].gettransaction(txid)['hex']))
|
||||
|
@ -254,18 +254,18 @@ class WalletTest(BitcoinTestFramework):
|
|||
connect_nodes_bi(self.nodes, 0, 1)
|
||||
connect_nodes_bi(self.nodes, 1, 2)
|
||||
connect_nodes_bi(self.nodes, 0, 2)
|
||||
self.sync_all([self.nodes[0:3]])
|
||||
self.sync_all(self.nodes[0:3])
|
||||
|
||||
txid_not_broadcast = self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 2)
|
||||
tx_obj_not_broadcast = self.nodes[0].gettransaction(txid_not_broadcast)
|
||||
self.nodes[1].generate(1) # mine a block, tx should not be in there
|
||||
self.sync_all([self.nodes[0:3]])
|
||||
self.sync_all(self.nodes[0:3])
|
||||
assert_equal(self.nodes[2].getbalance(), node_2_bal) # should not be changed because tx was not broadcasted
|
||||
|
||||
# now broadcast from another node, mine a block, sync, and check the balance
|
||||
self.nodes[1].sendrawtransaction(tx_obj_not_broadcast['hex'])
|
||||
self.nodes[1].generate(1)
|
||||
self.sync_all([self.nodes[0:3]])
|
||||
self.sync_all(self.nodes[0:3])
|
||||
node_2_bal += 2
|
||||
tx_obj_not_broadcast = self.nodes[0].gettransaction(txid_not_broadcast)
|
||||
assert_equal(self.nodes[2].getbalance(), node_2_bal)
|
||||
|
@ -341,7 +341,7 @@ class WalletTest(BitcoinTestFramework):
|
|||
address_to_import = self.nodes[2].getnewaddress()
|
||||
txid = self.nodes[0].sendtoaddress(address_to_import, 1)
|
||||
self.nodes[0].generate(1)
|
||||
self.sync_all([self.nodes[0:3]])
|
||||
self.sync_all(self.nodes[0:3])
|
||||
|
||||
# 2. Import address from node2 to node1
|
||||
self.nodes[1].importaddress(address_to_import)
|
||||
|
@ -367,15 +367,15 @@ class WalletTest(BitcoinTestFramework):
|
|||
coinbase_addr = self.nodes[1].getnewaddress()
|
||||
block_hash = self.nodes[0].generatetoaddress(1, coinbase_addr)[0]
|
||||
coinbase_txid = self.nodes[0].getblock(block_hash)['tx'][0]
|
||||
self.sync_all([self.nodes[0:3]])
|
||||
self.sync_all(self.nodes[0:3])
|
||||
|
||||
# Check that the txid and balance is found by node1
|
||||
self.nodes[1].gettransaction(coinbase_txid)
|
||||
|
||||
# check if wallet or blockchain maintenance changes the balance
|
||||
self.sync_all([self.nodes[0:3]])
|
||||
self.sync_all(self.nodes[0:3])
|
||||
blocks = self.nodes[0].generate(2)
|
||||
self.sync_all([self.nodes[0:3]])
|
||||
self.sync_all(self.nodes[0:3])
|
||||
balance_nodes = [self.nodes[i].getbalance() for i in range(3)]
|
||||
block_count = self.nodes[0].getblockcount()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue