Skip to content

Commit

Permalink
grandpa reorg test (#2167)
Browse files Browse the repository at this point in the history
Signed-off-by: turuslan <turuslan.devbox@gmail.com>
Co-authored-by: kamilsa <kamilsa16@gmail.com>
  • Loading branch information
turuslan and kamilsa authored Aug 5, 2024
1 parent 16a461a commit f9754e3
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion test/core/blockchain/block_tree_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,13 @@ struct BlockTreeTest : public testing::Test {
return {hash, header};
}

uint32_t state_nonce_ = 0;
BlockHash addHeaderToRepository(const BlockHash &parent, BlockNumber number) {
Hash256 state;
memcpy(state.data(), &state_nonce_, sizeof(state_nonce_));
++state_nonce_;
return std::get<0>(addHeaderToRepositoryAndGet(
parent, number, {}, SlotType::SecondaryPlain));
parent, number, state, SlotType::SecondaryPlain));
}

BlockHash addHeaderToRepository(const BlockHash &parent,
Expand Down Expand Up @@ -788,6 +792,11 @@ TEST_F(BlockTreeTest, GetBestChain_TwoChains) {

ASSERT_OUTCOME_SUCCESS(best_info, block_tree_->getBestContaining(T_hash));
ASSERT_EQ(best_info.hash, D2_hash);

// test grandpa best chain selection when target block is not on best chain
// /~https://github.com/paritytech/polkadot-sdk/pull/5153
// /~https://github.com/paritytech/polkadot-sdk/blob/776e95748901b50ff2833a7d27ea83fd91fbf9d1/substrate/client/consensus/grandpa/src/tests.rs#L1823-L1931
EXPECT_EQ(block_tree_->getBestContaining(C1_hash).value().hash, C1_hash);
}

/**
Expand Down

0 comments on commit f9754e3

Please sign in to comment.