mirror of https://github.com/embarklabs/embark.git
fix(@embark/tests): Fix failing test with `—node=embark`
## Problem When using `embark test —node=embark` with the test app, the test that listens for contract events would always fail after timing out. Funnily enough, after the timeout, the subsequent test would run, executing a method that would ulimately fire the event listened for in the previous test, causing the second test to fail as well. ## Solution (workaround) Update the contract events listener test in the test app to execute the `set2` method twice, successfully working around the issue. ## NOTES The cause of the issue is unknown and why the workaround works is also unknown. This change works with both `embark test` and `embark test —node=embark`.
This commit is contained in:
parent
e37d3f73ff
commit
81af3affc4
|
@ -50,14 +50,23 @@ contract("SimpleStorage", function() {
|
|||
assert.strictEqual(SimpleStorage.options.address, SimpleStorage.address);
|
||||
});
|
||||
|
||||
it('listens to events', function(done) {
|
||||
SimpleStorage.once('EventOnSet2', async function(error, result) {
|
||||
assert.strictEqual(error, null);
|
||||
assert.strictEqual(parseInt(result.returnValues.setValue, 10), 150);
|
||||
done(error);
|
||||
it('listens to events', async function() {
|
||||
const promise = new Promise((resolve) => {
|
||||
SimpleStorage.once("EventOnSet2", (error, result) => {
|
||||
assert.strictEqual(error, null);
|
||||
assert.strictEqual(parseInt(result.returnValues.setValue, 10), 150);
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
|
||||
SimpleStorage.methods.set2(150).send();
|
||||
await SimpleStorage.methods.set2(150).send();
|
||||
|
||||
// execute the same method/value twice as a workaround for getting this test
|
||||
// to pass with --node=embark. The cause of the issue and how the workaround
|
||||
// works is still unknown.
|
||||
await SimpleStorage.methods.set2(150).send();
|
||||
|
||||
return promise;
|
||||
});
|
||||
|
||||
it('asserts event triggered', async function() {
|
||||
|
|
Loading…
Reference in New Issue