Merge branch 'develop' into p2p

This commit is contained in:
subtly 2015-01-10 19:46:05 +01:00
commit feb4288b27
21 changed files with 3697 additions and 284 deletions

View File

@ -50,7 +50,7 @@ public:
msg += *extra; msg += *extra;
BOOST_FAIL(msg); BOOST_FAIL(msg);
} }
std::string generatedInterfaceString = m_compilerStack.getJsonDocumentation("", DocumentationType::ABI_INTERFACE); std::string generatedInterfaceString = m_compilerStack.getMetadata("", DocumentationType::ABI_INTERFACE);
Json::Value generatedInterface; Json::Value generatedInterface;
m_reader.parse(generatedInterfaceString, generatedInterface); m_reader.parse(generatedInterfaceString, generatedInterface);
Json::Value expectedInterface; Json::Value expectedInterface;
@ -236,20 +236,6 @@ BOOST_AUTO_TEST_CASE(const_function)
"}\n"; "}\n";
char const* interface = R"([ char const* interface = R"([
{
"name": "boo",
"constant": true,
"inputs": [{
"name": "a",
"type": "uint32"
}],
"outputs": [
{
"name": "b",
"type": "uint256"
}
]
},
{ {
"name": "foo", "name": "foo",
"constant": false, "constant": false,
@ -269,6 +255,20 @@ BOOST_AUTO_TEST_CASE(const_function)
"type": "uint256" "type": "uint256"
} }
] ]
},
{
"name": "boo",
"constant": true,
"inputs": [{
"name": "a",
"type": "uint32"
}],
"outputs": [
{
"name": "b",
"type": "uint256"
}
]
} }
])"; ])";

View File

