mirror of
https://github.com/status-im/embark-area-51.git
synced 2025-01-11 14:34:40 +00:00
Merge pull request #511 from embark-framework/event-test
add a test to test events
This commit is contained in:
commit
cd5ce085bf
@ -13,6 +13,7 @@ library Assert {
|
|||||||
contract SimpleStorage is Ownable {
|
contract SimpleStorage is Ownable {
|
||||||
uint public storedData;
|
uint public storedData;
|
||||||
address public registar;
|
address public registar;
|
||||||
|
event EventOnSet2(bool passed, string message);
|
||||||
|
|
||||||
function() public payable { }
|
function() public payable { }
|
||||||
|
|
||||||
@ -30,6 +31,7 @@ contract SimpleStorage is Ownable {
|
|||||||
|
|
||||||
function set2(uint x, uint unusedGiveWarning) public onlyOwner {
|
function set2(uint x, uint unusedGiveWarning) public onlyOwner {
|
||||||
storedData = x;
|
storedData = x;
|
||||||
|
emit EventOnSet2(true, "hi");
|
||||||
}
|
}
|
||||||
|
|
||||||
function get() public view returns (uint retVal) {
|
function get() public view returns (uint retVal) {
|
||||||
|
@ -37,4 +37,15 @@ contract("SimpleStorage", function () {
|
|||||||
assert.strictEqual(SimpleStorage.options.address, SimpleStorage.address);
|
assert.strictEqual(SimpleStorage.options.address, SimpleStorage.address);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('listens to events', function (done) {
|
||||||
|
SimpleStorage.once('EventOnSet2', async function(error, _result){
|
||||||
|
assert.strictEqual(error, null);
|
||||||
|
let result = await SimpleStorage.methods.get().call();
|
||||||
|
assert.strictEqual(parseInt(result, 10), 150);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
|
SimpleStorage.methods.set2(150, 100).send();
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user