Exemplo n.º 1
0
 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()
Exemplo n.º 2
0
 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')
Exemplo n.º 3
0
 def test_add_initial_nodes(self, sandbox: Sandbox):
     for i in range(NUM_NODES):
         sandbox.add_node(i, params=constants.NODE_PARAMS)
Exemplo n.º 4
0
 def test_proposal_period(self, sandbox: Sandbox):
     assert_all_clients_in_period(sandbox.all_clients(), 'proposal')
Exemplo n.º 5
0
 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')
Exemplo n.º 6
0
 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))
Exemplo n.º 7
0
 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)
Exemplo n.º 8
0
 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()
Exemplo n.º 9
0
 def test_node_1_bootstrapped(self, sandbox: Sandbox):
     sandbox.client(1).bootstrapped()
Exemplo n.º 10
0
 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
         )
Exemplo n.º 11
0
 def test_bootstrap(self, sandbox: Sandbox):
     client = sandbox.client(0)
     assert client.sync_state() == 'synced'
Exemplo n.º 12
0
 def test_bootstrap(self, sandbox: Sandbox):
     sandbox.client(0).bootstrapped()
     sandbox.client(1).bootstrapped()
Exemplo n.º 13
0
 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'
Exemplo n.º 14
0
 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)
Exemplo n.º 15
0
 def test_terminate_node_0(self, sandbox: Sandbox):
     sandbox.node(0).terminate()
Exemplo n.º 16
0
 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)
Exemplo n.º 17
0
 def test_restart_node_2(self, sandbox: Sandbox):
     sandbox.node(2).run()
     assert sandbox.client(2).check_node_listening()
Exemplo n.º 18
0
 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)
Exemplo n.º 19
0
 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()
Exemplo n.º 20
0
 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']])
Exemplo n.º 21
0
 def test_client_knows_proto_b(self, sandbox: Sandbox):
     client = sandbox.client(0)
     protos = client.list_protocols()
     assert PROTO_B in protos
Exemplo n.º 22
0
 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))
Exemplo n.º 23
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]
Exemplo n.º 24
0
 def test_level(self, sandbox: Sandbox):
     level = 2
     for client in sandbox.all_clients():
         assert utils.check_level(client, level)
Exemplo n.º 25
0
 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')
Exemplo n.º 26
0
 def test_terminate_nodes_1_and_2(self, sandbox: Sandbox):
     sandbox.node(1).terminate()
     sandbox.node(2).terminate()
Exemplo n.º 27
0
 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')
Exemplo n.º 28
0
 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))
Exemplo n.º 29
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
Exemplo n.º 30
0
 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'