@ -96,7 +96,7 @@ BOOST_AUTO_TEST_CASE(smoke_test)
"}\n"; "}\n";
bytes code = compileContract(sourceCode); bytes code = compileContract(sourceCode);
unsigned boilerplateSize = 40; unsigned boilerplateSize = 73;
bytes expectation({byte(Instruction::JUMPDEST), bytes expectation({byte(Instruction::JUMPDEST),
byte(Instruction::PUSH1), 0x0, // initialize local variable x byte(Instruction::PUSH1), 0x0, // initialize local variable x
byte(Instruction::PUSH1), 0x2, byte(Instruction::PUSH1), 0x2,
@ -115,9 +115,8 @@ BOOST_AUTO_TEST_CASE(different_argument_numbers)
" function g() returns (uint e, uint h) { h = f(1, 2, 3); }\n" " function g() returns (uint e, uint h) { h = f(1, 2, 3); }\n"
"}\n"; "}\n";
bytes code = compileContract(sourceCode); bytes code = compileContract(sourceCode);
unsigned shift = 103;
unsigned shift = 68; unsigned boilerplateSize = 116;
unsigned boilerplateSize = 81;
bytes expectation({byte(Instruction::JUMPDEST), bytes expectation({byte(Instruction::JUMPDEST),
byte(Instruction::PUSH1), 0x0, // initialize return variable d byte(Instruction::PUSH1), 0x0, // initialize return variable d
byte(Instruction::DUP3), byte(Instruction::DUP3),
@ -135,10 +134,10 @@ BOOST_AUTO_TEST_CASE(different_argument_numbers)
byte(Instruction::JUMPDEST), // beginning of g byte(Instruction::JUMPDEST), // beginning of g
byte(Instruction::PUSH1), 0x0, byte(Instruction::PUSH1), 0x0,
byte(Instruction::PUSH1), 0x0, // initialized e and h byte(Instruction::PUSH1), 0x0, // initialized e and h
byte(Instruction::PUSH1), byte(0x2a + shift), // ret address byte(Instruction::PUSH1), byte(0x21 + shift), // ret address
byte(Instruction::PUSH1), 0x1, byte(Instruction::PUSH1), 0xff, byte(Instruction::AND), byte(Instruction::PUSH1), 0x1,
byte(Instruction::PUSH1), 0x2, byte(Instruction::PUSH1), 0xff, byte(Instruction::AND), byte(Instruction::PUSH1), 0x2,
byte(Instruction::PUSH1), 0x3, byte(Instruction::PUSH1), 0xff, byte(Instruction::AND), byte(Instruction::PUSH1), 0x3,
byte(Instruction::PUSH1), byte(0x1 + shift), byte(Instruction::PUSH1), byte(0x1 + shift),
// stack here: ret e h 0x20 1 2 3 0x1 // stack here: ret e h 0x20 1 2 3 0x1
byte(Instruction::JUMP), byte(Instruction::JUMP),
@ -166,9 +165,8 @@ BOOST_AUTO_TEST_CASE(ifStatement)
" function f() { bool x; if (x) 77; else if (!x) 78; else 79; }" " function f() { bool x; if (x) 77; else if (!x) 78; else 79; }"
"}\n"; "}\n";
bytes code = compileContract(sourceCode); bytes code = compileContract(sourceCode);
unsigned shift = 60;
unsigned shift = 27; unsigned boilerplateSize = 73;
unsigned boilerplateSize = 40;
bytes expectation({byte(Instruction::JUMPDEST), bytes expectation({byte(Instruction::JUMPDEST),
byte(Instruction::PUSH1), 0x0, byte(Instruction::PUSH1), 0x0,
byte(Instruction::DUP1), byte(Instruction::DUP1),
@ -208,9 +206,8 @@ BOOST_AUTO_TEST_CASE(loops)
" function f() { while(true){1;break;2;continue;3;return;4;} }" " function f() { while(true){1;break;2;continue;3;return;4;} }"
"}\n"; "}\n";
bytes code = compileContract(sourceCode); bytes code = compileContract(sourceCode);
unsigned shift = 60;
unsigned shift = 27; unsigned boilerplateSize = 73;
unsigned boilerplateSize = 40;
bytes expectation({byte(Instruction::JUMPDEST), bytes expectation({byte(Instruction::JUMPDEST),
byte(Instruction::JUMPDEST), byte(Instruction::JUMPDEST),
byte(Instruction::PUSH1), 0x1, byte(Instruction::PUSH1), 0x1,

View File

@ -17,6 +17,7 @@
*/ */
/** /**
* @author Christian <c@ethdev.com> * @author Christian <c@ethdev.com>
* @author Gav Wood <g@ethdev.com>
* @date 2014 * @date 2014
* Unit tests for the solidity expression compiler, testing the behaviour of the code. * Unit tests for the solidity expression compiler, testing the behaviour of the code.
*/ */
@ -44,7 +45,7 @@ BOOST_AUTO_TEST_CASE(smoke_test)
" function f(uint a) returns(uint d) { return a * 7; }\n" " function f(uint a) returns(uint d) { return a * 7; }\n"
"}\n"; "}\n";
compileAndRun(sourceCode); compileAndRun(sourceCode);
testSolidityAgainstCppOnRange(0, [](u256 const& a) -> u256 { return a * 7; }, 0, 100); testSolidityAgainstCppOnRange("f(uint256)", [](u256 const& a) -> u256 { return a * 7; }, 0, 100);
} }
BOOST_AUTO_TEST_CASE(empty_contract) BOOST_AUTO_TEST_CASE(empty_contract)
@ -52,7 +53,7 @@ BOOST_AUTO_TEST_CASE(empty_contract)
char const* sourceCode = "contract test {\n" char const* sourceCode = "contract test {\n"
"}\n"; "}\n";
compileAndRun(sourceCode); compileAndRun(sourceCode);
BOOST_CHECK(callContractFunction(0, bytes()).empty()); BOOST_CHECK(callContractFunction("i_am_not_there()", bytes()).empty());
} }
BOOST_AUTO_TEST_CASE(recursive_calls) BOOST_AUTO_TEST_CASE(recursive_calls)
@ -72,7 +73,7 @@ BOOST_AUTO_TEST_CASE(recursive_calls)
return n * recursive_calls_cpp(n - 1); return n * recursive_calls_cpp(n - 1);
}; };
testSolidityAgainstCppOnRange(0, recursive_calls_cpp, 0, 5); testSolidityAgainstCppOnRange("f(uint256)", recursive_calls_cpp, 0, 5);
} }
BOOST_AUTO_TEST_CASE(multiple_functions) BOOST_AUTO_TEST_CASE(multiple_functions)
@ -84,11 +85,11 @@ BOOST_AUTO_TEST_CASE(multiple_functions)
" function f() returns(uint n) { return 3; }\n" " function f() returns(uint n) { return 3; }\n"
"}\n"; "}\n";
compileAndRun(sourceCode); compileAndRun(sourceCode);
BOOST_CHECK(callContractFunction(0, bytes()) == toBigEndian(u256(0))); BOOST_CHECK(callContractFunction("a()", bytes()) == toBigEndian(u256(0)));
BOOST_CHECK(callContractFunction(1, bytes()) == toBigEndian(u256(1))); BOOST_CHECK(callContractFunction("b()", bytes()) == toBigEndian(u256(1)));
BOOST_CHECK(callContractFunction(2, bytes()) == toBigEndian(u256(2))); BOOST_CHECK(callContractFunction("c()", bytes()) == toBigEndian(u256(2)));
BOOST_CHECK(callContractFunction(3, bytes()) == toBigEndian(u256(3))); BOOST_CHECK(callContractFunction("f()", bytes()) == toBigEndian(u256(3)));
BOOST_CHECK(callContractFunction(4, bytes()) == bytes()); BOOST_CHECK(callContractFunction("i_am_not_there()", bytes()) == bytes());
} }
BOOST_AUTO_TEST_CASE(while_loop) BOOST_AUTO_TEST_CASE(while_loop)
@ -112,7 +113,7 @@ BOOST_AUTO_TEST_CASE(while_loop)
return nfac; return nfac;
}; };
testSolidityAgainstCppOnRange(0, while_loop_cpp, 0, 5); testSolidityAgainstCppOnRange("f(uint256)", while_loop_cpp, 0, 5);
} }
BOOST_AUTO_TEST_CASE(break_outside_loop) BOOST_AUTO_TEST_CASE(break_outside_loop)
@ -124,7 +125,7 @@ BOOST_AUTO_TEST_CASE(break_outside_loop)
" }\n" " }\n"
"}\n"; "}\n";
compileAndRun(sourceCode); compileAndRun(sourceCode);
testSolidityAgainstCpp(0, [](u256 const&) -> u256 { return 2; }, u256(0)); testSolidityAgainstCpp("f(uint256)", [](u256 const&) -> u256 { return 2; }, u256(0));
} }
BOOST_AUTO_TEST_CASE(nested_loops) BOOST_AUTO_TEST_CASE(nested_loops)
@ -173,7 +174,7 @@ BOOST_AUTO_TEST_CASE(nested_loops)
return n; return n;
}; };
testSolidityAgainstCppOnRange(0, nested_loops_cpp, 0, 12); testSolidityAgainstCppOnRange("f(uint256)", nested_loops_cpp, 0, 12);
} }
BOOST_AUTO_TEST_CASE(for_loop) BOOST_AUTO_TEST_CASE(for_loop)
@ -195,7 +196,7 @@ BOOST_AUTO_TEST_CASE(for_loop)
return nfac; return nfac;
}; };
testSolidityAgainstCppOnRange(0, for_loop_cpp, 0, 5); testSolidityAgainstCppOnRange("f(uint256)", for_loop_cpp, 0, 5);
} }
BOOST_AUTO_TEST_CASE(for_loop_empty) BOOST_AUTO_TEST_CASE(for_loop_empty)
@ -223,7 +224,7 @@ BOOST_AUTO_TEST_CASE(for_loop_empty)
return ret; return ret;
}; };
testSolidityAgainstCpp(0, for_loop_empty_cpp); testSolidityAgainstCpp("f()", for_loop_empty_cpp);
} }
BOOST_AUTO_TEST_CASE(for_loop_simple_init_expr) BOOST_AUTO_TEST_CASE(for_loop_simple_init_expr)
@ -247,7 +248,7 @@ BOOST_AUTO_TEST_CASE(for_loop_simple_init_expr)
return nfac; return nfac;
}; };
testSolidityAgainstCppOnRange(0, for_loop_simple_init_expr_cpp, 0, 5); testSolidityAgainstCppOnRange("f(uint256)", for_loop_simple_init_expr_cpp, 0, 5);
} }
BOOST_AUTO_TEST_CASE(calling_other_functions) BOOST_AUTO_TEST_CASE(calling_other_functions)
@ -292,11 +293,11 @@ BOOST_AUTO_TEST_CASE(calling_other_functions)
return y; return y;
}; };
testSolidityAgainstCpp(2, collatz_cpp, u256(0)); testSolidityAgainstCpp("run(uint256)", collatz_cpp, u256(0));
testSolidityAgainstCpp(2, collatz_cpp, u256(1)); testSolidityAgainstCpp("run(uint256)", collatz_cpp, u256(1));
testSolidityAgainstCpp(2, collatz_cpp, u256(2)); testSolidityAgainstCpp("run(uint256)", collatz_cpp, u256(2));
testSolidityAgainstCpp(2, collatz_cpp, u256(8)); testSolidityAgainstCpp("run(uint256)", collatz_cpp, u256(8));
testSolidityAgainstCpp(2, collatz_cpp, u256(127)); testSolidityAgainstCpp("run(uint256)", collatz_cpp, u256(127));
} }
BOOST_AUTO_TEST_CASE(many_local_variables) BOOST_AUTO_TEST_CASE(many_local_variables)
@ -317,7 +318,7 @@ BOOST_AUTO_TEST_CASE(many_local_variables)
u256 y = a + b + c + x1 + x2 + x3; u256 y = a + b + c + x1 + x2 + x3;
return y + b + x2; return y + b + x2;
}; };
testSolidityAgainstCpp(0, f, u256(0x1000), u256(0x10000), u256(0x100000)); testSolidityAgainstCpp("run(uint256,uint256,uint256)", f, u256(0x1000), u256(0x10000), u256(0x100000));
} }
BOOST_AUTO_TEST_CASE(packing_unpacking_types) BOOST_AUTO_TEST_CASE(packing_unpacking_types)
@ -330,7 +331,7 @@ BOOST_AUTO_TEST_CASE(packing_unpacking_types)
" }\n" " }\n"
"}\n"; "}\n";
compileAndRun(sourceCode); compileAndRun(sourceCode);
BOOST_CHECK(callContractFunction(0, fromHex("01""0f0f0f0f""f0f0f0f0f0f0f0f0")) BOOST_CHECK(callContractFunction("run(bool,uint32,uint64)", fromHex("01""0f0f0f0f""f0f0f0f0f0f0f0f0"))
== fromHex("00000000000000000000000000000000000000""01""f0f0f0f0""0f0f0f0f0f0f0f0f")); == fromHex("00000000000000000000000000000000000000""01""f0f0f0f0""0f0f0f0f0f0f0f0f"));
} }
@ -342,7 +343,7 @@ BOOST_AUTO_TEST_CASE(multiple_return_values)
" }\n" " }\n"
"}\n"; "}\n";
compileAndRun(sourceCode); compileAndRun(sourceCode);
BOOST_CHECK(callContractFunction(0, bytes(1, 1) + toBigEndian(u256(0xcd))) BOOST_CHECK(callContractFunction("run(bool,uint256)", bytes(1, 1) + toBigEndian(u256(0xcd)))
== toBigEndian(u256(0xcd)) + bytes(1, 1) + toBigEndian(u256(0))); == toBigEndian(u256(0xcd)) + bytes(1, 1) + toBigEndian(u256(0)));
} }
@ -362,7 +363,7 @@ BOOST_AUTO_TEST_CASE(short_circuiting)
return n; return n;
}; };
testSolidityAgainstCppOnRange(0, short_circuiting_cpp, 0, 2); testSolidityAgainstCppOnRange("run(uint256)", short_circuiting_cpp, 0, 2);
} }
BOOST_AUTO_TEST_CASE(high_bits_cleaning) BOOST_AUTO_TEST_CASE(high_bits_cleaning)
@ -382,7 +383,7 @@ BOOST_AUTO_TEST_CASE(high_bits_cleaning)
return 0; return 0;
return x; return x;
}; };
testSolidityAgainstCpp(0, high_bits_cleaning_cpp); testSolidityAgainstCpp("run()", high_bits_cleaning_cpp);
} }
BOOST_AUTO_TEST_CASE(sign_extension) BOOST_AUTO_TEST_CASE(sign_extension)
@ -402,7 +403,7 @@ BOOST_AUTO_TEST_CASE(sign_extension)
return 0; return 0;
return u256(x) * -1; return u256(x) * -1;
}; };
testSolidityAgainstCpp(0, sign_extension_cpp); testSolidityAgainstCpp("run()", sign_extension_cpp);
} }
BOOST_AUTO_TEST_CASE(small_unsigned_types) BOOST_AUTO_TEST_CASE(small_unsigned_types)
@ -419,7 +420,7 @@ BOOST_AUTO_TEST_CASE(small_unsigned_types)
uint32_t x = uint32_t(0xffffff) * 0xffffff; uint32_t x = uint32_t(0xffffff) * 0xffffff;
return x / 0x100; return x / 0x100;
}; };
testSolidityAgainstCpp(0, small_unsigned_types_cpp); testSolidityAgainstCpp("run()", small_unsigned_types_cpp);
} }
BOOST_AUTO_TEST_CASE(small_signed_types) BOOST_AUTO_TEST_CASE(small_signed_types)
@ -434,7 +435,7 @@ BOOST_AUTO_TEST_CASE(small_signed_types)
{ {
return -int32_t(10) * -int64_t(20); return -int32_t(10) * -int64_t(20);
}; };
testSolidityAgainstCpp(0, small_signed_types_cpp); testSolidityAgainstCpp("run()", small_signed_types_cpp);
} }
BOOST_AUTO_TEST_CASE(strings) BOOST_AUTO_TEST_CASE(strings)
@ -457,12 +458,12 @@ BOOST_AUTO_TEST_CASE(strings)
expectation[4] = byte(0xff); expectation[4] = byte(0xff);
expectation[5] = byte('_'); expectation[5] = byte('_');
expectation[6] = byte('_'); expectation[6] = byte('_');
BOOST_CHECK(callContractFunction(0, bytes()) == expectation); BOOST_CHECK(callContractFunction("fixed()", bytes()) == expectation);
expectation = bytes(17, 0); expectation = bytes(17, 0);
expectation[0] = 0; expectation[0] = 0;
expectation[1] = 2; expectation[1] = 2;
expectation[16] = 1; expectation[16] = 1;
BOOST_CHECK(callContractFunction(1, bytes({0x00, 0x02, 0x01})) == expectation); BOOST_CHECK(callContractFunction("pipeThrough(string2,bool)", bytes({0x00, 0x02, 0x01})) == expectation);
} }
BOOST_AUTO_TEST_CASE(empty_string_on_stack) BOOST_AUTO_TEST_CASE(empty_string_on_stack)
@ -476,7 +477,7 @@ BOOST_AUTO_TEST_CASE(empty_string_on_stack)
" }\n" " }\n"
"}\n"; "}\n";
compileAndRun(sourceCode); compileAndRun(sourceCode);
BOOST_CHECK(callContractFunction(0, bytes(1, 0x02)) == bytes({0x00, 0x02, 0x61/*'a'*/, 0x62/*'b'*/, 0x63/*'c'*/, 0x00})); BOOST_CHECK(callContractFunction("run(string0,uint8)", bytes(1, 0x02)) == bytes({0x00, 0x02, 0x61/*'a'*/, 0x62/*'b'*/, 0x63/*'c'*/, 0x00}));
} }
BOOST_AUTO_TEST_CASE(state_smoke_test) BOOST_AUTO_TEST_CASE(state_smoke_test)
@ -494,14 +495,14 @@ BOOST_AUTO_TEST_CASE(state_smoke_test)
" }\n" " }\n"
"}\n"; "}\n";
compileAndRun(sourceCode); compileAndRun(sourceCode);
BOOST_CHECK(callContractFunction(0, bytes(1, 0x00)) == toBigEndian(u256(0))); BOOST_CHECK(callContractFunction("get(uint8)", bytes(1, 0x00)) == toBigEndian(u256(0)));
BOOST_CHECK(callContractFunction(0, bytes(1, 0x01)) == toBigEndian(u256(0))); BOOST_CHECK(callContractFunction("get(uint8)", bytes(1, 0x01)) == toBigEndian(u256(0)));
BOOST_CHECK(callContractFunction(1, bytes(1, 0x00) + toBigEndian(u256(0x1234))) == bytes()); BOOST_CHECK(callContractFunction("set(uint8,uint256)", bytes(1, 0x00) + toBigEndian(u256(0x1234))) == bytes());
BOOST_CHECK(callContractFunction(1, bytes(1, 0x01) + toBigEndian(u256(0x8765))) == bytes()); BOOST_CHECK(callContractFunction("set(uint8,uint256)", bytes(1, 0x01) + toBigEndian(u256(0x8765))) == bytes());
BOOST_CHECK(callContractFunction(0, bytes(1, 0x00)) == toBigEndian(u256(0x1234))); BOOST_CHECK(callContractFunction("get(uint8)", bytes(1, 0x00)) == toBigEndian(u256(0x1234)));
BOOST_CHECK(callContractFunction(0, bytes(1, 0x01)) == toBigEndian(u256(0x8765))); BOOST_CHECK(callContractFunction("get(uint8)", bytes(1, 0x01)) == toBigEndian(u256(0x8765)));
BOOST_CHECK(callContractFunction(1, bytes(1, 0x00) + toBigEndian(u256(0x3))) == bytes()); BOOST_CHECK(callContractFunction("set(uint8,uint256)", bytes(1, 0x00) + toBigEndian(u256(0x3))) == bytes());
BOOST_CHECK(callContractFunction(0, bytes(1, 0x00)) == toBigEndian(u256(0x3))); BOOST_CHECK(callContractFunction("get(uint8)", bytes(1, 0x00)) == toBigEndian(u256(0x3)));
} }
BOOST_AUTO_TEST_CASE(compound_assign) BOOST_AUTO_TEST_CASE(compound_assign)
@ -529,14 +530,14 @@ BOOST_AUTO_TEST_CASE(compound_assign)
value2 *= value3 + value1; value2 *= value3 + value1;
return value2 += 7; return value2 += 7;
}; };
testSolidityAgainstCpp(0, f, u256(0), u256(6)); testSolidityAgainstCpp("f(uint256,uint256)", f, u256(0), u256(6));
testSolidityAgainstCpp(0, f, u256(1), u256(3)); testSolidityAgainstCpp("f(uint256,uint256)", f, u256(1), u256(3));
testSolidityAgainstCpp(0, f, u256(2), u256(25)); testSolidityAgainstCpp("f(uint256,uint256)", f, u256(2), u256(25));
testSolidityAgainstCpp(0, f, u256(3), u256(69)); testSolidityAgainstCpp("f(uint256,uint256)", f, u256(3), u256(69));
testSolidityAgainstCpp(0, f, u256(4), u256(84)); testSolidityAgainstCpp("f(uint256,uint256)", f, u256(4), u256(84));
testSolidityAgainstCpp(0, f, u256(5), u256(2)); testSolidityAgainstCpp("f(uint256,uint256)", f, u256(5), u256(2));
testSolidityAgainstCpp(0, f, u256(6), u256(51)); testSolidityAgainstCpp("f(uint256,uint256)", f, u256(6), u256(51));
testSolidityAgainstCpp(0, f, u256(7), u256(48)); testSolidityAgainstCpp("f(uint256,uint256)", f, u256(7), u256(48));
} }
BOOST_AUTO_TEST_CASE(simple_mapping) BOOST_AUTO_TEST_CASE(simple_mapping)
@ -553,21 +554,21 @@ BOOST_AUTO_TEST_CASE(simple_mapping)
compileAndRun(sourceCode); compileAndRun(sourceCode);
// msvc seems to have problems with initializer-list, when there is only 1 param in the list // msvc seems to have problems with initializer-list, when there is only 1 param in the list
BOOST_CHECK(callContractFunction(0, bytes(1, 0x00)) == bytes(1, 0x00)); BOOST_CHECK(callContractFunction("get(uint8)", bytes(1, 0x00)) == bytes(1, 0x00));
BOOST_CHECK(callContractFunction(0, bytes(1, 0x01)) == bytes(1, 0x00)); BOOST_CHECK(callContractFunction("get(uint8)", bytes(1, 0x01)) == bytes(1, 0x00));
BOOST_CHECK(callContractFunction(0, bytes(1, 0xa7)) == bytes(1, 0x00)); BOOST_CHECK(callContractFunction("get(uint8)", bytes(1, 0xa7)) == bytes(1, 0x00));
callContractFunction(1, bytes({0x01, 0xa1})); callContractFunction("set(uint8,uint8)", bytes({0x01, 0xa1}));
BOOST_CHECK(callContractFunction(0, bytes(1, 0x00)) == bytes(1, 0x00)); BOOST_CHECK(callContractFunction("get(uint8)", bytes(1, 0x00)) == bytes(1, 0x00));
BOOST_CHECK(callContractFunction(0, bytes(1, 0x01)) == bytes(1, 0xa1)); BOOST_CHECK(callContractFunction("get(uint8)", bytes(1, 0x01)) == bytes(1, 0xa1));
BOOST_CHECK(callContractFunction(0, bytes(1, 0xa7)) == bytes(1, 0x00)); BOOST_CHECK(callContractFunction("get(uint8)", bytes(1, 0xa7)) == bytes(1, 0x00));
callContractFunction(1, bytes({0x00, 0xef})); callContractFunction("set(uint8,uint8)", bytes({0x00, 0xef}));
BOOST_CHECK(callContractFunction(0, bytes(1, 0x00)) == bytes(1, 0xef)); BOOST_CHECK(callContractFunction("get(uint8)", bytes(1, 0x00)) == bytes(1, 0xef));
BOOST_CHECK(callContractFunction(0, bytes(1, 0x01)) == bytes(1, 0xa1)); BOOST_CHECK(callContractFunction("get(uint8)", bytes(1, 0x01)) == bytes(1, 0xa1));
BOOST_CHECK(callContractFunction(0, bytes(1, 0xa7)) == bytes(1, 0x00)); BOOST_CHECK(callContractFunction("get(uint8)", bytes(1, 0xa7)) == bytes(1, 0x00));
callContractFunction(1, bytes({0x01, 0x05})); callContractFunction("set(uint8,uint8)", bytes({0x01, 0x05}));
BOOST_CHECK(callContractFunction(0, bytes(1, 0x00)) == bytes(1, 0xef)); BOOST_CHECK(callContractFunction("get(uint8)", bytes(1, 0x00)) == bytes(1, 0xef));
BOOST_CHECK(callContractFunction(0, bytes(1, 0x01)) == bytes(1, 0x05)); BOOST_CHECK(callContractFunction("get(uint8)", bytes(1, 0x01)) == bytes(1, 0x05));
BOOST_CHECK(callContractFunction(0, bytes(1, 0xa7)) == bytes(1, 0x00)); BOOST_CHECK(callContractFunction("get(uint8)", bytes(1, 0xa7)) == bytes(1, 0x00));
} }
BOOST_AUTO_TEST_CASE(mapping_state) BOOST_AUTO_TEST_CASE(mapping_state)
@ -611,38 +612,38 @@ BOOST_AUTO_TEST_CASE(mapping_state)
auto getVoteCount = bind(&Ballot::getVoteCount, &ballot, _1); auto getVoteCount = bind(&Ballot::getVoteCount, &ballot, _1);
auto grantVoteRight = bind(&Ballot::grantVoteRight, &ballot, _1); auto grantVoteRight = bind(&Ballot::grantVoteRight, &ballot, _1);
auto vote = bind(&Ballot::vote, &ballot, _1, _2); auto vote = bind(&Ballot::vote, &ballot, _1, _2);
testSolidityAgainstCpp(0, getVoteCount, u160(0)); testSolidityAgainstCpp("getVoteCount(address)", getVoteCount, u160(0));
testSolidityAgainstCpp(0, getVoteCount, u160(1)); testSolidityAgainstCpp("getVoteCount(address)", getVoteCount, u160(1));
testSolidityAgainstCpp(0, getVoteCount, u160(2)); testSolidityAgainstCpp("getVoteCount(address)", getVoteCount, u160(2));
// voting without vote right shourd be rejected // voting without vote right shourd be rejected
testSolidityAgainstCpp(2, vote, u160(0), u160(2)); testSolidityAgainstCpp("vote(address,address)", vote, u160(0), u160(2));
testSolidityAgainstCpp(0, getVoteCount, u160(0)); testSolidityAgainstCpp("getVoteCount(address)", getVoteCount, u160(0));
testSolidityAgainstCpp(0, getVoteCount, u160(1)); testSolidityAgainstCpp("getVoteCount(address)", getVoteCount, u160(1));
testSolidityAgainstCpp(0, getVoteCount, u160(2)); testSolidityAgainstCpp("getVoteCount(address)", getVoteCount, u160(2));
// grant vote rights // grant vote rights
testSolidityAgainstCpp(1, grantVoteRight, u160(0)); testSolidityAgainstCpp("grantVoteRight(address)", grantVoteRight, u160(0));
testSolidityAgainstCpp(1, grantVoteRight, u160(1)); testSolidityAgainstCpp("grantVoteRight(address)", grantVoteRight, u160(1));
// vote, should increase 2's vote count // vote, should increase 2's vote count
testSolidityAgainstCpp(2, vote, u160(0), u160(2)); testSolidityAgainstCpp("vote(address,address)", vote, u160(0), u160(2));
testSolidityAgainstCpp(0, getVoteCount, u160(0)); testSolidityAgainstCpp("getVoteCount(address)", getVoteCount, u160(0));
testSolidityAgainstCpp(0, getVoteCount, u160(1)); testSolidityAgainstCpp("getVoteCount(address)", getVoteCount, u160(1));
testSolidityAgainstCpp(0, getVoteCount, u160(2)); testSolidityAgainstCpp("getVoteCount(address)", getVoteCount, u160(2));
// vote again, should be rejected // vote again, should be rejected
testSolidityAgainstCpp(2, vote, u160(0), u160(1)); testSolidityAgainstCpp("vote(address,address)", vote, u160(0), u160(1));
testSolidityAgainstCpp(0, getVoteCount, u160(0)); testSolidityAgainstCpp("getVoteCount(address)", getVoteCount, u160(0));
testSolidityAgainstCpp(0, getVoteCount, u160(1)); testSolidityAgainstCpp("getVoteCount(address)", getVoteCount, u160(1));
testSolidityAgainstCpp(0, getVoteCount, u160(2)); testSolidityAgainstCpp("getVoteCount(address)", getVoteCount, u160(2));
// vote without right to vote // vote without right to vote
testSolidityAgainstCpp(2, vote, u160(2), u160(1)); testSolidityAgainstCpp("vote(address,address)", vote, u160(2), u160(1));
testSolidityAgainstCpp(0, getVoteCount, u160(0)); testSolidityAgainstCpp("getVoteCount(address)", getVoteCount, u160(0));
testSolidityAgainstCpp(0, getVoteCount, u160(1)); testSolidityAgainstCpp("getVoteCount(address)", getVoteCount, u160(1));
testSolidityAgainstCpp(0, getVoteCount, u160(2)); testSolidityAgainstCpp("getVoteCount(address)", getVoteCount, u160(2));
// grant vote right and now vote again // grant vote right and now vote again
testSolidityAgainstCpp(1, grantVoteRight, u160(2)); testSolidityAgainstCpp("grantVoteRight(address)", grantVoteRight, u160(2));
testSolidityAgainstCpp(2, vote, u160(2), u160(1)); testSolidityAgainstCpp("vote(address,address)", vote, u160(2), u160(1));
testSolidityAgainstCpp(0, getVoteCount, u160(0)); testSolidityAgainstCpp("getVoteCount(address)", getVoteCount, u160(0));
testSolidityAgainstCpp(0, getVoteCount, u160(1)); testSolidityAgainstCpp("getVoteCount(address)", getVoteCount, u160(1));
testSolidityAgainstCpp(0, getVoteCount, u160(2)); testSolidityAgainstCpp("getVoteCount(address)", getVoteCount, u160(2));
} }
BOOST_AUTO_TEST_CASE(mapping_state_inc_dec) BOOST_AUTO_TEST_CASE(mapping_state_inc_dec)
@ -673,7 +674,7 @@ BOOST_AUTO_TEST_CASE(mapping_state_inc_dec)
table[value]++; table[value]++;
return --table[value++]; return --table[value++];
}; };
testSolidityAgainstCppOnRange(0, f, 0, 5); testSolidityAgainstCppOnRange("f(uint256)", f, 0, 5);
} }
BOOST_AUTO_TEST_CASE(multi_level_mapping) BOOST_AUTO_TEST_CASE(multi_level_mapping)
@ -693,14 +694,14 @@ BOOST_AUTO_TEST_CASE(multi_level_mapping)
if (_z == 0) return table[_x][_y]; if (_z == 0) return table[_x][_y];
else return table[_x][_y] = _z; else return table[_x][_y] = _z;
}; };
testSolidityAgainstCpp(0, f, u256(4), u256(5), u256(0)); testSolidityAgainstCpp("f(uint256,uint256,uint256)", f, u256(4), u256(5), u256(0));
testSolidityAgainstCpp(0, f, u256(5), u256(4), u256(0)); testSolidityAgainstCpp("f(uint256,uint256,uint256)", f, u256(5), u256(4), u256(0));
testSolidityAgainstCpp(0, f, u256(4), u256(5), u256(9)); testSolidityAgainstCpp("f(uint256,uint256,uint256)", f, u256(4), u256(5), u256(9));
testSolidityAgainstCpp(0, f, u256(4), u256(5), u256(0)); testSolidityAgainstCpp("f(uint256,uint256,uint256)", f, u256(4), u256(5), u256(0));
testSolidityAgainstCpp(0, f, u256(5), u256(4), u256(0)); testSolidityAgainstCpp("f(uint256,uint256,uint256)", f, u256(5), u256(4), u256(0));
testSolidityAgainstCpp(0, f, u256(5), u256(4), u256(7)); testSolidityAgainstCpp("f(uint256,uint256,uint256)", f, u256(5), u256(4), u256(7));
testSolidityAgainstCpp(0, f, u256(4), u256(5), u256(0)); testSolidityAgainstCpp("f(uint256,uint256,uint256)", f, u256(4), u256(5), u256(0));
testSolidityAgainstCpp(0, f, u256(5), u256(4), u256(0)); testSolidityAgainstCpp("f(uint256,uint256,uint256)", f, u256(5), u256(4), u256(0));
} }
BOOST_AUTO_TEST_CASE(structs) BOOST_AUTO_TEST_CASE(structs)
@ -735,9 +736,9 @@ BOOST_AUTO_TEST_CASE(structs)
" }\n" " }\n"
"}\n"; "}\n";
compileAndRun(sourceCode); compileAndRun(sourceCode);
BOOST_CHECK(callContractFunction(0) == bytes(1, 0x00)); BOOST_CHECK(callContractFunction("check()") == bytes(1, 0x00));
BOOST_CHECK(callContractFunction(1) == bytes()); BOOST_CHECK(callContractFunction("set()") == bytes());
BOOST_CHECK(callContractFunction(0) == bytes(1, 0x01)); BOOST_CHECK(callContractFunction("check()") == bytes(1, 0x01));
} }
BOOST_AUTO_TEST_CASE(struct_reference) BOOST_AUTO_TEST_CASE(struct_reference)
@ -763,9 +764,9 @@ BOOST_AUTO_TEST_CASE(struct_reference)
" }\n" " }\n"
"}\n"; "}\n";
compileAndRun(sourceCode); compileAndRun(sourceCode);
BOOST_CHECK(callContractFunction(0) == bytes(1, 0x00)); BOOST_CHECK(callContractFunction("check()") == bytes(1, 0x00));
BOOST_CHECK(callContractFunction(1) == bytes()); BOOST_CHECK(callContractFunction("set()") == bytes());
BOOST_CHECK(callContractFunction(0) == bytes(1, 0x01)); BOOST_CHECK(callContractFunction("check()") == bytes(1, 0x01));
} }
BOOST_AUTO_TEST_CASE(constructor) BOOST_AUTO_TEST_CASE(constructor)
@ -786,8 +787,8 @@ BOOST_AUTO_TEST_CASE(constructor)
{ {
return data[_x]; return data[_x];
}; };
testSolidityAgainstCpp(0, get, u256(6)); testSolidityAgainstCpp("get(uint256)", get, u256(6));
testSolidityAgainstCpp(0, get, u256(7)); testSolidityAgainstCpp("get(uint256)", get, u256(7));
} }
BOOST_AUTO_TEST_CASE(balance) BOOST_AUTO_TEST_CASE(balance)
@ -798,7 +799,7 @@ BOOST_AUTO_TEST_CASE(balance)
" }\n" " }\n"
"}\n"; "}\n";
compileAndRun(sourceCode, 23); compileAndRun(sourceCode, 23);
BOOST_CHECK(callContractFunction(0) == toBigEndian(u256(23))); BOOST_CHECK(callContractFunction("getBalance()") == toBigEndian(u256(23)));
} }
BOOST_AUTO_TEST_CASE(blockchain) BOOST_AUTO_TEST_CASE(blockchain)
@ -811,7 +812,7 @@ BOOST_AUTO_TEST_CASE(blockchain)
" }\n" " }\n"
"}\n"; "}\n";
compileAndRun(sourceCode, 27); compileAndRun(sourceCode, 27);
BOOST_CHECK(callContractFunction(0, bytes{0}, u256(28)) == toBigEndian(u256(28)) + bytes(20, 0) + toBigEndian(u256(1))); BOOST_CHECK(callContractFunction("someInfo()", bytes{0}, u256(28)) == toBigEndian(u256(28)) + bytes(20, 0) + toBigEndian(u256(1)));
} }
BOOST_AUTO_TEST_CASE(function_types) BOOST_AUTO_TEST_CASE(function_types)
@ -830,8 +831,8 @@ BOOST_AUTO_TEST_CASE(function_types)
" }\n" " }\n"
"}\n"; "}\n";
compileAndRun(sourceCode); compileAndRun(sourceCode);
BOOST_CHECK(callContractFunction(0, bytes{0}) == toBigEndian(u256(11))); BOOST_CHECK(callContractFunction("a(bool)", bytes{0}) == toBigEndian(u256(11)));
BOOST_CHECK(callContractFunction(0, bytes{1}) == toBigEndian(u256(12))); BOOST_CHECK(callContractFunction("a(bool)", bytes{1}) == toBigEndian(u256(12)));
} }
BOOST_AUTO_TEST_CASE(send_ether) BOOST_AUTO_TEST_CASE(send_ether)
@ -845,10 +846,107 @@ BOOST_AUTO_TEST_CASE(send_ether)
u256 amount(130); u256 amount(130);
compileAndRun(sourceCode, amount + 1); compileAndRun(sourceCode, amount + 1);
u160 address(23); u160 address(23);
BOOST_CHECK(callContractFunction(0, address, amount) == toBigEndian(u256(1))); BOOST_CHECK(callContractFunction("a(address,uint256)", address, amount) == toBigEndian(u256(1)));
BOOST_CHECK_EQUAL(m_state.balance(address), amount); BOOST_CHECK_EQUAL(m_state.balance(address), amount);
} }
BOOST_AUTO_TEST_CASE(log0)
{
char const* sourceCode = "contract test {\n"
" function a() {\n"
" log0(1);\n"
" }\n"
"}\n";
compileAndRun(sourceCode);
callContractFunction("a()");
BOOST_CHECK_EQUAL(m_logs.size(), 1);
BOOST_CHECK_EQUAL(m_logs[0].address, m_contractAddress);
BOOST_CHECK_EQUAL(h256(m_logs[0].data), h256(u256(1)));
BOOST_CHECK_EQUAL(m_logs[0].topics.size(), 0);
}
BOOST_AUTO_TEST_CASE(log1)
{
char const* sourceCode = "contract test {\n"
" function a() {\n"
" log1(1, 2);\n"
" }\n"
"}\n";
compileAndRun(sourceCode);
callContractFunction("a()");
BOOST_CHECK_EQUAL(m_logs.size(), 1);
BOOST_CHECK_EQUAL(m_logs[0].address, m_contractAddress);
BOOST_CHECK_EQUAL(h256(m_logs[0].data), h256(u256(1)));
BOOST_CHECK_EQUAL(m_logs[0].topics.size(), 1);
BOOST_CHECK_EQUAL(m_logs[0].topics[0], h256(u256(2)));
}
BOOST_AUTO_TEST_CASE(log2)
{
char const* sourceCode = "contract test {\n"
" function a() {\n"
" log2(1, 2, 3);\n"
" }\n"
"}\n";
compileAndRun(sourceCode);
callContractFunction("a()");
BOOST_CHECK_EQUAL(m_logs.size(), 1);
BOOST_CHECK_EQUAL(m_logs[0].address, m_contractAddress);
BOOST_CHECK_EQUAL(h256(m_logs[0].data), h256(u256(1)));
BOOST_CHECK_EQUAL(m_logs[0].topics.size(), 2);
for (unsigned i = 0; i < 2; ++i)
BOOST_CHECK_EQUAL(m_logs[0].topics[i], h256(u256(i + 2)));
}
BOOST_AUTO_TEST_CASE(log3)
{
char const* sourceCode = "contract test {\n"
" function a() {\n"
" log3(1, 2, 3, 4);\n"
" }\n"
"}\n";
compileAndRun(sourceCode);
callContractFunction("a()");
BOOST_CHECK_EQUAL(m_logs.size(), 1);
BOOST_CHECK_EQUAL(m_logs[0].address, m_contractAddress);
BOOST_CHECK_EQUAL(h256(m_logs[0].data), h256(u256(1)));
BOOST_CHECK_EQUAL(m_logs[0].topics.size(), 3);
for (unsigned i = 0; i < 3; ++i)
BOOST_CHECK_EQUAL(m_logs[0].topics[i], h256(u256(i + 2)));
}
BOOST_AUTO_TEST_CASE(log4)
{
char const* sourceCode = "contract test {\n"
" function a() {\n"
" log4(1, 2, 3, 4, 5);\n"
" }\n"
"}\n";
compileAndRun(sourceCode);
callContractFunction("a()");
BOOST_CHECK_EQUAL(m_logs.size(), 1);
BOOST_CHECK_EQUAL(m_logs[0].address, m_contractAddress);
BOOST_CHECK_EQUAL(h256(m_logs[0].data), h256(u256(1)));
BOOST_CHECK_EQUAL(m_logs[0].topics.size(), 4);
for (unsigned i = 0; i < 4; ++i)
BOOST_CHECK_EQUAL(m_logs[0].topics[i], h256(u256(i + 2)));
}
BOOST_AUTO_TEST_CASE(log_in_constructor)
{
char const* sourceCode = "contract test {\n"
" function test() {\n"
" log1(1, 2);\n"
" }\n"
"}\n";
compileAndRun(sourceCode);
BOOST_CHECK_EQUAL(m_logs.size(), 1);
BOOST_CHECK_EQUAL(m_logs[0].address, m_contractAddress);
BOOST_CHECK_EQUAL(h256(m_logs[0].data), h256(u256(1)));
BOOST_CHECK_EQUAL(m_logs[0].topics.size(), 1);
BOOST_CHECK_EQUAL(m_logs[0].topics[0], h256(u256(2)));
}
BOOST_AUTO_TEST_CASE(suicide) BOOST_AUTO_TEST_CASE(suicide)
{ {
char const* sourceCode = "contract test {\n" char const* sourceCode = "contract test {\n"
@ -860,7 +958,7 @@ BOOST_AUTO_TEST_CASE(suicide)
u256 amount(130); u256 amount(130);
compileAndRun(sourceCode, amount); compileAndRun(sourceCode, amount);
u160 address(23); u160 address(23);
BOOST_CHECK(callContractFunction(0, address) == bytes()); BOOST_CHECK(callContractFunction("a(address)", address) == bytes());
BOOST_CHECK(!m_state.addressHasCode(m_contractAddress)); BOOST_CHECK(!m_state.addressHasCode(m_contractAddress));
BOOST_CHECK_EQUAL(m_state.balance(address), amount); BOOST_CHECK_EQUAL(m_state.balance(address), amount);
} }
@ -877,9 +975,9 @@ BOOST_AUTO_TEST_CASE(sha3)
{ {
return dev::sha3(toBigEndian(_x)); return dev::sha3(toBigEndian(_x));
}; };
testSolidityAgainstCpp(0, f, u256(4)); testSolidityAgainstCpp("a(hash256)", f, u256(4));
testSolidityAgainstCpp(0, f, u256(5)); testSolidityAgainstCpp("a(hash256)", f, u256(5));
testSolidityAgainstCpp(0, f, u256(-1)); testSolidityAgainstCpp("a(hash256)", f, u256(-1));
} }
BOOST_AUTO_TEST_CASE(sha256) BOOST_AUTO_TEST_CASE(sha256)
@ -896,9 +994,9 @@ BOOST_AUTO_TEST_CASE(sha256)
dev::sha256(dev::ref(toBigEndian(_input)), bytesRef(&ret[0], 32)); dev::sha256(dev::ref(toBigEndian(_input)), bytesRef(&ret[0], 32));
return ret; return ret;
}; };
testSolidityAgainstCpp(0, f, u256(4)); testSolidityAgainstCpp("a(hash256)", f, u256(4));
testSolidityAgainstCpp(0, f, u256(5)); testSolidityAgainstCpp("a(hash256)", f, u256(5));
testSolidityAgainstCpp(0, f, u256(-1)); testSolidityAgainstCpp("a(hash256)", f, u256(-1));
} }
BOOST_AUTO_TEST_CASE(ripemd) BOOST_AUTO_TEST_CASE(ripemd)
@ -915,9 +1013,9 @@ BOOST_AUTO_TEST_CASE(ripemd)
dev::ripemd160(dev::ref(toBigEndian(_input)), bytesRef(&ret[0], 32)); dev::ripemd160(dev::ref(toBigEndian(_input)), bytesRef(&ret[0], 32));
return u256(ret) >> (256 - 160); return u256(ret) >> (256 - 160);
}; };
testSolidityAgainstCpp(0, f, u256(4)); testSolidityAgainstCpp("a(hash256)", f, u256(4));
testSolidityAgainstCpp(0, f, u256(5)); testSolidityAgainstCpp("a(hash256)", f, u256(5));
testSolidityAgainstCpp(0, f, u256(-1)); testSolidityAgainstCpp("a(hash256)", f, u256(-1));
} }
BOOST_AUTO_TEST_CASE(ecrecover) BOOST_AUTO_TEST_CASE(ecrecover)
@ -933,7 +1031,7 @@ BOOST_AUTO_TEST_CASE(ecrecover)
u256 r("0x73b1693892219d736caba55bdb67216e485557ea6b6af75f37096c9aa6a5a75f"); u256 r("0x73b1693892219d736caba55bdb67216e485557ea6b6af75f37096c9aa6a5a75f");
u256 s("0xeeb940b1d03b21e36b0e47e79769f095fe2ab855bd91e3a38756b7d75a9c4549"); u256 s("0xeeb940b1d03b21e36b0e47e79769f095fe2ab855bd91e3a38756b7d75a9c4549");
u160 addr("0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b"); u160 addr("0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b");
BOOST_CHECK(callContractFunction(0, h, v, r, s) == toBigEndian(addr)); BOOST_CHECK(callContractFunction("a(hash256,uint8,hash256,hash256)", h, v, r, s) == toBigEndian(addr));
} }
BOOST_AUTO_TEST_CASE(inter_contract_calls) BOOST_AUTO_TEST_CASE(inter_contract_calls)
@ -959,11 +1057,11 @@ BOOST_AUTO_TEST_CASE(inter_contract_calls)
compileAndRun(sourceCode, 0, "Helper"); compileAndRun(sourceCode, 0, "Helper");
u160 const helperAddress = m_contractAddress; u160 const helperAddress = m_contractAddress;
compileAndRun(sourceCode, 0, "Main"); compileAndRun(sourceCode, 0, "Main");
BOOST_REQUIRE(callContractFunction(2, helperAddress) == bytes()); BOOST_REQUIRE(callContractFunction("setHelper(address)", helperAddress) == bytes());
BOOST_REQUIRE(callContractFunction(1, helperAddress) == toBigEndian(helperAddress)); BOOST_REQUIRE(callContractFunction("getHelper()", helperAddress) == toBigEndian(helperAddress));
u256 a(3456789); u256 a(3456789);
u256 b("0x282837623374623234aa74"); u256 b("0x282837623374623234aa74");
BOOST_REQUIRE(callContractFunction(0, a, b) == toBigEndian(a * b)); BOOST_REQUIRE(callContractFunction("callHelper(uint256,uint256)", a, b) == toBigEndian(a * b));
} }
BOOST_AUTO_TEST_CASE(inter_contract_calls_with_complex_parameters) BOOST_AUTO_TEST_CASE(inter_contract_calls_with_complex_parameters)
@ -989,12 +1087,12 @@ BOOST_AUTO_TEST_CASE(inter_contract_calls_with_complex_parameters)
compileAndRun(sourceCode, 0, "Helper"); compileAndRun(sourceCode, 0, "Helper");
u160 const helperAddress = m_contractAddress; u160 const helperAddress = m_contractAddress;
compileAndRun(sourceCode, 0, "Main"); compileAndRun(sourceCode, 0, "Main");
BOOST_REQUIRE(callContractFunction(2, helperAddress) == bytes()); BOOST_REQUIRE(callContractFunction("setHelper(address)", helperAddress) == bytes());
BOOST_REQUIRE(callContractFunction(1, helperAddress) == toBigEndian(helperAddress)); BOOST_REQUIRE(callContractFunction("getHelper()", helperAddress) == toBigEndian(helperAddress));
u256 a(3456789); u256 a(3456789);
u256 b("0x282837623374623234aa74"); u256 b("0x282837623374623234aa74");
BOOST_REQUIRE(callContractFunction(0, a, true, b) == toBigEndian(a * 3)); BOOST_REQUIRE(callContractFunction("callHelper(uint256,bool,uint256)", a, true, b) == toBigEndian(a * 3));
BOOST_REQUIRE(callContractFunction(0, a, false, b) == toBigEndian(b * 3)); BOOST_REQUIRE(callContractFunction("callHelper(uint256,bool,uint256)", a, false, b) == toBigEndian(b * 3));
} }
BOOST_AUTO_TEST_CASE(inter_contract_calls_accessing_this) BOOST_AUTO_TEST_CASE(inter_contract_calls_accessing_this)
@ -1020,9 +1118,9 @@ BOOST_AUTO_TEST_CASE(inter_contract_calls_accessing_this)
compileAndRun(sourceCode, 0, "Helper"); compileAndRun(sourceCode, 0, "Helper");
u160 const helperAddress = m_contractAddress; u160 const helperAddress = m_contractAddress;
compileAndRun(sourceCode, 0, "Main"); compileAndRun(sourceCode, 0, "Main");
BOOST_REQUIRE(callContractFunction(2, helperAddress) == bytes()); BOOST_REQUIRE(callContractFunction("setHelper(address)", helperAddress) == bytes());
BOOST_REQUIRE(callContractFunction(1, helperAddress) == toBigEndian(helperAddress)); BOOST_REQUIRE(callContractFunction("getHelper()", helperAddress) == toBigEndian(helperAddress));
BOOST_REQUIRE(callContractFunction(0) == toBigEndian(helperAddress)); BOOST_REQUIRE(callContractFunction("callHelper()") == toBigEndian(helperAddress));
} }
BOOST_AUTO_TEST_CASE(calls_to_this) BOOST_AUTO_TEST_CASE(calls_to_this)
@ -1051,11 +1149,11 @@ BOOST_AUTO_TEST_CASE(calls_to_this)
compileAndRun(sourceCode, 0, "Helper"); compileAndRun(sourceCode, 0, "Helper");
u160 const helperAddress = m_contractAddress; u160 const helperAddress = m_contractAddress;
compileAndRun(sourceCode, 0, "Main"); compileAndRun(sourceCode, 0, "Main");
BOOST_REQUIRE(callContractFunction(2, helperAddress) == bytes()); BOOST_REQUIRE(callContractFunction("setHelper(address)", helperAddress) == bytes());
BOOST_REQUIRE(callContractFunction(1, helperAddress) == toBigEndian(helperAddress)); BOOST_REQUIRE(callContractFunction("getHelper()", helperAddress) == toBigEndian(helperAddress));
u256 a(3456789); u256 a(3456789);
u256 b("0x282837623374623234aa74"); u256 b("0x282837623374623234aa74");
BOOST_REQUIRE(callContractFunction(0, a, b) == toBigEndian(a * b + 10)); BOOST_REQUIRE(callContractFunction("callHelper(uint256,uint256)", a, b) == toBigEndian(a * b + 10));
} }
BOOST_AUTO_TEST_CASE(inter_contract_calls_with_local_vars) BOOST_AUTO_TEST_CASE(inter_contract_calls_with_local_vars)
@ -1086,11 +1184,11 @@ BOOST_AUTO_TEST_CASE(inter_contract_calls_with_local_vars)
compileAndRun(sourceCode, 0, "Helper"); compileAndRun(sourceCode, 0, "Helper");
u160 const helperAddress = m_contractAddress; u160 const helperAddress = m_contractAddress;
compileAndRun(sourceCode, 0, "Main"); compileAndRun(sourceCode, 0, "Main");
BOOST_REQUIRE(callContractFunction(2, helperAddress) == bytes()); BOOST_REQUIRE(callContractFunction("setHelper(address)", helperAddress) == bytes());
BOOST_REQUIRE(callContractFunction(1, helperAddress) == toBigEndian(helperAddress)); BOOST_REQUIRE(callContractFunction("getHelper()", helperAddress) == toBigEndian(helperAddress));
u256 a(3456789); u256 a(3456789);
u256 b("0x282837623374623234aa74"); u256 b("0x282837623374623234aa74");
BOOST_REQUIRE(callContractFunction(0, a, b) == toBigEndian(a * b + 9)); BOOST_REQUIRE(callContractFunction("callHelper(uint256,uint256)", a, b) == toBigEndian(a * b + 9));
} }
BOOST_AUTO_TEST_CASE(strings_in_calls) BOOST_AUTO_TEST_CASE(strings_in_calls)
@ -1116,9 +1214,9 @@ BOOST_AUTO_TEST_CASE(strings_in_calls)
compileAndRun(sourceCode, 0, "Helper"); compileAndRun(sourceCode, 0, "Helper");
u160 const helperAddress = m_contractAddress; u160 const helperAddress = m_contractAddress;
compileAndRun(sourceCode, 0, "Main"); compileAndRun(sourceCode, 0, "Main");
BOOST_REQUIRE(callContractFunction(2, helperAddress) == bytes()); BOOST_REQUIRE(callContractFunction("setHelper(address)", helperAddress) == bytes());
BOOST_REQUIRE(callContractFunction(1, helperAddress) == toBigEndian(helperAddress)); BOOST_REQUIRE(callContractFunction("getHelper()", helperAddress) == toBigEndian(helperAddress));
BOOST_CHECK(callContractFunction(0, bytes({0, 'a', 1})) == bytes({0, 'a', 0, 0, 0})); BOOST_CHECK(callContractFunction("callHelper(string2,bool)", bytes({0, 'a', 1})) == bytes({0, 'a', 0, 0, 0}));
} }
BOOST_AUTO_TEST_CASE(constructor_arguments) BOOST_AUTO_TEST_CASE(constructor_arguments)
@ -1143,8 +1241,8 @@ BOOST_AUTO_TEST_CASE(constructor_arguments)
function getName() returns (string3 ret) { return h.getName(); } function getName() returns (string3 ret) { return h.getName(); }
})"; })";
compileAndRun(sourceCode, 0, "Main"); compileAndRun(sourceCode, 0, "Main");
BOOST_REQUIRE(callContractFunction(0) == bytes({byte(0x01)})); BOOST_REQUIRE(callContractFunction("getFlag()") == bytes({byte(0x01)}));
BOOST_REQUIRE(callContractFunction(1) == bytes({'a', 'b', 'c'})); BOOST_REQUIRE(callContractFunction("getName()") == bytes({'a', 'b', 'c'}));
} }
BOOST_AUTO_TEST_CASE(functions_called_by_constructor) BOOST_AUTO_TEST_CASE(functions_called_by_constructor)
@ -1161,7 +1259,7 @@ BOOST_AUTO_TEST_CASE(functions_called_by_constructor)
function setName(string3 _name) { name = _name; } function setName(string3 _name) { name = _name; }
})"; })";
compileAndRun(sourceCode); compileAndRun(sourceCode);
BOOST_REQUIRE(callContractFunction(0) == bytes({'a', 'b', 'c'})); BOOST_REQUIRE(callContractFunction("getName()") == bytes({'a', 'b', 'c'}));
} }
BOOST_AUTO_TEST_SUITE_END() BOOST_AUTO_TEST_SUITE_END()

