From bcd6602bafad055f525a41526cc5d9b315f5f4db Mon Sep 17 00:00:00 2001 From: Dimitry Date: Sat, 15 Aug 2015 12:11:41 +0300 Subject: [PATCH] Fill tests --- .../bcValidBlockTestFiller.json | 2 +- test/libethereum/blockchain.cpp | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/test/libethereum/BlockchainTestsFiller/bcValidBlockTestFiller.json b/test/libethereum/BlockchainTestsFiller/bcValidBlockTestFiller.json index a1995ddbd..c983ca107 100644 --- a/test/libethereum/BlockchainTestsFiller/bcValidBlockTestFiller.json +++ b/test/libethereum/BlockchainTestsFiller/bcValidBlockTestFiller.json @@ -167,7 +167,7 @@ }, "expect" : { "095e7baea6a6c7c4c2dfeb977efac326af552d87" : { - "balance" : "100" + "balance" : "5100" } }, "pre" : { diff --git a/test/libethereum/blockchain.cpp b/test/libethereum/blockchain.cpp index 0188951b2..475904b27 100644 --- a/test/libethereum/blockchain.cpp +++ b/test/libethereum/blockchain.cpp @@ -73,6 +73,7 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) BlockHeader biGenesisBlock = constructBlock(o["genesisBlockHeader"].get_obj(), h256{}); State trueState(OverlayDB(State::openDB(td_stateDB_tmp.path(), h256{}, WithExisting::Kill)), BaseState::Empty); + Block trueBlock; //lastBlock of trueBlockchain ImportTest::importState(o["pre"].get_obj(), trueState); o["pre"] = fillJsonWithState(trueState); //convert all fields to hex trueState.commit(); @@ -133,7 +134,8 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) FullBlockChain bc(rlpGenesisBlock.out(), AccountMap(), td_bc.path(), WithExisting::Kill); //OverlayDB database (State::openDB(td_stateDB.path(), h256{}, WithExisting::Kill)); - State state = importer.m_statePre; + State state(OverlayDB(State::openDB(td_stateDB.path(), h256{}, WithExisting::Kill)), BaseState::Empty); //= importer.m_statePre; + ImportTest::importState(o["pre"].get_obj(), state); state.commit(); //import previous blocks @@ -149,7 +151,6 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) bc.sync(uncleQueue, state.db(), 4); bc.attemptImport(blockFromSet, state.db()); vBiBlocks.push_back(BlockHeader(blockFromSet)); - //state.sync(bc); } // get txs @@ -189,9 +190,9 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) } bc.sync(uncleBlockQueue, state.db(), 4); - Block block = bc.genesisBlock(state.db()); - //mine a new block on top of previously imported + Block block = bc.genesisBlock(state.db()); //NOT CLEAR WHAT IT RETURNS IF bc INITIALIZED WITH CUSTOM GENESIS BLOCK + block.setBeneficiary(biGenesisBlock.beneficiary()); try { block.sync(bc); @@ -284,7 +285,7 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) //attempt to import new block to the true blockchain trueBc.sync(uncleBlockQueue, trueState.db(), 4); trueBc.attemptImport(block2.out(), trueState.db()); - //trueState.sync(trueBc); + trueBlock = block; //seems to be the last imported block blockSet newBlock; newBlock.first = block2.out(); @@ -316,7 +317,7 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) AccountMaskMap expectStateMap; State stateExpect(OverlayDB(), BaseState::Empty); ImportTest::importState(o["expect"].get_obj(), stateExpect, expectStateMap); - ImportTest::compareStates(stateExpect, trueState, expectStateMap, Options::get().checkState ? WhenError::Throw : WhenError::DontThrow); + ImportTest::compareStates(stateExpect, trueBlock.state(), expectStateMap, Options::get().checkState ? WhenError::Throw : WhenError::DontThrow); o.erase(o.find("expect")); }