2018-11-28 22:01:13 +00:00
|
|
|
/*global describe, it, web3, config*/
|
|
|
|
const assert = require('assert');
|
|
|
|
const SimpleStorage = require('Embark/contracts/SimpleStorage');
|
|
|
|
const EmbarkJS = require('Embark/EmbarkJS');
|
|
|
|
|
|
|
|
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() {
|
2019-11-07 15:59:26 +00:00
|
|
|
it('should have access to ENS functions and registered test.eth', async function() {
|
2019-08-30 20:50:20 +00:00
|
|
|
const rootAddress = await EmbarkJS.Names.resolve('test.eth');
|
2018-11-28 22:01:13 +00:00
|
|
|
assert.strictEqual(rootAddress, web3.eth.defaultAccount);
|
|
|
|
|
|
|
|
const rootName = await EmbarkJS.Names.lookup(rootAddress);
|
2019-08-30 20:50:20 +00:00
|
|
|
assert.strictEqual(rootName, 'test.eth');
|
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() {
|
|
|
|
const contract = new EmbarkJS.Blockchain.Contract({abi: SimpleStorage.options.jsonInterface, address: SimpleStorage.options.address, web3: web3});
|
|
|
|
const result = await contract.methods.get().call();
|
|
|
|
assert.strictEqual(parseInt(result, 10), 100);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|