def test_new_block_header_pool(self):
    id1 = Identity.create_random_identity()
    acc1 = Address.create_from_identity(id1, full_shard_key=0)
    with ClusterContext(1, acc1) as clusters:
        shard_state = clusters[0].get_shard_state(2)
        b1 = _tip_gen(shard_state)
        add_result = call_async(clusters[0].master.add_raw_minor_block(b1.header.branch, b1.serialize()))
        self.assertTrue(add_result)
        clusters[0].master.env.quark_chain_config.SKIP_MINOR_DIFFICULTY_CHECK = False
        b2 = b1.create_block_to_append(difficulty=12345)
        shard = clusters[0].slave_list[0].shards[b2.header.branch]
        with self.assertRaises(ValueError):
            call_async(shard.handle_new_block(b2))
        self.assertTrue((b2.header.get_hash() not in shard.state.new_block_header_pool))
def test_new_block_header_pool(self):
    id1 = Identity.create_random_identity()
    acc1 = Address.create_from_identity(id1, full_shard_key=0)
    with ClusterContext(1, acc1) as clusters:
        shard_state = clusters[0].get_shard_state(2)
        b1 = _tip_gen(shard_state)
        add_result = call_async(clusters[0].master.add_raw_minor_block(b1.header.branch, b1.serialize()))
        self.assertTrue(add_result)
        clusters[0].master.env.quark_chain_config.SKIP_MINOR_DIFFICULTY_CHECK = False
        b2 = b1.create_block_to_append(difficulty=12345)
        shard = clusters[0].slave_list[0].shards[b2.header.branch]
        with self.assertRaises(ValueError):
            call_async(shard.handle_new_block(b2))
        self.assertTrue((b2.header.get_hash() not in shard.state.new_block_header_pool))