def test_all_nodes_boostrap(self, sandbox: Sandbox): assert sandbox.client(0).sync_state() == 'synced' assert sandbox.client(1).sync_state() == 'synced' sandbox.client(2).bootstrapped()
def test_vote_in_promotion_phase(self, sandbox: Sandbox): client = sandbox.client(0) listings = client.get_listings() for listing in listings: client.submit_ballot(listing["pkh"], PROTO_B, 'yay')
def test_add_initial_nodes(self, sandbox: Sandbox): for i in range(NUM_NODES): sandbox.add_node(i, params=constants.NODE_PARAMS)
def test_proposal_period(self, sandbox: Sandbox): assert_all_clients_in_period(sandbox.all_clients(), 'proposal')
def test_delegates_vote_proto_b(self, sandbox: Sandbox): client = sandbox.client(0) listings = client.get_listings() # submit ballot for all bakers with listings for listing in listings: client.submit_ballot(listing["pkh"], PROTO_B, 'yay')
def test_bake_node_2(self, sandbox: Sandbox): """Client 2 bakes block B at level 3, not communicated to 0 and 1""" utils.bake(sandbox.client(2))
def test_check_level(self, sandbox: Sandbox): """All nodes are at level 3, head is either block A or B""" level = 3 for client in sandbox.all_clients(): assert utils.check_level(client, level)
def test_add_node(self, sandbox: Sandbox): sandbox.add_node( 1, params=params(1), log_levels=LOG_LEVEL, config_client=False ) sandbox.client(1).bootstrapped()
def test_node_1_bootstrapped(self, sandbox: Sandbox): sandbox.client(1).bootstrapped()
def test_add_nodes(self, sandbox: Sandbox): for i in range(2, NUM_NODES): sandbox.add_node( i, params=params(), config_client=False, log_levels=LOG_LEVEL )
def test_bootstrap(self, sandbox: Sandbox): client = sandbox.client(0) assert client.sync_state() == 'synced'
def test_bootstrap(self, sandbox: Sandbox): sandbox.client(0).bootstrapped() sandbox.client(1).bootstrapped()
def test_sync_status(self, sandbox: Sandbox): assert sandbox.client(0).sync_state() == 'synced' assert sandbox.client(1).sync_state() == 'synced' assert sandbox.client(2).sync_state() == 'synced'
def test_disconnect_node(self, sandbox: Sandbox): """node 1 is disconnected from baker""" sandbox.client(1).ban_peer(sandbox.node(0).p2p_port) sandbox.client(0).ban_peer(sandbox.node(1).p2p_port)
def test_terminate_node_0(self, sandbox: Sandbox): sandbox.node(0).terminate()
def test_setup_network(self, sandbox: Sandbox): sandbox.add_node(0, params=params(), log_levels=LOG_LEVEL) protocol.activate(sandbox.client(0)) sandbox.add_baker(0, ['bootstrap5'], proto=protocol.DAEMON)
def test_restart_node_2(self, sandbox: Sandbox): sandbox.node(2).run() assert sandbox.client(2).check_node_listening()
def test_kill_baker(self, sandbox: Sandbox): """Bake a few blocks and kill baker""" time.sleep(2) sandbox.rm_baker(0, proto=protocol.DAEMON) time.sleep(5)
def test_restart_all(self, sandbox: Sandbox): sandbox.node(0).run() sandbox.node(1).run() sandbox.client(0).check_node_listening() sandbox.client(1).check_node_listening()
def test_operation_applied(self, sandbox: Sandbox, session: dict): """Check operation is in mempool""" client = sandbox.client(1) assert utils.check_mempool_contains_operations(client, [session['operation']])
def test_client_knows_proto_b(self, sandbox: Sandbox): client = sandbox.client(0) protos = client.list_protocols() assert PROTO_B in protos
def test_init(self, sandbox: Sandbox): for i in range(NUM_NODES): sandbox.add_node(i, params=constants.NODE_PARAMS) protocol.activate(sandbox.client(0), activate_in_the_past=True) utils.bake(sandbox.client(0))
def test_check_proto_b_proposed(self, sandbox: Sandbox): clients = sandbox.all_clients() wait_until_level(clients, sandbox.client(0).get_level()) for client in clients: proposals = client.get_proposals() assert PROTO_B in [proto for (proto, _) in proposals]
def test_level(self, sandbox: Sandbox): level = 2 for client in sandbox.all_clients(): assert utils.check_level(client, level)
def test_wait_for_cooldown(self, sandbox: Sandbox): client = sandbox.client(0) bake_until_next_voting_period(client, BAKER, OFFSET) clients = sandbox.all_clients() wait_until_level(clients, client.get_level()) assert_all_clients_in_period(clients, 'cooldown')
def test_terminate_nodes_1_and_2(self, sandbox: Sandbox): sandbox.node(1).terminate() sandbox.node(2).terminate()
def test_wait_for_adoption(self, sandbox: Sandbox): client = sandbox.client(0) bake_until_next_voting_period(client, BAKER) clients = sandbox.all_clients() wait_until_level(clients, client.get_level()) assert_all_clients_in_period(clients, 'adoption')
def test_bake_node_0(self, sandbox: Sandbox): """Client 0 bakes block A at level 3, not communicated to 1 and 2 Inject an endorsement to ensure a different hash""" sandbox.client(0).endorse('bootstrap1') utils.bake(sandbox.client(0))
def test_no_peers(self, sandbox: Sandbox): """ Initially, nobody knows other peers. """ for client in sandbox.all_clients(): res = client.p2p_stat() assert not res.peers
def test_all_nodes_boostrap(self, sandbox: Sandbox): """Eventually, 1 and 2 are bootstrapped with the chain stuck. """ sandbox.client(1).bootstrapped() sandbox.client(2).bootstrapped() assert sandbox.client(1).sync_state() == 'stuck' assert sandbox.client(2).sync_state() == 'stuck'