def test_get_root_block_header_sync_with_start_equal_end(self):
    id1 = Identity.create_random_identity()
    acc1 = Address.create_from_identity(id1, full_shard_key=0)
    with ClusterContext(2, acc1, connect=False) as clusters:
        master0 = clusters[0].master
        root_block_list = []
        for i in range(5):
            root_block = call_async(master0.get_next_block_to_mine(Address.create_empty_account(), branch_value=None))
            call_async(master0.add_root_block(root_block))
            root_block_list.append(root_block)
        assert_true_with_timeout((lambda : (master0.root_state.tip == root_block_list[(- 1)].header)))
        master1 = clusters[1].master
        for i in range(3):
            call_async(master1.add_root_block(root_block_list[i]))
        for i in range(1):
            root_block = call_async(master1.get_next_block_to_mine(acc1, branch_value=None))
            call_async(master1.add_root_block(root_block))
        master1.synchronizer.root_block_header_list_limit = 3
        call_async(clusters[1].network.connect('127.0.0.1', clusters[0].network.env.cluster_config.P2P_PORT))
        assert_true_with_timeout((lambda : (master1.root_state.tip == root_block_list[(- 1)].header)))
        self.assertEqual(master1.synchronizer.stats.blocks_downloaded, 2)
        self.assertEqual(master1.synchronizer.stats.headers_downloaded, 6)
        self.assertEqual(master1.synchronizer.stats.ancestor_lookup_requests, 2)
def test_get_root_block_header_sync_with_start_equal_end(self):
    id1 = Identity.create_random_identity()
    acc1 = Address.create_from_identity(id1, full_shard_key=0)
    with ClusterContext(2, acc1, connect=False) as clusters:
        master0 = clusters[0].master
        root_block_list = []
        for i in range(5):
            root_block = call_async(master0.get_next_block_to_mine(Address.create_empty_account(), branch_value=None))
            call_async(master0.add_root_block(root_block))
            root_block_list.append(root_block)
        assert_true_with_timeout((lambda : (master0.root_state.tip == root_block_list[(- 1)].header)))
        master1 = clusters[1].master
        for i in range(3):
            call_async(master1.add_root_block(root_block_list[i]))
        for i in range(1):
            root_block = call_async(master1.get_next_block_to_mine(acc1, branch_value=None))
            call_async(master1.add_root_block(root_block))
        master1.synchronizer.root_block_header_list_limit = 3
        call_async(clusters[1].network.connect('127.0.0.1', clusters[0].network.env.cluster_config.P2P_PORT))
        assert_true_with_timeout((lambda : (master1.root_state.tip == root_block_list[(- 1)].header)))
        self.assertEqual(master1.synchronizer.stats.blocks_downloaded, 2)
        self.assertEqual(master1.synchronizer.stats.headers_downloaded, 6)
        self.assertEqual(master1.synchronizer.stats.ancestor_lookup_requests, 2)