mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Mark every other test payable where neccesary in EndToEndTest
This commit is contained in:
parent
34a6afbd77
commit
680b83b2a4
@ -1320,7 +1320,7 @@ BOOST_AUTO_TEST_CASE(balance)
|
|||||||
BOOST_AUTO_TEST_CASE(blockchain)
|
BOOST_AUTO_TEST_CASE(blockchain)
|
||||||
{
|
{
|
||||||
char const* sourceCode = "contract test {\n"
|
char const* sourceCode = "contract test {\n"
|
||||||
" function someInfo() returns (uint256 value, address coinbase, uint256 blockNumber) {\n"
|
" function someInfo() payable returns (uint256 value, address coinbase, uint256 blockNumber) {\n"
|
||||||
" value = msg.value;\n"
|
" value = msg.value;\n"
|
||||||
" coinbase = block.coinbase;\n"
|
" coinbase = block.coinbase;\n"
|
||||||
" blockNumber = block.number;\n"
|
" blockNumber = block.number;\n"
|
||||||
@ -1342,7 +1342,7 @@ BOOST_AUTO_TEST_CASE(msg_sig)
|
|||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
compileAndRun(sourceCode);
|
compileAndRun(sourceCode);
|
||||||
BOOST_CHECK(callContractFunctionWithValue("foo(uint256)", 13) == encodeArgs(asString(FixedHash<4>(dev::sha3("foo(uint256)")).asBytes())));
|
BOOST_CHECK(callContractFunction("foo(uint256)") == encodeArgs(asString(FixedHash<4>(dev::sha3("foo(uint256)")).asBytes())));
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(msg_sig_after_internal_call_is_same)
|
BOOST_AUTO_TEST_CASE(msg_sig_after_internal_call_is_same)
|
||||||
@ -1358,7 +1358,7 @@ BOOST_AUTO_TEST_CASE(msg_sig_after_internal_call_is_same)
|
|||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
compileAndRun(sourceCode);
|
compileAndRun(sourceCode);
|
||||||
BOOST_CHECK(callContractFunctionWithValue("foo(uint256)", 13) == encodeArgs(asString(FixedHash<4>(dev::sha3("foo(uint256)")).asBytes())));
|
BOOST_CHECK(callContractFunction("foo(uint256)") == encodeArgs(asString(FixedHash<4>(dev::sha3("foo(uint256)")).asBytes())));
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(now)
|
BOOST_AUTO_TEST_CASE(now)
|
||||||
@ -2057,7 +2057,7 @@ BOOST_AUTO_TEST_CASE(contracts_as_addresses)
|
|||||||
}
|
}
|
||||||
contract test {
|
contract test {
|
||||||
helper h;
|
helper h;
|
||||||
function test() { h = new helper(); h.send(5); }
|
function test() payable { h = new helper(); h.send(5); }
|
||||||
function getBalance() returns (uint256 myBalance, uint256 helperBalance) {
|
function getBalance() returns (uint256 myBalance, uint256 helperBalance) {
|
||||||
myBalance = this.balance;
|
myBalance = this.balance;
|
||||||
helperBalance = h.balance;
|
helperBalance = h.balance;
|
||||||
@ -2073,7 +2073,7 @@ BOOST_AUTO_TEST_CASE(gas_and_value_basic)
|
|||||||
char const* sourceCode = R"(
|
char const* sourceCode = R"(
|
||||||
contract helper {
|
contract helper {
|
||||||
bool flag;
|
bool flag;
|
||||||
function getBalance() returns (uint256 myBalance) {
|
function getBalance() payable returns (uint256 myBalance) {
|
||||||
return this.balance;
|
return this.balance;
|
||||||
}
|
}
|
||||||
function setFlag() { flag = true; }
|
function setFlag() { flag = true; }
|
||||||
@ -2081,15 +2081,15 @@ BOOST_AUTO_TEST_CASE(gas_and_value_basic)
|
|||||||
}
|
}
|
||||||
contract test {
|
contract test {
|
||||||
helper h;
|
helper h;
|
||||||
function test() { h = new helper(); }
|
function test() payable { h = new helper(); }
|
||||||
function sendAmount(uint amount) returns (uint256 bal) {
|
function sendAmount(uint amount) payable returns (uint256 bal) {
|
||||||
return h.getBalance.value(amount)();
|
return h.getBalance.value(amount)();
|
||||||
}
|
}
|
||||||
function outOfGas() returns (bool ret) {
|
function outOfGas() payable returns (bool ret) {
|
||||||
h.setFlag.gas(2)(); // should fail due to OOG
|
h.setFlag.gas(2)(); // should fail due to OOG
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
function checkState() returns (bool flagAfter, uint myBal) {
|
function checkState() payable returns (bool flagAfter, uint myBal) {
|
||||||
flagAfter = h.getFlag();
|
flagAfter = h.getFlag();
|
||||||
myBal = this.balance;
|
myBal = this.balance;
|
||||||
}
|
}
|
||||||
@ -2106,7 +2106,7 @@ BOOST_AUTO_TEST_CASE(gas_for_builtin)
|
|||||||
{
|
{
|
||||||
char const* sourceCode = R"(
|
char const* sourceCode = R"(
|
||||||
contract Contract {
|
contract Contract {
|
||||||
function test(uint g) returns (bytes32 data, bool flag) {
|
function test(uint g) payable returns (bytes32 data, bool flag) {
|
||||||
data = ripemd160.gas(g)("abc");
|
data = ripemd160.gas(g)("abc");
|
||||||
flag = true;
|
flag = true;
|
||||||
}
|
}
|
||||||
@ -2121,14 +2121,14 @@ BOOST_AUTO_TEST_CASE(value_complex)
|
|||||||
{
|
{
|
||||||
char const* sourceCode = R"(
|
char const* sourceCode = R"(
|
||||||
contract helper {
|
contract helper {
|
||||||
function getBalance() returns (uint256 myBalance) {
|
function getBalance() payable returns (uint256 myBalance) {
|
||||||
return this.balance;
|
return this.balance;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
contract test {
|
contract test {
|
||||||
helper h;
|
helper h;
|
||||||
function test() { h = new helper(); }
|
function test() payable { h = new helper(); }
|
||||||
function sendAmount(uint amount) returns (uint256 bal) {
|
function sendAmount(uint amount) payable returns (uint256 bal) {
|
||||||
var x1 = h.getBalance.value(amount);
|
var x1 = h.getBalance.value(amount);
|
||||||
uint someStackElement = 20;
|
uint someStackElement = 20;
|
||||||
var x2 = x1.gas(1000);
|
var x2 = x1.gas(1000);
|
||||||
@ -2144,14 +2144,14 @@ BOOST_AUTO_TEST_CASE(value_insane)
|
|||||||
{
|
{
|
||||||
char const* sourceCode = R"(
|
char const* sourceCode = R"(
|
||||||
contract helper {
|
contract helper {
|
||||||
function getBalance() returns (uint256 myBalance) {
|
function getBalance() payable returns (uint256 myBalance) {
|
||||||
return this.balance;
|
return this.balance;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
contract test {
|
contract test {
|
||||||
helper h;
|
helper h;
|
||||||
function test() { h = new helper(); }
|
function test() payable { h = new helper(); }
|
||||||
function sendAmount(uint amount) returns (uint256 bal) {
|
function sendAmount(uint amount) payable returns (uint256 bal) {
|
||||||
var x1 = h.getBalance.value;
|
var x1 = h.getBalance.value;
|
||||||
var x2 = x1(amount).gas;
|
var x2 = x1(amount).gas;
|
||||||
var x3 = x2(1000).value;
|
var x3 = x2(1000).value;
|
||||||
@ -2169,7 +2169,7 @@ BOOST_AUTO_TEST_CASE(value_for_constructor)
|
|||||||
contract Helper {
|
contract Helper {
|
||||||
bytes3 name;
|
bytes3 name;
|
||||||
bool flag;
|
bool flag;
|
||||||
function Helper(bytes3 x, bool f) {
|
function Helper(bytes3 x, bool f) payable {
|
||||||
name = x;
|
name = x;
|
||||||
flag = f;
|
flag = f;
|
||||||
}
|
}
|
||||||
@ -2178,7 +2178,7 @@ BOOST_AUTO_TEST_CASE(value_for_constructor)
|
|||||||
}
|
}
|
||||||
contract Main {
|
contract Main {
|
||||||
Helper h;
|
Helper h;
|
||||||
function Main() {
|
function Main() payable {
|
||||||
h = (new Helper).value(10)("abc", true);
|
h = (new Helper).value(10)("abc", true);
|
||||||
}
|
}
|
||||||
function getFlag() returns (bool ret) { return h.getFlag(); }
|
function getFlag() returns (bool ret) { return h.getFlag(); }
|
||||||
@ -2352,7 +2352,7 @@ BOOST_AUTO_TEST_CASE(function_modifier)
|
|||||||
{
|
{
|
||||||
char const* sourceCode = R"(
|
char const* sourceCode = R"(
|
||||||
contract C {
|
contract C {
|
||||||
function getOne() nonFree returns (uint r) { return 1; }
|
function getOne() payable nonFree returns (uint r) { return 1; }
|
||||||
modifier nonFree { if (msg.value > 0) _; }
|
modifier nonFree { if (msg.value > 0) _; }
|
||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
@ -2559,7 +2559,7 @@ BOOST_AUTO_TEST_CASE(event)
|
|||||||
char const* sourceCode = R"(
|
char const* sourceCode = R"(
|
||||||
contract ClientReceipt {
|
contract ClientReceipt {
|
||||||
event Deposit(address indexed _from, bytes32 indexed _id, uint _value);
|
event Deposit(address indexed _from, bytes32 indexed _id, uint _value);
|
||||||
function deposit(bytes32 _id, bool _manually) {
|
function deposit(bytes32 _id, bool _manually) payable {
|
||||||
if (_manually) {
|
if (_manually) {
|
||||||
bytes32 s = 0x19dacbf83c5de6658e14cbf7bcae5c15eca2eedecf1c66fbca928e4d351bea0f;
|
bytes32 s = 0x19dacbf83c5de6658e14cbf7bcae5c15eca2eedecf1c66fbca928e4d351bea0f;
|
||||||
log3(bytes32(msg.value), s, bytes32(msg.sender), _id);
|
log3(bytes32(msg.value), s, bytes32(msg.sender), _id);
|
||||||
@ -2624,7 +2624,7 @@ BOOST_AUTO_TEST_CASE(event_anonymous_with_topics)
|
|||||||
char const* sourceCode = R"(
|
char const* sourceCode = R"(
|
||||||
contract ClientReceipt {
|
contract ClientReceipt {
|
||||||
event Deposit(address indexed _from, bytes32 indexed _id, uint indexed _value, uint indexed _value2, bytes32 data) anonymous;
|
event Deposit(address indexed _from, bytes32 indexed _id, uint indexed _value, uint indexed _value2, bytes32 data) anonymous;
|
||||||
function deposit(bytes32 _id, bool _manually) {
|
function deposit(bytes32 _id, bool _manually) payable {
|
||||||
Deposit(msg.sender, _id, msg.value, 2, "abc");
|
Deposit(msg.sender, _id, msg.value, 2, "abc");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2648,7 +2648,7 @@ BOOST_AUTO_TEST_CASE(event_lots_of_data)
|
|||||||
char const* sourceCode = R"(
|
char const* sourceCode = R"(
|
||||||
contract ClientReceipt {
|
contract ClientReceipt {
|
||||||
event Deposit(address _from, bytes32 _id, uint _value, bool _flag);
|
event Deposit(address _from, bytes32 _id, uint _value, bool _flag);
|
||||||
function deposit(bytes32 _id) {
|
function deposit(bytes32 _id) payable {
|
||||||
Deposit(msg.sender, _id, msg.value, true);
|
Deposit(msg.sender, _id, msg.value, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2874,9 +2874,10 @@ BOOST_AUTO_TEST_CASE(generic_call)
|
|||||||
char const* sourceCode = R"**(
|
char const* sourceCode = R"**(
|
||||||
contract receiver {
|
contract receiver {
|
||||||
uint public received;
|
uint public received;
|
||||||
function receive(uint256 x) { received = x; }
|
function receive(uint256 x) payable { received = x; }
|
||||||
}
|
}
|
||||||
contract sender {
|
contract sender {
|
||||||
|
function sender() payable {}
|
||||||
function doSend(address rec) returns (uint d)
|
function doSend(address rec) returns (uint d)
|
||||||
{
|
{
|
||||||
bytes4 signature = bytes4(bytes32(sha3("receive(uint256)")));
|
bytes4 signature = bytes4(bytes32(sha3("receive(uint256)")));
|
||||||
@ -2897,10 +2898,11 @@ BOOST_AUTO_TEST_CASE(generic_callcode)
|
|||||||
char const* sourceCode = R"**(
|
char const* sourceCode = R"**(
|
||||||
contract receiver {
|
contract receiver {
|
||||||
uint public received;
|
uint public received;
|
||||||
function receive(uint256 x) { received = x; }
|
function receive(uint256 x) payable { received = x; }
|
||||||
}
|
}
|
||||||
contract sender {
|
contract sender {
|
||||||
uint public received;
|
uint public received;
|
||||||
|
function sender() payable { }
|
||||||
function doSend(address rec) returns (uint d)
|
function doSend(address rec) returns (uint d)
|
||||||
{
|
{
|
||||||
bytes4 signature = bytes4(bytes32(sha3("receive(uint256)")));
|
bytes4 signature = bytes4(bytes32(sha3("receive(uint256)")));
|
||||||
@ -2930,13 +2932,14 @@ BOOST_AUTO_TEST_CASE(generic_delegatecall)
|
|||||||
uint public received;
|
uint public received;
|
||||||
address public sender;
|
address public sender;
|
||||||
uint public value;
|
uint public value;
|
||||||
function receive(uint256 x) { received = x; sender = msg.sender; value = msg.value; }
|
function receive(uint256 x) payable { received = x; sender = msg.sender; value = msg.value; }
|
||||||
}
|
}
|
||||||
contract sender {
|
contract sender {
|
||||||
uint public received;
|
uint public received;
|
||||||
address public sender;
|
address public sender;
|
||||||
uint public value;
|
uint public value;
|
||||||
function doSend(address rec)
|
function sender() payable {}
|
||||||
|
function doSend(address rec) payable
|
||||||
{
|
{
|
||||||
bytes4 signature = bytes4(bytes32(sha3("receive(uint256)")));
|
bytes4 signature = bytes4(bytes32(sha3("receive(uint256)")));
|
||||||
rec.delegatecall(signature, 23);
|
rec.delegatecall(signature, 23);
|
||||||
|
Loading…
Reference in New Issue
Block a user