diff --git a/test/functional/feature_accounts_validation.py b/test/functional/feature_accounts_validation.py index 5265d8a50d..c3cc12547c 100755 --- a/test/functional/feature_accounts_validation.py +++ b/test/functional/feature_accounts_validation.py @@ -21,7 +21,7 @@ def run_test(self): node = self.nodes[0] node1 = self.nodes[1] node.generate(101) - self.sync_all() + self.sync_blocks() assert_equal(node.getblockcount(), 101) # eunos @@ -30,7 +30,7 @@ def run_test(self): destination = node.getnewaddress() node.utxostoaccount({account: "10@0"}) node.generate(1) - self.sync_all() + self.sync_blocks() # Check we have expected balance assert_equal(node1.getaccount(account)[0], "10.00000000@DFI") @@ -44,7 +44,7 @@ def run_test(self): # Generate a block node.generate(1) - self.sync_all() + self.sync_blocks() stats = node.getblockstats(blockcount + 1) assert_equal(stats["total_out"], 18199952120) diff --git a/test/functional/feature_anchor_rewards.py b/test/functional/feature_anchor_rewards.py index 72750ad65d..f4d39c5493 100755 --- a/test/functional/feature_anchor_rewards.py +++ b/test/functional/feature_anchor_rewards.py @@ -51,7 +51,7 @@ def initmasternodesforanchors(self, offset_hours, blocks): def mine_diff(self, height): if self.nodes[0].getblockcount() < height: self.nodes[0].generate(height - self.nodes[0].getblockcount()) - self.sync_all() + self.sync_blocks() # Tiem is hours to move node time forward and blocks the number of blocks # to mine in each hour. Offset allows us to put check clock back. @@ -329,7 +329,7 @@ def run_test(self): print ("Rollback!") self.nodes[2].generate(2) connect_nodes_bi(self.nodes, 1, 2) - self.sync_all() + self.sync_blocks() wait_until(lambda: len(self.nodes[0].spv_listanchorrewardconfirms()) == 1, timeout=10) # while rollback, it should appear w/o wait assert_equal(len(self.nodes[0].spv_listanchorrewards()), 0) @@ -342,7 +342,7 @@ def run_test(self): assert_equal(self.nodes[0].listcommunitybalances()['AnchorReward'], Decimal('6.30000000')) # 2 more blocks on this chain self.nodes[1].generate(1) - self.sync_all() + self.sync_blocks() # Reward after assert_equal(self.nodes[0].listcommunitybalances()['AnchorReward'], Decimal('0.10000000')) @@ -356,7 +356,6 @@ def run_test(self): # Mine forward 6 hours, from 9 hours ago, 5 blocks an hour self.rotateandgenerate(6, 9, 5) - self.sync_all() wait_until(lambda: self.authsquorum(60), timeout=10) rewardAddress2 = self.nodes[0].getnewaddress("", "legacy") @@ -374,7 +373,6 @@ def run_test(self): # Mine forward 3 hours, from 9 hours ago, 5 blocks an hour self.rotateandgenerate(3, 3, 15) - self.sync_all() wait_until(lambda: self.authsquorum(60), timeout=10) # for rollback. HERE, to deny cofirmations for node2 @@ -422,7 +420,7 @@ def run_test(self): print ("Rollback a rewards") self.nodes[2].generate(3) connect_nodes_bi(self.nodes, 1, 2) - self.sync_all() + self.sync_blocks() wait_until(lambda: len(self.nodes[0].spv_listanchorrewardconfirms()) == 1, timeout=10) assert_equal(len(self.nodes[0].spv_listanchorrewards()), 1) diff --git a/test/functional/feature_any_accounts_to_accounts.py b/test/functional/feature_any_accounts_to_accounts.py index a29f3260c7..2d2a15662b 100755 --- a/test/functional/feature_any_accounts_to_accounts.py +++ b/test/functional/feature_any_accounts_to_accounts.py @@ -86,7 +86,7 @@ def run_test(self): break self.nodes[0].generate(1) - self.sync_all() + self.sync_blocks() start_block_count = self.nodes[0].getblockcount() @@ -137,7 +137,7 @@ def run_test(self): self.nodes[0].generate(1) - self.sync_all(enabled_nodes) + self.sync_blocks(enabled_nodes) # check that RPC getaccounts is equal of node1_wallet_rpc = [] @@ -178,7 +178,7 @@ def run_test(self): self.sync_mempools(enabled_nodes) self.nodes[0].generate(1) - self.sync_all(enabled_nodes) + self.sync_blocks(enabled_nodes) wallet2_addr1_balance = self.nodes[0].getaccount(wallet2_addr1, {}, True) wallet2_addr2_balance = self.nodes[0].getaccount(wallet2_addr2, {}, True) @@ -197,7 +197,7 @@ def run_test(self): self.sync_mempools(enabled_nodes) self.nodes[0].generate(1) - self.sync_all(enabled_nodes) + self.sync_blocks(enabled_nodes) wallet1_change_addr_balance = self.nodes[0].getaccount(wallet1_change_addr, {}, True) @@ -212,7 +212,7 @@ def run_test(self): self.nodes[0].sendtoaddress(wallet2_addr2, 1) self.nodes[0].generate(1) - self.sync_all(enabled_nodes) + self.sync_blocks(enabled_nodes) # send tokens from wallet2 to wallet1 with manual "from" param accsFrom = {} @@ -225,7 +225,7 @@ def run_test(self): self.sync_mempools(enabled_nodes) self.nodes[0].generate(1) - self.sync_all(enabled_nodes) + self.sync_blocks(enabled_nodes) # check that wallet2 is empty wallet2_addr1_balance = self.nodes[0].getaccount(wallet2_addr1, {}, True) diff --git a/test/functional/feature_checkpoint.py b/test/functional/feature_checkpoint.py index d42eb5f33b..b499d97e88 100755 --- a/test/functional/feature_checkpoint.py +++ b/test/functional/feature_checkpoint.py @@ -22,7 +22,7 @@ def set_test_params(self): def run_test(self): self.nodes[0].generate(100) - self.sync_all() + self.sync_blocks() # Stop node #1 for future revert self.stop_node(1) diff --git a/test/functional/feature_communitybalance_reorg.py b/test/functional/feature_communitybalance_reorg.py index b23e24130e..b983376650 100755 --- a/test/functional/feature_communitybalance_reorg.py +++ b/test/functional/feature_communitybalance_reorg.py @@ -20,7 +20,7 @@ def set_test_params(self): def run_test(self): # Generate across nodes self.nodes[0].generate(10) - self.sync_all() + self.sync_blocks() # Disconnect disconnect_nodes(self.nodes[0], 1) @@ -40,7 +40,7 @@ def run_test(self): # Reconnect nodes. Should switch node 0 to node 1 chain reorging blocks. connect_nodes(self.nodes[0], 1) - self.sync_all() + self.sync_blocks() # Make sure we are on the longer chain assert_equal(self.nodes[0].getblockcount(), 31) diff --git a/test/functional/feature_initdist.py b/test/functional/feature_initdist.py index 4898886584..2a8593bf4e 100755 --- a/test/functional/feature_initdist.py +++ b/test/functional/feature_initdist.py @@ -29,7 +29,7 @@ def setup_network(self): for i in range(self.num_nodes - 1): connect_nodes_bi(self.nodes, i, i + 1) - self.sync_all() + self.sync_blocks() def run_test(self): @@ -38,7 +38,7 @@ def run_test(self): assert(self.nodes[0].getbalance() == 0) assert(self.nodes[1].getbalance() == 0) self.nodes[2].generate(100) - self.sync_all() + self.sync_blocks() assert(self.nodes[0].getbalance() == 50) utxo0 = self.nodes[0].listunspent() @@ -48,9 +48,9 @@ def run_test(self): addr = self.nodes[1].getnewaddress("", "legacy") self.nodes[0].sendtoaddress(addr, 42) - self.sync_all() + self.sync_mempools() self.nodes[2].generate(1) - self.sync_all() + self.sync_blocks() assert(self.nodes[0].getbalance() >= 7.99) assert(self.nodes[1].getbalance() == 42) diff --git a/test/functional/feature_listaccounts_pagination.py b/test/functional/feature_listaccounts_pagination.py index 9b087ff652..dfdad8b4f2 100755 --- a/test/functional/feature_listaccounts_pagination.py +++ b/test/functional/feature_listaccounts_pagination.py @@ -16,22 +16,17 @@ def set_test_params(self): ['-txnotokens=0', '-amkheight=50', '-eunosheight=101'], ['-txnotokens=0', '-amkheight=50', '-eunosheight=101'], ] - def synchronize(self, node: int, full: bool = False): - self.nodes[node].generate(1) - self.sync_blocks([self.nodes[0], self.nodes[1]]) - if full: - self.sync_mempools([self.nodes[0], self.nodes[1]]) def run_test(self): node = self.nodes[0] node1 = self.nodes[1] node.generate(101) - self.sync_all() + self.sync_blocks() assert_equal(node.getblockcount(), 101) # eunos # Get addresses and set up account account = node.getnewaddress() node.utxostoaccount({account: "10@0"}) node.generate(1) - self.sync_all() + self.sync_blocks() addressInfo = node.getaddressinfo(account) accountkey1 = addressInfo["scriptPubKey"] + "@0" #key of the first account accounts = node1.listaccounts() @@ -52,7 +47,7 @@ def run_test(self): account2 = node.getnewaddress() node.utxostoaccount({account2: "10@0"}) node.generate(1) - self.sync_all() + self.sync_blocks() addressInfo = node.getaddressinfo(account2) accountkey2 = addressInfo["scriptPubKey"] + "@0" #key of the second account accounts = node1.listaccounts() @@ -81,11 +76,11 @@ def run_test(self): #Add another account from other node account3 = node1.getnewaddress() node.sendtoaddress(account3, 50) - self.synchronize(0, full=True) - self.synchronize(1, full=True) + node.generate(1) + self.sync_blocks() node1.utxostoaccount({account3: "10@0"}) node1.generate(1) - self.sync_all() + self.sync_blocks() addressInfo = node1.getaddressinfo(account3) accounts = node.listaccounts() #make sure we have three account in the system diff --git a/test/functional/feature_loan_vault.py b/test/functional/feature_loan_vault.py index 53778d0f14..51be11343a 100755 --- a/test/functional/feature_loan_vault.py +++ b/test/functional/feature_loan_vault.py @@ -58,7 +58,7 @@ def run_test(self): self.nodes[0].createvault(ownerAddress2, 'LOAN0003') self.nodes[0].createvault(ownerAddress2, 'LOAN0003') self.nodes[0].generate(1) - self.sync_all() + self.sync_blocks() # 4 * 0.5, fee is 1DFI in regtest assert_equal(self.nodes[0].getburninfo()['feeburn'], Decimal('2')) @@ -464,7 +464,7 @@ def run_test(self): address = self.nodes[0].getnewaddress() self.nodes[1].sendtokenstoaddress({}, { address: '1.50@BTC'}) self.nodes[1].generate(1) - self.sync_all() + self.sync_blocks() vaultId4 = self.nodes[0].createvault(address, 'LOAN000A') self.nodes[0].generate(1) self.nodes[0].deposittovault(vaultId4, address, '1.25@BTC') # 1.25@BTC as collateral factor 0.8 diff --git a/test/functional/feature_masternode_operator.py b/test/functional/feature_masternode_operator.py index 46bbf5a145..273057dcc3 100755 --- a/test/functional/feature_masternode_operator.py +++ b/test/functional/feature_masternode_operator.py @@ -38,10 +38,9 @@ def run_test(self): self.log.info("Mining blocks ...") startNode0 = self.nodes[0].getblockcount() + 1 self.nodes[0].generate(10) - print(self.nodes[0].getblockcount()) - self.sync_all() + self.sync_blocks() self.nodes[1].generate(10) - self.sync_all() + self.sync_blocks() minters = set() for x in range(startNode0, startNode0 + 10): diff --git a/test/functional/feature_mempool_dakota.py b/test/functional/feature_mempool_dakota.py index 80233d5ae9..b03a18428d 100755 --- a/test/functional/feature_mempool_dakota.py +++ b/test/functional/feature_mempool_dakota.py @@ -25,7 +25,7 @@ def run_test(self): node = self.nodes[0] node1 = self.nodes[1] node.generate(101) - self.sync_all() + self.sync_blocks() assert_equal(node.getblockcount(), 101) # Dakota height @@ -33,13 +33,12 @@ def run_test(self): wallet1_addr = node1.getnewaddress("", "legacy") node.sendtoaddress(wallet1_addr, "3.1") node.generate(1) - self.sync_all() + self.sync_blocks() collateral = node1.createmasternode(wallet1_addr) - node.generate(1) - self.sync_all() assert_raises_rpc_error(-26, "collateral-locked", node1.utxostoaccount, {wallet1_addr: "0.09@0"}) + self.sync_mempools() node.generate(1) - self.sync_all() + self.sync_blocks() assert_equal(node1.listmasternodes({}, False)[collateral], "PRE_ENABLED") assert_equal(node1.getmasternode(collateral)[collateral]["state"], "PRE_ENABLED") node.generate(10) @@ -47,7 +46,7 @@ def run_test(self): node1.utxostoaccount({wallet1_addr: "0.09@0"}) node.generate(1) - self.sync_all() + self.sync_blocks() if __name__ == '__main__': MempoolDakotaTest().main () diff --git a/test/functional/feature_minchainwork.py b/test/functional/feature_minchainwork.py index 1eae3801fc..977214ee89 100755 --- a/test/functional/feature_minchainwork.py +++ b/test/functional/feature_minchainwork.py @@ -82,7 +82,7 @@ def run_test(self): # insufficient work chain, in which case we'd need to reconnect them to # continue the test. - self.sync_all() + self.sync_blocks() self.log.info("Blockcounts: %s", [n.getblockcount() for n in self.nodes]) if __name__ == '__main__': diff --git a/test/functional/feature_mine_cached.py b/test/functional/feature_mine_cached.py index dc97763a25..546d045a6b 100755 --- a/test/functional/feature_mine_cached.py +++ b/test/functional/feature_mine_cached.py @@ -30,12 +30,12 @@ def run_test(self): assert_equal(len(self.nodes[0].listtokens()), 1) # only one token == DFI self.nodes[0].generate(101) - self.sync_all() + self.sync_blocks() wallet0_addr = self.nodes[0].getnewaddress("", "legacy") self.nodes[0].utxostoaccount({wallet0_addr: "10@0"}) self.nodes[0].generate(1) - self.sync_all() + self.sync_blocks() to = {} wallet1_addr = self.nodes[1].getnewaddress("", "legacy") diff --git a/test/functional/feature_oracles.py b/test/functional/feature_oracles.py index 62dcc735c4..8816bd196d 100755 --- a/test/functional/feature_oracles.py +++ b/test/functional/feature_oracles.py @@ -93,15 +93,13 @@ def assert_compare_oracle_data(self, oracle_data_json, oracle_id=None, oracle_ad tpjs, tpps), True): raise Exception("prices are not equal") - def synchronize(self, node: int, full: bool = False): + def synchronize(self, node: int): self.nodes[node].generate(1) self.sync_blocks([self.nodes[0], self.nodes[1], self.nodes[2]]) - if full: - self.sync_mempools([self.nodes[0], self.nodes[1], self.nodes[2]]) def run_test(self): self.nodes[0].generate(200) - self.sync_all() + self.sync_blocks() # === stop node #3 for future revert === self.stop_node(3) @@ -117,7 +115,7 @@ def run_test(self): self.nodes[0].sendtoaddress(oracle_address1, 50) self.nodes[0].sendtoaddress(oracle_address2, 50) - self.synchronize(0, full=True) + self.synchronize(0) send_money_tx1, send_money_tx2 = \ [self.find_address_tx(self.nodes[2], address) for address in [oracle_address1, oracle_address2]] @@ -156,7 +154,7 @@ def run_test(self): assert_raises_rpc_error(-5, 'Need foundation member authorization', self.nodes[2].removeoracle, oracle_id1) - self.synchronize(node=0, full=True) + self.synchronize(node=0) all_oracles = self.nodes[1].listoracles() assert_equal(all_oracles, [oracle_id1]) @@ -345,7 +343,7 @@ def run_test(self): self.nodes[2].setoracledata(oracle_id1, timestamp - 7200, token_prices1) self.nodes[2].setoracledata(oracle_id3, timestamp - 7200, [{"currency":"USD", "tokenAmount":"7@PT"}]) - self.synchronize(node=2, full=True) + self.synchronize(node=2) pt_in_usd_raw_prices = self.nodes[1].listlatestrawprices({"currency":"USD", "token":"PT"}) @@ -380,7 +378,5 @@ def run_test(self): self.nodes[0].removeoracle(oracle_id1) self.nodes[0].removeoracle(oracle_id2) - self.synchronize(node=0, full=True) - if __name__ == '__main__': OraclesTest().main() diff --git a/test/functional/feature_poolpair.py b/test/functional/feature_poolpair.py index f571550665..aa33bdb45d 100755 --- a/test/functional/feature_poolpair.py +++ b/test/functional/feature_poolpair.py @@ -32,7 +32,7 @@ def run_test(self): assert_equal(len(self.nodes[0].listtokens()), 1) # only one token == DFI self.nodes[0].generate(100) - self.sync_all() + self.sync_blocks() # Stop node #3 for future revert self.stop_node(3) diff --git a/test/functional/feature_poolpair_liquidity.py b/test/functional/feature_poolpair_liquidity.py index b41a0f61fd..d7a13a1534 100755 --- a/test/functional/feature_poolpair_liquidity.py +++ b/test/functional/feature_poolpair_liquidity.py @@ -61,7 +61,7 @@ def run_test(self): # transfer silver self.nodes[1].accounttoaccount(accountSilver, {accountGold: "1000@" + symbolSILVER}) self.nodes[1].generate(1) - self.sync_all([self.nodes[0], self.nodes[1]]) + self.sync_blocks([self.nodes[0], self.nodes[1]]) # create pool self.nodes[0].createpoolpair({ @@ -133,7 +133,7 @@ def run_test(self): assert_equal(amountGold, initialGold - 100) assert_equal(amountSilver, initialSilver - 1100) - self.sync_all([self.nodes[0], self.nodes[1]]) + self.sync_blocks([self.nodes[0], self.nodes[1]]) accountGoldInfo = self.nodes[1].getaccount(accountGold, {}, True) assert_equal(str(accountGoldInfo[idGS]), "99.99999000") @@ -157,7 +157,7 @@ def run_test(self): # transfer tokens self.nodes[0].accounttoaccount(accountGold, {accountTest: ["500@" + symbolSILVER, "500@" + symbolGOLD]}) self.nodes[0].generate(1) - self.sync_all([self.nodes[0], self.nodes[3]]) + self.sync_blocks([self.nodes[0], self.nodes[3]]) accountTestInfo = self.nodes[3].getaccount(accountTest, {}, True) accountGoldInfo = self.nodes[3].getaccount(accountGold, {}, True) @@ -172,10 +172,10 @@ def run_test(self): "*": ["50@" + symbolGOLD, "400@" + symbolSILVER] }, accountTest, []) - self.sync_all([self.nodes[0], self.nodes[3]]) + self.sync_mempools([self.nodes[0], self.nodes[3]]) self.nodes[0].generate(1) - self.sync_all([self.nodes[0], self.nodes[3]]) + self.sync_blocks([self.nodes[0], self.nodes[3]]) accountTestInfo = self.nodes[3].getaccount(accountTest, {}, True) pool = self.nodes[3].getpoolpair("GS", True) @@ -324,9 +324,9 @@ def run_test(self): resAmountB = make_rounded_decimal(gsAmountAcc2 * poolReserveB / poolLiquidity) # transfer - self.sync_all([self.nodes[0], self.nodes[3]]) + self.sync_blocks([self.nodes[0], self.nodes[3]]) self.nodes[3].removepoolliquidity(accountTest, str(gsAmountAcc2)+"@GS", []) - self.sync_all([self.nodes[0], self.nodes[3]]) + self.sync_mempools([self.nodes[0], self.nodes[3]]) self.nodes[0].generate(1) accountTestInfo = self.nodes[0].getaccount(accountTest, {}, True) diff --git a/test/functional/feature_poolswap.py b/test/functional/feature_poolswap.py index 9f385ab413..ae67809560 100755 --- a/test/functional/feature_poolswap.py +++ b/test/functional/feature_poolswap.py @@ -37,8 +37,6 @@ def set_test_params(self): def run_test(self): assert_equal(len(self.nodes[0].listtokens()), 1) # only one token == DFI - #self.nodes[0].generate(100) - #self.sync_all() self.setup_tokens() # Stop node #3 for future revert self.stop_node(3) diff --git a/test/functional/feature_rbf.py b/test/functional/feature_rbf.py index fac3d0b48b..a773801646 100755 --- a/test/functional/feature_rbf.py +++ b/test/functional/feature_rbf.py @@ -85,9 +85,6 @@ def run_test(self): make_utxo(self.nodes[0], 1*COIN) - # Ensure nodes are synced - self.sync_all() - self.log.info("Running test simple doublespend...") self.test_simple_doublespend() @@ -124,19 +121,12 @@ def test_simple_doublespend(self): """Simple doublespend""" tx0_outpoint = make_utxo(self.nodes[0], int(1.1*COIN)) - # make_utxo may have generated a bunch of blocks, so we need to sync - # before we can spend the coins generated, or else the resulting - # transactions might not be accepted by our peers. - self.sync_all() - tx1a = CTransaction() tx1a.vin = [CTxIn(tx0_outpoint, nSequence=0)] tx1a.vout = [CTxOut(1 * COIN, CScript([b'a' * 35]))] tx1a_hex = txToHex(tx1a) tx1a_txid = self.nodes[0].sendrawtransaction(tx1a_hex, 0) - self.sync_all() - # Should fail because we haven't changed the fee tx1b = CTransaction() tx1b.vin = [CTxIn(tx0_outpoint, nSequence=0)] diff --git a/test/functional/feature_segwit.py b/test/functional/feature_segwit.py index c0f59b3a7b..ecefa10335 100755 --- a/test/functional/feature_segwit.py +++ b/test/functional/feature_segwit.py @@ -79,7 +79,6 @@ def skip_test_if_missing_module(self): def setup_network(self): super().setup_network() connect_nodes(self.nodes[0], 2) - self.sync_all() def success_mine(self, node, txid, sign, redeem_script=""): send_to_witness(1, node, getutxo(txid), self.pubkey[0], False, Decimal("49.998"), sign, redeem_script) @@ -140,8 +139,7 @@ def run_test(self): p2sh_ids[n][v].append(send_to_witness(v, self.nodes[0], find_spendable_utxo(self.nodes[0], 50), self.pubkey[n], True, Decimal("49.999"))) self.nodes[0].generate(1) # block 163 - # self.sync_blocks() - self.sync_all() + self.sync_blocks() # Make sure all nodes recognize the transactions as theirs assert_equal(self.nodes[0].getbalance(), balance_presetup - 60 * 50 + 20 * Decimal("49.999") + 50) diff --git a/test/functional/feature_sendtokenstoaddress.py b/test/functional/feature_sendtokenstoaddress.py index f1b825187b..c4e0b773a8 100755 --- a/test/functional/feature_sendtokenstoaddress.py +++ b/test/functional/feature_sendtokenstoaddress.py @@ -61,7 +61,7 @@ def run_test(self): self.nodes[0].sendtokenstoaddress({}, to, "forward") self.nodes[0].generate(1) - self.sync_all() + self.sync_blocks() wallet1_addr1_balance = self.nodes[0].getaccount(wallet1_addr1, {}, True) wallet1_addr2_balance = self.nodes[0].getaccount(wallet1_addr2, {}, True) @@ -79,7 +79,7 @@ def run_test(self): self.nodes[1].sendtokenstoaddress({}, to, "pie") self.nodes[1].generate(1) - self.sync_all() + self.sync_blocks() wallet1_addr1_balance = self.nodes[0].getaccount(wallet1_addr1, {}, True) wallet1_addr2_balance = self.nodes[0].getaccount(wallet1_addr2, {}, True) @@ -96,7 +96,7 @@ def run_test(self): self.nodes[1].sendtokenstoaddress({}, to, "crumbs") self.nodes[1].generate(1) - self.sync_all() + self.sync_blocks() wallet1_addr1_balance = self.nodes[0].getaccount(wallet1_addr1, {}, True) wallet1_addr2_balance = self.nodes[0].getaccount(wallet1_addr2, {}, True) diff --git a/test/functional/feature_tokens_basic.py b/test/functional/feature_tokens_basic.py index bbcc6998db..db2640971a 100755 --- a/test/functional/feature_tokens_basic.py +++ b/test/functional/feature_tokens_basic.py @@ -29,7 +29,7 @@ def run_test(self): assert_equal(len(self.nodes[0].listtokens()), 1) # only one token == DFI self.nodes[0].generate(100) - self.sync_all() + self.sync_blocks() # Stop node #2 for future revert self.stop_node(2) diff --git a/test/functional/feature_tokens_dat.py b/test/functional/feature_tokens_dat.py index 694fe67cc4..1af4940fc3 100755 --- a/test/functional/feature_tokens_dat.py +++ b/test/functional/feature_tokens_dat.py @@ -32,7 +32,7 @@ def run_test(self): assert_equal(len(self.nodes[0].listtokens()), 1) # only one token == DFI self.nodes[0].generate(100) - self.sync_all() + self.sync_blocks() # Stop node #3 for future revert self.stop_node(3) diff --git a/test/functional/feature_update_mn.py b/test/functional/feature_update_mn.py index 1a84262612..4badb8411c 100755 --- a/test/functional/feature_update_mn.py +++ b/test/functional/feature_update_mn.py @@ -26,7 +26,7 @@ def set_test_params(self): def run_test(self): assert_equal(len(self.nodes[0].listmasternodes()), 8) self.nodes[0].generate(100) - self.sync_all() + self.sync_blocks() # CREATION: #======================== @@ -52,11 +52,11 @@ def run_test(self): assert_equal(self.nodes[0].listmasternodes({}, False)[idnode0], "PRE_ENABLED") assert_equal(self.nodes[0].getmasternode(idnode0)[idnode0]["state"], "PRE_ENABLED") self.nodes[0].generate(10) + self.sync_blocks() + assert_equal(self.nodes[0].listmasternodes({}, False)[idnode0], "ENABLED") assert_equal(self.nodes[1].listmasternodes()[idnode0]["operatorAuthAddress"], collateral0) - self.sync_all() - # UPDATING #======================== #assert_raises_rpc_error(-8, "updatemasternode cannot be called before Fortcanning hard fork", self.nodes[0].updatemasternode, idnode0, collateral0) @@ -70,7 +70,7 @@ def run_test(self): #self.nodes[0].updatemasternode(idnode0, collateral1) #self.nodes[0].generate(1) - #self.sync_all() + #self.sync_blocks() #assert_equal(self.nodes[1].listmasternodes()[idnode0]["operatorAuthAddress"], collateral1) @@ -90,7 +90,7 @@ def run_test(self): self.nodes[0].generate(1) assert_equal(self.nodes[0].listmasternodes()[idnode0]['state'], "PRE_RESIGNED") self.nodes[0].generate(40) - self.sync_all() + self.sync_blocks() assert_equal(self.nodes[0].listmasternodes()[idnode0]['state'], "RESIGNED") # Spend unlocked collateral diff --git a/test/functional/interface_rest.py b/test/functional/interface_rest.py index ae8a3c5fb0..ae9ff1df98 100755 --- a/test/functional/interface_rest.py +++ b/test/functional/interface_rest.py @@ -82,14 +82,14 @@ def run_test(self): not_related_address = "2MxqoHEdNQTyYeX1mHcbrrpzgojbosTpCvJ" self.nodes[0].generate(1) - self.sync_all() + self.sync_blocks() self.nodes[1].generate(nblocks=100, address=not_related_address) - self.sync_all() + self.sync_blocks() assert_equal(self.nodes[0].getbalance(), 50) txid = self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 0.1) - self.sync_all() + self.sync_mempools() self.log.info("Test the /tx URI") @@ -109,7 +109,7 @@ def run_test(self): self.log.info("Query an unspent TXO using the /getutxos URI") self.nodes[1].generate(nblocks=1, address=not_related_address) - self.sync_all() + self.sync_blocks() bb_hash = self.nodes[0].getbestblockhash() assert_equal(self.nodes[1].getbalance(), Decimal("0.1")) @@ -184,7 +184,7 @@ def run_test(self): assert_equal(len(json_obj['utxos']), 0) self.nodes[0].generate(1) - self.sync_all() + self.sync_blocks() json_obj = self.test_rest_request("/getutxos/{}-{}".format(*spending)) assert_equal(len(json_obj['utxos']), 1) @@ -205,7 +205,7 @@ def run_test(self): self.test_rest_request("/getutxos/checkmempool/{}".format(long_uri), http_method='POST', status=200) self.nodes[0].generate(1) # generate block to not affect upcoming tests - self.sync_all() + self.sync_blocks() self.log.info("Test the /block, /blockhashbyheight and /headers URIs") bb_hash = self.nodes[0].getbestblockhash() @@ -276,7 +276,7 @@ def run_test(self): # See if we can get 5 headers in one response self.nodes[1].generate(5) - self.sync_all() + self.sync_blocks() json_obj = self.test_rest_request("/headers/5/{}".format(bb_hash)) assert_equal(len(json_obj), 5) # now we should have 5 header objects diff --git a/test/functional/interface_zmq.py b/test/functional/interface_zmq.py index fcd2d9995e..280a3c0c12 100755 --- a/test/functional/interface_zmq.py +++ b/test/functional/interface_zmq.py @@ -78,7 +78,7 @@ def test_basic(self): num_blocks = 5 self.log.info("Generate %(n)d blocks (and %(n)d coinbase txes)" % {"n": num_blocks}) genhashes = self.nodes[0].generate(nblocks=num_blocks, address=ADDRESS_BCRT1_UNSPENDABLE) - self.sync_all() + self.sync_blocks() for x in range(num_blocks): # Should receive the coinbase txid. @@ -104,7 +104,7 @@ def test_basic(self): if self.is_wallet_compiled(): self.log.info("Wait for tx from second node") payment_txid = self.nodes[1].sendtoaddress(self.nodes[0].getnewaddress(), 1.0) - self.sync_all() + self.sync_mempools() # Should receive the broadcasted txid. txid = hashtx.receive() diff --git a/test/functional/mempool_packages.py b/test/functional/mempool_packages.py index fbf64fabae..3b3ae92efd 100755 --- a/test/functional/mempool_packages.py +++ b/test/functional/mempool_packages.py @@ -279,7 +279,7 @@ def run_test(self): # Mine these in a block self.nodes[0].generate(1) - self.sync_all() + self.sync_blocks() # Now generate tx8, with a big fee inputs = [ {'txid' : tx1_id, 'vout': 0}, {'txid' : txid, 'vout': 0} ] diff --git a/test/functional/mempool_persist.py b/test/functional/mempool_persist.py index 46d16518a0..347dffe96b 100755 --- a/test/functional/mempool_persist.py +++ b/test/functional/mempool_persist.py @@ -56,13 +56,13 @@ def run_test(self): self.log.debug("Mine a single block to get out of IBD") self.nodes[0].generate(1) - self.sync_all() + self.sync_blocks() self.log.debug("Send 5 transactions from node2 (to its own address)") for i in range(5): last_txid = self.nodes[2].sendtoaddress(self.nodes[2].getnewaddress(), Decimal("10")) node2_balance = self.nodes[2].getbalance() - self.sync_all() + self.sync_mempools() self.log.debug("Verify that node0 and node1 have 5 transactions in their mempools") assert_equal(len(self.nodes[0].getrawmempool()), 5) diff --git a/test/functional/mempool_reorg.py b/test/functional/mempool_reorg.py index cc2f9e63fc..aaebfad21c 100755 --- a/test/functional/mempool_reorg.py +++ b/test/functional/mempool_reorg.py @@ -29,7 +29,7 @@ def run_test(self): # Mine four blocks. After this, nodes[0] blocks # 101, 102, and 103 are spend-able. new_blocks = self.nodes[1].generate(4) - self.sync_all() + self.sync_blocks() node0_address = self.nodes[0].getnewaddress() node1_address = self.nodes[1].getnewaddress() diff --git a/test/functional/p2p_segwit.py b/test/functional/p2p_segwit.py index 6bc6d9fa53..b424ad96cd 100755 --- a/test/functional/p2p_segwit.py +++ b/test/functional/p2p_segwit.py @@ -199,7 +199,7 @@ def setup_network(self): self.setup_nodes() connect_nodes(self.nodes[0], 1) connect_nodes(self.nodes[0], 2) - self.sync_all() + self.sync_blocks() # Helper functions diff --git a/test/functional/p2p_segwit2.py b/test/functional/p2p_segwit2.py index 7005f1140e..9c3d1430f3 100755 --- a/test/functional/p2p_segwit2.py +++ b/test/functional/p2p_segwit2.py @@ -49,7 +49,6 @@ from test_framework.util import ( assert_equal, assert_greater_than, - connect_nodes, ) # The versionbit bit used to signal activation of SegWit @@ -166,12 +165,6 @@ def set_test_params(self): def skip_test_if_missing_module(self): self.skip_if_no_wallet() - def setup_network(self): - self.setup_nodes() - connect_nodes(self.nodes[0], 1) - connect_nodes(self.nodes[0], 2) - self.sync_all() - # Helper functions def build_next_block(self, version=4): diff --git a/test/functional/rpc_createmultisig.py b/test/functional/rpc_createmultisig.py index dfc9467069..60c8fa1736 100755 --- a/test/functional/rpc_createmultisig.py +++ b/test/functional/rpc_createmultisig.py @@ -37,7 +37,7 @@ def run_test(self): self.log.info('Generating blocks ...') node0.generate(149) - self.sync_all() + self.sync_blocks() self.moved = 0 for self.nkeys in [3, 5]: @@ -84,7 +84,7 @@ def check_addmultisigaddress_errors(self): def checkbalances(self): node0, node1, node2 = self.nodes node0.generate(100) - self.sync_all() + self.sync_blocks() bal0 = node0.getbalance() bal1 = node1.getbalance() diff --git a/test/functional/rpc_fundrawtransaction.py b/test/functional/rpc_fundrawtransaction.py index 2ca7d2c66e..507afe72a1 100755 --- a/test/functional/rpc_fundrawtransaction.py +++ b/test/functional/rpc_fundrawtransaction.py @@ -56,9 +56,9 @@ def run_test(self): self.fee_tolerance = 2 * self.min_relay_tx_fee / 1000 self.nodes[2].generate(1) - self.sync_all() + self.sync_blocks() self.nodes[0].generate(121) - self.sync_all() + self.sync_blocks() self.test_change_position() self.test_simple() @@ -112,7 +112,7 @@ def test_change_position(self): self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 5.0) self.nodes[0].generate(1) - self.sync_all() + self.sync_blocks() def test_simple(self): ############### @@ -477,9 +477,9 @@ def test_spend_2of2(self): # send 1.2 BTC to msig addr self.nodes[0].sendtoaddress(mSigObj, 1.2) - self.sync_all() + self.sync_mempools() self.nodes[1].generate(1) - self.sync_all() + self.sync_blocks() oldBalance = self.nodes[1].getbalance() inputs = [] @@ -489,9 +489,9 @@ def test_spend_2of2(self): signedTx = self.nodes[2].signrawtransactionwithwallet(fundedTx['hex']) self.nodes[2].sendrawtransaction(signedTx['hex']) - self.sync_all() + self.sync_mempools() self.nodes[1].generate(1) - self.sync_all() + self.sync_blocks() # make sure funds are received at node1 assert_equal(oldBalance+Decimal('1.10000000'), self.nodes[1].getbalance()) @@ -515,7 +515,7 @@ def test_locked_wallet(self): # Again lock the watchonly UTXO or nodes[0] may spend it, because # lockunspent is memory-only and thus lost on restart self.nodes[0].lockunspent(False, [{"txid": self.watchonly_txid, "vout": self.watchonly_vout}]) - self.sync_all() + self.sync_blocks() # drain the keypool self.nodes[1].getnewaddress() @@ -546,7 +546,7 @@ def test_locked_wallet(self): signedTx = self.nodes[1].signrawtransactionwithwallet(fundedTx['hex']) self.nodes[1].sendrawtransaction(signedTx['hex']) self.nodes[1].generate(1) - self.sync_all() + self.sync_blocks() # make sure funds are received at node1 assert_equal(oldBalance+Decimal('51.10000000'), self.nodes[0].getbalance()) @@ -558,14 +558,14 @@ def test_many_inputs_fee(self): #empty node1, send some small coins from node0 to node1 self.nodes[1].sendtoaddress(self.nodes[0].getnewaddress(), self.nodes[1].getbalance(), "", "", True) - self.sync_all() + self.sync_mempools() self.nodes[0].generate(1) - self.sync_all() + self.sync_blocks() for i in range(0,20): self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 0.01) self.nodes[0].generate(1) - self.sync_all() + self.sync_blocks() #fund a tx with ~20 small inputs inputs = [] @@ -588,14 +588,14 @@ def test_many_inputs_send(self): #again, empty node1, send some small coins from node0 to node1 self.nodes[1].sendtoaddress(self.nodes[0].getnewaddress(), self.nodes[1].getbalance(), "", "", True) - self.sync_all() + self.sync_mempools() self.nodes[0].generate(1) - self.sync_all() + self.sync_blocks() for i in range(0,20): self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 0.01) self.nodes[0].generate(1) - self.sync_all() + self.sync_blocks() #fund a tx with ~20 small inputs oldBalance = self.nodes[0].getbalance() @@ -606,9 +606,9 @@ def test_many_inputs_send(self): fundedTx = self.nodes[1].fundrawtransaction(rawtx) fundedAndSignedTx = self.nodes[1].signrawtransactionwithwallet(fundedTx['hex']) self.nodes[1].sendrawtransaction(fundedAndSignedTx['hex']) - self.sync_all() + self.sync_mempools() self.nodes[0].generate(1) - self.sync_all() + self.sync_blocks() assert_equal(oldBalance+Decimal('50.19000000'), self.nodes[0].getbalance()) #0.19+block reward def test_op_return(self): @@ -670,7 +670,7 @@ def test_all_watched_funds(self): assert signedtx["complete"] self.nodes[0].sendrawtransaction(signedtx["hex"]) self.nodes[0].generate(1) - self.sync_all() + self.sync_blocks() def test_option_feerate(self): ####################### diff --git a/test/functional/rpc_getblockstats.py b/test/functional/rpc_getblockstats.py index 64b66feba9..54496375b5 100755 --- a/test/functional/rpc_getblockstats.py +++ b/test/functional/rpc_getblockstats.py @@ -46,13 +46,11 @@ def generate_test_data(self, filename): address = self.nodes[0].get_genesis_keys().ownerAuthAddress self.nodes[0].sendtoaddress(address=address, amount=10, subtractfeefromamount=True) self.nodes[0].generate(1) - self.sync_all() self.nodes[0].sendtoaddress(address=address, amount=10, subtractfeefromamount=True) self.nodes[0].sendtoaddress(address=address, amount=10, subtractfeefromamount=False) self.nodes[0].settxfee(amount=0.003) self.nodes[0].sendtoaddress(address=address, amount=1, subtractfeefromamount=True) - self.sync_all() self.nodes[0].generate(1) self.expected_stats = self.get_stats() @@ -83,7 +81,6 @@ def load_test_data(self, filename): # Set the timestamps from the file so that the nodes can get out of Initial Block Download self.nodes[0].setmocktime(mocktime) - self.sync_all() for b in blocks: self.nodes[0].submitblock(b) @@ -96,7 +93,6 @@ def run_test(self): else: self.load_test_data(test_data) - self.sync_all() stats = self.get_stats() # Make sure all valid statistics are included but nothing else is diff --git a/test/functional/rpc_getchaintips.py b/test/functional/rpc_getchaintips.py index c42fbeb455..c4416210ea 100755 --- a/test/functional/rpc_getchaintips.py +++ b/test/functional/rpc_getchaintips.py @@ -28,8 +28,8 @@ def run_test(self): self.split_network() self.nodes[0].generate(10) self.nodes[2].generate(20) - self.sync_all(self.nodes[:2]) - self.sync_all(self.nodes[2:]) + self.sync_blocks(self.nodes[:2]) + self.sync_blocks(self.nodes[2:]) tips = self.nodes[1].getchaintips () assert_equal (len (tips), 1) diff --git a/test/functional/rpc_getmininginfo.py b/test/functional/rpc_getmininginfo.py index 7ba78fda43..45ce1b5807 100755 --- a/test/functional/rpc_getmininginfo.py +++ b/test/functional/rpc_getmininginfo.py @@ -41,10 +41,10 @@ def run_test(self): self.log.info("Mining blocks ...") self.nodes[0].generate(10) - self.sync_all() + self.sync_blocks() self.nodes[1].generate(25) self.nodes[1].generatetoaddress(25, node0_keys.operatorAuthAddress) - self.sync_all() + self.sync_blocks() # getmininginfo() on node[0], should only return one master node in the response array resp0 = self.nodes[0].getmininginfo() diff --git a/test/functional/rpc_mn_basic.py b/test/functional/rpc_mn_basic.py index 94de9691b8..c0cdd84229 100755 --- a/test/functional/rpc_mn_basic.py +++ b/test/functional/rpc_mn_basic.py @@ -28,7 +28,7 @@ def set_test_params(self): def run_test(self): assert_equal(len(self.nodes[0].listmasternodes()), 8) self.nodes[0].generate(100) - self.sync_all() + self.sync_blocks() # Stop node #2 for future revert self.stop_node(2) diff --git a/test/functional/rpc_psbt.py b/test/functional/rpc_psbt.py index 916058a9ec..d1771d9c4a 100755 --- a/test/functional/rpc_psbt.py +++ b/test/functional/rpc_psbt.py @@ -105,7 +105,7 @@ def run_test(self): signed_tx = self.nodes[0].signrawtransactionwithwallet(rawtx['hex'])['hex'] txid = self.nodes[0].sendrawtransaction(signed_tx) self.nodes[0].generate(6) - self.sync_all() + self.sync_blocks() # Find the output pos p2sh_pos = -1 @@ -184,7 +184,7 @@ def run_test(self): txid1 = self.nodes[0].sendtoaddress(node1_addr, 13) txid2 = self.nodes[0].sendtoaddress(node2_addr, 13) blockhash = self.nodes[0].generate(6)[0] - self.sync_all() + self.sync_blocks() vout1 = find_output(self.nodes[1], txid1, 13, blockhash=blockhash) vout2 = find_output(self.nodes[2], txid2, 13, blockhash=blockhash) @@ -204,7 +204,7 @@ def run_test(self): finalized = self.nodes[0].finalizepsbt(combined)['hex'] self.nodes[0].sendrawtransaction(finalized) self.nodes[0].generate(6) - self.sync_all() + self.sync_blocks() # Test additional args in walletcreatepsbt # Make sure both pre-included and funded inputs @@ -335,7 +335,7 @@ def run_test(self): addr3 = self.nodes[1].getnewaddress("", "p2sh-segwit") txid3 = self.nodes[0].sendtoaddress(addr3, 11) vout3 = find_output(self.nodes[0], txid3, 11) - self.sync_all() + self.sync_mempools() def test_psbt_input_keys(psbt_input, keys): """Check that the psbt input has only the expected keys.""" @@ -373,7 +373,7 @@ def test_psbt_input_keys(psbt_input, keys): txid4 = self.nodes[0].sendtoaddress(addr4, 5) vout4 = find_output(self.nodes[0], txid4, 5) self.nodes[0].generate(6) - self.sync_all() + self.sync_blocks() psbt2 = self.nodes[1].createpsbt([{"txid":txid4, "vout":vout4}], {self.nodes[0].getnewaddress():Decimal('4.999')}) psbt2 = self.nodes[1].walletprocesspsbt(psbt2)['psbt'] psbt2_decoded = self.nodes[0].decodepsbt(psbt2) @@ -387,7 +387,7 @@ def test_psbt_input_keys(psbt_input, keys): txid = self.nodes[0].sendtoaddress(addr, 7) addrinfo = self.nodes[1].getaddressinfo(addr) blockhash = self.nodes[0].generate(6)[0] - self.sync_all() + self.sync_blocks() vout = find_output(self.nodes[0], txid, 7, blockhash=blockhash) psbt = self.nodes[1].createpsbt([{"txid":txid, "vout":vout}], {self.nodes[0].getnewaddress("", "p2sh-segwit"):Decimal('6.999')}) analyzed = self.nodes[0].analyzepsbt(psbt) diff --git a/test/functional/rpc_rawtransaction.py b/test/functional/rpc_rawtransaction.py index d5fc668e73..e09326e6dd 100755 --- a/test/functional/rpc_rawtransaction.py +++ b/test/functional/rpc_rawtransaction.py @@ -17,7 +17,7 @@ from io import BytesIO from test_framework.messages import CTransaction, ToHex from test_framework.test_framework import DefiTestFramework -from test_framework.util import assert_equal, assert_raises_rpc_error, connect_nodes_bi, hex_str_to_bytes +from test_framework.util import assert_equal, assert_raises_rpc_error, hex_str_to_bytes class multidict(dict): """Dictionary that allows duplicate keys. @@ -51,22 +51,18 @@ def set_test_params(self): def skip_test_if_missing_module(self): self.skip_if_no_wallet() - def setup_network(self): - super().setup_network() - connect_nodes_bi(self.nodes, 0, 2) - def run_test(self): self.log.info('prepare some coins for multiple *rawtransaction commands') self.nodes[2].generate(1) - self.sync_all() + self.sync_blocks() self.nodes[0].generate(101) - self.sync_all() + self.sync_blocks() self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(),1.5) self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(),1.0) self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(),5.0) - self.sync_all() + self.sync_mempools() self.nodes[0].generate(5) - self.sync_all() + self.sync_blocks() self.log.info('Test getrawtransactions on genesis block') block = self.nodes[0].getblock(self.nodes[0].getblockhash(0)) @@ -215,7 +211,7 @@ def run_test(self): # make a tx by sending then generate 2 blocks; block1 has the tx in it tx = self.nodes[2].sendtoaddress(self.nodes[1].getnewaddress(), 1) block1, block2 = self.nodes[2].generate(2) - self.sync_all() + self.sync_blocks() # We should be able to get the raw transaction by providing the correct block gottx = self.nodes[0].getrawtransaction(tx, True, block1) assert_equal(gottx['txid'], tx) @@ -261,9 +257,9 @@ def run_test(self): # send 1.2 BTC to msig adr txId = self.nodes[0].sendtoaddress(mSigObj, 1.2) - self.sync_all() + self.sync_mempools() self.nodes[0].generate(1) - self.sync_all() + self.sync_blocks() assert_equal(self.nodes[2].getbalance(), bal+Decimal('1.20000000')) #node2 has both keys of the 2of2 ms addr., tx should affect the balance @@ -282,9 +278,9 @@ def run_test(self): txId = self.nodes[0].sendtoaddress(mSigObj, 2.2) decTx = self.nodes[0].gettransaction(txId) rawTx = self.nodes[0].decoderawtransaction(decTx['hex']) - self.sync_all() + self.sync_mempools() self.nodes[0].generate(1) - self.sync_all() + self.sync_blocks() #THIS IS AN INCOMPLETE FEATURE #NODE2 HAS TWO OF THREE KEY AND THE FUNDS SHOULD BE SPENDABLE AND COUNT AT BALANCE CALCULATION @@ -305,9 +301,9 @@ def run_test(self): assert_equal(rawTxSigned['complete'], True) #node2 can sign the tx compl., own two of three keys self.nodes[2].sendrawtransaction(rawTxSigned['hex']) rawTx = self.nodes[0].decoderawtransaction(rawTxSigned['hex']) - self.sync_all() + self.sync_mempools() self.nodes[0].generate(1) - self.sync_all() + self.sync_blocks() assert_equal(self.nodes[0].getbalance(), bal+Decimal('50.00000000')+Decimal('2.19000000')) #block reward + tx # 2of2 test for combining transactions @@ -325,9 +321,9 @@ def run_test(self): txId = self.nodes[0].sendtoaddress(mSigObj, 2.2) decTx = self.nodes[0].gettransaction(txId) rawTx2 = self.nodes[0].decoderawtransaction(decTx['hex']) - self.sync_all() + self.sync_mempools() self.nodes[0].generate(1) - self.sync_all() + self.sync_blocks() assert_equal(self.nodes[2].getbalance(), bal) # the funds of a 2of2 multisig tx should not be marked as spendable @@ -350,9 +346,9 @@ def run_test(self): self.log.debug(rawTxComb) self.nodes[2].sendrawtransaction(rawTxComb) rawTx2 = self.nodes[0].decoderawtransaction(rawTxComb) - self.sync_all() + self.sync_mempools() self.nodes[0].generate(1) - self.sync_all() + self.sync_blocks() assert_equal(self.nodes[0].getbalance(), bal+Decimal('50.00000000')+Decimal('2.19000000')) #block reward + tx # decoderawtransaction tests @@ -439,7 +435,7 @@ def run_test(self): rawTx = self.nodes[0].getrawtransaction(txId, True) vout = next(o for o in rawTx['vout'] if o['value'] == Decimal('1.00000000')) - self.sync_all() + self.sync_mempools() inputs = [{ "txid" : txId, "vout" : vout['n'] }] outputs = { self.nodes[0].getnewaddress() : Decimal("0.99999000") } # 1000 sat fee rawTx = self.nodes[2].createrawtransaction(inputs, outputs) diff --git a/test/functional/rpc_signrawtransaction.py b/test/functional/rpc_signrawtransaction.py index dbe6145c38..ae551491c9 100755 --- a/test/functional/rpc_signrawtransaction.py +++ b/test/functional/rpc_signrawtransaction.py @@ -155,7 +155,7 @@ def witness_script_test(self): self.nodes[0].generate(101) self.nodes[0].sendtoaddress(p2sh_p2wsh_address["address"], 49.999) self.nodes[0].generate(1) - self.sync_all() + self.sync_blocks() # Find the UTXO for the transaction node[1] should have received, check witnessScript matches unspent_output = self.nodes[1].listunspent(0, 999999, [p2sh_p2wsh_address["address"]])[0] assert_equal(unspent_output["witnessScript"], p2sh_p2wsh_address["redeemScript"]) diff --git a/test/functional/rpc_txoutproof.py b/test/functional/rpc_txoutproof.py index 7b93ad086a..6a97399113 100755 --- a/test/functional/rpc_txoutproof.py +++ b/test/functional/rpc_txoutproof.py @@ -6,7 +6,7 @@ from test_framework.messages import CMerkleBlock, FromHex, ToHex from test_framework.test_framework import DefiTestFramework -from test_framework.util import assert_equal, assert_raises_rpc_error, connect_nodes +from test_framework.util import assert_equal, assert_raises_rpc_error class MerkleBlockTest(DefiTestFramework): def set_test_params(self): @@ -18,18 +18,10 @@ def set_test_params(self): def skip_test_if_missing_module(self): self.skip_if_no_wallet() - def setup_network(self): - self.setup_nodes() - connect_nodes(self.nodes[0], 1) - connect_nodes(self.nodes[0], 2) - connect_nodes(self.nodes[0], 3) - - self.sync_all() - def run_test(self): self.log.info("Mining blocks...") self.nodes[0].generate(105) - self.sync_all() + self.sync_blocks() chain_height = self.nodes[1].getblockcount() assert_equal(chain_height, 105) @@ -46,7 +38,7 @@ def run_test(self): self.nodes[0].generate(1) blockhash = self.nodes[0].getblockhash(chain_height + 1) - self.sync_all() + self.sync_blocks() txlist = [] blocktxn = self.nodes[0].getblock(blockhash, True)["tx"] @@ -61,7 +53,7 @@ def run_test(self): tx3 = self.nodes[1].createrawtransaction([txin_spent], {self.nodes[0].getnewaddress(): 49.98}) txid3 = self.nodes[0].sendrawtransaction(self.nodes[1].signrawtransactionwithwallet(tx3)["hex"]) self.nodes[0].generate(1) - self.sync_all() + self.sync_blocks() txid_spent = txin_spent["txid"] txid_unspent = txid1 if txin_spent["txid"] != txid1 else txid2 diff --git a/test/functional/test_framework/test_framework.py b/test/functional/test_framework/test_framework.py index 0cca31cef4..1ffb122eb7 100755 --- a/test/functional/test_framework/test_framework.py +++ b/test/functional/test_framework/test_framework.py @@ -283,7 +283,7 @@ def setup_network(self): # two halves that can work on competing chains. for i in range(self.num_nodes - 1): connect_nodes_bi(self.nodes, i, i + 1) - self.sync_all() + self.sync_blocks() def setup_nodes(self): """Override this method to customize test node setup""" @@ -504,8 +504,8 @@ def split_network(self): """ disconnect_nodes(self.nodes[1], 2) disconnect_nodes(self.nodes[2], 1) - self.sync_all(self.nodes[:2]) - self.sync_all(self.nodes[2:]) + self.sync_blocks(self.nodes[:2]) + self.sync_blocks(self.nodes[2:]) def join_network(self): """ diff --git a/test/functional/wallet_address_types.py b/test/functional/wallet_address_types.py index 2506171a0f..d1c6dc5b44 100755 --- a/test/functional/wallet_address_types.py +++ b/test/functional/wallet_address_types.py @@ -88,7 +88,7 @@ def setup_network(self): for i, j in itertools.product(range(self.num_nodes), repeat=2): if i > j: connect_nodes_bi(self.nodes, i, j) - self.sync_all() + self.sync_blocks() def get_balances(self, confirmed=True): """Return a list of confirmed or unconfirmed balances.""" diff --git a/test/functional/wallet_avoidreuse.py b/test/functional/wallet_avoidreuse.py index 3c27c7beaf..5961e2b558 100755 --- a/test/functional/wallet_avoidreuse.py +++ b/test/functional/wallet_avoidreuse.py @@ -85,12 +85,12 @@ def run_test(self): self.test_immutable() self.nodes[0].generate(110) - self.sync_all() + self.sync_blocks() reset_balance(self.nodes[1], self.nodes[0].getnewaddress()) - self.sync_all() + self.sync_mempools() self.test_fund_send_fund_senddirty() reset_balance(self.nodes[1], self.nodes[0].getnewaddress()) - self.sync_all() + self.sync_mempools() self.test_fund_send_fund_send() def test_persistence(self): @@ -144,7 +144,7 @@ def test_fund_send_fund_senddirty(self): self.nodes[0].sendtoaddress(fundaddr, 10) self.nodes[0].generate(1) - self.sync_all() + self.sync_blocks() # listunspent should show 1 single, unused 10 btc output assert_unspent(self.nodes[1], total_count=1, total_sum=10, reused_supported=True, reused_count=0) @@ -164,7 +164,7 @@ def test_fund_send_fund_senddirty(self): self.nodes[0].sendtoaddress(fundaddr, 10) self.nodes[0].generate(1) - self.sync_all() + self.sync_blocks() # listunspent should show 2 total outputs (5, 10 btc), one unused (5), one reused (10) assert_unspent(self.nodes[1], total_count=2, total_sum=15, reused_count=1, reused_sum=10) @@ -197,7 +197,7 @@ def test_fund_send_fund_send(self): self.nodes[0].sendtoaddress(fundaddr, 10) self.nodes[0].generate(1) - self.sync_all() + self.sync_blocks() # listunspent should show 1 single, unused 10 btc output assert_unspent(self.nodes[1], total_count=1, total_sum=10, reused_supported=True, reused_count=0) @@ -215,7 +215,7 @@ def test_fund_send_fund_send(self): self.nodes[0].sendtoaddress(fundaddr, 10) self.nodes[0].generate(1) - self.sync_all() + self.sync_blocks() # listunspent should show 2 total outputs (5, 10 btc), one unused (5), one reused (10) assert_unspent(self.nodes[1], total_count=2, total_sum=15, reused_count=1, reused_sum=10) diff --git a/test/functional/wallet_backup.py b/test/functional/wallet_backup.py index f8081dac47..fe1671f8ae 100755 --- a/test/functional/wallet_backup.py +++ b/test/functional/wallet_backup.py @@ -61,10 +61,6 @@ def setup_network(self): connect_nodes(self.nodes[1], 3) connect_nodes(self.nodes[2], 3) connect_nodes(self.nodes[2], 0) - self.sync_all() - # TestNode.Mocktime = int(time.time()) - # TestNode.Mocktime = self.nodes[0].getblockheader(self.nodes[0].getbestblockhash())["time"] + 1 - # set_node_times(self.nodes, TestNode.Mocktime) def one_send(self, from_node, to_address): if (randint(1,2) == 1): @@ -148,7 +144,7 @@ def run_test(self): # Generate 101 more blocks, so any fees paid mature self.nodes[3].generate(101) - self.sync_all() + self.sync_blocks() balance0 = self.nodes[0].getbalance() balance1 = self.nodes[1].getbalance() diff --git a/test/functional/wallet_balance.py b/test/functional/wallet_balance.py index ba217130a7..c1f3fb826b 100755 --- a/test/functional/wallet_balance.py +++ b/test/functional/wallet_balance.py @@ -70,10 +70,10 @@ def run_test(self): self.log.info("Mining blocks ...") self.nodes[0].generate(1) - self.sync_all() + self.sync_blocks() self.nodes[1].generate(1) self.nodes[1].generate(nblocks=101, address=ADDRESS_WATCHONLY) - self.sync_all() + self.sync_blocks() assert_equal(self.nodes[0].getbalances()['mine']['trusted'], 50) assert_equal(self.nodes[0].getwalletinfo()['balance'], 50) @@ -98,11 +98,11 @@ def run_test(self): self.nodes[0].sendrawtransaction(txs[0]['hex']) self.nodes[1].sendrawtransaction(txs[0]['hex']) # sending on both nodes is faster than waiting for propagation - self.sync_all() + self.sync_mempools() txs = create_transactions(self.nodes[1], self.nodes[0].getnewaddress(), 60, [Decimal('0.01'), Decimal('0.02')]) self.nodes[1].sendrawtransaction(txs[0]['hex']) self.nodes[0].sendrawtransaction(txs[0]['hex']) # sending on both nodes is faster than waiting for propagation - self.sync_all() + self.sync_mempools() # First argument of getbalance must be set to "*" assert_raises_rpc_error(-32, "dummy first argument must be excluded or set to \"*\"", self.nodes[1].getbalance, "") @@ -134,13 +134,13 @@ def test_balances(*, fee_node_1=0): # Node 1 bumps the transaction fee and resends self.nodes[1].sendrawtransaction(txs[1]['hex']) self.nodes[0].sendrawtransaction(txs[1]['hex']) # sending on both nodes is faster than waiting for propagation - self.sync_all() + self.sync_mempools() self.log.info("Test getbalance and getunconfirmedbalance with conflicted unconfirmed inputs") test_balances(fee_node_1=Decimal('0.02')) self.nodes[1].generate(nblocks=1, address=ADDRESS_WATCHONLY) - self.sync_all() + self.sync_blocks() # balances are correct after the transactions are confirmed assert_equal(self.nodes[0].getbalance(), Decimal('69.99')) # node 1's send plus change from node 0's send @@ -150,7 +150,7 @@ def test_balances(*, fee_node_1=0): txs = create_transactions(self.nodes[1], self.nodes[0].getnewaddress(), Decimal('29.97'), [Decimal('0.01')]) self.nodes[1].sendrawtransaction(txs[0]['hex']) self.nodes[1].generate(nblocks=2, address=ADDRESS_WATCHONLY) - self.sync_all() + self.sync_blocks() # getbalance with a minconf incorrectly excludes coins that have been spent more recently than the minconf blocks ago # TODO: fix getbalance tracking of coin spentness depth @@ -166,7 +166,7 @@ def test_balances(*, fee_node_1=0): dst = self.nodes[1].getnewaddress() self.nodes[1].unloadwallet('') self.nodes[0].sendtoaddress(dst, 0.1) - self.sync_all() + self.sync_mempools() self.nodes[1].loadwallet('') after = self.nodes[1].getunconfirmedbalance() assert_equal(before + Decimal('0.1'), after) @@ -192,12 +192,12 @@ def test_balances(*, fee_node_1=0): tx_replace = self.nodes[0].signrawtransactionwithwallet(tx_replace)['hex'] # Total balance is given by the sum of outputs of the tx total_amount = sum([o['value'] for o in self.nodes[0].decoderawtransaction(tx_replace)['vout']]) - self.sync_all() + self.sync_mempools() self.nodes[1].sendrawtransaction(hexstring=tx_replace, maxfeerate=0) # Now confirm tx_replace block_reorg = self.nodes[1].generate(nblocks=1, address=ADDRESS_WATCHONLY)[0] - self.sync_all() + self.sync_blocks() assert_equal(self.nodes[0].getbalance(minconf=0), total_amount) self.log.info('Put txs back into mempool of node 1 (not node 0)') @@ -214,7 +214,7 @@ def test_balances(*, fee_node_1=0): sync_blocks(self.nodes) self.nodes[1].sendrawtransaction(tx_orig) self.nodes[1].generate(nblocks=1, address=ADDRESS_WATCHONLY) - self.sync_all() + self.sync_blocks() assert_equal(self.nodes[0].getbalance(minconf=0), total_amount + 1) # The reorg recovered our fee of 1 coin diff --git a/test/functional/wallet_basic.py b/test/functional/wallet_basic.py index a6b8b41ae5..27d6dc9763 100755 --- a/test/functional/wallet_basic.py +++ b/test/functional/wallet_basic.py @@ -35,7 +35,7 @@ def setup_network(self): 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_blocks(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""" @@ -60,9 +60,9 @@ def run_test(self): assert_equal(walletinfo['immature_balance'], 50) assert_equal(walletinfo['balance'], 0) - self.sync_all(self.nodes[0:3]) + self.sync_blocks(self.nodes[0:3]) self.nodes[1].generate(101) - self.sync_all(self.nodes[0:3]) + self.sync_blocks(self.nodes[0:3]) assert_equal(self.nodes[0].getbalance(), 50) assert_equal(self.nodes[1].getbalance(), 50) @@ -109,7 +109,7 @@ def run_test(self): # 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_blocks(self.nodes[0:3]) # Exercise locking of unspent outputs unspent_0 = self.nodes[2].listunspent()[0] @@ -145,7 +145,7 @@ def run_test(self): # 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_blocks(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 @@ -174,7 +174,7 @@ def run_test(self): # Have node1 mine a block to confirm transactions: self.nodes[1].generate(1) - self.sync_all(self.nodes[0:3]) + self.sync_blocks(self.nodes[0:3]) assert_equal(self.nodes[0].getbalance(), 0) assert_equal(self.nodes[2].getbalance(), 94) @@ -189,14 +189,14 @@ def run_test(self): 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_blocks(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_blocks(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'])) @@ -204,7 +204,7 @@ def run_test(self): # 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_blocks(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) @@ -212,14 +212,14 @@ def run_test(self): # 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_blocks(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'])) self.start_node(3) connect_nodes_bi(self.nodes, 0, 3) - self.sync_all() + self.sync_blocks() # check if we can list zero value tx as available coins # 1. create raw_tx @@ -236,9 +236,9 @@ def run_test(self): zero_value_txid = decoded_raw_tx['txid'] self.nodes[1].sendrawtransaction(signed_raw_tx['hex']) - self.sync_all() + self.sync_mempools() self.nodes[1].generate(1) # mine a block - self.sync_all() + self.sync_blocks() unspent_txs = self.nodes[0].listunspent() # zero value tx must be in listunspents output found = False @@ -256,18 +256,18 @@ def run_test(self): 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_blocks(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_blocks(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_blocks(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) @@ -344,7 +344,7 @@ def run_test(self): 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_blocks(self.nodes[0:3]) # 2. Import address from node2 to node1 self.nodes[1].importaddress(address_to_import) @@ -370,15 +370,15 @@ def run_test(self): coinbase_addr = self.nodes[1].getnewaddress() block_hash = self.nodes[0].generate(nblocks=1, address=coinbase_addr)[0] coinbase_txid = self.nodes[0].getblock(block_hash)['tx'][0] - self.sync_all(self.nodes[0:3]) + self.sync_blocks(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_blocks(self.nodes[0:3]) blocks = self.nodes[0].generate(2) - self.sync_all(self.nodes[0:3]) + self.sync_blocks(self.nodes[0:3]) balance_nodes = [self.nodes[i].getbalance() for i in range(3)] block_count = self.nodes[0].getblockcount() diff --git a/test/functional/wallet_bumpfee.py b/test/functional/wallet_bumpfee.py index db7b77c199..532c2e25d7 100755 --- a/test/functional/wallet_bumpfee.py +++ b/test/functional/wallet_bumpfee.py @@ -24,7 +24,6 @@ assert_equal, assert_greater_than, assert_raises_rpc_error, - connect_nodes_bi, hex_str_to_bytes, set_node_times, ) @@ -50,24 +49,19 @@ def run_test(self): self.nodes[1].encryptwallet(WALLET_PASSPHRASE) self.nodes[1].walletpassphrase(WALLET_PASSPHRASE, WALLET_PASSPHRASE_TIMEOUT) - connect_nodes_bi(self.nodes, 0, 1) - self.sync_all() - peer_node, rbf_node = self.nodes rbf_node_address = rbf_node.getnewaddress() # fund rbf node with 10 coins of 0.001 btc (100,000 satoshis) self.log.info("Mining blocks...") peer_node.generate(110) - self.sync_all() for i in range(25): peer_node.sendtoaddress(rbf_node_address, 0.001) # we need to move time to sync set_node_times([rbf_node], TestNode.Mocktime) - self.sync_all() peer_node.generate(1) - self.sync_all() + self.sync_blocks() assert_equal(rbf_node.getbalance(), Decimal("0.025")) self.log.info("Running tests") diff --git a/test/functional/wallet_bumpfee_totalfee_deprecation.py b/test/functional/wallet_bumpfee_totalfee_deprecation.py index c42bfc21d2..350dbe94d2 100755 --- a/test/functional/wallet_bumpfee_totalfee_deprecation.py +++ b/test/functional/wallet_bumpfee_totalfee_deprecation.py @@ -23,11 +23,10 @@ def skip_test_if_missing_module(self): def run_test(self): peer_node, rbf_node = self.nodes peer_node.generate(110) - self.sync_all() + self.sync_blocks() peer_node.sendtoaddress(rbf_node.getnewaddress(), 0.001) - self.sync_all() peer_node.generate(1) - self.sync_all() + self.sync_blocks() rbfid = spend_one_input(rbf_node, peer_node.getnewaddress()) self.log.info("Testing bumpfee with totalFee argument raises RPC error with deprecation message") diff --git a/test/functional/wallet_groups.py b/test/functional/wallet_groups.py index f23f5ec994..acd12b2098 100755 --- a/test/functional/wallet_groups.py +++ b/test/functional/wallet_groups.py @@ -40,7 +40,7 @@ def run_test(self): [self.nodes[0].sendtoaddress(addr, 0.5) for addr in addrs] self.nodes[0].generate(1) - self.sync_all() + self.sync_blocks() # For each node, send 0.2 coins back to 0; # - node[1] should pick one 0.5 UTXO and leave the rest @@ -85,7 +85,7 @@ def run_test(self): self.nodes[0].sendrawtransaction(signed_tx['hex']) self.nodes[0].generate(1) - self.sync_all() + self.sync_blocks() # Check that we can create a transaction that only requires ~100 of our # utxos, without pulling in all outputs and creating a transaction that diff --git a/test/functional/wallet_hd.py b/test/functional/wallet_hd.py index 6c689565d1..3dd7b37245 100755 --- a/test/functional/wallet_hd.py +++ b/test/functional/wallet_hd.py @@ -62,7 +62,7 @@ def run_test(self): change_addrV= self.nodes[1].getaddressinfo(change_addr) assert_equal(change_addrV["hdkeypath"], "m/0'/1'/1'") #second internal child key - self.sync_all() + self.sync_blocks() assert_equal(self.nodes[1].getbalance(), NUM_HD_ADDS + 1) self.log.info("Restore backup ...") @@ -85,7 +85,7 @@ def run_test(self): assert_equal(hd_info_2["hdseedid"], masterkeyid) assert_equal(hd_add, hd_add_2) connect_nodes_bi(self.nodes, 0, 1) - self.sync_all() + self.sync_blocks() # Needs rescan self.stop_node(1) @@ -101,7 +101,7 @@ def run_test(self): shutil.copyfile(os.path.join(self.nodes[1].datadir, "hd.bak"), os.path.join(self.nodes[1].datadir, "regtest", "wallets", "wallet.dat")) self.start_node(1, extra_args=self.extra_args[1]) connect_nodes_bi(self.nodes, 0, 1) - self.sync_all() + self.sync_blocks() # Wallet automatically scans blocks older than key on startup assert_equal(self.nodes[1].getbalance(), NUM_HD_ADDS + 1) out = self.nodes[1].rescanblockchain(0, 1) diff --git a/test/functional/wallet_import_rescan.py b/test/functional/wallet_import_rescan.py index 125aaadf48..03ba7e5dbf 100755 --- a/test/functional/wallet_import_rescan.py +++ b/test/functional/wallet_import_rescan.py @@ -192,7 +192,7 @@ def run_test(self): ) self.nodes[0].reset_mocktime() # reset generate's inner Mocktime to mint with those from set_node_times() self.nodes[0].generate(1) - self.sync_all() + self.sync_blocks() # For each variation of wallet key import, invoke the import RPC and # check the results from getbalance and listtransactions. diff --git a/test/functional/wallet_importprunedfunds.py b/test/functional/wallet_importprunedfunds.py index 78a3d5eb22..04fa36e029 100755 --- a/test/functional/wallet_importprunedfunds.py +++ b/test/functional/wallet_importprunedfunds.py @@ -23,7 +23,7 @@ def run_test(self): self.log.info("Mining blocks...") self.nodes[0].generate(101) - self.sync_all() + self.sync_blocks() # address address1 = self.nodes[0].getnewaddress() @@ -37,8 +37,6 @@ def run_test(self): address_info = self.nodes[0].getaddressinfo(address1) assert_equal(address_info['ismine'], True) - self.sync_all() - # Node 1 sync test assert_equal(self.nodes[1].getblockcount(), 101) @@ -71,7 +69,7 @@ def run_test(self): rawtxn3 = self.nodes[0].gettransaction(txnid3)['hex'] proof3 = self.nodes[0].gettxoutproof([txnid3]) - self.sync_all() + self.sync_blocks() # Import with no affiliated address assert_raises_rpc_error(-5, "No addresses", self.nodes[1].importprunedfunds, rawtxn1, proof1) diff --git a/test/functional/wallet_keypool_topup.py b/test/functional/wallet_keypool_topup.py index ccefdf65af..b23bfcf4f5 100755 --- a/test/functional/wallet_keypool_topup.py +++ b/test/functional/wallet_keypool_topup.py @@ -73,7 +73,7 @@ def run_test(self): shutil.copyfile(wallet_backup_path, wallet_path) self.start_node(idx, self.extra_args[idx]) connect_nodes_bi(self.nodes, 0, idx) - self.sync_all() + self.sync_blocks() self.log.info("Verify keypool is restored and balance is correct") assert_equal(self.nodes[idx].getbalance(), 15) diff --git a/test/functional/wallet_listreceivedby.py b/test/functional/wallet_listreceivedby.py index 1789283a2a..80c75df014 100755 --- a/test/functional/wallet_listreceivedby.py +++ b/test/functional/wallet_listreceivedby.py @@ -33,7 +33,7 @@ def run_test(self): # Send from node 0 to 1 addr = self.nodes[1].getnewaddress() txid = self.nodes[0].sendtoaddress(addr, 0.1) - self.sync_all() + self.sync_mempools() # Check not listed in listreceivedbyaddress because has 0 confirmations assert_array_result(self.nodes[1].listreceivedbyaddress(), @@ -42,7 +42,7 @@ def run_test(self): True) # Bury Tx under 10 block so it will be returned by listreceivedbyaddress self.nodes[1].generate(10) - self.sync_all() + self.sync_blocks() assert_array_result(self.nodes[1].listreceivedbyaddress(), {"address": addr}, {"address": addr, "label": "", "amount": Decimal("0.1"), "confirmations": 10, "txids": [txid, ]}) @@ -77,7 +77,7 @@ def run_test(self): other_addr = self.nodes[1].getnewaddress() txid2 = self.nodes[0].sendtoaddress(other_addr, 0.1) self.nodes[0].generate(1) - self.sync_all() + self.sync_blocks() # Same test as above should still pass expected = {"address": addr, "label": "", "amount": Decimal("0.1"), "confirmations": 11, "txids": [txid, ]} res = self.nodes[1].listreceivedbyaddress(0, True, True, addr) @@ -102,7 +102,7 @@ def run_test(self): # Send from node 0 to 1 addr = self.nodes[1].getnewaddress() txid = self.nodes[0].sendtoaddress(addr, 0.1) - self.sync_all() + self.sync_mempools() # Check balance is 0 because of 0 confirmations balance = self.nodes[1].getreceivedbyaddress(addr) @@ -114,7 +114,7 @@ def run_test(self): # Bury Tx under 10 block so it will be returned by the default getreceivedbyaddress self.nodes[1].generate(10) - self.sync_all() + self.sync_blocks() balance = self.nodes[1].getreceivedbyaddress(addr) assert_equal(balance, Decimal("0.1")) @@ -131,7 +131,7 @@ def run_test(self): balance_by_label = self.nodes[1].getreceivedbylabel(label) txid = self.nodes[0].sendtoaddress(addr, 0.1) - self.sync_all() + self.sync_mempools() # listreceivedbylabel should return received_by_label_json because of 0 confirmations assert_array_result(self.nodes[1].listreceivedbylabel(), @@ -143,7 +143,7 @@ def run_test(self): assert_equal(balance, balance_by_label) self.nodes[1].generate(10) - self.sync_all() + self.sync_blocks() # listreceivedbylabel should return updated received list assert_array_result(self.nodes[1].listreceivedbylabel(), {"label": label}, diff --git a/test/functional/wallet_listsinceblock.py b/test/functional/wallet_listsinceblock.py index e2c2c89cbf..27adeaf695 100755 --- a/test/functional/wallet_listsinceblock.py +++ b/test/functional/wallet_listsinceblock.py @@ -17,7 +17,7 @@ def skip_test_if_missing_module(self): def run_test(self): self.nodes[2].generate(101) - self.sync_all() + self.sync_blocks() self.test_no_blockhash() self.test_invalid_blockhash() @@ -28,7 +28,7 @@ def run_test(self): def test_no_blockhash(self): txid = self.nodes[2].sendtoaddress(self.nodes[0].getnewaddress(), 1) blockhash, = self.nodes[2].generate(1) - self.sync_all() + self.sync_blocks() txs = self.nodes[0].listtransactions() assert_array_result(txs, {"txid": txid}, { @@ -98,8 +98,8 @@ def test_reorg(self): self.nodes[2].generate(7) self.log.info('lastblockhash=%s' % (lastblockhash)) - self.sync_all(self.nodes[:2]) - self.sync_all(self.nodes[2:]) + self.sync_blocks(self.nodes[:2]) + self.sync_blocks(self.nodes[2:]) self.join_network() @@ -142,7 +142,7 @@ def test_double_spend(self): node wallet. ''' - self.sync_all() + self.sync_blocks() # Split network into two self.split_network() @@ -182,7 +182,7 @@ def test_double_spend(self): self.join_network() - self.sync_all() + self.sync_blocks() # gettransaction should work for txid1 assert self.nodes[0].gettransaction(txid1)['txid'] == txid1, "gettransaction failed to find txid1" @@ -221,7 +221,7 @@ def test_double_send(self): 3 (aa1, aa2, aa3). ''' - self.sync_all() + self.sync_blocks() # Split network into two self.split_network() @@ -261,7 +261,7 @@ def test_double_send(self): self.join_network() - self.sync_all() + self.sync_blocks() # gettransaction should work for txid1 self.nodes[0].gettransaction(txid1) diff --git a/test/functional/wallet_listtransactions.py b/test/functional/wallet_listtransactions.py index b0d8a5919a..fc64df21da 100755 --- a/test/functional/wallet_listtransactions.py +++ b/test/functional/wallet_listtransactions.py @@ -29,10 +29,10 @@ def skip_test_if_missing_module(self): def run_test(self): self.nodes[0].generate(1) # Get out of IBD - self.sync_all() + self.sync_blocks() # Simple send, 0 to 1: txid = self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 0.1) - self.sync_all() + self.sync_mempools() assert_array_result(self.nodes[0].listtransactions(), {"txid": txid}, {"category": "send", "amount": Decimal("-0.1"), "confirmations": 0}) @@ -41,7 +41,7 @@ def run_test(self): {"category": "receive", "amount": Decimal("0.1"), "confirmations": 0}) # mine a block, confirmations should change: self.nodes[0].generate(1) - self.sync_all() + self.sync_blocks() assert_array_result(self.nodes[0].listtransactions(), {"txid": txid}, {"category": "send", "amount": Decimal("-0.1"), "confirmations": 1}) @@ -64,7 +64,7 @@ def run_test(self): self.nodes[0].getnewaddress(): 0.33, self.nodes[1].getnewaddress(): 0.44} txid = self.nodes[1].sendmany("", send_to) - self.sync_all() + self.sync_mempools() assert_array_result(self.nodes[1].listtransactions(), {"category": "send", "amount": Decimal("-0.11")}, {"txid": txid}) @@ -95,7 +95,7 @@ def run_test(self): self.nodes[0].importaddress(multisig["redeemScript"], "watchonly", False, True) txid = self.nodes[1].sendtoaddress(multisig["address"], 0.1) self.nodes[1].generate(1) - self.sync_all() + self.sync_blocks() assert len(self.nodes[0].listtransactions(label="watchonly", count=100, include_watchonly=False)) == 0 assert_array_result(self.nodes[0].listtransactions(label="watchonly", count=100, include_watchonly=True), {"category": "receive", "amount": Decimal("0.1")}, diff --git a/test/functional/wallet_zapwallettxes.py b/test/functional/wallet_zapwallettxes.py index 255c1754a9..6de50dc4da 100755 --- a/test/functional/wallet_zapwallettxes.py +++ b/test/functional/wallet_zapwallettxes.py @@ -33,15 +33,15 @@ def skip_test_if_missing_module(self): def run_test(self): self.log.info("Mining blocks...") self.nodes[0].generate(1) - self.sync_all() + self.sync_blocks() self.nodes[1].generate(100) - self.sync_all() + self.sync_blocks() # This transaction will be confirmed txid1 = self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 10) self.nodes[0].generate(1) - self.sync_all() + self.sync_blocks() # This transaction will not be confirmed txid2 = self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 20)