assert False if get_validators() == set(["test0", "test1", "test2", "test3"]): break time.sleep(1) print("stage 4 done") ctx.next_nonce = 100 # 5. Record the latest height and bring down the first node, wait for couple epochs to pass status = observer.get_status() last_height = status['sync_info']['latest_block_height'] ctx.nodes = [boot_node, node2, node3, node4, observer] ctx.act_to_val = [4, 4, 4, 4, 4] boot_node.kill() seen_boot_heights = set() sent_txs = False while True: assert time.time() - started < TIMEOUT status = observer.get_status() hash_ = status['sync_info']['latest_block_hash'] new_height = status['sync_info']['latest_block_height'] seen_boot_heights.add(new_height) if new_height > largest_height: largest_height = new_height print(new_height) if new_height >= last_height + TARGET_HEIGHT:
if time.time() - started > TIMEOUT: print(get_validators()) assert False if get_validators() == set(["test0", "test1"]): break time.sleep(1) ctx.next_nonce = 100 # 5. Record the latest height and bring down the first node, wait for couple epochs to pass status = node2.get_status() last_height = status['sync_info']['latest_block_height'] ctx.nodes = [boot_node, node2, observer] ctx.act_to_val = [1, 1, 1] boot_node.kill() seen_boot_heights = set() sent_txs = False while True: assert time.time() - started < TIMEOUT status = node2.get_status() hash_ = status['sync_info']['latest_block_hash'] new_height = status['sync_info']['latest_block_height'] seen_boot_heights.add(new_height) if new_height > largest_height: largest_height = new_height print(new_height) if new_height >= last_height + TWENTY_FIVE:
if mode == 'manytx': if ctx.get_balances() == ctx.expected_balances: ctx.send_moar_txs(hash_, 3, False) print("Sending moar txs at height %s" % boot_height) time.sleep(0.1) boot_heights = boot_node.get_all_heights() assert catch_up_height in boot_heights, "%s not in %s" % (catch_up_height, boot_heights) tracker.reset() # the transition might have happened before we initialized the tracker if catch_up_height >= 100: assert tracker.check("transition to State Sync") elif catch_up_height <= 30: assert not tracker.check("transition to State Sync") if mode == 'manytx': while ctx.get_balances() != ctx.expected_balances: assert time.time() - started < TIMEOUT print("Waiting for the old node to catch up. Current balances: %s; Expected balances: %s" % (ctx.get_balances(), ctx.expected_balances)) time.sleep(1) # requery the balances from the newly started node ctx.nodes.append(node2) ctx.act_to_val = [2, 2, 2] while ctx.get_balances() != ctx.expected_balances: assert time.time() - started < TIMEOUT print("Waiting for the new node to catch up. Current balances: %s; Expected balances: %s" % (ctx.get_balances(), ctx.expected_balances)) time.sleep(1)