2018-07-25 20:01:42 +00:00
|
|
|
/*global contract, config, it, assert, before*/
|
|
|
|
const Resolver = require('Embark/contracts/Resolver');
|
|
|
|
|
|
|
|
const namehash = require('eth-ens-namehash');
|
|
|
|
const address = '0x38ac14a9B6a7c8F9C46e4804074186c9F201D0A0';
|
|
|
|
const rootNode = namehash.hash('embark.eth');
|
|
|
|
|
|
|
|
config({
|
|
|
|
contracts: {
|
|
|
|
"ENSRegistry": {
|
|
|
|
"args": []
|
|
|
|
},
|
|
|
|
"Resolver": {
|
|
|
|
"args": ["$ENSRegistry"]
|
|
|
|
},
|
|
|
|
"FIFSRegistrar": {
|
|
|
|
"args": ["$ENSRegistry", rootNode],
|
|
|
|
"onDeploy": [
|
|
|
|
`ENSRegistry.methods.setOwner('${rootNode}', web3.eth.defaultAccount).send().then(() => {
|
2018-07-26 12:59:34 +00:00
|
|
|
ENSRegistry.methods.setResolver('${rootNode}', "$Resolver").send();
|
2018-08-24 13:48:14 +00:00
|
|
|
Resolver.methods.setAddr('${rootNode}', '${address}').send();
|
2018-07-26 12:59:34 +00:00
|
|
|
});`
|
2018-07-25 20:01:42 +00:00
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
contract("ENS", function () {
|
2018-08-24 13:48:14 +00:00
|
|
|
it("should have registered embark.eth", function () {
|
|
|
|
let maxRetry = 20;
|
|
|
|
let domainAddress;
|
2018-07-25 20:01:42 +00:00
|
|
|
|
2018-08-24 13:48:14 +00:00
|
|
|
const wait = setInterval(async () => {
|
|
|
|
domainAddress = await Resolver.methods.addr(rootNode).call();
|
|
|
|
if (domainAddress || maxRetry === 0) {
|
|
|
|
clearInterval(wait);
|
|
|
|
assert.strictEqual(domainAddress, address);
|
2018-07-26 12:59:34 +00:00
|
|
|
return;
|
|
|
|
}
|
2018-08-24 13:48:14 +00:00
|
|
|
maxRetry--;
|
2018-07-30 15:57:00 +00:00
|
|
|
}, 50);
|
2018-07-25 20:01:42 +00:00
|
|
|
});
|
|
|
|
});
|