View File

@ -174,8 +174,8 @@ BOOST_AUTO_TEST_CASE(comparison)
bytes code = compileFirstExpression(sourceCode); bytes code = compileFirstExpression(sourceCode);
bytes expectation({byte(eth::Instruction::PUSH1), 0x1, bytes expectation({byte(eth::Instruction::PUSH1), 0x1,
byte(eth::Instruction::PUSH2), 0x11, 0xaa, byte(eth::Instruction::PUSH2), 0xff, 0xff, byte(eth::Instruction::AND), byte(eth::Instruction::PUSH2), 0x11, 0xaa,
byte(eth::Instruction::PUSH2), 0x10, 0xaa, byte(eth::Instruction::PUSH2), 0xff, 0xff, byte(eth::Instruction::AND), byte(eth::Instruction::PUSH2), 0x10, 0xaa,
byte(eth::Instruction::LT), byte(eth::Instruction::LT),
byte(eth::Instruction::EQ), byte(eth::Instruction::EQ),
byte(eth::Instruction::ISZERO)}); byte(eth::Instruction::ISZERO)});
@ -189,20 +189,18 @@ BOOST_AUTO_TEST_CASE(short_circuiting)
"}\n"; "}\n";
bytes code = compileFirstExpression(sourceCode); bytes code = compileFirstExpression(sourceCode);
bytes expectation({byte(eth::Instruction::PUSH1), 0xa, bytes expectation({byte(eth::Instruction::PUSH1), 0x12, // 8 + 10
byte(eth::Instruction::PUSH1), 0x8, byte(eth::Instruction::PUSH1), 0x4,
byte(eth::Instruction::ADD), byte(eth::Instruction::PUSH1), 0xff, byte(eth::Instruction::AND),
byte(eth::Instruction::PUSH1), 0x4, byte(eth::Instruction::PUSH1), 0xff, byte(eth::Instruction::AND),
byte(eth::Instruction::GT), byte(eth::Instruction::GT),
byte(eth::Instruction::ISZERO), // after this we have 10 + 8 >= 4 byte(eth::Instruction::ISZERO), // after this we have 4 <= 8 + 10
byte(eth::Instruction::DUP1), byte(eth::Instruction::DUP1),
byte(eth::Instruction::PUSH1), 0x20, byte(eth::Instruction::PUSH1), 0x11,
byte(eth::Instruction::JUMPI), // short-circuit if it is true byte(eth::Instruction::JUMPI), // short-circuit if it is true
byte(eth::Instruction::POP), byte(eth::Instruction::POP),
byte(eth::Instruction::PUSH1), 0x2, byte(eth::Instruction::PUSH1), 0xff, byte(eth::Instruction::AND), byte(eth::Instruction::PUSH1), 0x2,
byte(eth::Instruction::PUSH1), 0x9, byte(eth::Instruction::PUSH1), 0xff, byte(eth::Instruction::AND), byte(eth::Instruction::PUSH1), 0x9,
byte(eth::Instruction::EQ), byte(eth::Instruction::EQ),
byte(eth::Instruction::ISZERO), // after this we have 2 != 9 byte(eth::Instruction::ISZERO), // after this we have 9 != 2
byte(eth::Instruction::JUMPDEST), byte(eth::Instruction::JUMPDEST),
byte(eth::Instruction::PUSH1), 0x1, byte(eth::Instruction::PUSH1), 0x1,
byte(eth::Instruction::EQ), byte(eth::Instruction::EQ),
@ -213,28 +211,24 @@ BOOST_AUTO_TEST_CASE(short_circuiting)
BOOST_AUTO_TEST_CASE(arithmetics) BOOST_AUTO_TEST_CASE(arithmetics)
{ {
char const* sourceCode = "contract test {\n" char const* sourceCode = "contract test {\n"
" function f() { var x = ((((((((9 ^ 8) & 7) | 6) - 5) + 4) % 3) / 2) * 1); }" " function f(uint y) { var x = ((((((((y ^ 8) & 7) | 6) - 5) + 4) % 3) / 2) * 1); }"
"}\n"; "}\n";
bytes code = compileFirstExpression(sourceCode); bytes code = compileFirstExpression(sourceCode, {}, {{"test", "f", "y"}, {"test", "f", "x"}});
bytes expectation({byte(eth::Instruction::PUSH1), 0x1, bytes expectation({byte(eth::Instruction::PUSH1), 0x1,
byte(eth::Instruction::PUSH1), 0x2, byte(eth::Instruction::PUSH1), 0x2,
byte(eth::Instruction::PUSH1), 0xff, byte(eth::Instruction::AND),
byte(eth::Instruction::PUSH1), 0x3, byte(eth::Instruction::PUSH1), 0x3,
byte(eth::Instruction::PUSH1), 0xff, byte(eth::Instruction::AND),
byte(eth::Instruction::PUSH1), 0x4, byte(eth::Instruction::PUSH1), 0x4,
byte(eth::Instruction::PUSH1), 0x5, byte(eth::Instruction::PUSH1), 0x5,
byte(eth::Instruction::PUSH1), 0x6, byte(eth::Instruction::PUSH1), 0x6,
byte(eth::Instruction::PUSH1), 0x7, byte(eth::Instruction::PUSH1), 0x7,
byte(eth::Instruction::PUSH1), 0x8, byte(eth::Instruction::PUSH1), 0x8,
byte(eth::Instruction::PUSH1), 0x9, byte(eth::Instruction::DUP10),
byte(eth::Instruction::XOR), byte(eth::Instruction::XOR),
byte(eth::Instruction::AND), byte(eth::Instruction::AND),
byte(eth::Instruction::OR), byte(eth::Instruction::OR),
byte(eth::Instruction::SUB), byte(eth::Instruction::SUB),
byte(eth::Instruction::ADD), byte(eth::Instruction::ADD),
byte(eth::Instruction::PUSH1), 0xff, byte(eth::Instruction::AND),
byte(eth::Instruction::MOD), byte(eth::Instruction::MOD),
byte(eth::Instruction::PUSH1), 0xff, byte(eth::Instruction::AND),
byte(eth::Instruction::DIV), byte(eth::Instruction::DIV),
byte(eth::Instruction::MUL)}); byte(eth::Instruction::MUL)});
BOOST_CHECK_EQUAL_COLLECTIONS(code.begin(), code.end(), expectation.begin(), expectation.end()); BOOST_CHECK_EQUAL_COLLECTIONS(code.begin(), code.end(), expectation.begin(), expectation.end());
@ -243,15 +237,15 @@ BOOST_AUTO_TEST_CASE(arithmetics)
BOOST_AUTO_TEST_CASE(unary_operators) BOOST_AUTO_TEST_CASE(unary_operators)
{ {
char const* sourceCode = "contract test {\n" char const* sourceCode = "contract test {\n"
" function f() { var x = !(~+- 1 == 2); }" " function f(int y) { var x = !(~+- y == 2); }"
"}\n"; "}\n";
bytes code = compileFirstExpression(sourceCode); bytes code = compileFirstExpression(sourceCode, {}, {{"test", "f", "y"}, {"test", "f", "x"}});
bytes expectation({byte(eth::Instruction::PUSH1), 0x2, byte(eth::Instruction::PUSH1), 0xff, byte(eth::Instruction::AND), bytes expectation({byte(eth::Instruction::PUSH1), 0x2,
byte(eth::Instruction::PUSH1), 0x1, byte(eth::Instruction::DUP3),
byte(eth::Instruction::PUSH1), 0x0, byte(eth::Instruction::PUSH1), 0x0,
byte(eth::Instruction::SUB), byte(eth::Instruction::SUB),
byte(eth::Instruction::NOT), byte(eth::Instruction::PUSH1), 0xff, byte(eth::Instruction::AND), byte(eth::Instruction::NOT),
byte(eth::Instruction::EQ), byte(eth::Instruction::EQ),
byte(eth::Instruction::ISZERO)}); byte(eth::Instruction::ISZERO)});
BOOST_CHECK_EQUAL_COLLECTIONS(code.begin(), code.end(), expectation.begin(), expectation.end()); BOOST_CHECK_EQUAL_COLLECTIONS(code.begin(), code.end(), expectation.begin(), expectation.end());
@ -315,7 +309,7 @@ BOOST_AUTO_TEST_CASE(assignment)
bytes code = compileFirstExpression(sourceCode, {}, {{"test", "f", "a"}, {"test", "f", "b"}}); bytes code = compileFirstExpression(sourceCode, {}, {{"test", "f", "a"}, {"test", "f", "b"}});
// Stack: a, b // Stack: a, b
bytes expectation({byte(eth::Instruction::PUSH1), 0x2, byte(eth::Instruction::PUSH1), 0xff, byte(eth::Instruction::AND), bytes expectation({byte(eth::Instruction::PUSH1), 0x2,
byte(eth::Instruction::DUP2), byte(eth::Instruction::DUP2),
byte(eth::Instruction::DUP4), byte(eth::Instruction::DUP4),
byte(eth::Instruction::ADD), byte(eth::Instruction::ADD),
@ -338,14 +332,14 @@ BOOST_AUTO_TEST_CASE(function_call)
{{"test", "f", "a"}, {"test", "f", "b"}}); {{"test", "f", "a"}, {"test", "f", "b"}});
// Stack: a, b // Stack: a, b
bytes expectation({byte(eth::Instruction::PUSH1), 0x02, byte(eth::Instruction::PUSH1), 0xff, byte(eth::Instruction::AND), bytes expectation({byte(eth::Instruction::PUSH1), 0x02,
byte(eth::Instruction::PUSH1), 0x12, byte(eth::Instruction::PUSH1), 0x0c,
byte(eth::Instruction::PUSH1), 0x01, byte(eth::Instruction::PUSH1), 0xff, byte(eth::Instruction::AND), byte(eth::Instruction::PUSH1), 0x01,
byte(eth::Instruction::DUP5), byte(eth::Instruction::DUP5),
byte(eth::Instruction::ADD), byte(eth::Instruction::ADD),
// Stack here: a b 2 <ret label> (a+1) // Stack here: a b 2 <ret label> (a+1)
byte(eth::Instruction::DUP4), byte(eth::Instruction::DUP4),
byte(eth::Instruction::PUSH1), 0x19, byte(eth::Instruction::PUSH1), 0x13,
byte(eth::Instruction::JUMP), byte(eth::Instruction::JUMP),
byte(eth::Instruction::JUMPDEST), byte(eth::Instruction::JUMPDEST),
// Stack here: a b 2 g(a+1, b) // Stack here: a b 2 g(a+1, b)
@ -363,40 +357,36 @@ BOOST_AUTO_TEST_CASE(function_call)
BOOST_AUTO_TEST_CASE(negative_literals_8bits) BOOST_AUTO_TEST_CASE(negative_literals_8bits)
{ {
// these all fit in 8 bits
char const* sourceCode = "contract test {\n" char const* sourceCode = "contract test {\n"
" function f() { int8 x = -0 + -1 + -0x01 + -127 + -128; }\n" " function f() { int8 x = -0x80; }\n"
"}\n"; "}\n";
bytes code = compileFirstExpression(sourceCode); bytes code = compileFirstExpression(sourceCode);
bytes expectation(bytes({byte(eth::Instruction::PUSH32)}) + bytes(31, 0xff) + bytes(1, 0x80) + bytes expectation(bytes({byte(eth::Instruction::PUSH32)}) + bytes(31, 0xff) + bytes(1, 0x80));
bytes({byte(eth::Instruction::PUSH32)}) + bytes(31, 0xff) + bytes(1, 0x81) +
bytes({byte(eth::Instruction::PUSH32)}) + bytes(32, 0xff) +
bytes({byte(eth::Instruction::PUSH32)}) + bytes(32, 0xff) +
bytes({byte(eth::Instruction::PUSH1), 0x00,
byte(eth::Instruction::ADD),
byte(eth::Instruction::ADD),
byte(eth::Instruction::ADD),
byte(eth::Instruction::ADD)}));
BOOST_CHECK_EQUAL_COLLECTIONS(code.begin(), code.end(), expectation.begin(), expectation.end()); BOOST_CHECK_EQUAL_COLLECTIONS(code.begin(), code.end(), expectation.begin(), expectation.end());
} }
BOOST_AUTO_TEST_CASE(negative_literals_16bits) BOOST_AUTO_TEST_CASE(negative_literals_16bits)
{ {
// -1 should need 8 bits, -129 should need 16 bits, how many bits are used is visible
// from the SIGNEXTEND opcodes
char const* sourceCode = "contract test {\n" char const* sourceCode = "contract test {\n"
" function f() { int64 x = int64(-1 + -129); }\n" " function f() { int64 x = ~0xabc; }\n"
"}\n"; "}\n";
bytes code = compileFirstExpression(sourceCode); bytes code = compileFirstExpression(sourceCode);
bytes expectation(bytes({byte(eth::Instruction::PUSH32)}) + bytes(31, 0xff) + bytes(1, 0x7f) + bytes expectation(bytes({byte(eth::Instruction::PUSH32)}) + bytes(30, 0xff) + bytes{0xf5, 0x43});
bytes({byte(eth::Instruction::PUSH32)}) + bytes(32, 0xff) + BOOST_CHECK_EQUAL_COLLECTIONS(code.begin(), code.end(), expectation.begin(), expectation.end());
bytes({byte(eth::Instruction::PUSH1), 0x00, }
byte(eth::Instruction::SIGNEXTEND),
byte(eth::Instruction::ADD), BOOST_AUTO_TEST_CASE(intermediately_overflowing_literals)
byte(eth::Instruction::PUSH1), 0x01, {
byte(eth::Instruction::SIGNEXTEND)})); // first literal itself is too large for 256 bits but it fits after all constant operations
// have been applied
char const* sourceCode = "contract test {\n"
" function f() { var x = (0xffffffffffffffffffffffffffffffffffffffff * 0xffffffffffffffffffffffffff01) & 0xbf; }\n"
"}\n";
bytes code = compileFirstExpression(sourceCode);
bytes expectation(bytes({byte(eth::Instruction::PUSH1), 0xbf}));
BOOST_CHECK_EQUAL_COLLECTIONS(code.begin(), code.end(), expectation.begin(), expectation.end()); BOOST_CHECK_EQUAL_COLLECTIONS(code.begin(), code.end(), expectation.begin(), expectation.end());
} }

View File

@ -38,7 +38,7 @@ namespace test
namespace namespace
{ {
void parseTextAndResolveNames(std::string const& _source) ASTPointer<SourceUnit> parseTextAndResolveNames(std::string const& _source)
{ {
Parser parser; Parser parser;
ASTPointer<SourceUnit> sourceUnit = parser.parse(std::make_shared<Scanner>(CharStream(_source))); ASTPointer<SourceUnit> sourceUnit = parser.parse(std::make_shared<Scanner>(CharStream(_source)));
@ -50,6 +50,8 @@ void parseTextAndResolveNames(std::string const& _source)
for (ASTPointer<ASTNode> const& node: sourceUnit->getNodes()) for (ASTPointer<ASTNode> const& node: sourceUnit->getNodes())
if (ContractDefinition* contract = dynamic_cast<ContractDefinition*>(node.get())) if (ContractDefinition* contract = dynamic_cast<ContractDefinition*>(node.get()))
resolver.checkTypeRequirements(*contract); resolver.checkTypeRequirements(*contract);
return sourceUnit;
} }
} }
@ -321,6 +323,40 @@ BOOST_AUTO_TEST_CASE(comparison_bitop_precedence)
BOOST_CHECK_NO_THROW(parseTextAndResolveNames(text)); BOOST_CHECK_NO_THROW(parseTextAndResolveNames(text));
} }
BOOST_AUTO_TEST_CASE(function_canonical_signature)
{
ASTPointer<SourceUnit> sourceUnit;
char const* text = "contract Test {\n"
" function foo(uint256 arg1, uint64 arg2, bool arg3) returns (uint256 ret) {\n"
" ret = arg1 + arg2;\n"
" }\n"
"}\n";
BOOST_CHECK_NO_THROW(sourceUnit = parseTextAndResolveNames(text));
for (ASTPointer<ASTNode> const& node: sourceUnit->getNodes())
if (ContractDefinition* contract = dynamic_cast<ContractDefinition*>(node.get()))
{
auto functions = contract->getDefinedFunctions();
BOOST_CHECK_EQUAL("foo(uint256,uint64,bool)", functions[0]->getCanonicalSignature());
}
}
BOOST_AUTO_TEST_CASE(function_canonical_signature_type_aliases)
{
ASTPointer<SourceUnit> sourceUnit;
char const* text = "contract Test {\n"
" function boo(uint arg1, hash arg2, address arg3) returns (uint ret) {\n"
" ret = 5;\n"
" }\n"
"}\n";
BOOST_CHECK_NO_THROW(sourceUnit = parseTextAndResolveNames(text));
for (ASTPointer<ASTNode> const& node: sourceUnit->getNodes())
if (ContractDefinition* contract = dynamic_cast<ContractDefinition*>(node.get()))
{
auto functions = contract->getDefinedFunctions();
BOOST_CHECK_EQUAL("boo(uint256,hash256,address)", functions[0]->getCanonicalSignature());
}
}
BOOST_AUTO_TEST_SUITE_END() BOOST_AUTO_TEST_SUITE_END()
} }

View File

@ -56,9 +56,9 @@ public:
} }
if (_userDocumentation) if (_userDocumentation)
generatedDocumentationString = m_compilerStack.getJsonDocumentation("", DocumentationType::NATSPEC_USER); generatedDocumentationString = m_compilerStack.getMetadata("", DocumentationType::NATSPEC_USER);
else else
generatedDocumentationString = m_compilerStack.getJsonDocumentation("", DocumentationType::NATSPEC_DEV); generatedDocumentationString = m_compilerStack.getMetadata("", DocumentationType::NATSPEC_DEV);
Json::Value generatedDocumentation; Json::Value generatedDocumentation;
m_reader.parse(generatedDocumentationString, generatedDocumentation); m_reader.parse(generatedDocumentationString, generatedDocumentation);
Json::Value expectedDocumentation; Json::Value expectedDocumentation;

View File

@ -48,19 +48,19 @@ public:
m_optimize = true; m_optimize = true;
bytes optimizedBytecode = compileAndRun(_sourceCode, _value, _contractName); bytes optimizedBytecode = compileAndRun(_sourceCode, _value, _contractName);
int sizeDiff = nonOptimizedBytecode.size() - optimizedBytecode.size(); int sizeDiff = nonOptimizedBytecode.size() - optimizedBytecode.size();
BOOST_CHECK_MESSAGE(sizeDiff == int(_expectedSizeDecrease), "Bytecode did only shrink by " BOOST_CHECK_MESSAGE(sizeDiff == int(_expectedSizeDecrease), "Bytecode shrank by "
+ boost::lexical_cast<string>(sizeDiff) + " bytes, expected: " + boost::lexical_cast<string>(sizeDiff) + " bytes, expected: "
+ boost::lexical_cast<string>(_expectedSizeDecrease)); + boost::lexical_cast<string>(_expectedSizeDecrease));
m_optimizedContract = m_contractAddress; m_optimizedContract = m_contractAddress;
} }
template <class... Args> template <class... Args>
void compareVersions(byte _index, Args const&... _arguments) void compareVersions(std::string _sig, Args const&... _arguments)
{ {
m_contractAddress = m_nonOptimizedContract; m_contractAddress = m_nonOptimizedContract;
bytes nonOptimizedOutput = callContractFunction(_index, _arguments...); bytes nonOptimizedOutput = callContractFunction(_sig, _arguments...);
m_contractAddress = m_optimizedContract; m_contractAddress = m_optimizedContract;
bytes optimizedOutput = callContractFunction(_index, _arguments...); bytes optimizedOutput = callContractFunction(_sig, _arguments...);
BOOST_CHECK_MESSAGE(nonOptimizedOutput == optimizedOutput, "Computed values do not match." BOOST_CHECK_MESSAGE(nonOptimizedOutput == optimizedOutput, "Computed values do not match."
"\nNon-Optimized: " + toHex(nonOptimizedOutput) + "\nNon-Optimized: " + toHex(nonOptimizedOutput) +
"\nOptimized: " + toHex(optimizedOutput)); "\nOptimized: " + toHex(optimizedOutput));
@ -81,8 +81,8 @@ BOOST_AUTO_TEST_CASE(smoke_test)
return a; return a;
} }
})"; })";
compileBothVersions(4, sourceCode); compileBothVersions(29, sourceCode);
compareVersions(0, u256(7)); compareVersions("f(uint256)", u256(7));
} }
BOOST_AUTO_TEST_CASE(large_integers) BOOST_AUTO_TEST_CASE(large_integers)
@ -91,23 +91,23 @@ BOOST_AUTO_TEST_CASE(large_integers)
contract test { contract test {
function f() returns (uint a, uint b) { function f() returns (uint a, uint b) {
a = 0x234234872642837426347000000; a = 0x234234872642837426347000000;
b = 0x110000000000000000000000002; b = 0x10000000000000000000000002;
} }
})"; })";
compileBothVersions(28, sourceCode); compileBothVersions(36, sourceCode);
compareVersions(0); compareVersions("f()");
} }
BOOST_AUTO_TEST_CASE(invariants) BOOST_AUTO_TEST_CASE(invariants)
{ {
char const* sourceCode = R"( char const* sourceCode = R"(
contract test { contract test {
function f(uint a) returns (uint b) { function f(int a) returns (int b) {
return (((a + (1 - 1)) ^ 0) | 0) & (uint(0) - 1); return int(0) | (int(1) * (int(0) ^ (0 + a)));
} }
})"; })";
compileBothVersions(28, sourceCode); compileBothVersions(41, sourceCode);
compareVersions(0, u256(0x12334664)); compareVersions("f(uint256)", u256(0x12334664));
} }
BOOST_AUTO_TEST_CASE(unused_expressions) BOOST_AUTO_TEST_CASE(unused_expressions)
@ -120,23 +120,23 @@ BOOST_AUTO_TEST_CASE(unused_expressions)
data; data;
} }
})"; })";
compileBothVersions(11, sourceCode); compileBothVersions(33, sourceCode);
compareVersions(0); compareVersions("f()");
} }
BOOST_AUTO_TEST_CASE(constant_folding_both_sides) BOOST_AUTO_TEST_CASE(constant_folding_both_sides)
{ {
// if constants involving the same associative and commutative operator are applied from both // if constants involving the same associative and commutative operator are applied from both
// sides, the operator should be applied only once, because the expression compiler // sides, the operator should be applied only once, because the expression compiler pushes
// (even in non-optimized mode) pushes literals as late as possible // literals as late as possible
char const* sourceCode = R"( char const* sourceCode = R"(
contract test { contract test {
function f(uint x) returns (uint y) { function f(uint x) returns (uint y) {
return 98 ^ (7 * ((1 | (x | 1000)) * 40) ^ 102); return 98 ^ (7 * ((1 | (x | 1000)) * 40) ^ 102);
} }
})"; })";
compileBothVersions(31, sourceCode); compileBothVersions(37, sourceCode);
compareVersions(0); compareVersions("f(uint256)");
} }
BOOST_AUTO_TEST_SUITE_END() BOOST_AUTO_TEST_SUITE_END()

View File

@ -103,14 +103,17 @@ BOOST_AUTO_TEST_CASE(negative_numbers)
BOOST_CHECK_EQUAL(scanner.getCurrentToken(), Token::VAR); BOOST_CHECK_EQUAL(scanner.getCurrentToken(), Token::VAR);
BOOST_CHECK_EQUAL(scanner.next(), Token::IDENTIFIER); BOOST_CHECK_EQUAL(scanner.next(), Token::IDENTIFIER);
BOOST_CHECK_EQUAL(scanner.next(), Token::ASSIGN); BOOST_CHECK_EQUAL(scanner.next(), Token::ASSIGN);
BOOST_CHECK_EQUAL(scanner.next(), Token::SUB);
BOOST_CHECK_EQUAL(scanner.next(), Token::NUMBER); BOOST_CHECK_EQUAL(scanner.next(), Token::NUMBER);
BOOST_CHECK_EQUAL(scanner.getCurrentLiteral(), "-.2"); BOOST_CHECK_EQUAL(scanner.getCurrentLiteral(), ".2");
BOOST_CHECK_EQUAL(scanner.next(), Token::ADD); BOOST_CHECK_EQUAL(scanner.next(), Token::ADD);
BOOST_CHECK_EQUAL(scanner.next(), Token::SUB);
BOOST_CHECK_EQUAL(scanner.next(), Token::NUMBER); BOOST_CHECK_EQUAL(scanner.next(), Token::NUMBER);
BOOST_CHECK_EQUAL(scanner.getCurrentLiteral(), "-0x78"); BOOST_CHECK_EQUAL(scanner.getCurrentLiteral(), "0x78");
BOOST_CHECK_EQUAL(scanner.next(), Token::ADD); BOOST_CHECK_EQUAL(scanner.next(), Token::ADD);
BOOST_CHECK_EQUAL(scanner.next(), Token::SUB);
BOOST_CHECK_EQUAL(scanner.next(), Token::NUMBER); BOOST_CHECK_EQUAL(scanner.next(), Token::NUMBER);
BOOST_CHECK_EQUAL(scanner.getCurrentLiteral(), "-7.3"); BOOST_CHECK_EQUAL(scanner.getCurrentLiteral(), "7.3");
BOOST_CHECK_EQUAL(scanner.next(), Token::ADD); BOOST_CHECK_EQUAL(scanner.next(), Token::ADD);
BOOST_CHECK_EQUAL(scanner.next(), Token::NUMBER); BOOST_CHECK_EQUAL(scanner.next(), Token::NUMBER);
BOOST_CHECK_EQUAL(scanner.getCurrentLiteral(), "8.9"); BOOST_CHECK_EQUAL(scanner.getCurrentLiteral(), "8.9");
@ -130,8 +133,9 @@ BOOST_AUTO_TEST_CASE(locations)
BOOST_CHECK_EQUAL(scanner.next(), Token::SEMICOLON); BOOST_CHECK_EQUAL(scanner.next(), Token::SEMICOLON);
BOOST_CHECK_EQUAL(scanner.getCurrentLocation().start, 24); BOOST_CHECK_EQUAL(scanner.getCurrentLocation().start, 24);
BOOST_CHECK_EQUAL(scanner.getCurrentLocation().end, 25); BOOST_CHECK_EQUAL(scanner.getCurrentLocation().end, 25);
BOOST_CHECK_EQUAL(scanner.next(), Token::SUB);
BOOST_CHECK_EQUAL(scanner.next(), Token::NUMBER); BOOST_CHECK_EQUAL(scanner.next(), Token::NUMBER);
BOOST_CHECK_EQUAL(scanner.getCurrentLocation().start, 26); BOOST_CHECK_EQUAL(scanner.getCurrentLocation().start, 27);
BOOST_CHECK_EQUAL(scanner.getCurrentLocation().end, 32); BOOST_CHECK_EQUAL(scanner.getCurrentLocation().end, 32);
BOOST_CHECK_EQUAL(scanner.next(), Token::IDENTIFIER); BOOST_CHECK_EQUAL(scanner.next(), Token::IDENTIFIER);
BOOST_CHECK_EQUAL(scanner.getCurrentLocation().start, 45); BOOST_CHECK_EQUAL(scanner.getCurrentLocation().start, 45);

View File

@ -489,4 +489,12 @@ void processCommandLineOptions()
} }
} }
LastHashes lastHashes(u256 _currentBlockNumber)
{
LastHashes ret;
for (u256 i = 1; i <= 256 && i <= _currentBlockNumber; ++i)
ret.push_back(sha3(toString(_currentBlockNumber - i)));
return ret;
}
} } // namespaces } } // namespaces

View File

@ -77,6 +77,7 @@ void executeTests(const std::string& _name, const std::string& _testPathAppendix
std::string getTestPath(); std::string getTestPath();
void userDefinedTest(std::string testTypeFlag, std::function<void(json_spirit::mValue&, bool)> doTests); void userDefinedTest(std::string testTypeFlag, std::function<void(json_spirit::mValue&, bool)> doTests);
void processCommandLineOptions(); void processCommandLineOptions();
eth::LastHashes lastHashes(u256 _currentBlockNumber);
template<typename mapType> template<typename mapType>
void checkAddresses(mapType& _expectedAddrs, mapType& _resultAddrs) void checkAddresses(mapType& _expectedAddrs, mapType& _resultAddrs)

View File

@ -74,6 +74,12 @@ struct Setup
} }
}; };
string fromAscii(string _s)
{
bytes b = asBytes(_s);
return "0x" + toHex(b);
}
BOOST_FIXTURE_TEST_SUITE(environment, Setup) BOOST_FIXTURE_TEST_SUITE(environment, Setup)
BOOST_AUTO_TEST_CASE(jsonrpc_defaultBlock) BOOST_AUTO_TEST_CASE(jsonrpc_defaultBlock)
@ -312,6 +318,18 @@ BOOST_AUTO_TEST_CASE(contract_storage)
} }
} }
BOOST_AUTO_TEST_CASE(sha3)
{
cnote << "Testing jsonrpc sha3...";
string testString = "multiply(uint256)";
h256 expected = dev::sha3(testString);
auto hexValue = fromAscii(testString);
string result = jsonrpcClient->web3_sha3(hexValue);
BOOST_CHECK_EQUAL(toJS(expected), result);
BOOST_CHECK_EQUAL("0xc6888fa159d67f77c2f3d7a402e199802766bd7e8d4d1ecd2274fc920265d56a", result);
}
BOOST_AUTO_TEST_SUITE_END() BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_SUITE_END() BOOST_AUTO_TEST_SUITE_END()

