mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge branch 'develop' of https://github.com/ethereum/cpp-ethereum into develop
This commit is contained in:
commit
1858e08198
@ -76,6 +76,7 @@ BOOST_AUTO_TEST_CASE(basic_test)
|
|||||||
char const* interface = R"([
|
char const* interface = R"([
|
||||||
{
|
{
|
||||||
"name": "f",
|
"name": "f",
|
||||||
|
"const": false,
|
||||||
"inputs": [
|
"inputs": [
|
||||||
{
|
{
|
||||||
"name": "a",
|
"name": "a",
|
||||||
@ -114,6 +115,7 @@ BOOST_AUTO_TEST_CASE(multiple_methods)
|
|||||||
char const* interface = R"([
|
char const* interface = R"([
|
||||||
{
|
{
|
||||||
"name": "f",
|
"name": "f",
|
||||||
|
"const": false,
|
||||||
"inputs": [
|
"inputs": [
|
||||||
{
|
{
|
||||||
"name": "a",
|
"name": "a",
|
||||||
@ -129,6 +131,7 @@ BOOST_AUTO_TEST_CASE(multiple_methods)
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "g",
|
"name": "g",
|
||||||
|
"const": false,
|
||||||
"inputs": [
|
"inputs": [
|
||||||
{
|
{
|
||||||
"name": "b",
|
"name": "b",
|
||||||
@ -156,6 +159,7 @@ BOOST_AUTO_TEST_CASE(multiple_params)
|
|||||||
char const* interface = R"([
|
char const* interface = R"([
|
||||||
{
|
{
|
||||||
"name": "f",
|
"name": "f",
|
||||||
|
"const": false,
|
||||||
"inputs": [
|
"inputs": [
|
||||||
{
|
{
|
||||||
"name": "a",
|
"name": "a",
|
||||||
@ -189,6 +193,7 @@ BOOST_AUTO_TEST_CASE(multiple_methods_order)
|
|||||||
char const* interface = R"([
|
char const* interface = R"([
|
||||||
{
|
{
|
||||||
"name": "c",
|
"name": "c",
|
||||||
|
"const": false,
|
||||||
"inputs": [
|
"inputs": [
|
||||||
{
|
{
|
||||||
"name": "b",
|
"name": "b",
|
||||||
@ -204,6 +209,7 @@ BOOST_AUTO_TEST_CASE(multiple_methods_order)
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "f",
|
"name": "f",
|
||||||
|
"const": false,
|
||||||
"inputs": [
|
"inputs": [
|
||||||
{
|
{
|
||||||
"name": "a",
|
"name": "a",
|
||||||
@ -222,6 +228,53 @@ BOOST_AUTO_TEST_CASE(multiple_methods_order)
|
|||||||
checkInterface(sourceCode, interface);
|
checkInterface(sourceCode, interface);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(const_function)
|
||||||
|
{
|
||||||
|
char const* sourceCode = "contract test {\n"
|
||||||
|
" function foo(uint a, uint b) returns(uint d) { return a + b; }\n"
|
||||||
|
" function boo(uint32 a) const returns(uint b) { return a * 4; }\n"
|
||||||
|
"}\n";
|
||||||
|
|
||||||
|
char const* interface = R"([
|
||||||
|
{
|
||||||
|
"name": "boo",
|
||||||
|
"const": true,
|
||||||
|
"inputs": [{
|
||||||
|
"name": "a",
|
||||||
|
"type": "uint32"
|
||||||
|
}],
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "b",
|
||||||
|
"type": "uint256"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "foo",
|
||||||
|
"const": false,
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"name": "a",
|
||||||
|
"type": "uint256"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "b",
|
||||||
|
"type": "uint256"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "d",
|
||||||
|
"type": "uint256"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
])";
|
||||||
|
|
||||||
|
checkInterface(sourceCode, interface);
|
||||||
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE_END()
|
BOOST_AUTO_TEST_SUITE_END()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -504,6 +504,41 @@ BOOST_AUTO_TEST_CASE(state_smoke_test)
|
|||||||
BOOST_CHECK(callContractFunction(0, bytes(1, 0x00)) == toBigEndian(u256(0x3)));
|
BOOST_CHECK(callContractFunction(0, bytes(1, 0x00)) == toBigEndian(u256(0x3)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(compound_assign)
|
||||||
|
{
|
||||||
|
char const* sourceCode = "contract test {\n"
|
||||||
|
" uint value1;\n"
|
||||||
|
" uint value2;\n"
|
||||||
|
" function f(uint x, uint y) returns (uint w) {\n"
|
||||||
|
" uint value3 = y;"
|
||||||
|
" value1 += x;\n"
|
||||||
|
" value3 *= x;"
|
||||||
|
" value2 *= value3 + value1;\n"
|
||||||
|
" return value2 += 7;"
|
||||||
|
" }\n"
|
||||||
|
"}\n";
|
||||||
|
compileAndRun(sourceCode);
|
||||||
|
|
||||||
|
u256 value1;
|
||||||
|
u256 value2;
|
||||||
|
auto f = [&](u256 const& _x, u256 const& _y) -> u256
|
||||||
|
{
|
||||||
|
u256 value3 = _y;
|
||||||
|
value1 += _x;
|
||||||
|
value3 *= _x;
|
||||||
|
value2 *= value3 + value1;
|
||||||
|
return value2 += 7;
|
||||||
|
};
|
||||||
|
testSolidityAgainstCpp(0, f, u256(0), u256(6));
|
||||||
|
testSolidityAgainstCpp(0, f, u256(1), u256(3));
|
||||||
|
testSolidityAgainstCpp(0, f, u256(2), u256(25));
|
||||||
|
testSolidityAgainstCpp(0, f, u256(3), u256(69));
|
||||||
|
testSolidityAgainstCpp(0, f, u256(4), u256(84));
|
||||||
|
testSolidityAgainstCpp(0, f, u256(5), u256(2));
|
||||||
|
testSolidityAgainstCpp(0, f, u256(6), u256(51));
|
||||||
|
testSolidityAgainstCpp(0, f, u256(7), u256(48));
|
||||||
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(simple_mapping)
|
BOOST_AUTO_TEST_CASE(simple_mapping)
|
||||||
{
|
{
|
||||||
char const* sourceCode = "contract test {\n"
|
char const* sourceCode = "contract test {\n"
|
||||||
|
@ -141,5 +141,168 @@
|
|||||||
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
|
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
|
||||||
"data" : ""
|
"data" : ""
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
"refund50_1" : {
|
||||||
|
"env" : {
|
||||||
|
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
|
||||||
|
"currentNumber" : "0",
|
||||||
|
"currentGasLimit" : "1000000",
|
||||||
|
"currentDifficulty" : "256",
|
||||||
|
"currentTimestamp" : 1,
|
||||||
|
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"
|
||||||
|
},
|
||||||
|
"pre" : {
|
||||||
|
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
|
||||||
|
"balance" : "1000000000000000000",
|
||||||
|
"nonce" : 0,
|
||||||
|
"code" : "{ [[ 1 ]] 0 [[ 2 ]] 0 [[ 3 ]] 0 [[ 4 ]] 0 [[ 5 ]] 0 }",
|
||||||
|
"storage" : {
|
||||||
|
"0x01" : "0x01",
|
||||||
|
"0x02" : "0x01",
|
||||||
|
"0x03" : "0x01",
|
||||||
|
"0x04" : "0x01",
|
||||||
|
"0x05" : "0x01"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
|
||||||
|
"balance" : "10000",
|
||||||
|
"nonce" : 0,
|
||||||
|
"code" : "",
|
||||||
|
"storage": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"transaction" : {
|
||||||
|
"nonce" : "0",
|
||||||
|
"gasPrice" : "1",
|
||||||
|
"gasLimit" : "10000",
|
||||||
|
"to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
|
||||||
|
"value" : "0",
|
||||||
|
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
|
||||||
|
"data" : ""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
"refund50_2" : {
|
||||||
|
"env" : {
|
||||||
|
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
|
||||||
|
"currentNumber" : "0",
|
||||||
|
"currentGasLimit" : "1000000",
|
||||||
|
"currentDifficulty" : "256",
|
||||||
|
"currentTimestamp" : 1,
|
||||||
|
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"
|
||||||
|
},
|
||||||
|
"pre" : {
|
||||||
|
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
|
||||||
|
"balance" : "1000000000000000000",
|
||||||
|
"nonce" : 0,
|
||||||
|
"code" : "{ [[ 10 ]] 1 [[ 11 ]] 1 [[ 1 ]] 0 [[ 2 ]] 0 [[ 3 ]] 0 [[ 4 ]] 0 [[ 5 ]] 0 }",
|
||||||
|
"storage" : {
|
||||||
|
"0x01" : "0x01",
|
||||||
|
"0x02" : "0x01",
|
||||||
|
"0x03" : "0x01",
|
||||||
|
"0x04" : "0x01",
|
||||||
|
"0x05" : "0x01"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
|
||||||
|
"balance" : "10000",
|
||||||
|
"nonce" : 0,
|
||||||
|
"code" : "",
|
||||||
|
"storage": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"transaction" : {
|
||||||
|
"nonce" : "0",
|
||||||
|
"gasPrice" : "1",
|
||||||
|
"gasLimit" : "10000",
|
||||||
|
"to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
|
||||||
|
"value" : "0",
|
||||||
|
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
|
||||||
|
"data" : ""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
"refund500" : {
|
||||||
|
"env" : {
|
||||||
|
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
|
||||||
|
"currentNumber" : "0",
|
||||||
|
"currentGasLimit" : "1000000",
|
||||||
|
"currentDifficulty" : "256",
|
||||||
|
"currentTimestamp" : 1,
|
||||||
|
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"
|
||||||
|
},
|
||||||
|
"pre" : {
|
||||||
|
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
|
||||||
|
"balance" : "1000000000000000000",
|
||||||
|
"nonce" : 0,
|
||||||
|
"code" : "{ @@1 @@2 [[ 10 ]] (EXP 2 0xff) [[ 11 ]] (BALANCE (ADDRESS)) [[ 1 ]] 0 [[ 2 ]] 0 [[ 3 ]] 0 [[ 4 ]] 0 [[ 5 ]] 0 [[ 6 ]] 0 }",
|
||||||
|
"storage" : {
|
||||||
|
"0x01" : "0x01",
|
||||||
|
"0x02" : "0x01",
|
||||||
|
"0x03" : "0x01",
|
||||||
|
"0x04" : "0x01",
|
||||||
|
"0x05" : "0x01",
|
||||||
|
"0x06" : "0x01"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
|
||||||
|
"balance" : "10000",
|
||||||
|
"nonce" : 0,
|
||||||
|
"code" : "",
|
||||||
|
"storage": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"transaction" : {
|
||||||
|
"nonce" : "0",
|
||||||
|
"gasPrice" : "1",
|
||||||
|
"gasLimit" : "10000",
|
||||||
|
"to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
|
||||||
|
"value" : "0",
|
||||||
|
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
|
||||||
|
"data" : ""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
"refund600" : {
|
||||||
|
"env" : {
|
||||||
|
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6",
|
||||||
|
"currentNumber" : "0",
|
||||||
|
"currentGasLimit" : "1000000",
|
||||||
|
"currentDifficulty" : "256",
|
||||||
|
"currentTimestamp" : 1,
|
||||||
|
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"
|
||||||
|
},
|
||||||
|
"pre" : {
|
||||||
|
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
|
||||||
|
"balance" : "1000000000000000000",
|
||||||
|
"nonce" : 0,
|
||||||
|
"code" : "{ @@1 @@2 [[ 10 ]] (EXP 2 0xffff) [[ 11 ]] (BALANCE (ADDRESS)) [[ 1 ]] 0 [[ 2 ]] 0 [[ 3 ]] 0 [[ 4 ]] 0 [[ 5 ]] 0 [[ 6 ]] 0 }",
|
||||||
|
"storage" : {
|
||||||
|
"0x01" : "0x01",
|
||||||
|
"0x02" : "0x01",
|
||||||
|
"0x03" : "0x01",
|
||||||
|
"0x04" : "0x01",
|
||||||
|
"0x05" : "0x01",
|
||||||
|
"0x06" : "0x01"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
|
||||||
|
"balance" : "10000",
|
||||||
|
"nonce" : 0,
|
||||||
|
"code" : "",
|
||||||
|
"storage": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"transaction" : {
|
||||||
|
"nonce" : "0",
|
||||||
|
"gasPrice" : "1",
|
||||||
|
"gasLimit" : "10000",
|
||||||
|
"to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
|
||||||
|
"value" : "0",
|
||||||
|
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
|
||||||
|
"data" : ""
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user