Merge pull request #33 from sc-forks/events-unit-test
Add (disabled) events filter unit testpull/34/head
commit
937ad30c28
@ -0,0 +1,24 @@ |
||||
/* eslint-env node, mocha */ |
||||
/* global artifacts, contract, assert */ |
||||
|
||||
const Events = artifacts.require('./Events.sol'); |
||||
|
||||
contract('Events', () => { |
||||
it('logs events correctly', done => { |
||||
const loggedEvents = []; |
||||
Events.deployed().then(instance => { |
||||
const allEvents = instance.allEvents(); |
||||
allEvents.watch((error, event) => { loggedEvents.push(event); }); |
||||
|
||||
instance.test(5).then(() => { |
||||
if (loggedEvents.length > 2) {
|
||||
assert(false, 'Did not filter events correctly');
|
||||
} else {
|
||||
assert(true);
|
||||
} |
||||
|
||||
done(); |
||||
}); |
||||
}); |
||||
}); |
||||
}); |
@ -0,0 +1,17 @@ |
||||
pragma solidity ^0.4.3; |
||||
|
||||
contract Events { |
||||
uint x = 0; |
||||
event LogEventOne( uint x, address y); |
||||
event LogEventTwo( uint x, address y); |
||||
|
||||
function test(uint val) { |
||||
LogEventOne(100, msg.sender); |
||||
x = x + val; |
||||
LogEventTwo(200, msg.sender); |
||||
} |
||||
|
||||
function getX() returns (uint){ |
||||
return x; |
||||
} |
||||
} |
Loading…
Reference in new issue