Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests: Replace sync_all with sync_blocks/sync_mempools #1074

Merged
merged 2 commits into from
Jan 27, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Replace sync_all with sync_blocks or sync_mempools where applicable
  • Loading branch information
Bushstar committed Jan 27, 2022
commit db0d6157d663c958baaf06b1498c0c6daa36b6dc
6 changes: 3 additions & 3 deletions test/functional/feature_accounts_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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")
Expand All @@ -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)
Expand Down
10 changes: 4 additions & 6 deletions test/functional/feature_anchor_rewards.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)
Expand All @@ -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'))
Expand All @@ -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")
Expand All @@ -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
Expand Down Expand Up @@ -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)

Expand Down
12 changes: 6 additions & 6 deletions test/functional/feature_any_accounts_to_accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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 = []
Expand Down Expand Up @@ -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)
Expand All @@ -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)

Expand All @@ -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 = {}
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion test/functional/feature_checkpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions test/functional/feature_communitybalance_reorg.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions test/functional/feature_initdist.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):

Expand All @@ -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()
Expand All @@ -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)
Expand Down
17 changes: 6 additions & 11 deletions test/functional/feature_listaccounts_pagination.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions test/functional/feature_loan_vault.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'))
Expand Down Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions test/functional/feature_masternode_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
11 changes: 5 additions & 6 deletions test/functional/feature_mempool_dakota.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,29 +25,28 @@ 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

# Get addresses and set up account
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)
assert_equal(node.listmasternodes({}, False)[collateral], "ENABLED")

node1.utxostoaccount({wallet1_addr: "0.09@0"})
node.generate(1)
self.sync_all()
self.sync_blocks()

if __name__ == '__main__':
MempoolDakotaTest().main ()
2 changes: 1 addition & 1 deletion test/functional/feature_minchainwork.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__':
Expand Down
4 changes: 2 additions & 2 deletions test/functional/feature_mine_cached.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
14 changes: 5 additions & 9 deletions test/functional/feature_oracles.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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]]
Expand Down Expand Up @@ -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])
Expand Down Expand Up @@ -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"})

Expand Down Expand Up @@ -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()
2 changes: 1 addition & 1 deletion test/functional/feature_poolpair.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading