From 51a139531630a4ad00d4aa54738a2f1a1c9eff0e Mon Sep 17 00:00:00 2001 From: Anthony Laibe Date: Fri, 24 Aug 2018 14:48:14 +0100 Subject: [PATCH] Update ENS test using global --- test_apps/test_app/test/ens_spec.js | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/test_apps/test_app/test/ens_spec.js b/test_apps/test_app/test/ens_spec.js index 7c564734..c22e45fc 100644 --- a/test_apps/test_app/test/ens_spec.js +++ b/test_apps/test_app/test/ens_spec.js @@ -18,9 +18,7 @@ config({ "onDeploy": [ `ENSRegistry.methods.setOwner('${rootNode}', web3.eth.defaultAccount).send().then(() => { ENSRegistry.methods.setResolver('${rootNode}', "$Resolver").send(); - Resolver.methods.setAddr('${rootNode}', '${address}').send().then(() => { - global.ensTestReady = true; - }); + Resolver.methods.setAddr('${rootNode}', '${address}').send(); });` ] } @@ -28,21 +26,18 @@ config({ }); contract("ENS", function () { - this.timeout(1000); + it("should have registered embark.eth", function () { + let maxRetry = 20; + let domainAddress; - before(function (done) { - // Wait for onDeploy to finish - const wait = setInterval(() => { - if (!global.ensTestReady) { + const wait = setInterval(async () => { + domainAddress = await Resolver.methods.addr(rootNode).call(); + if (domainAddress || maxRetry === 0) { + clearInterval(wait); + assert.strictEqual(domainAddress, address); return; } - clearInterval(wait); - done(); + maxRetry--; }, 50); }); - - it("should have registered embark.eth", async function () { - const domainAddress = await Resolver.methods.addr(rootNode).call(); - assert.strictEqual(domainAddress, address); - }); });