Skip to content

Commit a8c179d

Browse files
committed
Minor refactoring & correction of test generation.
1 parent d6375bd commit a8c179d

File tree

4 files changed

+242
-197
lines changed

4 files changed

+242
-197
lines changed

test/libsolidity/SemanticTest.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,10 @@ TestCase::TestResult SemanticTest::runTest(ostream& _stream, string const& _line
271271

272272
if (m_transactionSuccessful != !test.call().expectations.failure || outputMismatch)
273273
success = false;
274-
success = checkLogs(test);
274+
275+
if (success)
276+
success = checkLogs(test);
277+
275278
test.setFailure(!m_transactionSuccessful);
276279
}
277280

@@ -450,10 +453,10 @@ bool SemanticTest::checkLogs(TestFunctionCall& _call)
450453

451454
// Finally we update the consumed logs within the producer.
452455
for (auto& logIdx: m_touchedLogs[&producer->call()])
453-
producer->consumedLogs().insert(logIdx);
456+
producer->consumedLogIndexes().insert(logIdx);
454457

455458
// It is ok if some builtins consumed log events.
456-
return producer->consumedLogs().size() >= producer->logs().size();
459+
return producer->consumedLogIndexes().size() >= producer->logs().size();
457460
}
458461
return true;
459462
}

test/libsolidity/semanticTests/events/event_emit.sol

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,23 @@ contract ClientReceipt {
22
event A(address _from, bytes32 _id, uint _value);
33
event B(address _from, bytes32 _id, uint indexed _value) anonymous;
44
event C(address _from, bytes32 indexed _id, uint _value);
5-
function deposit(bytes32 _id) public payable {
5+
function deposit(bytes32 _id) public payable returns(uint256) {
66
emit A(msg.sender, _id, msg.value);
77
emit B(msg.sender, _id, msg.value);
88
emit C(msg.sender, _id, msg.value);
9+
10+
return msg.value;
911
}
1012
}
1113

1214
// ====
1315
// compileViaYul: false
1416
// ----
15-
// deposit(bytes32), 18 wei: 0x1234 ->
16-
// logs.expectEvent(uint256,string): 0, "A(address,bytes32,uint256)" -> 0x1212121212121212121212121212120000000012, 0x1234, 0x12
17-
// logs.expectEvent(uint256,string): 1, "" -> 0x12, 0x1212121212121212121212121212120000000012, 0x1234
18-
// logs.expectEvent(uint256,string): 2, "C(address,bytes32,uint256)" -> 0x1234, 0x1212121212121212121212121212120000000012, 0x12
17+
// deposit(bytes32), 28 wei: 0x1234 -> 0x1c
18+
// logs.expectEvent(uint256,string): 0, "A(address,bytes32,uint256)" -> 0x1212121212121212121212121212120000000012, 0x1234, 0x1c
19+
// logs.expectEvent(uint256,string): 1, "" -> 0x1c, 0x1212121212121212121212121212120000000012, 0x1234
20+
// logs.expectEvent(uint256,string): 2, "C(address,bytes32,uint256)" -> 0x1234, 0x1212121212121212121212121212120000000012, 0x1c
21+
// deposit(bytes32), 23 wei: 0x1234 -> 0x17
22+
// logs.expectEvent(uint256,string): 0, "A(address,bytes32,uint256)" -> 0x1212121212121212121212121212120000000012, 0x1234, 0x17
23+
// logs.expectEvent(uint256,string): 1, "" -> 0x17, 0x1212121212121212121212121212120000000012, 0x1234
24+
// logs.expectEvent(uint256,string): 2, "C(address,bytes32,uint256)" -> 0x1234, 0x1212121212121212121212121212120000000012, 0x17

0 commit comments

Comments
 (0)