From d01152a161422d448431cf839b342c2ddabacd20 Mon Sep 17 00:00:00 2001 From: Andrei Maiboroda Date: Thu, 27 Apr 2017 17:21:21 +0200 Subject: [PATCH] Fix tests after that relied on the medstate in receipts --- test/jsontests | 2 +- test/tools/libtesteth/BlockChainHelper.cpp | 5 +++-- test/unittests/libethereum/Block.cpp | 19 +++++++++---------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/test/jsontests b/test/jsontests index c1375d55be2..82e7385f219 160000 --- a/test/jsontests +++ b/test/jsontests @@ -1 +1 @@ -Subproject commit c1375d55be21ff5b37a91a061cca0a2fe0e9b920 +Subproject commit 82e7385f219ba361fe98dac282fb33905ae3c1f7 diff --git a/test/tools/libtesteth/BlockChainHelper.cpp b/test/tools/libtesteth/BlockChainHelper.cpp index eced4084f31..7fbf1dafe87 100644 --- a/test/tools/libtesteth/BlockChainHelper.cpp +++ b/test/tools/libtesteth/BlockChainHelper.cpp @@ -501,8 +501,9 @@ bool TestBlockChain::addBlock(TestBlock const& _block) Block block = (m_blockChain.get()->genesisBlock(genesisDB)); block.sync(*m_blockChain.get()); - //BOOST_REQUIRE(m_lastBlock.blockHeader().hash() == BlockHeader(block.blockData()).hash()); - m_lastBlock.setState(/*block.fromPending(10000)*/block.state()); + State st(block.state()); + st.setRoot(block.info().stateRoot()); + m_lastBlock.setState(st); return true; } diff --git a/test/unittests/libethereum/Block.cpp b/test/unittests/libethereum/Block.cpp index 934eb3c6eec..0f284b0594d 100644 --- a/test/unittests/libethereum/Block.cpp +++ b/test/unittests/libethereum/Block.cpp @@ -59,7 +59,7 @@ BOOST_AUTO_TEST_CASE(bStates) OverlayDB const& genesisDB = genesisBlock.state().db(); BlockChain const& blockchain = testBlockchain.interface(); - State stateBofore = testBlockchain.topBlock().state(); + h256 stateBefore = testBlockchain.topBlock().state().rootHash(); TestBlock testBlock; TestTransaction transaction1 = TestTransaction::defaultTransaction(1); @@ -76,17 +76,16 @@ BOOST_AUTO_TEST_CASE(bStates) Block block2 = blockchain.genesisBlock(genesisDB); block2.populateFromChain(blockchain, testBlock.blockHeader().hash()); -/* State stateAfterInsert = block2.fromPending(0); //get the state of blockchain on previous block - BOOST_REQUIRE(ImportTest::compareStates(stateBofore, stateAfterInsert) == 0); + h256 stateAfterInsert = block2.stateRootBeforeTx(0); //get the state of blockchain on previous block + BOOST_REQUIRE_EQUAL(stateBefore, stateAfterInsert); - // TODO remove this - State stateAfterInsert1 = block2.fromPending(1); //get the state of blockchain on current block executed - BOOST_REQUIRE(ImportTest::compareStates(stateAfterInsert, stateAfterInsert1, eth::AccountMaskMap(), WhenError::DontThrow) == 1); + h256 stateAfterInsert1 = block2.stateRootBeforeTx(1); //get the state of blockchain on current block executed + BOOST_REQUIRE(stateAfterInsert != stateAfterInsert1); + + h256 stateAfterInsert2 = block2.stateRootBeforeTx(2); //get the state of blockchain on current block executed + BOOST_REQUIRE(stateBefore != stateAfterInsert2); + BOOST_REQUIRE(stateAfterInsert1 != stateAfterInsert2); - State stateAfterInsert2 = block2.fromPending(2); //get the state of blockchain on current block executed - BOOST_REQUIRE(ImportTest::compareStates(stateBofore, stateAfterInsert2, eth::AccountMaskMap(), WhenError::DontThrow) == 1); - BOOST_REQUIRE(ImportTest::compareStates(stateAfterInsert1, stateAfterInsert2, eth::AccountMaskMap(), WhenError::DontThrow) == 1); -*/ //Block2 will start a new block on top of blockchain BOOST_REQUIRE(block1.info() == block2.info()); block2.sync(blockchain);