aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/contracts/AuctionRegistrar.cpp4
-rw-r--r--test/contracts/Wallet.cpp6
-rw-r--r--test/libsolidity/ABIEncoderTests.cpp28
-rw-r--r--test/libsolidity/SolidityEndToEndTest.cpp106
-rw-r--r--test/libsolidity/syntaxTests/types/empty_tuple_event.sol3
5 files changed, 36 insertions, 111 deletions
diff --git a/test/contracts/AuctionRegistrar.cpp b/test/contracts/AuctionRegistrar.cpp
index a02b09ee..f5abb83d 100644
--- a/test/contracts/AuctionRegistrar.cpp
+++ b/test/contracts/AuctionRegistrar.cpp
@@ -175,10 +175,10 @@ contract GlobalRegistrar is Registrar, AuctionSystem {
m_toRecord[_name].primary = _a;
if (_primary)
{
- PrimaryChanged(_name, _a);
+ emit PrimaryChanged(_name, _a);
m_toName[_a] = _name;
}
- Changed(_name);
+ emit Changed(_name);
}
function setSubRegistrar(string _name, address _registrar) onlyrecordowner(_name) {
m_toRecord[_name].subRegistrar = _registrar;
diff --git a/test/contracts/Wallet.cpp b/test/contracts/Wallet.cpp
index 6e7b97d2..0e42eeb1 100644
--- a/test/contracts/Wallet.cpp
+++ b/test/contracts/Wallet.cpp
@@ -215,7 +215,7 @@ contract multiowned {
uint ownerIndexBit = 2**ownerIndex;
// make sure we (the message sender) haven't confirmed this operation previously.
if (pending.ownersDone & ownerIndexBit == 0) {
- Confirmation(msg.sender, _operation);
+ emit Confirmation(msg.sender, _operation);
// ok - check if count is enough to go ahead.
if (pending.yetNeeded <= 1) {
// enough confirmations: reset and run interior.
@@ -392,7 +392,7 @@ contract Wallet is multisig, multiowned, daylimit {
function execute(address _to, uint _value, bytes _data) external onlyowner returns (bytes32 _r) {
// first, take the opportunity to check that we're under the daily limit.
if (underLimit(_value)) {
- SingleTransact(msg.sender, _value, _to, _data);
+ emit SingleTransact(msg.sender, _value, _to, _data);
// yes - just execute the call.
_to.call.value(_value)(_data);
return 0;
@@ -412,7 +412,7 @@ contract Wallet is multisig, multiowned, daylimit {
function confirm(bytes32 _h) onlymanyowners(_h) returns (bool) {
if (m_txs[_h].to != 0x0000000000000000000000000000000000000000) {
m_txs[_h].to.call.value(m_txs[_h].value)(m_txs[_h].data);
- MultiTransact(msg.sender, _h, m_txs[_h].value, m_txs[_h].to, m_txs[_h].data);
+ emit MultiTransact(msg.sender, _h, m_txs[_h].value, m_txs[_h].to, m_txs[_h].data);
delete m_txs[_h];
return true;
}
diff --git a/test/libsolidity/ABIEncoderTests.cpp b/test/libsolidity/ABIEncoderTests.cpp
index c5ece5df..9b6250d8 100644
--- a/test/libsolidity/ABIEncoderTests.cpp
+++ b/test/libsolidity/ABIEncoderTests.cpp
@@ -68,7 +68,7 @@ BOOST_AUTO_TEST_CASE(value_types)
assembly { b := 7 }
C c;
assembly { c := sub(0, 5) }
- E(10, uint16(uint256(-2)), uint24(0x12121212), int24(int256(-1)), bytes3(x), b, c);
+ emit E(10, uint16(uint256(-2)), uint24(0x12121212), int24(int256(-1)), bytes3(x), b, c);
}
}
)";
@@ -87,7 +87,7 @@ BOOST_AUTO_TEST_CASE(string_literal)
contract C {
event E(string, bytes20, string);
function f() public {
- E("abcdef", "abcde", "abcdefabcdefgehabcabcasdfjklabcdefabcedefghabcabcasdfjklabcdefabcdefghabcabcasdfjklabcdeefabcdefghabcabcasdefjklabcdefabcdefghabcabcasdfjkl");
+ emit E("abcdef", "abcde", "abcdefabcdefgehabcabcasdfjklabcdefabcedefghabcabcasdfjklabcdefabcdefghabcabcasdfjklabcdeefabcdefghabcabcasdefjklabcdefabcdefghabcabcasdfjkl");
}
}
)";
@@ -133,7 +133,7 @@ BOOST_AUTO_TEST_CASE(conversion)
int8 c;
int16 d;
assembly { a := sub(0, 1) c := 0x0101ff d := 0xff01 }
- E(10, x, a, uint8(b), c, int8(d));
+ emit E(10, x, a, uint8(b), c, int8(d));
}
}
)";
@@ -159,7 +159,7 @@ BOOST_AUTO_TEST_CASE(memory_array_one_dim)
mstore(add(x, mul(add(i, 1), 0x20)), add(0xfffffffe, i))
}
}
- E(10, x, 11);
+ emit E(10, x, 11);
}
}
)";
@@ -188,7 +188,7 @@ BOOST_AUTO_TEST_CASE(memory_array_two_dim)
x[0][2] = -1;
x[1][0] = 4;
x[1][1] = 5;
- E(10, x, 11);
+ emit E(10, x, 11);
}
}
)";
@@ -208,7 +208,7 @@ BOOST_AUTO_TEST_CASE(memory_byte_array)
bytes[] memory x = new bytes[](2);
x[0] = "abcabcdefghjklmnopqrsuvwabcdefgijklmnopqrstuwabcdefgijklmnoprstuvw";
x[1] = "abcdefghijklmnopqrtuvwabcfghijklmnopqstuvwabcdeghijklmopqrstuvw";
- E(10, x, 11);
+ emit E(10, x, 11);
}
}
)";
@@ -234,7 +234,7 @@ BOOST_AUTO_TEST_CASE(storage_byte_array)
function f() public {
short = "123456789012345678901234567890a";
long = "ffff123456789012345678901234567890afffffffff123456789012345678901234567890a";
- E(short, long);
+ emit E(short, long);
}
}
)";
@@ -261,7 +261,7 @@ BOOST_AUTO_TEST_CASE(storage_array)
sstore(1, sub(0, 2))
sstore(2, sub(0, 3))
}
- E(addr);
+ emit E(addr);
}
}
)";
@@ -282,7 +282,7 @@ BOOST_AUTO_TEST_CASE(storage_array_dyn)
addr.push(0x0000000000000000000000000000000000000001);
addr.push(0x0000000000000000000000000000000000000002);
addr.push(0x0000000000000000000000000000000000000003);
- E(addr);
+ emit E(addr);
}
}
)";
@@ -308,7 +308,7 @@ BOOST_AUTO_TEST_CASE(storage_array_compact)
x.push(6);
x.push(-7);
x.push(8);
- E(x);
+ emit E(x);
}
}
)";
@@ -329,7 +329,7 @@ BOOST_AUTO_TEST_CASE(external_function)
function(uint) external returns (uint) g;
function f(uint) public returns (uint) {
g = this.f;
- E(this.f, g);
+ emit E(this.f, g);
}
}
)";
@@ -351,7 +351,7 @@ BOOST_AUTO_TEST_CASE(external_function_cleanup)
function f(uint) public returns (uint) {
function(uint) external returns (uint)[1] memory h;
assembly { sstore(0, sub(0, 1)) mstore(h, sub(0, 1)) }
- E(h[0], g);
+ emit E(h[0], g);
}
}
)";
@@ -368,7 +368,7 @@ BOOST_AUTO_TEST_CASE(calldata)
contract C {
event E(bytes);
function f(bytes a) external {
- E(a);
+ emit E(a);
}
}
)";
@@ -426,7 +426,7 @@ BOOST_AUTO_TEST_CASE(structs)
s.sub[0].x[0] = 11;
s.sub[1].x[0] = 12;
s.sub[2].x[1] = 13;
- e(x, s);
+ emit e(x, s);
return (x, s);
}
}
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp
index 42b5d417..65a0a216 100644
--- a/test/libsolidity/SolidityEndToEndTest.cpp
+++ b/test/libsolidity/SolidityEndToEndTest.cpp
@@ -3122,7 +3122,7 @@ BOOST_AUTO_TEST_CASE(event)
bytes32 s = 0x19dacbf83c5de6658e14cbf7bcae5c15eca2eedecf1c66fbca928e4d351bea0f;
log3(bytes32(msg.value), s, bytes32(uint256(msg.sender)), _id);
} else {
- Deposit(msg.sender, _id, msg.value);
+ emit Deposit(msg.sender, _id, msg.value);
}
}
}
@@ -3172,7 +3172,7 @@ BOOST_AUTO_TEST_CASE(event_no_arguments)
contract ClientReceipt {
event Deposit();
function deposit() {
- Deposit();
+ emit Deposit();
}
}
)";
@@ -3186,28 +3186,6 @@ BOOST_AUTO_TEST_CASE(event_no_arguments)
BOOST_CHECK_EQUAL(m_logs[0].topics[0], dev::keccak256(string("Deposit()")));
}
-BOOST_AUTO_TEST_CASE(event_access_through_base_name)
-{
- char const* sourceCode = R"(
- contract A {
- event x();
- }
- contract B is A {
- function f() returns (uint) {
- A.x();
- return 1;
- }
- }
- )";
- compileAndRun(sourceCode);
- callContractFunction("f()");
- BOOST_REQUIRE_EQUAL(m_logs.size(), 1);
- BOOST_CHECK_EQUAL(m_logs[0].address, m_contractAddress);
- BOOST_CHECK(m_logs[0].data.empty());
- BOOST_REQUIRE_EQUAL(m_logs[0].topics.size(), 1);
- BOOST_CHECK_EQUAL(m_logs[0].topics[0], dev::keccak256(string("x()")));
-}
-
BOOST_AUTO_TEST_CASE(event_access_through_base_name_emit)
{
char const* sourceCode = R"(
@@ -3238,67 +3216,15 @@ BOOST_AUTO_TEST_CASE(events_with_same_name)
event Deposit(address _addr);
event Deposit(address _addr, uint _amount);
function deposit() returns (uint) {
- Deposit();
- return 1;
- }
- function deposit(address _addr) returns (uint) {
- Deposit(_addr);
- return 1;
- }
- function deposit(address _addr, uint _amount) returns (uint) {
- Deposit(_addr, _amount);
- return 1;
- }
- }
- )";
- u160 const c_loggedAddress = m_contractAddress;
-
- compileAndRun(sourceCode);
- ABI_CHECK(callContractFunction("deposit()"), encodeArgs(u256(1)));
- BOOST_REQUIRE_EQUAL(m_logs.size(), 1);
- BOOST_CHECK_EQUAL(m_logs[0].address, m_contractAddress);
- BOOST_CHECK(m_logs[0].data.empty());
- BOOST_REQUIRE_EQUAL(m_logs[0].topics.size(), 1);
- BOOST_CHECK_EQUAL(m_logs[0].topics[0], dev::keccak256(string("Deposit()")));
-
- ABI_CHECK(callContractFunction("deposit(address)", c_loggedAddress), encodeArgs(u256(1)));
- BOOST_REQUIRE_EQUAL(m_logs.size(), 1);
- BOOST_CHECK_EQUAL(m_logs[0].address, m_contractAddress);
- BOOST_CHECK(m_logs[0].data == encodeArgs(c_loggedAddress));
- BOOST_REQUIRE_EQUAL(m_logs[0].topics.size(), 1);
- BOOST_CHECK_EQUAL(m_logs[0].topics[0], dev::keccak256(string("Deposit(address)")));
-
- ABI_CHECK(callContractFunction("deposit(address,uint256)", c_loggedAddress, u256(100)), encodeArgs(u256(1)));
- BOOST_REQUIRE_EQUAL(m_logs.size(), 1);
- BOOST_CHECK_EQUAL(m_logs[0].address, m_contractAddress);
- BOOST_CHECK(m_logs[0].data == encodeArgs(c_loggedAddress, 100));
- BOOST_REQUIRE_EQUAL(m_logs[0].topics.size(), 1);
- BOOST_CHECK_EQUAL(m_logs[0].topics[0], dev::keccak256(string("Deposit(address,uint256)")));
-}
-
-BOOST_AUTO_TEST_CASE(events_with_same_name_inherited)
-{
- char const* sourceCode = R"(
- contract A {
- event Deposit();
- }
-
- contract B {
- event Deposit(address _addr);
- }
-
- contract ClientReceipt is A, B {
- event Deposit(address _addr, uint _amount);
- function deposit() returns (uint) {
- Deposit();
+ emit Deposit();
return 1;
}
function deposit(address _addr) returns (uint) {
- Deposit(_addr);
+ emit Deposit(_addr);
return 1;
}
function deposit(address _addr, uint _amount) returns (uint) {
- Deposit(_addr, _amount);
+ emit Deposit(_addr, _amount);
return 1;
}
}
@@ -3386,7 +3312,7 @@ BOOST_AUTO_TEST_CASE(event_anonymous)
contract ClientReceipt {
event Deposit() anonymous;
function deposit() {
- Deposit();
+ emit Deposit();
}
}
)";
@@ -3401,7 +3327,7 @@ BOOST_AUTO_TEST_CASE(event_anonymous_with_topics)
contract ClientReceipt {
event Deposit(address indexed _from, bytes32 indexed _id, uint indexed _value, uint indexed _value2, bytes32 data) anonymous;
function deposit(bytes32 _id) payable {
- Deposit(msg.sender, _id, msg.value, 2, "abc");
+ emit Deposit(msg.sender, _id, msg.value, 2, "abc");
}
}
)";
@@ -3425,7 +3351,7 @@ BOOST_AUTO_TEST_CASE(event_lots_of_data)
contract ClientReceipt {
event Deposit(address _from, bytes32 _id, uint _value, bool _flag);
function deposit(bytes32 _id) payable {
- Deposit(msg.sender, _id, msg.value, true);
+ emit Deposit(msg.sender, _id, msg.value, true);
}
}
)";
@@ -3446,7 +3372,7 @@ BOOST_AUTO_TEST_CASE(event_really_lots_of_data)
contract ClientReceipt {
event Deposit(uint fixeda, bytes dynx, uint fixedb);
function deposit() {
- Deposit(10, msg.data, 15);
+ emit Deposit(10, msg.data, 15);
}
}
)";
@@ -3470,7 +3396,7 @@ BOOST_AUTO_TEST_CASE(event_really_lots_of_data_from_storage)
x[0] = "A";
x[1] = "B";
x[2] = "C";
- Deposit(10, x, 15);
+ emit Deposit(10, x, 15);
}
}
)";
@@ -3495,7 +3421,7 @@ BOOST_AUTO_TEST_CASE(event_really_really_lots_of_data_from_storage)
x[1] = "B";
x[2] = "C";
x[30] = "Z";
- Deposit(10, x, 15);
+ emit Deposit(10, x, 15);
}
}
)";
@@ -3523,7 +3449,7 @@ BOOST_AUTO_TEST_CASE(event_indexed_string)
y[1] = 5;
y[2] = 6;
y[3] = 7;
- E(x, y);
+ emit E(x, y);
}
}
)";
@@ -4246,7 +4172,7 @@ BOOST_AUTO_TEST_CASE(storing_invalid_boolean)
assembly {
tmp := 5
}
- Ev(tmp);
+ emit Ev(tmp);
return 1;
}
}
@@ -6034,12 +5960,12 @@ BOOST_AUTO_TEST_CASE(invalid_enum_logged)
assembly {
garbled := 5
}
- Log(garbled);
+ emit Log(garbled);
return 1;
}
function test_log_ok() returns (uint) {
X x = X.A;
- Log(x);
+ emit Log(x);
return 1;
}
}
@@ -11932,7 +11858,7 @@ BOOST_AUTO_TEST_CASE(snark)
input[7] = 9643208548031422463313148630985736896287522941726746581856185889848792022807;
input[8] = 18066496933330839731877828156604;
if (verify(input, proof) == 0) {
- Verified("Transaction successfully verified.");
+ emit Verified("Transaction successfully verified.");
return true;
} else {
return false;
diff --git a/test/libsolidity/syntaxTests/types/empty_tuple_event.sol b/test/libsolidity/syntaxTests/types/empty_tuple_event.sol
index 0e9c84cb..24327db0 100644
--- a/test/libsolidity/syntaxTests/types/empty_tuple_event.sol
+++ b/test/libsolidity/syntaxTests/types/empty_tuple_event.sol
@@ -6,5 +6,4 @@ contract C {
}
}
// ----
-// TypeError: (95-106): Event invocations have to be prefixed by "emit".
-// Warning: (95-106): Tuple component cannot be empty.
+// ParserError: (95-99): Expected primary expression.