View File

@ -56,34 +56,36 @@ public:
return m_output; return m_output;
} }
bytes const& callContractFunction(byte _index, bytes const& _data = bytes(), u256 const& _value = 0) bytes const& callContractFunction(std::string _sig, bytes const& _data = bytes(),
u256 const& _value = 0)
{ {
sendMessage(bytes(1, _index) + _data, false, _value); FixedHash<4> hash(dev::sha3(_sig));
sendMessage(hash.asBytes() + _data, false, _value);
return m_output; return m_output;
} }
template <class... Args> template <class... Args>
bytes const& callContractFunction(byte _index, Args const&... _arguments) bytes const& callContractFunction(std::string _sig, Args const&... _arguments)
{ {
return callContractFunction(_index, argsToBigEndian(_arguments...)); return callContractFunction(_sig, argsToBigEndian(_arguments...));
} }
template <class CppFunction, class... Args> template <class CppFunction, class... Args>
void testSolidityAgainstCpp(byte _index, CppFunction const& _cppFunction, Args const&... _arguments) void testSolidityAgainstCpp(std::string _sig, CppFunction const& _cppFunction, Args const&... _arguments)
{ {
bytes solidityResult = callContractFunction(_index, _arguments...); bytes solidityResult = callContractFunction(_sig, _arguments...);
bytes cppResult = callCppAndEncodeResult(_cppFunction, _arguments...); bytes cppResult = callCppAndEncodeResult(_cppFunction, _arguments...);
BOOST_CHECK_MESSAGE(solidityResult == cppResult, "Computed values do not match." BOOST_CHECK_MESSAGE(solidityResult == cppResult, "Computed values do not match."
"\nSolidity: " + toHex(solidityResult) + "\nC++: " + toHex(cppResult)); "\nSolidity: " + toHex(solidityResult) + "\nC++: " + toHex(cppResult));
} }
template <class CppFunction, class... Args> template <class CppFunction, class... Args>
void testSolidityAgainstCppOnRange(byte _index, CppFunction const& _cppFunction, void testSolidityAgainstCppOnRange(std::string _sig, CppFunction const& _cppFunction,
u256 const& _rangeStart, u256 const& _rangeEnd) u256 const& _rangeStart, u256 const& _rangeEnd)
{ {
for (u256 argument = _rangeStart; argument < _rangeEnd; ++argument) for (u256 argument = _rangeStart; argument < _rangeEnd; ++argument)
{ {
bytes solidityResult = callContractFunction(_index, argument); bytes solidityResult = callContractFunction(_sig, argument);
bytes cppResult = callCppAndEncodeResult(_cppFunction, argument); bytes cppResult = callCppAndEncodeResult(_cppFunction, argument);
BOOST_CHECK_MESSAGE(solidityResult == cppResult, "Computed values do not match." BOOST_CHECK_MESSAGE(solidityResult == cppResult, "Computed values do not match."
"\nSolidity: " + toHex(solidityResult) + "\nC++: " + toHex(cppResult) + "\nSolidity: " + toHex(solidityResult) + "\nC++: " + toHex(cppResult) +
@ -143,6 +145,7 @@ private:
m_state.noteSending(m_sender); m_state.noteSending(m_sender);
executive.finalize(); executive.finalize();
m_output = executive.out().toVector(); m_output = executive.out().toVector();
m_logs = executive.logs();
} }
protected: protected:
@ -153,6 +156,7 @@ protected:
u256 const m_gasPrice = 100 * eth::szabo; u256 const m_gasPrice = 100 * eth::szabo;
u256 const m_gas = 1000000; u256 const m_gas = 1000000;
bytes m_output; bytes m_output;
eth::LogEntries m_logs;
}; };
} }

