Skip to content

Commit

Permalink
Feature/btc 200 (#16)
Browse files Browse the repository at this point in the history
* change the endorsedBlock validation

* fix
  • Loading branch information
Mr-Leshiy authored Feb 3, 2020
1 parent 594c36e commit f58fc1f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/vbk/pop_service/pop_service_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -597,8 +597,8 @@ bool txPopValidation(PopServiceImpl& pop, const CTransactionRef& tx, const CBloc

AssertLockHeld(cs_main);
const CBlockIndex* popEndorsementIdnex = LookupBlockIndex(popEndorsementHeader.GetHash());
if (popEndorsementIdnex == nullptr || pindexPrev.GetAncestor(popEndorsementIdnex->nHeight) == nullptr) {
return state.Invalid(TxValidationResult::TX_BAD_POP_DATA, "pop-tx-endorsed-block-not-from-this-chain", strprintf("[%s] can not find endorsed block in this chain: %s", tx->GetHash().ToString(), popEndorsementHeader.GetHash().ToString()));
if (popEndorsementIdnex == nullptr || !ChainActive().Contains(popEndorsementIdnex)) {
return state.Invalid(TxValidationResult::TX_BAD_POP_DATA, "pop-tx-endorsed-block-not-from-this-main-chain", strprintf("[%s] can not find endorsed block in the main chain: %s", tx->GetHash().ToString(), popEndorsementHeader.GetHash().ToString()));
}

CBlock popEndorsementBlock;
Expand Down
3 changes: 1 addition & 2 deletions src/vbk/test/unit/pop_service_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ BOOST_FIXTURE_TEST_CASE(blockPopValidation_test_wrong_index, PopServiceFixture)
Verify_Method(Method(pop_service_impl_mock, removePayloads)).Once();
}

BOOST_FIXTURE_TEST_CASE(blockPopValidation_test_wrong_ancestor, PopServiceFixture)
BOOST_FIXTURE_TEST_CASE(blockPopValidation_test_endorsed_block_not_from_main_chain, PopServiceFixture)
{
CBlockIndex* endorsedBlockIndex = ChainActive().Tip()->pprev->pprev->pprev;
CBlock endorsedBlock;
Expand All @@ -123,7 +123,6 @@ BOOST_FIXTURE_TEST_CASE(blockPopValidation_test_wrong_ancestor, PopServiceFixtur
BlockValidationState state;
InvalidateBlock(state, Params(), endorsedBlockIndex);
ActivateBestChain(state, Params());
ChainstateActive().ActivateBestChain(state, Params(), nullptr);
BOOST_CHECK(ChainActive().Height() < prevHeight);

CBlock block = createBlockWithPopTx(*this);
Expand Down

0 comments on commit f58fc1f

Please sign in to comment.