laconicd/tests/solidity/suites/storage/test/2_test_events.test.js
Yijia Su fa77bae105
tests: refactor solidity test cases (#249)
* Refactor

* add script to run all tests

* Spawn ethermintd in node script

* Update README

* kill process when test finished

* add new test case

* add yarn.lock inside tests to be tracked
2021-07-12 05:22:20 -04:00

33 lines
1.1 KiB
JavaScript

const EventTest = artifacts.require('EventTest');
const truffleAssert = require('truffle-assertions');
contract('Test EventTest Contract', async function (accounts) {
let eventInstance;
before(function () {
console.log(`Using Accounts (${accounts.length}): \n${accounts.join('\n')}`);
console.log('==========================\n');
})
it('should deploy EventTest contract', async function () {
eventInstance = await EventTest.new();
console.log(`Deployed EventTest at: ${eventInstance.address}`);
expect(eventInstance.address).not.to.be.undefined;
});
it('should emit events', async function () {
const tx = await eventInstance.storeWithEvent(888);
truffleAssert.eventEmitted(tx, 'ValueStored1', events => {
return events['0'].toString() === '888';
});
truffleAssert.eventEmitted(tx, 'ValueStored2', events => {
return events['0'].toString() === 'TestMsg' && events['1'].toString() === '888';
});
truffleAssert.eventEmitted(tx, 'ValueStored3', events => {
return events['0'].toString() === 'TestMsg' && events['1'].toString() === '888' && events['2'].toString() === '888';
});
});
})