103
stBlockHashTestFiller.json Normal file
View File

@ -0,0 +1,103 @@
{
"blockhash0" : {
"env" : {
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
"currentNumber" : "5",
"currentGasLimit" : "1000000",
"currentDifficulty" : "256",
"currentTimestamp" : 1,
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"
},
"pre" : {
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
"balance" : "1000000000000000000",
"nonce" : 0,
"code" : "{ [[ 0 ]] (BLOCKHASH 0) [[ 1 ]] (BLOCKHASH 5) [[ 2 ]] (BLOCKHASH 4) }",
"storage": {}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "100000",
"nonce" : 0,
"code" : "",
"storage": {}
}
},
"transaction" : {
"nonce" : "0",
"gasPrice" : "1",
"gasLimit" : "8500",
"to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
"value" : "10",
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
"data" : ""
}
},
"blockhashOutOfRange" : {
"env" : {
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
"currentNumber" : "257",
"currentGasLimit" : "1000000",
"currentDifficulty" : "256",
"currentTimestamp" : 1,
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"
},
"pre" : {
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
"balance" : "1000000000000000000",
"nonce" : 0,
"code" : "{ [[ 0 ]] (BLOCKHASH 0) [[ 1 ]] (BLOCKHASH 257) [[ 2 ]] (BLOCKHASH 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) }",
"storage": {}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "100000",
"nonce" : 0,
"code" : "",
"storage": {}
}
},
"transaction" : {
"nonce" : "0",
"gasPrice" : "1",
"gasLimit" : "8500",
"to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
"value" : "10",
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
"data" : ""
}
},
"blockhashInRange" : {
"env" : {
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
"currentNumber" : "257",
"currentGasLimit" : "1000000",
"currentDifficulty" : "256",
"currentTimestamp" : 1,
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"
},
"pre" : {
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
"balance" : "1000000000000000000",
"nonce" : 0,
"code" : "{ [[ 0 ]] (BLOCKHASH 1) [[ 1 ]] (BLOCKHASH 2) [[ 2 ]] (BLOCKHASH 256) }",
"storage": {}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "100000",
"nonce" : 0,
"code" : "",
"storage": {}
}
},
"transaction" : {
"nonce" : "0",
"gasPrice" : "1",
"gasLimit" : "8500",
"to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
"value" : "10",
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
"data" : ""
}
}
}

View File

