2020-01-24 11:04:42 +00:00
|
|
|
/*global artifacts, describe, it, web3, config*/
|
2018-11-28 22:01:13 +00:00
|
|
|
const assert = require('assert');
|
2020-01-24 11:04:42 +00:00
|
|
|
const SimpleStorage = artifacts.require('SimpleStorage');
|
|
|
|
const EmbarkJS = artifacts.require('EmbarkJS');
|
2018-11-28 22:01:13 +00:00
|
|
|
|
|
|
|
config({
|
2019-08-30 20:50:20 +00:00
|
|
|
namesystem: {
|
|
|
|
enabled: true,
|
|
|
|
register: {
|
|
|
|
"rootDomain": "test.eth"
|
|
|
|
}
|
|
|
|
},
|
2018-11-28 22:01:13 +00:00
|
|
|
contracts: {
|
2019-08-30 20:50:20 +00:00
|
|
|
deploy: {
|
|
|
|
"SimpleStorage": {
|
|
|
|
args: [100]
|
|
|
|
}
|
2018-11-28 22:01:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
describe("EmbarkJS functions", function() {
|
2020-01-29 15:45:59 +00:00
|
|
|
it('should have access to ENS functions (register, lookup and resolve)', function(done) {
|
|
|
|
const registerAddr = web3.utils.toChecksumAddress('0x1a2f3b98e434c02363f3dac3174af93c1d690914');
|
|
|
|
EmbarkJS.Names.registerSubDomain('subdomain', registerAddr, async (err) => {
|
|
|
|
try {
|
|
|
|
assert.strictEqual(err, null);
|
2018-11-28 22:01:13 +00:00
|
|
|
|
2020-01-29 15:45:59 +00:00
|
|
|
const rootAddress = await EmbarkJS.Names.resolve('test.eth');
|
|
|
|
assert.strictEqual(rootAddress, web3.eth.defaultAccount);
|
|
|
|
|
|
|
|
const rootName = await EmbarkJS.Names.lookup(rootAddress);
|
|
|
|
assert.strictEqual(rootName, 'test.eth');
|
|
|
|
|
|
|
|
const subRegisterAddr = await EmbarkJS.Names.resolve('subdomain.test.eth');
|
|
|
|
assert.strictEqual(subRegisterAddr, registerAddr);
|
|
|
|
|
|
|
|
done();
|
|
|
|
} catch (e) {
|
|
|
|
done(e);
|
|
|
|
}
|
|
|
|
});
|
2018-11-28 22:01:13 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should have access to Storage functions', async function() {
|
|
|
|
// Not calling the functions because it requires Swarm
|
|
|
|
assert.ok(EmbarkJS.Storage.saveText);
|
|
|
|
assert.ok(EmbarkJS.Storage.get);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should have access to Blockchain functions', async function() {
|
2020-01-29 15:45:59 +00:00
|
|
|
const contract = new EmbarkJS.Blockchain.Contract({
|
|
|
|
abi: SimpleStorage.options.jsonInterface,
|
|
|
|
address: SimpleStorage.options.address,
|
|
|
|
web3: web3
|
|
|
|
});
|
2018-11-28 22:01:13 +00:00
|
|
|
const result = await contract.methods.get().call();
|
|
|
|
assert.strictEqual(parseInt(result, 10), 100);
|
|
|
|
});
|
|
|
|
});
|