Skip to content
This repository has been archived by the owner on Oct 28, 2021. It is now read-only.

Commit

Permalink
fix NoProof block signature
Browse files Browse the repository at this point in the history
  • Loading branch information
winsvega committed Aug 24, 2018
1 parent fc9ec11 commit 0397a83
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
9 changes: 2 additions & 7 deletions test/tools/jsontests/BlockChainTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -440,10 +440,6 @@ void testBCTest(json_spirit::mObject const& _o)
TestBlock genesisBlock(_o.at("genesisBlockHeader").get_obj(), _o.at("pre").get_obj());

TestBlockChain::MiningType const miningType = getMiningType(_o);
eth::IncludeSeal includeSeal = (miningType == TestBlockChain::MiningType::ForceEthash ||
miningType == TestBlockChain::MiningType::Default) ?
WithSeal :
WithoutSeal;
TestBlockChain blockchain(genesisBlock, miningType);
TestBlockChain testChain(genesisBlock, miningType);
assert(testChain.getInterface().isKnown(genesisBlock.blockHeader().hash(WithSeal)));
Expand Down Expand Up @@ -539,8 +535,7 @@ void testBCTest(json_spirit::mObject const& _o)
}

//Check that imported block to the chain is equal to declared block from test
bytes importedblock =
testChain.getInterface().block(blockFromFields.blockHeader().hash(includeSeal));
bytes importedblock = testChain.getInterface().block(blockFromFields.blockHeader().hash());
TestBlock inchainBlock(toHex(importedblock));
checkBlocks(inchainBlock, blockFromFields, testName);

Expand Down Expand Up @@ -571,7 +566,7 @@ void testBCTest(json_spirit::mObject const& _o)

//Check lastblock hash
BOOST_REQUIRE((_o.count("lastblockhash") > 0));
string lastTrueBlockHash = toHexPrefixed(testChain.topBlock().blockHeader().hash(includeSeal));
string lastTrueBlockHash = toHexPrefixed(testChain.topBlock().blockHeader().hash());
BOOST_CHECK_MESSAGE(lastTrueBlockHash == _o.at("lastblockhash").get_str(),
testName + "Boost check: lastblockhash does not match " + lastTrueBlockHash + " expected: " + _o.at("lastblockhash").get_str());

Expand Down
8 changes: 8 additions & 0 deletions test/tools/libtesteth/BlockChainHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,14 @@ void TestBlock::mine(TestBlockChain const& _bc)
}
else
recalcBlockHeaderBytes();

// Create dummy signature for NoProof blocks
if (Ethash::mixHash(m_blockHeader) == h256{0})
{
m_blockHeader.setSeal(Ethash::NonceField, h64{0});
m_blockHeader.setSeal(Ethash::MixHashField, h256{0});
recalcBlockHeaderBytes();
}
}

void TestBlock::setBlockHeader(BlockHeader const& _header)
Expand Down

0 comments on commit 0397a83

Please sign in to comment.