update test_app tests
This commit is contained in:
parent
a112f18d93
commit
55df42979f
|
@ -22,6 +22,7 @@ function getFilesFromDir(filePath, cb) {
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
run: function (filePath) {
|
run: function (filePath) {
|
||||||
|
const start = Date.now();
|
||||||
process.env.isTest = true;
|
process.env.isTest = true;
|
||||||
let failures = 0;
|
let failures = 0;
|
||||||
if (!filePath) {
|
if (!filePath) {
|
||||||
|
@ -82,11 +83,15 @@ module.exports = {
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
if (failures) {
|
if (failures) {
|
||||||
console.error(`Total number of failures: ${failures}`.red);
|
console.error(` > Total number of failures: ${failures}`.red.bold);
|
||||||
|
} else {
|
||||||
|
console.log(' > All tests passed'.green.bold);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clean contracts folder for next test run
|
// Clean contracts folder for next test run
|
||||||
fs.remove('.embark/contracts', (_err) => {
|
fs.remove('.embark/contracts', (_err) => {
|
||||||
|
const end = Date.now();
|
||||||
|
console.log('Total time', end - start);
|
||||||
process.exit(failures);
|
process.exit(failures);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,21 +1,24 @@
|
||||||
|
/*global contract, config, it, embark*/
|
||||||
|
const assert = require('assert');
|
||||||
|
const AnotherStorage = embark.require('Embark/contracts/AnotherStorage');
|
||||||
|
const SimpleStorage = embark.require('Embark/contracts/SimpleStorage');
|
||||||
|
|
||||||
|
config({
|
||||||
|
contracts: {
|
||||||
|
"SimpleStorage": {
|
||||||
|
args: [100]
|
||||||
|
},
|
||||||
|
"AnotherStorage": {
|
||||||
|
args: ["$SimpleStorage"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
contract("AnotherStorage", function() {
|
contract("AnotherStorage", function() {
|
||||||
this.timeout(0);
|
this.timeout(0);
|
||||||
before(function(done) {
|
|
||||||
this.timeout(0);
|
|
||||||
var contractsConfig = {
|
|
||||||
"SimpleStorage": {
|
|
||||||
args: [100]
|
|
||||||
},
|
|
||||||
"AnotherStorage": {
|
|
||||||
args: ["$SimpleStorage"]
|
|
||||||
}
|
|
||||||
};
|
|
||||||
EmbarkSpec.deployAll(contractsConfig, () => { done() });
|
|
||||||
});
|
|
||||||
|
|
||||||
it("set SimpleStorage address", async function() {
|
it("set SimpleStorage address", async function() {
|
||||||
let result = await AnotherStorage.methods.simpleStorageAddress().call();
|
let result = await AnotherStorage.methods.simpleStorageAddress().call();
|
||||||
assert.equal(result.toString(), SimpleStorage.options.address);
|
assert.equal(result.toString(), SimpleStorage.options.address);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,37 +1,42 @@
|
||||||
|
/*global contract, config, it, embark*/
|
||||||
|
const assert = require('assert');
|
||||||
|
const SomeContract = embark.require('Embark/contracts/SomeContract');
|
||||||
|
const SimpleStorage = embark.require('Embark/contracts/SimpleStorage');
|
||||||
|
const MyToken2 = embark.require('Embark/contracts/MyToken2');
|
||||||
|
|
||||||
|
config({
|
||||||
|
contracts: {
|
||||||
|
"SimpleStorage": {
|
||||||
|
args: [100]
|
||||||
|
},
|
||||||
|
"Token": {
|
||||||
|
deploy: false,
|
||||||
|
args: [1000]
|
||||||
|
},
|
||||||
|
"MyToken2": {
|
||||||
|
instanceOf: "Token",
|
||||||
|
args: [2000]
|
||||||
|
},
|
||||||
|
"SomeContract": {
|
||||||
|
"args": [
|
||||||
|
["$MyToken2", "$SimpleStorage"],
|
||||||
|
100
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
contract("SomeContract", function() {
|
contract("SomeContract", function() {
|
||||||
this.timeout(0);
|
this.timeout(0);
|
||||||
before(function(done) {
|
|
||||||
this.timeout(0);
|
|
||||||
var contractsConfig = {
|
|
||||||
"SimpleStorage": {
|
|
||||||
args: [100]
|
|
||||||
},
|
|
||||||
"Token": {
|
|
||||||
deploy: false,
|
|
||||||
args: [1000]
|
|
||||||
},
|
|
||||||
"MyToken2": {
|
|
||||||
instanceOf: "Token",
|
|
||||||
args: [2000]
|
|
||||||
},
|
|
||||||
"SomeContract": {
|
|
||||||
"args": [
|
|
||||||
["$MyToken2", "$SimpleStorage"],
|
|
||||||
100
|
|
||||||
]
|
|
||||||
}
|
|
||||||
};
|
|
||||||
EmbarkSpec.deployAll(contractsConfig, () => { done() });
|
|
||||||
});
|
|
||||||
|
|
||||||
it("set MyToken2 address", async function() {
|
it("set MyToken2 address", async function() {
|
||||||
let address = await SomeContract.methods.addr_1().call();
|
let address = await SomeContract.methods.addr_1().call();
|
||||||
assert.equal(address, MyToken2.options.address);
|
assert.strictEqual(address, MyToken2.options.address);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("set SimpleStorage address", async function() {
|
it("set SimpleStorage address", async function() {
|
||||||
let address = await SomeContract.methods.addr_2().call();
|
let address = await SomeContract.methods.addr_2().call();
|
||||||
assert.equal(address, SimpleStorage.options.address);
|
assert.strictEqual(address, SimpleStorage.options.address);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,22 +1,23 @@
|
||||||
|
/*global contract, config, it, embark*/
|
||||||
|
const assert = require('assert');
|
||||||
|
const Test2 = embark.require('Embark/contracts/Test2');
|
||||||
|
|
||||||
|
config({
|
||||||
|
contracts: {
|
||||||
|
"Test2": {
|
||||||
|
},
|
||||||
|
"ZAMyLib": {
|
||||||
|
},
|
||||||
|
"ZAMyLib2": {
|
||||||
|
"deploy": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
contract("Test", function() {
|
contract("Test", function() {
|
||||||
before(function(done) {
|
|
||||||
this.timeout(0);
|
|
||||||
var contractsConfig = {
|
|
||||||
"Test2": {
|
|
||||||
},
|
|
||||||
"ZAMyLib": {
|
|
||||||
},
|
|
||||||
"ZAMyLib2": {
|
|
||||||
"deploy": true
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
EmbarkSpec.deployAll(contractsConfig, () => { done() });
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should call library correctly", async function() {
|
it("should call library correctly", async function() {
|
||||||
let result = await Test2.methods.testAdd().call();
|
let result = await Test2.methods.testAdd().call();
|
||||||
assert.equal(result, 3);
|
assert.strictEqual(parseInt(result, 10), 3);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,23 +1,23 @@
|
||||||
/*global contract, before, EmbarkSpec, PluginStorage, SimpleStorage, it*/
|
/*global contract, config, it, embark*/
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
|
const PluginStorage = embark.require('Embark/contracts/PluginStorage');
|
||||||
|
const SimpleStorage = embark.require('Embark/contracts/SimpleStorage');
|
||||||
|
|
||||||
|
config({
|
||||||
|
contracts: {
|
||||||
|
"SimpleStorage": {
|
||||||
|
args: [100]
|
||||||
|
},
|
||||||
|
"PluginStorage": {
|
||||||
|
args: ["$SimpleStorage"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
contract("PluginSimpleStorage", function () {
|
contract("PluginSimpleStorage", function () {
|
||||||
this.timeout(0);
|
this.timeout(0);
|
||||||
|
|
||||||
before((done) => {
|
|
||||||
const contractsConfig = {
|
|
||||||
"SimpleStorage": {
|
|
||||||
args: [100]
|
|
||||||
},
|
|
||||||
"PluginStorage": {
|
|
||||||
args: ["$SimpleStorage"]
|
|
||||||
}
|
|
||||||
};
|
|
||||||
EmbarkSpec.deployAll(contractsConfig, () => {
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it("set SimpleStorage address", async function () {
|
it("set SimpleStorage address", async function () {
|
||||||
let result = await PluginStorage.methods.simpleStorageAddress().call();
|
let result = await PluginStorage.methods.simpleStorageAddress().call();
|
||||||
assert.equal(result.toString(), SimpleStorage.options.address);
|
assert.equal(result.toString(), SimpleStorage.options.address);
|
||||||
|
|
|
@ -1,31 +1,26 @@
|
||||||
|
/*global contract, config, it, embark*/
|
||||||
|
const assert = require('assert');
|
||||||
|
const SimpleStorage = embark.require('Embark/contracts/SimpleStorage');
|
||||||
|
|
||||||
contract("SimpleStorage", function() {
|
config({
|
||||||
|
contracts: {
|
||||||
|
"SimpleStorage": {
|
||||||
|
args: [100]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
contract("SimpleStorage", function () {
|
||||||
this.timeout(0);
|
this.timeout(0);
|
||||||
before(function(done) {
|
|
||||||
this.timeout(0);
|
|
||||||
|
|
||||||
//config({
|
it("should set constructor value", async function () {
|
||||||
// node: "http://localhost:8545"
|
|
||||||
//});
|
|
||||||
|
|
||||||
var contractsConfig = {
|
|
||||||
"SimpleStorage": {
|
|
||||||
args: [100]
|
|
||||||
}
|
|
||||||
};
|
|
||||||
EmbarkSpec.deployAll(contractsConfig, () => { done() });
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should set constructor value", async function() {
|
|
||||||
let result = await SimpleStorage.methods.storedData().call();
|
let result = await SimpleStorage.methods.storedData().call();
|
||||||
assert.equal(result, 100);
|
assert.strictEqual(parseInt(result, 10), 100);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("set storage value", async function() {
|
it("set storage value", async function () {
|
||||||
await SimpleStorage.methods.set(150).send();
|
await SimpleStorage.methods.set(150).send();
|
||||||
let result = await SimpleStorage.methods.get().call();
|
let result = await SimpleStorage.methods.get().call();
|
||||||
assert.equal(result, 499650);
|
assert.strictEqual(parseInt(result, 10), 499650);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,86 +1,82 @@
|
||||||
/*global describe, it, before*/
|
/*global describe, config, it, embark*/
|
||||||
|
const assert = require('assert');
|
||||||
|
const Token = embark.require('Embark/contracts/Token');
|
||||||
|
const MyToken = embark.require('Embark/contracts/MyToken');
|
||||||
|
const MyToken2 = embark.require('Embark/contracts/MyToken2');
|
||||||
|
const AlreadyDeployedToken = embark.require('Embark/contracts/AlreadyDeployedToken');
|
||||||
|
const Test = embark.require('Embark/contracts/Test');
|
||||||
|
|
||||||
describe("Token", function() {
|
config({
|
||||||
|
contracts: {
|
||||||
this.timeout(0);
|
ZAMyLib: {},
|
||||||
before(function(done) {
|
SimpleStorage: {
|
||||||
this.timeout(0);
|
args: [100]
|
||||||
|
},
|
||||||
//config({
|
AnotherStorage: {
|
||||||
// node: "http://localhost:8545"
|
args: ["$SimpleStorage"]
|
||||||
//});
|
},
|
||||||
|
Token: {
|
||||||
var contractsConfig = {
|
deploy: false,
|
||||||
"ZAMyLib": {
|
args: [1000]
|
||||||
},
|
},
|
||||||
"SimpleStorage": {
|
MyToken: {
|
||||||
args: [100]
|
instanceOf: "Token"
|
||||||
},
|
},
|
||||||
"AnotherStorage": {
|
MyToken2: {
|
||||||
args: ["$SimpleStorage"]
|
instanceOf: "Token",
|
||||||
},
|
args: [2000]
|
||||||
"Token": {
|
},
|
||||||
deploy: false,
|
AlreadyDeployedToken: {
|
||||||
args: [1000]
|
address: "0xCAFECAFECAFECAFECAFECAFECAFECAFECAFECAFE",
|
||||||
},
|
instanceOf: "Token"
|
||||||
"MyToken": {
|
},
|
||||||
instanceOf: "Token"
|
Test: {
|
||||||
},
|
onDeploy: ["Test.methods.changeAddress('$MyToken').send()"]
|
||||||
"MyToken2": {
|
},
|
||||||
instanceOf: "Token",
|
ContractArgs: {
|
||||||
args: [2000]
|
args: {
|
||||||
},
|
initialValue: 123,
|
||||||
"AlreadyDeployedToken": {
|
_addresses: ["$MyToken2", "$SimpleStorage"]
|
||||||
"address": "0xCAFECAFECAFECAFECAFECAFECAFECAFECAFECAFE",
|
|
||||||
instanceOf: "Token"
|
|
||||||
},
|
|
||||||
"Test": {
|
|
||||||
onDeploy: [
|
|
||||||
"Test.methods.changeAddress('$MyToken').send()"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"ContractArgs": {
|
|
||||||
"args": {
|
|
||||||
"initialValue": 123,
|
|
||||||
"_addresses": ["$MyToken2", "$SimpleStorage"]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"SomeContract": {
|
|
||||||
"args": [
|
|
||||||
["$MyToken2", "$SimpleStorage"],
|
|
||||||
100
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
};
|
},
|
||||||
EmbarkSpec.deployAll(contractsConfig, () => { done() });
|
SomeContract: {
|
||||||
});
|
args: [
|
||||||
|
["$MyToken2", "$SimpleStorage"],
|
||||||
it("not deploy Token", function() {
|
100
|
||||||
assert.equal(Token.address, "");
|
]
|
||||||
});
|
}
|
||||||
|
}
|
||||||
it("not deploy MyToken and MyToken2", function() {
|
});
|
||||||
assert.notEqual(MyToken.address, "");
|
|
||||||
assert.notEqual(MyToken2.address, "");
|
describe("Token", function () {
|
||||||
});
|
this.timeout(0);
|
||||||
|
|
||||||
it("set MyToken Balance correctly", async function() {
|
it("not deploy Token", function () {
|
||||||
let result = await MyToken.methods._supply().call();
|
assert.strictEqual(Token.address, undefined);
|
||||||
assert.equal(result, 1000);
|
});
|
||||||
});
|
|
||||||
|
it("should deploy MyToken and MyToken2", function () {
|
||||||
it("set MyToken2 Balance correctly", async function() {
|
assert.ok(MyToken.options.address);
|
||||||
let result = await MyToken2.methods._supply().call();
|
assert.ok(MyToken2.options.address);
|
||||||
assert.equal(result, 2000);
|
});
|
||||||
});
|
|
||||||
|
it("set MyToken Balance correctly", async function () {
|
||||||
it("get right address", function() {
|
let result = await MyToken.methods._supply().call();
|
||||||
assert.equal(AlreadyDeployedToken.address, "0xCAFECAFECAFECAFECAFECAFECAFECAFECAFECAFE");
|
assert.strictEqual(parseInt(result, 10), 1000);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should use onDeploy", async function() {
|
it("set MyToken2 Balance correctly", async function () {
|
||||||
let result = await Test.methods.addr().call();
|
let result = await MyToken2.methods._supply().call();
|
||||||
assert.equal(result, MyToken.address)
|
assert.strictEqual(parseInt(result, 10), 2000);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("get right address", function () {
|
||||||
|
assert.strictEqual(AlreadyDeployedToken.options.address.toLowerCase(),
|
||||||
|
"0xCAFECAFECAFECAFECAFECAFECAFECAFECAFECAFE".toLowerCase());
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should use onDeploy", async function () {
|
||||||
|
let result = await Test.methods.addr().call();
|
||||||
|
assert.strictEqual(result, MyToken.options.address);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue