Browse Source

Fill tests

cl-refactor
Dimitry 9 years ago
parent
commit
0e32935647
  1. 2
      test/libethereum/BlockchainTestsFiller/bcValidBlockTestFiller.json
  2. 13
      test/libethereum/blockchain.cpp

2
test/libethereum/BlockchainTestsFiller/bcValidBlockTestFiller.json

@ -167,7 +167,7 @@
},
"expect" : {
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
"balance" : "100"
"balance" : "5100"
}
},
"pre" : {

13
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<Ethash> 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"));
}

Loading…
Cancel
Save