Skip to content

Commit a912db4

Browse files
committed
[isoltest] Extract event specific end-to-end tests.
1 parent 315b626 commit a912db4

28 files changed

+612
-21
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
contract ClientReceipt {
2+
event Deposit(address indexed _from, bytes32 indexed _id, uint _value);
3+
function deposit(bytes32 _id, bool _manually) public payable {
4+
if (_manually) {
5+
bytes32 s = 0x19dacbf83c5de6658e14cbf7bcae5c15eca2eedecf1c66fbca928e4d351bea0f;
6+
uint value = msg.value;
7+
address sender = msg.sender;
8+
assembly {
9+
mstore(0, value)
10+
log3(0, 0x20, s, sender, _id)
11+
}
12+
} else {
13+
emit Deposit(msg.sender, _id, msg.value);
14+
}
15+
}
16+
}
17+
// ====
18+
// compileToEwasm: also
19+
// compileViaYul: also
20+
// ----
21+
// deposit(bytes32,bool), 18 wei: 0x1234, true ->
22+
// - log[0]
23+
// - topic[0]: keccak256('Deposit(address,bytes32,uint256)')
24+
// - topic[1]: 0000000000000000000000001212121212121212121212121212120000000012 (address)
25+
// - topic[2]: 0000000000000000000000000000000000000000000000000000000000001234 (bytes32)
26+
// - data[0]: 0000000000000000000000000000000000000000000000000000000000000012 (uint256)
27+
// deposit(bytes32,bool), 18 wei: 0x1234, false ->
28+
// - log[0]
29+
// - topic[0]: keccak256('Deposit(address,bytes32,uint256)')
30+
// - topic[1]: 0000000000000000000000001212121212121212121212121212120000000012 (address)
31+
// - topic[2]: 0000000000000000000000000000000000000000000000000000000000001234 (bytes32)
32+
// - data[0]: 0000000000000000000000000000000000000000000000000000000000000012 (uint256)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
contract A {
2+
event x();
3+
}
4+
contract B is A {
5+
function f() public returns (uint) {
6+
emit A.x();
7+
return 1;
8+
}
9+
}
10+
// ====
11+
// compileToEwasm: also
12+
// compileViaYul: also
13+
// ----
14+
// f() -> 1
15+
// - log[0]
16+
// - topic[0]: keccak256('x()')
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
contract ClientReceipt {
2+
event Deposit() anonymous;
3+
function deposit() public {
4+
emit Deposit();
5+
}
6+
}
7+
// ====
8+
// compileToEwasm: also
9+
// compileViaYul: also
10+
// ----
11+
// deposit() ->
12+
// - log[0]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
contract ClientReceipt {
2+
event Deposit(address indexed _from, bytes32 indexed _id, uint indexed _value, uint indexed _value2, bytes32 data) anonymous;
3+
function deposit(bytes32 _id) public payable {
4+
emit Deposit(msg.sender, _id, msg.value, 2, "abc");
5+
}
6+
}
7+
// ====
8+
// compileToEwasm: also
9+
// compileViaYul: also
10+
// ----
11+
// deposit(bytes32), 18 wei: 0x1234 ->
12+
// - log[0]
13+
// - topic[0]: 0000000000000000000000001212121212121212121212121212120000000012
14+
// - topic[1]: 0000000000000000000000000000000000000000000000000000000000001234
15+
// - topic[2]: 0000000000000000000000000000000000000000000000000000000000000012
16+
// - topic[3]: 0000000000000000000000000000000000000000000000000000000000000002
17+
// - data[0]: 6162630000000000000000000000000000000000000000000000000000000000
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
contract ClientReceipt {
2+
event Deposit(address indexed _from, bytes32 indexed _id, uint _value);
3+
constructor() {
4+
emit Deposit(msg.sender, bytes32("abc"), 7);
5+
}
6+
}
7+
// ====
8+
// compileToEwasm: also
9+
// compileViaYul: also
10+
// ----
11+
// constructor()
12+
// - log[0]
13+
// - topic[0]: keccak256('Deposit(address,bytes32,uint256)')
14+
// - topic[1]: 0000000000000000000000001212121212121212121212121212120000000012 (address)
15+
// - topic[2]: 6162630000000000000000000000000000000000000000000000000000000000 (bytes32)
16+
// - data[0]: 0000000000000000000000000000000000000000000000000000000000000007 (uint256)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
contract C {
2+
event E(uint[]);
3+
function createEvent(uint x) public {
4+
uint[] memory arr = new uint[](3);
5+
arr[0] = x;
6+
arr[1] = x + 1;
7+
arr[2] = x + 2;
8+
emit E(arr);
9+
}
10+
}
11+
// ====
12+
// compileToEwasm: also
13+
// compileViaYul: also
14+
// ----
15+
// createEvent(uint256): 42 ->
16+
// - log[0]
17+
// - topic[0]: keccak256('E(uint256[])')
18+
// - data[0]: 0000000000000000000000000000000000000000000000000000000000000020 (uint256[])
19+
// - data[1]: 0000000000000000000000000000000000000000000000000000000000000003
20+
// - data[2]: 000000000000000000000000000000000000000000000000000000000000002a
21+
// - data[3]: 000000000000000000000000000000000000000000000000000000000000002b
22+
// - data[4]: 000000000000000000000000000000000000000000000000000000000000002c
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
pragma abicoder v2;
2+
contract C {
3+
event E(uint[]);
4+
function createEvent(uint x) public {
5+
uint[] memory arr = new uint[](3);
6+
arr[0] = x;
7+
arr[1] = x + 1;
8+
arr[2] = x + 2;
9+
emit E(arr);
10+
}
11+
}
12+
// ====
13+
// compileToEwasm: also
14+
// compileViaYul: also
15+
// ----
16+
// createEvent(uint256): 42 ->
17+
// - log[0]
18+
// - topic[0]: keccak256('E(uint256[])')
19+
// - data[0]: 0000000000000000000000000000000000000000000000000000000000000020 (uint256[])
20+
// - data[1]: 0000000000000000000000000000000000000000000000000000000000000003
21+
// - data[2]: 000000000000000000000000000000000000000000000000000000000000002a
22+
// - data[3]: 000000000000000000000000000000000000000000000000000000000000002b
23+
// - data[4]: 000000000000000000000000000000000000000000000000000000000000002c
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
contract C {
2+
event E(uint[]);
3+
uint[] arr;
4+
function createEvent(uint x) public {
5+
while (arr.length < 3)
6+
arr.push();
7+
arr[0] = x;
8+
arr[1] = x + 1;
9+
arr[2] = x + 2;
10+
emit E(arr);
11+
}
12+
}
13+
// ====
14+
// compileToEwasm: also
15+
// compileViaYul: also
16+
// ----
17+
// createEvent(uint256): 42 ->
18+
// - log[0]
19+
// - topic[0]: keccak256('E(uint256[])')
20+
// - data[0]: 0000000000000000000000000000000000000000000000000000000000000020 (uint256[])
21+
// - data[1]: 0000000000000000000000000000000000000000000000000000000000000003
22+
// - data[2]: 000000000000000000000000000000000000000000000000000000000000002a
23+
// - data[3]: 000000000000000000000000000000000000000000000000000000000000002b
24+
// - data[4]: 000000000000000000000000000000000000000000000000000000000000002c
25+
// gas irOptimized: 120511
26+
// gas legacy: 119293
27+
// gas legacyOptimized: 117315
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
pragma abicoder v2;
2+
contract C {
3+
event E(uint[]);
4+
uint[] arr;
5+
function createEvent(uint x) public {
6+
while (arr.length < 3)
7+
arr.push();
8+
arr[0] = x;
9+
arr[1] = x + 1;
10+
arr[2] = x + 2;
11+
emit E(arr);
12+
}
13+
}
14+
// ====
15+
// compileToEwasm: also
16+
// compileViaYul: also
17+
// ----
18+
// createEvent(uint256): 42 ->
19+
// - log[0]
20+
// - topic[0]: keccak256('E(uint256[])')
21+
// - data[0]: 0000000000000000000000000000000000000000000000000000000000000020 (uint256[])
22+
// - data[1]: 0000000000000000000000000000000000000000000000000000000000000003
23+
// - data[2]: 000000000000000000000000000000000000000000000000000000000000002a
24+
// - data[3]: 000000000000000000000000000000000000000000000000000000000000002b
25+
// - data[4]: 000000000000000000000000000000000000000000000000000000000000002c
26+
// gas irOptimized: 120511
27+
// gas legacy: 119293
28+
// gas legacyOptimized: 117315
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
pragma abicoder v2;
2+
contract C {
3+
event E(uint[][]);
4+
function createEvent(uint x) public {
5+
uint[][] memory arr = new uint[][](2);
6+
arr[0] = new uint[](2);
7+
arr[1] = new uint[](2);
8+
arr[0][0] = x;
9+
arr[0][1] = x + 1;
10+
arr[1][0] = x + 2;
11+
arr[1][1] = x + 3;
12+
emit E(arr);
13+
}
14+
}
15+
// ====
16+
// compileToEwasm: also
17+
// compileViaYul: also
18+
// ----
19+
// createEvent(uint256): 42 ->
20+
// - log[0]
21+
// - topic[0]: keccak256('E(uint256[][])')
22+
// - data[0]: 0000000000000000000000000000000000000000000000000000000000000020 (uint256[][])
23+
// - data[1]: 0000000000000000000000000000000000000000000000000000000000000002
24+
// - data[2]: 0000000000000000000000000000000000000000000000000000000000000040
25+
// - data[3]: 00000000000000000000000000000000000000000000000000000000000000a0
26+
// - data[4]: 0000000000000000000000000000000000000000000000000000000000000002
27+
// - data[5]: 000000000000000000000000000000000000000000000000000000000000002a
28+
// - data[6]: 000000000000000000000000000000000000000000000000000000000000002b
29+
// - data[7]: 0000000000000000000000000000000000000000000000000000000000000002
30+
// - data[8]: 000000000000000000000000000000000000000000000000000000000000002c
31+
// - data[9]: 000000000000000000000000000000000000000000000000000000000000002d
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
pragma abicoder v2;
2+
contract C {
3+
event E(uint[][]);
4+
uint[][] arr;
5+
function createEvent(uint x) public {
6+
arr.push(new uint[](2));
7+
arr.push(new uint[](2));
8+
arr[0][0] = x;
9+
arr[0][1] = x + 1;
10+
arr[1][0] = x + 2;
11+
arr[1][1] = x + 3;
12+
emit E(arr);
13+
}
14+
}
15+
// ====
16+
// compileToEwasm: also
17+
// compileViaYul: also
18+
// ----
19+
// createEvent(uint256): 42 ->
20+
// - log[0]
21+
// - topic[0]: keccak256('E(uint256[][])')
22+
// - data[0]: 0000000000000000000000000000000000000000000000000000000000000020 (uint256[][])
23+
// - data[1]: 0000000000000000000000000000000000000000000000000000000000000002
24+
// - data[2]: 0000000000000000000000000000000000000000000000000000000000000040
25+
// - data[3]: 00000000000000000000000000000000000000000000000000000000000000a0
26+
// - data[4]: 0000000000000000000000000000000000000000000000000000000000000002
27+
// - data[5]: 000000000000000000000000000000000000000000000000000000000000002a
28+
// - data[6]: 000000000000000000000000000000000000000000000000000000000000002b
29+
// - data[7]: 0000000000000000000000000000000000000000000000000000000000000002
30+
// - data[8]: 000000000000000000000000000000000000000000000000000000000000002c
31+
// - data[9]: 000000000000000000000000000000000000000000000000000000000000002d
32+
// gas irOptimized: 191805
33+
// gas legacy: 190021
34+
// gas legacyOptimized: 186951
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
contract ClientReceipt {
2+
event Deposit(address indexed _from, bytes32 indexed _id, uint _value);
3+
function deposit(bytes32 _id) public payable {
4+
emit Deposit(msg.sender, _id, msg.value);
5+
}
6+
}
7+
// ====
8+
// compileToEwasm: also
9+
// compileViaYul: also
10+
// ----
11+
// deposit(bytes32), 18 wei: 0x1234 ->
12+
// - log[0]
13+
// - topic[0]: keccak256('Deposit(address,bytes32,uint256)')
14+
// - topic[1]: 0000000000000000000000001212121212121212121212121212120000000012 (address)
15+
// - topic[2]: 0000000000000000000000000000000000000000000000000000000000001234 (bytes32)
16+
// - data[0]: 0000000000000000000000000000000000000000000000000000000000000012 (uint256)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
contract C {
2+
event Test(function() external indexed);
3+
function f() public {
4+
emit Test(this.f);
5+
}
6+
}
7+
// ====
8+
// compileToEwasm: also
9+
// compileViaYul: also
10+
// ----
11+
// f() ->
12+
// - log[0]
13+
// - topic[0]: 16e407cc31a66b716200af7eadb4155035b14f295af52acbc4356b464d649b71
14+
// - topic[1]: 0fdd67305928fcac8d213d1e47bfa6165cd0b87b26121ff00000000000000000
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
contract C {
2+
string x;
3+
uint[4] y;
4+
event E(string indexed r, uint[4] indexed t);
5+
function deposit() public {
6+
for (uint i = 0; i < 90; i++)
7+
bytes(x).push(0);
8+
for (uint8 i = 0; i < 90; i++)
9+
bytes(x)[i] = bytes1(i);
10+
y[0] = 4;
11+
y[1] = 5;
12+
y[2] = 6;
13+
y[3] = 7;
14+
emit E(x, y);
15+
}
16+
}
17+
// ====
18+
// compileToEwasm: also
19+
// compileViaYul: also
20+
// ----
21+
// deposit() ->
22+
// - log[0]
23+
// - topic[0]: keccak256('E(string,uint256[4])')
24+
// - topic[1]: a7fb06bb999a5eb9aff9e0779953f4e1e4ce58044936c2f51c7fb879b85c08bd (string)
25+
// - topic[2]: e755d8cc1a8cde16a2a31160dcd8017ac32d7e2f13215b29a23cdae40a78aa81 (uint256[4])
26+
// gas irOptimized: 792278
27+
// gas legacy: 944742
28+
// gas legacyOptimized: 930774
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
contract ClientReceipt {
2+
event Deposit(address _from, bytes32 _id, uint _value, bool _flag);
3+
function deposit(bytes32 _id) public payable {
4+
emit Deposit(msg.sender, _id, msg.value, true);
5+
}
6+
}
7+
// ====
8+
// compileToEwasm: also
9+
// compileViaYul: also
10+
// ----
11+
// deposit(bytes32), 18 wei: 0x1234 ->
12+
// - log[0]
13+
// - topic[0]: keccak256('Deposit(address,bytes32,uint256,bool)')
14+
// - data[0]: 0000000000000000000000001212121212121212121212121212120000000012 (address)
15+
// - data[1]: 0000000000000000000000000000000000000000000000000000000000001234 (bytes32)
16+
// - data[2]: 0000000000000000000000000000000000000000000000000000000000000012 (uint256)
17+
// - data[3]: 0000000000000000000000000000000000000000000000000000000000000001 (bool)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
contract ClientReceipt {
2+
event Deposit();
3+
function deposit() public {
4+
emit Deposit();
5+
}
6+
}
7+
// ====
8+
// compileToEwasm: also
9+
// compileViaYul: also
10+
// ----
11+
// deposit() ->
12+
// - log[0]
13+
// - topic[0]: keccak256('Deposit()')
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
contract ClientReceipt {
2+
event Deposit(uint fixeda, bytes dynx, uint fixedb);
3+
function deposit() public {
4+
emit Deposit(10, msg.data, 15);
5+
}
6+
}
7+
// ====
8+
// compileToEwasm: also
9+
// compileViaYul: also
10+
// ----
11+
// deposit() ->
12+
// - log[0]
13+
// - topic[0]: keccak256('Deposit(uint256,bytes,uint256)')
14+
// - data[0]: 000000000000000000000000000000000000000000000000000000000000000a (uint256)
15+
// - data[1]: 0000000000000000000000000000000000000000000000000000000000000060 (bytes)
16+
// - data[2]: 000000000000000000000000000000000000000000000000000000000000000f (uint256)
17+
// - data[3]: 0000000000000000000000000000000000000000000000000000000000000004
18+
// - data[4]: d0e30db000000000000000000000000000000000000000000000000000000000

0 commit comments

Comments
 (0)