@ -12,7 +12,144 @@
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : { "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
"balance" : "1000000000000000000", "balance" : "1000000000000000000",
"nonce" : 0, "nonce" : 0,
"code" : "{ (MSTORE 0 0x601080600c6000396000f30060003554156009570060203560003555) [[ 0 ]] (CREATE 23 4 28) }", "code" : "{ (MSTORE 0 0x601080600c6000396000f3006000355415600957005b60203560003555) [[ 0 ]] (CREATE 23 3 29) }",
"storage": {}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "1000000000000000000",
"nonce" : 0,
"code" : "",
"storage": {}
}
},
"transaction" : {
"nonce" : "0",
"gasPrice" : "1",
"gasLimit" : "10000",
"to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
"value" : "100000",
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
"data" : ""
}
},
"createNameRegistratorOOG_MemExpansionInsufficientBalance": {
"env" : {
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
"currentNumber" : "0",
"currentGasLimit" : "1000000",
"currentDifficulty" : "256",
"currentTimestamp" : 1,
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"
},
"pre" : {
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
"balance" : "10000",
"nonce" : 0,
"code" : "{ (MSTORE 0 0x601080600c6000396000f3006000355415600957005b60203560003555) [[ 0 ]] (CREATE 11000 3 0xffffffffffffffffffffff) }",
"storage": {}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "1000000000000000000",
"nonce" : 0,
"code" : "",
"storage": {}
}
},
"transaction" : {
"nonce" : "0",
"gasPrice" : "1",
"gasLimit" : "10000",
"to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
"value" : "100000",
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
"data" : ""
}
},
"createNameRegistratorZeroMem": {
"env" : {
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
"currentNumber" : "0",
"currentGasLimit" : "1000000",
"currentDifficulty" : "256",
"currentTimestamp" : 1,
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"
},
"pre" : {
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
"balance" : "1000000000000000000",
"nonce" : 0,
"code" : "{ (MSTORE 0 0x601080600c6000396000f3006000355415600957005b60203560003555) [[ 0 ]] (CREATE 23 3 0) }",
"storage": {}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "1000000000000000000",
"nonce" : 0,
"code" : "",
"storage": {}
}
},
"transaction" : {
"nonce" : "0",
"gasPrice" : "1",
"gasLimit" : "10000",
"to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
"value" : "100000",
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
"data" : ""
}
},
"createNameRegistratorZeroMem2": {
"env" : {
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
"currentNumber" : "0",
"currentGasLimit" : "1000000",
"currentDifficulty" : "256",
"currentTimestamp" : 1,
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"
},
"pre" : {
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
"balance" : "1000000000000000000",
"nonce" : 0,
"code" : "{ (MSTORE 0 0x601080600c6000396000f3006000355415600957005b60203560003555) [[ 0 ]] (CREATE 23 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0) }",
"storage": {}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "1000000000000000000",
"nonce" : 0,
"code" : "",
"storage": {}
}
},
"transaction" : {
"nonce" : "0",
"gasPrice" : "1",
"gasLimit" : "10000",
"to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
"value" : "100000",
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
"data" : ""
}
},
"createNameRegistratorZeroMemExpansion": {
"env" : {
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
"currentNumber" : "0",
"currentGasLimit" : "1000000",
"currentDifficulty" : "256",
"currentTimestamp" : 1,
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"
},
"pre" : {
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
"balance" : "1000000000000000000",
"nonce" : 0,
"code" : "{ (MSTORE 0 0x601080600c6000396000f3006000355415600957005b60203560003555) [[ 0 ]] (CREATE 23 0 0) }",
"storage": {} "storage": {}
}, },
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
@ -46,7 +183,7 @@
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : { "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
"balance" : "1000000000000000000", "balance" : "1000000000000000000",
"nonce" : 0, "nonce" : 0,
"code" : "{ (MSTORE 0 0x601080600c6000396000f30060003554156009570060203560003555) [[ 0 ]] (CREATE 1000 4 28) }", "code" : "{ (MSTORE 0 0x601080600c6000396000f3006000355415600957005b60203560003555) [[ 0 ]] (CREATE 1000 3 29) }",
"storage": {} "storage": {}
}, },
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
@ -80,7 +217,7 @@
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : { "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
"balance" : "1000000000000000000", "balance" : "1000000000000000000",
"nonce" : 0, "nonce" : 0,
"code" : "{ (MSTORE 0 0x601080600c6000396000f30060003554156009570060203560003555) [[ 0 ]] (CREATE 23 0xfffffffffff 28) }", "code" : "{ (MSTORE 0 0x601080600c6000396000f3006000355415600957005b60203560003555) [[ 0 ]] (CREATE 23 0xfffffffffff 29) }",
"storage": {} "storage": {}
}, },
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
@ -114,7 +251,41 @@
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : { "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
"balance" : "1000000000000000000", "balance" : "1000000000000000000",
"nonce" : 0, "nonce" : 0,
"code" : "{ (MSTORE 0 0x601080600c6000396000f30060003554156009570060203560003555) [[ 0 ]] (CREATE 23 4 0xfffffffffff) }", "code" : "{ (MSTORE 0 0x601080600c6000396000f3006000355415600957005b60203560003555) [[ 0 ]] (CREATE 23 3 0xfffffffffff) }",
"storage": {}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "1000000000000000000",
"nonce" : 0,
"code" : "",
"storage": {}
}
},
"transaction" : {
"nonce" : "0",
"gasPrice" : "1",
"gasLimit" : "10000",
"to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
"value" : "100000",
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
"data" : ""
}
},
"balanceInputAddressTooBig": {
"env" : {
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
"currentNumber" : "0",
"currentGasLimit" : "1000000",
"currentDifficulty" : "256",
"currentTimestamp" : 1,
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"
},
"pre" : {
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
"balance" : "1000000000000000000",
"nonce" : 0,
"code" : "{ [[ 0 ]] (BALANCE 0xa94f5374fce5edbc8e2a8697c15331677e6ebf0baa ) }",
"storage": {} "storage": {}
}, },
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
@ -153,7 +324,175 @@
}, },
"945304eb96065b2a98b57a48a06ae28d285a71b5" : { "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
"balance" : "23", "balance" : "23",
"code" : "0x60003554156009570060203560003555", "code" : "0x6000355415600957005b60203560003555",
"nonce" : "0",
"storage" : {
}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "1000000000000000000",
"nonce" : 0,
"code" : "",
"storage": {}
}
},
"transaction" : {
"nonce" : "0",
"gasPrice" : "1",
"gasLimit" : "10000",
"to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
"value" : "100000",
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
"data" : ""
}
},
"CallToNameRegistratorMemOOGAndInsufficientBalance": {
"env" : {
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
"currentNumber" : "0",
"currentGasLimit" : "10000000",
"currentDifficulty" : "256",
"currentTimestamp" : 1,
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"
},
"pre" : {
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
"balance" : "1000000000000000000",
"nonce" : 0,
"code" : "{ (MSTORE 0 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) (MSTORE 32 0xaaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa ) [[ 0 ]] (CALL 0xffffffffff 0x945304eb96065b2a98b57a48a06ae28d285a71b5 23 0 0xffffffffffff 64 0) }",
"storage": {}
},
"945304eb96065b2a98b57a48a06ae28d285a71b5" : {
"balance" : "23",
"code" : "0x6000355415600957005b60203560003555",
"nonce" : "0",
"storage" : {
}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "1000000000000000000",
"nonce" : 0,
"code" : "",
"storage": {}
}
},
"transaction" : {
"nonce" : "0",
"gasPrice" : "1",
"gasLimit" : "10000",
"to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
"value" : "100000",
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
"data" : ""
}
},
"CallToNameRegistratorAddressTooBigLeft": {
"env" : {
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
"currentNumber" : "0",
"currentGasLimit" : "10000000",
"currentDifficulty" : "256",
"currentTimestamp" : 1,
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"
},
"pre" : {
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
"balance" : "1000000000000000000",
"nonce" : 0,
"code" : "{ (MSTORE 0 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) (MSTORE 32 0xaaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa ) [[ 0 ]] (CALL 1000 0xaa945304eb96065b2a98b57a48a06ae28d285a71b5 23 0 64 64 0) }",
"storage": {}
},
"945304eb96065b2a98b57a48a06ae28d285a71b5" : {
"balance" : "23",
"code" : "0x6000355415600957005b60203560003555",
"nonce" : "0",
"storage" : {
}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "1000000000000000000",
"nonce" : 0,
"code" : "",
"storage": {}
}
},
"transaction" : {
"nonce" : "0",
"gasPrice" : "1",
"gasLimit" : "10000",
"to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
"value" : "100000",
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
"data" : ""
}
},
"CallToNameRegistratorAddressTooBigRight": {
"env" : {
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
"currentNumber" : "0",
"currentGasLimit" : "10000000",
"currentDifficulty" : "256",
"currentTimestamp" : 1,
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"
},
"pre" : {
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
"balance" : "1000000000000000000",
"nonce" : 0,
"code" : "{ (MSTORE 0 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) (MSTORE 32 0xaaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa ) [[ 0 ]] (CALL 1000 0x945304eb96065b2a98b57a48a06ae28d285a71b5aa 23 0 64 64 0) }",
"storage": {}
},
"945304eb96065b2a98b57a48a06ae28d285a71b5" : {
"balance" : "23",
"code" : "0x6000355415600957005b60203560003555",
"nonce" : "0",
"storage" : {
}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "1000000000000000000",
"nonce" : 0,
"code" : "",
"storage": {}
}
},
"transaction" : {
"nonce" : "0",
"gasPrice" : "1",
"gasLimit" : "10000",
"to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
"value" : "100000",
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
"data" : ""
}
},
"CallToNameRegistratorZeorSizeMemExpansion": {
"env" : {
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
"currentNumber" : "0",
"currentGasLimit" : "10000000",
"currentDifficulty" : "256",
"currentTimestamp" : 1,
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"
},
"pre" : {
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
"balance" : "1000000000000000000",
"nonce" : 0,
"code" : "{ (MSTORE 0 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) (MSTORE 32 0xaaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa ) [[ 0 ]] (CALL 1000 0x945304eb96065b2a98b57a48a06ae28d285a71b5 23 0 0 0 0) }",
"storage": {}
},
"945304eb96065b2a98b57a48a06ae28d285a71b5" : {
"balance" : "23",
"code" : "0x6000355415600957005b60203560003555",
"nonce" : "0", "nonce" : "0",
"storage" : { "storage" : {
} }
@ -190,12 +529,12 @@
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : { "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
"balance" : "1000000000000000000", "balance" : "1000000000000000000",
"nonce" : 0, "nonce" : 0,
"code" : "{ (MSTORE 0 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) (MSTORE 32 0xaaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa ) [[ 0 ]] (CALL 1000 0x945304eb96065b2a98b57a48a06ae28d285a71b5 23 0 64 0 2) }", "code" : "{ [[ 0 ]] (CALL 1000 0x945304eb96065b2a98b57a48a06ae28d285a71b5 23 0 0 31 1) [[ 1 ]] @0 }",
"storage": {} "storage": {}
}, },
"945304eb96065b2a98b57a48a06ae28d285a71b5" : { "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
"balance" : "23", "balance" : "23",
"code" : "0x6001600155603760005360026000f3", "code" : "0x6001600155602a601f536001601ff3",
"nonce" : "0", "nonce" : "0",
"storage" : { "storage" : {
} }
@ -206,7 +545,88 @@
"code" : "", "code" : "",
"storage": {} "storage": {}
} }
},
"transaction" : {
"nonce" : "0",
"gasPrice" : "1",
"gasLimit" : "10000",
"to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
"value" : "100000",
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
"data" : ""
}
},
"CallToReturn1ForDynamicJump0": {
"env" : {
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
"currentNumber" : "0",
"currentGasLimit" : "10000000",
"currentDifficulty" : "256",
"currentTimestamp" : 1,
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"
},
"pre" : {
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
"balance" : "1000000000000000000",
"nonce" : 0,
"code" : "0x6001601f60006000601773945304eb96065b2a98b57a48a06ae28d285a71b56103e8f1600055600051565b6023602355",
"storage": {}
},
"945304eb96065b2a98b57a48a06ae28d285a71b5" : {
"balance" : "23",
"code" : "0x6001600155602a601f536001601ff3",
"nonce" : "0",
"storage" : {
}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "1000000000000000000",
"nonce" : 0,
"code" : "",
"storage": {}
}
},
"transaction" : {
"nonce" : "0",
"gasPrice" : "1",
"gasLimit" : "10000",
"to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
"value" : "100000",
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
"data" : ""
}
},
"CallToReturn1ForDynamicJump1": {
"env" : {
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
"currentNumber" : "0",
"currentGasLimit" : "10000000",
"currentDifficulty" : "256",
"currentTimestamp" : 1,
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"
},
"pre" : {
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
"balance" : "1000000000000000000",
"nonce" : 0,
"code" : "0x6001601f60006000601773945304eb96065b2a98b57a48a06ae28d285a71b56103e8f160005560005156605b6023602355",
"storage": {}
},
"945304eb96065b2a98b57a48a06ae28d285a71b5" : {
"balance" : "23",
"code" : "0x6001600155602b601f536001601ff3",
"nonce" : "0",
"storage" : {
}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "1000000000000000000",
"nonce" : 0,
"code" : "",
"storage": {}
}
}, },
"transaction" : { "transaction" : {
"nonce" : "0", "nonce" : "0",
@ -364,7 +784,7 @@
}, },
"945304eb96065b2a98b57a48a06ae28d285a71b5" : { "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
"balance" : "23", "balance" : "23",
"code" : "0x60003554156009570060203560003555", "code" : "0x6000355415600957005b60203560003555",
"nonce" : "0", "nonce" : "0",
"storage" : { "storage" : {
} }
@ -406,7 +826,7 @@
}, },
"945304eb96065b2a98b57a48a06ae28d285a71b5" : { "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
"balance" : "23", "balance" : "23",
"code" : "0x60003554156009570060203560003555", "code" : "0x6000355415600957005b60203560003555",
"nonce" : "0", "nonce" : "0",
"storage" : { "storage" : {
} }
@ -447,7 +867,7 @@
}, },
"945304eb96065b2a98b57a48a06ae28d285a71b5" : { "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
"balance" : "23", "balance" : "23",
"code" : "0x60003554156009570060203560003555", "code" : "0x6000355415600957005b60203560003555",
"nonce" : "0", "nonce" : "0",
"storage" : { "storage" : {
} }
@ -488,7 +908,7 @@
}, },
"945304eb96065b2a98b57a48a06ae28d285a71b5" : { "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
"balance" : "23", "balance" : "23",
"code" : "0x60003554156009570060203560003555", "code" : "0x6000355415600957005b60203560003555",
"nonce" : "0", "nonce" : "0",
"storage" : { "storage" : {
} }
@ -530,7 +950,7 @@
}, },
"945304eb96065b2a98b57a48a06ae28d285a71b5" : { "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
"balance" : "23", "balance" : "23",
"code" : "0x60003554156009570060203560003555", "code" : "0x6000355415600957005b60203560003555",
"nonce" : "0", "nonce" : "0",
"storage" : { "storage" : {
} }
@ -571,7 +991,7 @@
}, },
"945304eb96065b2a98b57a48a06ae28d285a71b5" : { "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
"balance" : "23", "balance" : "23",
"code" : "0x60003554156009570060203560003555", "code" : "0x6000355415600957005b60203560003555",
"nonce" : "0", "nonce" : "0",
"storage" : { "storage" : {
} }
@ -714,6 +1134,40 @@
} }
}, },
"CallRecursiveBomb0_OOG_atMaxCallDepth": {
"env" : {
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
"currentNumber" : "0",
"currentGasLimit" : "10000000000",
"currentDifficulty" : "256",
"currentTimestamp" : 1,
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"
},
"pre" : {
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
"balance" : "20000000",
"nonce" : 0,
"code" : "{ [[ 0 ]] (+ (SLOAD 0) 1) [[ 2 ]] (MUL (DIV @@0 0x0402) 0xfffffffffffffffffff) [[ 1 ]] (CALL (- (GAS) 1024) (ADDRESS) 0 0 (MUL (DIV @@0 0x0402) 0xfffffffffffffffffff) 0 0) } ",
"storage": {}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "1000000000000000000",
"nonce" : 0,
"code" : "",
"storage": {}
}
},
"transaction" : {
"nonce" : "0",
"gasPrice" : "1",
"gasLimit" : "1000000000",
"to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
"value" : "100000",
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
"data" : ""
}
},
"CallRecursiveBomb1": { "CallRecursiveBomb1": {
"env" : { "env" : {
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6", "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
@ -850,6 +1304,74 @@
} }
}, },
"suicideCallerAddresTooBigLeft": {
"env" : {
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
"currentNumber" : "0",
"currentGasLimit" : "10000000",
"currentDifficulty" : "256",
"currentTimestamp" : 1,
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"
},
"pre" : {
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
"balance" : "1000000000000000000",
"nonce" : 0,
"code" : "{ [[0]] (CALLER) (SUICIDE 0xaaa94f5374fce5edbc8e2a8697c15331677e6ebf0b)}",
"storage": {}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "1000000000000000000",
"nonce" : 0,
"code" : "",
"storage": {}
}
},
"transaction" : {
"nonce" : "0",
"gasPrice" : "1",
"gasLimit" : "1000000",
"to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
"value" : "100000",
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
"data" : ""
}
},
"suicideCallerAddresTooBigRight": {
"env" : {
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
"currentNumber" : "0",
"currentGasLimit" : "10000000",
"currentDifficulty" : "256",
"currentTimestamp" : 1,
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"
},
"pre" : {
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
"balance" : "1000000000000000000",
"nonce" : 0,
"code" : "{ [[0]] (CALLER) (SUICIDE 0xa94f5374fce5edbc8e2a8697c15331677e6ebf0baa)}",
"storage": {}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "1000000000000000000",
"nonce" : 0,
"code" : "",
"storage": {}
}
},
"transaction" : {
"nonce" : "0",
"gasPrice" : "1",
"gasLimit" : "1000000",
"to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
"value" : "100000",
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
"data" : ""
}
},
"suicideOrigin": { "suicideOrigin": {
"env" : { "env" : {
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6", "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
@ -1109,7 +1631,7 @@
}, },
"945304eb96065b2a98b57a48a06ae28d285a71b5" : { "945304eb96065b2a98b57a48a06ae28d285a71b5" : {
"balance" : "23", "balance" : "23",
"code" : "0x60003554156009570060203560003555", "code" : "0x6000355415600957005b60203560003555",
"nonce" : "0", "nonce" : "0",
"storage" : { "storage" : {
} }
@ -1132,6 +1654,129 @@
} }
}, },
"callcodeToNameRegistratorAddresTooBigLeft": {
"env" : {
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
"currentNumber" : "0",
"currentGasLimit" : "10000000",
"currentDifficulty" : "256",
"currentTimestamp" : 1,
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"
},
"pre" : {
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
"balance" : "1000000000000000000",
"nonce" : 0,
"code" : "{ (MSTORE 0 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) (MSTORE 32 0xaaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa ) [[ 0 ]] (CALLCODE 1000 0xaa945304eb96065b2a98b57a48a06ae28d285a71b5 23 0 64 64 0) }",
"storage": {}
},
"945304eb96065b2a98b57a48a06ae28d285a71b5" : {
"balance" : "23",
"code" : "0x6000355415600957005b60203560003555",
"nonce" : "0",
"storage" : {
}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "1000000000000000000",
"nonce" : 0,
"code" : "",
"storage": {}
}
},
"transaction" : {
"nonce" : "0",
"gasPrice" : "1",
"gasLimit" : "1000000",
"to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
"value" : "100000",
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
"data" : ""
}
},
"callcodeToNameRegistratorAddresTooBigRight": {
"env" : {
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
"currentNumber" : "0",
"currentGasLimit" : "10000000",
"currentDifficulty" : "256",
"currentTimestamp" : 1,
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"
},
"pre" : {
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
"balance" : "1000000000000000000",
"nonce" : 0,
"code" : "{ (MSTORE 0 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) (MSTORE 32 0xaaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa ) [[ 0 ]] (CALLCODE 1000 0x945304eb96065b2a98b57a48a06ae28d285a71b5aa 23 0 64 64 0) }",
"storage": {}
},
"945304eb96065b2a98b57a48a06ae28d285a71b5" : {
"balance" : "23",
"code" : "0x6000355415600957005b60203560003555",
"nonce" : "0",
"storage" : {
}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "1000000000000000000",
"nonce" : 0,
"code" : "",
"storage": {}
}
},
"transaction" : {
"nonce" : "0",
"gasPrice" : "1",
"gasLimit" : "1000000",
"to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
"value" : "100000",
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
"data" : ""
}
},
"callcodeToNameRegistratorZeroMemExpanion": {
"env" : {
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
"currentNumber" : "0",
"currentGasLimit" : "10000000",
"currentDifficulty" : "256",
"currentTimestamp" : 1,
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"
},
"pre" : {
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
"balance" : "1000000000000000000",
"nonce" : 0,
"code" : "{ (MSTORE 0 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) (MSTORE 32 0xaaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa ) [[ 0 ]] (CALLCODE 1000 0x945304eb96065b2a98b57a48a06ae28d285a71b5 23 0 0 0 0) }",
"storage": {}
},
"945304eb96065b2a98b57a48a06ae28d285a71b5" : {
"balance" : "23",
"code" : "0x6000355415600957005b60203560003555",
"nonce" : "0",
"storage" : {
}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "1000000000000000000",
"nonce" : 0,
"code" : "",
"storage": {}
}
},
"transaction" : {
"nonce" : "0",
"gasPrice" : "1",
"gasLimit" : "1000000",
"to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
"value" : "100000",
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
"data" : ""
}
},
"TestNameRegistrator": { "TestNameRegistrator": {
"env" : { "env" : {
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6", "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
@ -1145,7 +1790,7 @@
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : { "095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
"balance" : "1000000000000000000", "balance" : "1000000000000000000",
"nonce" : 0, "nonce" : 0,
"code" : "0x60003554156009570060203560003555", "code" : "0x6000355415600957005b60203560003555",
"storage": {} "storage": {}
}, },
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {

View File

@ -39,8 +39,6 @@ using namespace dev::eth;
namespace dev { namespace test { namespace dev { namespace test {
void doStateTests(json_spirit::mValue& v, bool _fillin) void doStateTests(json_spirit::mValue& v, bool _fillin)
{ {
processCommandLineOptions(); processCommandLineOptions();
@ -62,7 +60,7 @@ void doStateTests(json_spirit::mValue& v, bool _fillin)
try try
{ {
theState.execute(LastHashes(), tx, &output); theState.execute(lastHashes(importer.m_environment.currentBlock.number), tx, &output);
} }
catch (Exception const& _e) catch (Exception const& _e)
{ {
@ -157,6 +155,11 @@ BOOST_AUTO_TEST_CASE(stRefundTest)
dev::test::executeTests("stRefundTest", "/StateTests", dev::test::doStateTests); dev::test::executeTests("stRefundTest", "/StateTests", dev::test::doStateTests);
} }
BOOST_AUTO_TEST_CASE(stBlockHashTest)
{
dev::test::executeTests("stBlockHashTest", "/StateTests", dev::test::doStateTests);
}
BOOST_AUTO_TEST_CASE(stCreateTest) BOOST_AUTO_TEST_CASE(stCreateTest)
{ {
for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i) for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i)

3
vm.cpp
View File

@ -33,7 +33,7 @@ using namespace dev::eth;
using namespace dev::test; using namespace dev::test;
FakeExtVM::FakeExtVM(eth::BlockInfo const& _previousBlock, eth::BlockInfo const& _currentBlock, unsigned _depth): /// TODO: XXX: remove the default argument & fix. FakeExtVM::FakeExtVM(eth::BlockInfo const& _previousBlock, eth::BlockInfo const& _currentBlock, unsigned _depth): /// TODO: XXX: remove the default argument & fix.
ExtVMFace(Address(), Address(), Address(), 0, 1, bytesConstRef(), bytes(), _previousBlock, _currentBlock, LastHashes(), _depth) {} ExtVMFace(Address(), Address(), Address(), 0, 1, bytesConstRef(), bytes(), _previousBlock, _currentBlock, test::lastHashes(_currentBlock.number), _depth) {}
h160 FakeExtVM::create(u256 _endowment, u256& io_gas, bytesConstRef _init, OnOpFunc const&) h160 FakeExtVM::create(u256 _endowment, u256& io_gas, bytesConstRef _init, OnOpFunc const&)
{ {
@ -117,6 +117,7 @@ void FakeExtVM::importEnv(mObject& _o)
previousBlock.hash = h256(_o["previousHash"].get_str()); previousBlock.hash = h256(_o["previousHash"].get_str());
currentBlock.number = toInt(_o["currentNumber"]); currentBlock.number = toInt(_o["currentNumber"]);
lastHashes = test::lastHashes(currentBlock.number);
currentBlock.gasLimit = toInt(_o["currentGasLimit"]); currentBlock.gasLimit = toInt(_o["currentGasLimit"]);
currentBlock.difficulty = toInt(_o["currentDifficulty"]); currentBlock.difficulty = toInt(_o["currentDifficulty"]);
currentBlock.timestamp = toInt(_o["currentTimestamp"]); currentBlock.timestamp = toInt(_o["currentTimestamp"]);

View File

@ -814,6 +814,62 @@
} }
}, },
"sdiv4": {
"env" : {
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
"currentNumber" : "0",
"currentGasLimit" : "1000000",
"currentDifficulty" : "256",
"currentTimestamp" : 1,
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"
},
"pre" : {
"0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
"balance" : "1000000000000000000",
"nonce" : 0,
"code" : "{ [[ 0 ]] (SDIV 5 (- 0 4) ) }",
"storage": {}
}
},
"exec" : {
"address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6",
"origin" : "cd1722f2947def4cf144679da39c4c32bdc35681",
"caller" : "cd1722f2947def4cf144679da39c4c32bdc35681",
"value" : "1000000000000000000",
"data" : "",
"gasPrice" : "100000000000000",
"gas" : "10000"
}
},
"sdiv5": {
"env" : {
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
"currentNumber" : "0",
"currentGasLimit" : "1000000",
"currentDifficulty" : "256",
"currentTimestamp" : 1,
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"
},
"pre" : {
"0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
"balance" : "1000000000000000000",
"nonce" : 0,
"code" : "{ [[ 0 ]] (SDIV (- 0 57896044618658097711785492504343953926634992332820282019728792003956564819967) (- 0 1) ) }",
"storage": {}
}
},
"exec" : {
"address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6",
"origin" : "cd1722f2947def4cf144679da39c4c32bdc35681",
"caller" : "cd1722f2947def4cf144679da39c4c32bdc35681",
"value" : "1000000000000000000",
"data" : "",
"gasPrice" : "100000000000000",
"gas" : "10000"
}
},
"mod0": { "mod0": {
"env" : { "env" : {
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6", "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",

View File

@ -1,8 +1,8 @@
{ {
"prevhash": { "blockhashNotExistingBlock": {
"env" : { "env" : {
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6", "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
"currentNumber" : "0", "currentNumber" : "1",
"currentGasLimit" : "1000000", "currentGasLimit" : "1000000",
"currentDifficulty" : "256", "currentDifficulty" : "256",
"currentTimestamp" : 1, "currentTimestamp" : 1,
@ -12,7 +12,147 @@
"0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
"balance" : "1000000000000000000", "balance" : "1000000000000000000",
"nonce" : 0, "nonce" : 0,
"code" : "{ [[ 0 ]] (PREVHASH) }", "code" : "{ [[ 0 ]] (BLOCKHASH 2) }",
"storage": {}
}
},
"exec" : {
"address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6",
"origin" : "cd1722f3947def4cf144679da39c4c32bdc35681",
"caller" : "cd1722f3947def4cf144679da39c4c32bdc35681",
"value" : "1000000000000000000",
"data" : "",
"gasPrice" : "100000000000000",
"gas" : "10000"
}
},
"blockhashMyBlock": {
"env" : {
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
"currentNumber" : "1",
"currentGasLimit" : "1000000",
"currentDifficulty" : "256",
"currentTimestamp" : 1,
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"
},
"pre" : {
"0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
"balance" : "1000000000000000000",
"nonce" : 0,
"code" : "{ [[ 0 ]] (BLOCKHASH 1) }",
"storage": {}
}
},
"exec" : {
"address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6",
"origin" : "cd1722f3947def4cf144679da39c4c32bdc35681",
"caller" : "cd1722f3947def4cf144679da39c4c32bdc35681",
"value" : "1000000000000000000",
"data" : "",
"gasPrice" : "100000000000000",
"gas" : "10000"
}
},
"blockhash258Block": {
"env" : {
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
"currentNumber" : "258",
"currentGasLimit" : "1000000",
"currentDifficulty" : "256",
"currentTimestamp" : 1,
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"
},
"pre" : {
"0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
"balance" : "1000000000000000000",
"nonce" : 0,
"code" : "{ [[ 0 ]] (BLOCKHASH 1) }",
"storage": {}
}
},
"exec" : {
"address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6",
"origin" : "cd1722f3947def4cf144679da39c4c32bdc35681",
"caller" : "cd1722f3947def4cf144679da39c4c32bdc35681",
"value" : "1000000000000000000",
"data" : "",
"gasPrice" : "100000000000000",
"gas" : "10000"
}
},
"blockhash257Block": {
"env" : {
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
"currentNumber" : "257",
"currentGasLimit" : "1000000",
"currentDifficulty" : "256",
"currentTimestamp" : 1,
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"
},
"pre" : {
"0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
"balance" : "1000000000000000000",
"nonce" : 0,
"code" : "{ [[ 0 ]] (BLOCKHASH 0) }",
"storage": {}
}
},
"exec" : {
"address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6",
"origin" : "cd1722f3947def4cf144679da39c4c32bdc35681",
"caller" : "cd1722f3947def4cf144679da39c4c32bdc35681",
"value" : "1000000000000000000",
"data" : "",
"gasPrice" : "100000000000000",
"gas" : "10000"
}
},
"blockhashInRange": {
"env" : {
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
"currentNumber" : "257",
"currentGasLimit" : "1000000",
"currentDifficulty" : "256",
"currentTimestamp" : 1,
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"
},
"pre" : {
"0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
"balance" : "1000000000000000000",
"nonce" : 0,
"code" : "{ [[ 0 ]] (BLOCKHASH 1) [[ 1 ]] (BLOCKHASH 2) [[ 2 ]] (BLOCKHASH 256) }",
"storage": {}
}
},
"exec" : {
"address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6",
"origin" : "cd1722f3947def4cf144679da39c4c32bdc35681",
"caller" : "cd1722f3947def4cf144679da39c4c32bdc35681",
"value" : "1000000000000000000",
"data" : "",
"gasPrice" : "100000000000000",
"gas" : "10000"
}
},
"blockhashOutOfRange": {
"env" : {
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
"currentNumber" : "257",
"currentGasLimit" : "1000000",
"currentDifficulty" : "256",
"currentTimestamp" : 1,
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"
},
"pre" : {
"0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
"balance" : "1000000000000000000",
"nonce" : 0,
"code" : "{ [[ 0 ]] (BLOCKHASH 0) [[ 1 ]] (BLOCKHASH 257) [[ 2 ]] (BLOCKHASH 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) }",
"storage": {} "storage": {}
} }
}, },

View File

@ -83,6 +83,91 @@
} }
}, },
"balanceAddressInputTooBig": {
"env" : {
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
"currentNumber" : "0",
"currentGasLimit" : "1000000",
"currentDifficulty" : "256",
"currentTimestamp" : 1,
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"
},
"pre" : {
"0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
"balance" : "1000000000000000000",
"nonce" : 0,
"code" : "{ [[ 0 ]] (BALANCE 0xcd1722f3947def4cf144679da39c4c32bdc35681aa )}",
"storage": {}
}
},
"exec" : {
"address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6",
"origin" : "cd1722f3947def4cf144679da39c4c32bdc35681",
"caller" : "cd1722f3947def4cf144679da39c4c32bdc35681",
"value" : "1000000000000000000",
"data" : "",
"gasPrice" : "1000000000",
"gas" : "100000000000"
}
},
"balanceAddressInputTooBigRightMyAddress": {
"env" : {
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
"currentNumber" : "0",
"currentGasLimit" : "1000000",
"currentDifficulty" : "256",
"currentTimestamp" : 1,
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"
},
"pre" : {
"0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
"balance" : "1000000000000000000",
"nonce" : 0,
"code" : "{ [[ 0 ]] (BALANCE 0x0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6aa )}",
"storage": {}
}
},
"exec" : {
"address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6",
"origin" : "cd1722f3947def4cf144679da39c4c32bdc35681",
"caller" : "cd1722f3947def4cf144679da39c4c32bdc35681",
"value" : "1000000000000000000",
"data" : "",
"gasPrice" : "1000000000",
"gas" : "100000000000"
}
},
"balanceAddressInputTooBigLeftMyAddress": {
"env" : {
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
"currentNumber" : "0",
"currentGasLimit" : "1000000",
"currentDifficulty" : "256",
"currentTimestamp" : 1,
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"
},
"pre" : {
"0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
"balance" : "1000000000000000000",
"nonce" : 0,
"code" : "{ [[ 0 ]] (BALANCE 0xaa0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6 )}",
"storage": {}
}
},
"exec" : {
"address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6",
"origin" : "cd1722f3947def4cf144679da39c4c32bdc35681",
"caller" : "cd1722f3947def4cf144679da39c4c32bdc35681",
"value" : "1000000000000000000",
"data" : "",
"gasPrice" : "1000000000",
"gas" : "100000000000"
}
},
"balance1": { "balance1": {
"env" : { "env" : {
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6", "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
@ -478,6 +563,34 @@
} }
}, },
"calldatacopyZeroMemExpansion": {
"env" : {
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
"currentNumber" : "0",
"currentGasLimit" : "1000000",
"currentDifficulty" : "256",
"currentTimestamp" : 1,
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"
},
"pre" : {
"0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
"balance" : "1000000000000000000",
"nonce" : 0,
"code" : "{ (CALLDATACOPY 0 0 0 ) [[ 0 ]] @0}",
"storage": {}
}
},
"exec" : {
"address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6",
"origin" : "cd1722f3947def4cf144679da39c4c32bdc35681",
"caller" : "cd1722f3947def4cf144679da39c4c32bdc35681",
"value" : "1000000000000000000",
"data" : "0x1234567890abcdef01234567890abcdef",
"gasPrice" : "1000000000",
"gas" : "100000000000"
}
},
"calldatacopy_DataIndexTooHigh": { "calldatacopy_DataIndexTooHigh": {
"env" : { "env" : {
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6", "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
@ -674,7 +787,7 @@
} }
}, },
"codecopy1": { "codecopy0": {
"env" : { "env" : {
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6", "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
"currentNumber" : "0", "currentNumber" : "0",
@ -687,7 +800,35 @@
"0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
"balance" : "1000000000000000000", "balance" : "1000000000000000000",
"nonce" : 0, "nonce" : 0,
"code" : "{ (CODECOPY 0 0 (CODESIZE) ) [[ 0 ]] @0 }", "code" : "{ (CODECOPY 0 0 5 ) [[ 0 ]] @0 }",
"storage": {}
}
},
"exec" : {
"address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6",
"origin" : "cd1722f3947def4cf144679da39c4c32bdc35681",
"caller" : "cd1722f3947def4cf144679da39c4c32bdc35681",
"value" : "1000000000000000000",
"data" : "0x1234567890abcdef01234567890abcdef",
"gasPrice" : "1000000000",
"gas" : "100000000000"
}
},
"codecopyZeroMemExpansion": {
"env" : {
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
"currentNumber" : "0",
"currentGasLimit" : "1000000",
"currentDifficulty" : "256",
"currentTimestamp" : 1,
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"
},
"pre" : {
"0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
"balance" : "1000000000000000000",
"nonce" : 0,
"code" : "{ (CODECOPY 0 0 0 ) [[ 0 ]] @0 }",
"storage": {} "storage": {}
} }
}, },
@ -730,6 +871,63 @@
} }
}, },
"ExtCodeSizeAddressInputTooBigRightMyAddress": {
"env" : {
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
"currentNumber" : "0",
"currentGasLimit" : "1000000",
"currentDifficulty" : "256",
"currentTimestamp" : 1,
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"
},
"pre" : {
"0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
"balance" : "1000000000000000000",
"nonce" : 0,
"code" : "{ [[ 0 ]] (EXTCODESIZE 0x0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6aa )}",
"storage": {}
}
},
"exec" : {
"address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6",
"origin" : "cd1722f3947def4cf144679da39c4c32bdc35681",
"caller" : "cd1722f3947def4cf144679da39c4c32bdc35681",
"value" : "1000000000000000000",
"data" : "",
"gasPrice" : "1000000000",
"gas" : "100000000000"
}
},
"ExtCodeSizeAddressInputTooBigLeftMyAddress": {
"env" : {
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
"currentNumber" : "0",
"currentGasLimit" : "1000000",
"currentDifficulty" : "256",
"currentTimestamp" : 1,
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"
},
"pre" : {
"0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
"balance" : "1000000000000000000",
"nonce" : 0,
"code" : "{ [[ 0 ]] (EXTCODESIZE 0xaa0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6 )}",
"storage": {}
}
},
"exec" : {
"address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6",
"origin" : "cd1722f3947def4cf144679da39c4c32bdc35681",
"caller" : "cd1722f3947def4cf144679da39c4c32bdc35681",
"value" : "1000000000000000000",
"data" : "",
"gasPrice" : "1000000000",
"gas" : "100000000000"
}
},
"extcodesize0": { "extcodesize0": {
"env" : { "env" : {
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6", "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
@ -825,6 +1023,40 @@
} }
}, },
"extcodecopyZeroMemExpansion": {
"env" : {
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
"currentNumber" : "0",
"currentGasLimit" : "1000000",
"currentDifficulty" : "256",
"currentTimestamp" : 1,
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"
},
"pre" : {
"0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
"balance" : "1000000000000000000",
"nonce" : 0,
"code" : "{ (EXTCODECOPY (CALLER) 0 0 0 ) ) [[ 0 ]] @0 }",
"storage": {}
},
"cd1722f3947def4cf144679da39c4c32bdc35681" : {
"balance" : "1000000000000000000",
"nonce" : 0,
"code" : "{ [[ 0 ]] 5 }",
"storage": {}
}
},
"exec" : {
"address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6",
"origin" : "cd1722f3947def4cf144679da39c4c32bdc35681",
"caller" : "cd1722f3947def4cf144679da39c4c32bdc35681",
"value" : "1000000000000000000",
"data" : "0x1234567890abcdef01234567890abcdef",
"gasPrice" : "123456789",
"gas" : "100000000000"
}
},
"extcodecopy0": { "extcodecopy0": {
"env" : { "env" : {
@ -858,6 +1090,74 @@
"gasPrice" : "123456789", "gasPrice" : "123456789",
"gas" : "100000000000" "gas" : "100000000000"
} }
},
"extcodecopy0AddressTooBigLeft": {
"env" : {
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
"currentNumber" : "0",
"currentGasLimit" : "1000000",
"currentDifficulty" : "256",
"currentTimestamp" : 1,
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"
},
"pre" : {
"0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
"balance" : "1000000000000000000",
"nonce" : 0,
"code" : "{ (EXTCODECOPY 0xaacd1722f3947def4cf144679da39c4c32bdc35681 0 0 (EXTCODESIZE (CALLER) ) ) [[ 0 ]] @0 }",
"storage": {}
},
"cd1722f3947def4cf144679da39c4c32bdc35681" : {
"balance" : "1000000000000000000",
"nonce" : 0,
"code" : "{ [[ 0 ]] 5 }",
"storage": {}
}
},
"exec" : {
"address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6",
"origin" : "cd1722f3947def4cf144679da39c4c32bdc35681",
"caller" : "cd1722f3947def4cf144679da39c4c32bdc35681",
"value" : "1000000000000000000",
"data" : "0x1234567890abcdef01234567890abcdef",
"gasPrice" : "123456789",
"gas" : "100000000000"
}
},
"extcodecopy0AddressTooBigRight": {
"env" : {
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
"currentNumber" : "0",
"currentGasLimit" : "1000000",
"currentDifficulty" : "256",
"currentTimestamp" : 1,
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"
},
"pre" : {
"0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
"balance" : "1000000000000000000",
"nonce" : 0,
"code" : "{ (EXTCODECOPY 0xcd1722f3947def4cf144679da39c4c32bdc35681aa 0 0 (EXTCODESIZE (CALLER) ) ) [[ 0 ]] @0 }",
"storage": {}
},
"cd1722f3947def4cf144679da39c4c32bdc35681" : {
"balance" : "1000000000000000000",
"nonce" : 0,
"code" : "{ [[ 0 ]] 5 }",
"storage": {}
}
},
"exec" : {
"address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6",
"origin" : "cd1722f3947def4cf144679da39c4c32bdc35681",
"caller" : "cd1722f3947def4cf144679da39c4c32bdc35681",
"value" : "1000000000000000000",
"data" : "0x1234567890abcdef01234567890abcdef",
"gasPrice" : "123456789",
"gas" : "100000000000"
}
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -12,6 +12,16 @@ class WebThreeStubClient : public jsonrpc::Client
public: public:
WebThreeStubClient(jsonrpc::IClientConnector &conn) : jsonrpc::Client(conn) {} WebThreeStubClient(jsonrpc::IClientConnector &conn) : jsonrpc::Client(conn) {}
std::string web3_sha3(const std::string& param1) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p.append(param1);
Json::Value result = this->CallMethod("web3_sha3",p);
if (result.isString())
return result.asString();
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
std::string eth_coinbase() throw (jsonrpc::JsonRpcException) std::string eth_coinbase() throw (jsonrpc::JsonRpcException)
{ {
Json::Value p; Json::Value p;