Merge pull request #557 from ethereum/fixRemixTest_Event

Handle array of events
pull/571/head
yann300 4 years ago committed by GitHub
commit 27aa909b55
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      libs/remix-tests/src/testRunner.ts
  2. 4
      libs/remix-tests/tests/examples_1/simple_storage.sol

@ -286,7 +286,9 @@ export function runTest (testName: string, testObject: any, contractDetails: Com
const assertionEventHashes = assertionEvents.map(e => Web3.utils.sha3(e.name + '(' + e.params.join() + ')') )
let testPassed = false
for (const i in receipt.events) {
const event = receipt.events[i]
let events = receipt.events[i]
if (!Array.isArray(events)) events = [events]
for (const event of events) {
const eIndex = assertionEventHashes.indexOf(event.raw.topics[0]) // event name topic will always be at index 0
if (eIndex >= 0) {
const testEvent = web3.eth.abi.decodeParameters(assertionEvents[eIndex].params, event.raw.data)
@ -317,6 +319,7 @@ export function runTest (testName: string, testObject: any, contractDetails: Com
testPassed = true
}
}
}
if (testPassed) {
const resp: TestResultInterface = {

@ -2,12 +2,16 @@ pragma solidity >= 0.5.0 < 0.8.0;
contract SimpleStorage {
uint public storedData;
event Stored(uint256 value);
constructor() public {
storedData = 100;
}
function set(uint x) public {
storedData = x;
emit Stored(x);
emit Stored(x+10); // for testing multiple events only
}
function get() public view returns (uint retVal) {

Loading…
Cancel
Save