Browse Source

Merge branch 'poc9trie' of github.com:ethereum/cpp-ethereum into poc9trie

cl-refactor
Gav Wood 10 years ago
parent
commit
dbe37c613b
  1. 2
      libevmcore/Instruction.cpp
  2. 2
      test/TestHelper.cpp
  3. 69
      test/stMemoryStressTestFiller.json
  4. 1463
      test/stMemoryTestFiller.json
  5. 682
      test/stQuadraticComplexityTestFiller.json
  6. 55
      test/state.cpp

2
libevmcore/Instruction.cpp

@ -217,7 +217,7 @@ static const std::map<Instruction, InstructionInfo> c_instructionInfo =
{ Instruction::PC, { "PC", 0, 0, 1, false, BaseTier } },
{ Instruction::MSIZE, { "MSIZE", 0, 0, 1, false, BaseTier } },
{ Instruction::GAS, { "GAS", 0, 0, 1, false, BaseTier } },
{ Instruction::JUMPDEST, { "JUMPDEST", 0, 1, 0, true, SpecialTier } },
{ Instruction::JUMPDEST, { "JUMPDEST", 0, 0, 0, true, SpecialTier } },
{ Instruction::PUSH1, { "PUSH1", 1, 0, 1, false, VeryLowTier } },
{ Instruction::PUSH2, { "PUSH2", 2, 0, 1, false, VeryLowTier } },
{ Instruction::PUSH3, { "PUSH3", 3, 0, 1, false, VeryLowTier } },

2
test/TestHelper.cpp

@ -195,6 +195,8 @@ void ImportTest::exportTest(bytes _output, State& _statePost)
}
m_TestObject["post"] = json_spirit::mValue(postState);
m_TestObject["postStateRoot"] = toHex(_statePost.rootHash().asBytes());
// export pre state
json_spirit::mObject preState;

69
test/stMemoryStressTestFiller.json

@ -0,0 +1,69 @@
{
"mload32bitBound": {
"env" : {
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
"currentNumber" : "0",
"currentGasLimit" : "17592320524892",
"currentDifficulty" : "256",
"currentTimestamp" : "1",
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"
},
"pre" : {
"0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
"balance" : "1000000000000000000",
"nonce" : "0",
"code" : "{ [[ 1 ]] (MLOAD 4294967296) } ",
"storage": {}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "175923205248920",
"nonce" : "0",
"code" : "",
"storage": {}
}
},
"transaction" : {
"nonce" : "0",
"gasPrice" : "1",
"gasLimit" : "17592320524892",
"to" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6",
"value" : "10",
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
"data" : ""
}
},
"mload32bitBound2": {
"env" : {
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
"currentNumber" : "0",
"currentGasLimit" : "37791080412587",
"currentDifficulty" : "256",
"currentTimestamp" : "1",
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"
},
"pre" : {
"0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
"balance" : "1000000000000000000",
"nonce" : "0",
"code" : "{ [[ 1 ]] (MLOAD 6294967296) } ",
"storage": {}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "377910804219850",
"nonce" : "0",
"code" : "",
"storage": {}
}
},
"transaction" : {
"nonce" : "0",
"gasPrice" : "1",
"gasLimit" : "37791080412587",
"to" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6",
"value" : "10",
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
"data" : ""
}
}
}

1463
test/stMemoryTestFiller.json

File diff suppressed because it is too large

682
test/stQuadraticComplexityTestFiller.json

File diff suppressed because one or more lines are too long

55
test/state.cpp

@ -71,7 +71,13 @@ void doStateTests(json_spirit::mValue& v, bool _fillin)
}
if (_fillin)
{
#if ETH_FATDB
importer.exportTest(output, theState);
#else
BOOST_THROW_EXCEPTION(Exception() << errinfo_comment("You can not fill tests when FATDB is switched off"));
#endif
}
else
{
BOOST_REQUIRE(o.count("post") > 0);
@ -84,6 +90,7 @@ void doStateTests(json_spirit::mValue& v, bool _fillin)
checkLog(theState.pending().size() ? theState.log(0) : LogEntries(), importer.m_environment.sub.logs);
// check addresses
#if ETH_FATDB
auto expectedAddrs = importer.m_statePost.addresses();
auto resultAddrs = theState.addresses();
for (auto& expectedPair : expectedAddrs)
@ -102,6 +109,8 @@ void doStateTests(json_spirit::mValue& v, bool _fillin)
}
}
checkAddresses<map<Address, u256> >(expectedAddrs, resultAddrs);
#endif
BOOST_CHECK_MESSAGE(theState.rootHash() == h256(o["postStateRoot"].get_str()), "wrong post state root");
}
}
}
@ -159,11 +168,53 @@ BOOST_AUTO_TEST_CASE(stBlockHashTest)
dev::test::executeTests("stBlockHashTest", "/StateTests", dev::test::doStateTests);
}
BOOST_AUTO_TEST_CASE(stSolidityTest)
BOOST_AUTO_TEST_CASE(stQuadraticComplexityTest)
{
for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i)
{
string arg = boost::unit_test::framework::master_test_suite().argv[i];
if (arg == "--quadratic" || arg == "--all")
{
auto start = chrono::steady_clock::now();
dev::test::executeTests("stQuadraticComplexityTest", "/StateTests", dev::test::doStateTests);
auto end = chrono::steady_clock::now();
auto duration(chrono::duration_cast<chrono::milliseconds>(end - start));
cnote << "test duration: " << duration.count() << " milliseconds.\n";
}
}
}
BOOST_AUTO_TEST_CASE(stMemoryStressTest)
{
dev::test::executeTests("stSolidityTest", "/StateTests", dev::test::doStateTests);
for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i)
{
string arg = boost::unit_test::framework::master_test_suite().argv[i];
if (arg == "--memory" || arg == "--all")
{
auto start = chrono::steady_clock::now();
dev::test::executeTests("stMemoryStressTest", "/StateTests", dev::test::doStateTests);
auto end = chrono::steady_clock::now();
auto duration(chrono::duration_cast<chrono::milliseconds>(end - start));
cnote << "test duration: " << duration.count() << " milliseconds.\n";
}
}
}
BOOST_AUTO_TEST_CASE(stSolidityTest)
{
dev::test::executeTests("stSolidityTest", "/StateTests", dev::test::doStateTests);
}
BOOST_AUTO_TEST_CASE(stMemoryTest)
{
dev::test::executeTests("stMemoryTest", "/StateTests", dev::test::doStateTests);
}
BOOST_AUTO_TEST_CASE(stCreateTest)
{
for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i)

Loading…
Cancel
Save