Merge pull request #474 from embark-framework/features/test-revamp-multi
Revamp tests to use a cleaner syntax and be faster
This commit is contained in:
commit
3e3c0b82b2
|
@ -189,9 +189,6 @@ class Cmd {
|
||||||
.description(__('run tests'))
|
.description(__('run tests'))
|
||||||
.action(function (file, options) {
|
.action(function (file, options) {
|
||||||
i18n.setOrDetectLocale(options.locale);
|
i18n.setOrDetectLocale(options.locale);
|
||||||
embark.initConfig('development', {
|
|
||||||
embarkConfig: 'embark.json', interceptLogs: false
|
|
||||||
});
|
|
||||||
embark.runTests(file);
|
embark.runTests(file);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,6 +98,10 @@ class ContractDeployer {
|
||||||
return next();
|
return next();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO find a better way to do that
|
||||||
|
if (process.env.isTest) {
|
||||||
|
return self.deployContract(contract, next);
|
||||||
|
}
|
||||||
// TODO: this should be a plugin API instead, if not existing, it should by default deploy the contract
|
// TODO: this should be a plugin API instead, if not existing, it should by default deploy the contract
|
||||||
self.events.request("deploy:contract:shouldDeploy", contract, function(trackedContract) {
|
self.events.request("deploy:contract:shouldDeploy", contract, function(trackedContract) {
|
||||||
if (!trackedContract) {
|
if (!trackedContract) {
|
||||||
|
|
|
@ -14,7 +14,7 @@ function log(eventType, eventName) {
|
||||||
//console.log(eventType, eventName);
|
//console.log(eventType, eventName);
|
||||||
}
|
}
|
||||||
|
|
||||||
EventEmitter.prototype._maxListeners = 200;
|
EventEmitter.prototype._maxListeners = 300;
|
||||||
const _on = EventEmitter.prototype.on;
|
const _on = EventEmitter.prototype.on;
|
||||||
const _setHandler = EventEmitter.prototype.setHandler;
|
const _setHandler = EventEmitter.prototype.setHandler;
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ const supported_languages = ['en', 'pt', 'fr'];
|
||||||
i18n.configure({
|
i18n.configure({
|
||||||
locales: supported_languages,
|
locales: supported_languages,
|
||||||
register: global,
|
register: global,
|
||||||
//updateFiles: false,
|
updateFiles: false,
|
||||||
directory: path.join(__dirname, 'locales')
|
directory: path.join(__dirname, 'locales')
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -126,9 +126,6 @@
|
||||||
"Unable to start the blockchain process. Is Geth installed?": "Unable to start the blockchain process. Is Geth installed?",
|
"Unable to start the blockchain process. Is Geth installed?": "Unable to start the blockchain process. Is Geth installed?",
|
||||||
"Error while downloading the file": "Error while downloading the file",
|
"Error while downloading the file": "Error while downloading the file",
|
||||||
"Error while loading the content of ": "Error while loading the content of ",
|
"Error while loading the content of ": "Error while loading the content of ",
|
||||||
"IPFS node is offline": "IPFS node is offline",
|
|
||||||
"IPFS node detected": "IPFS node detected",
|
|
||||||
"Webserver is offline": "Webserver is offline",
|
|
||||||
"Installing packages...": "Installing packages...",
|
"Installing packages...": "Installing packages...",
|
||||||
"Next steps:": "Next steps:",
|
"Next steps:": "Next steps:",
|
||||||
"open another console in the same directory and run": "open another console in the same directory and run",
|
"open another console in the same directory and run": "open another console in the same directory and run",
|
||||||
|
@ -152,6 +149,9 @@
|
||||||
"Starting ipfs process": "Starting ipfs process",
|
"Starting ipfs process": "Starting ipfs process",
|
||||||
"ipfs process started": "ipfs process started",
|
"ipfs process started": "ipfs process started",
|
||||||
"Starting swarm process": "Starting swarm process",
|
"Starting swarm process": "Starting swarm process",
|
||||||
|
"unknown command": "unknown command",
|
||||||
|
"Simulator not found; Please install it with \"%s\"": "Simulator not found; Please install it with \"%s\"",
|
||||||
|
"IMPORTANT: if you using a NodeJS version older than 6.9.1 then you need to install an older version of testrpc \"%s\"": "IMPORTANT: if you using a NodeJS version older than 6.9.1 then you need to install an older version of testrpc \"%s\"",
|
||||||
"swarm process started": "swarm process started",
|
"swarm process started": "swarm process started",
|
||||||
"Storage process for swarm ended before the end of this process. Code: 12": "Storage process for swarm ended before the end of this process. Code: 12",
|
"Storage process for swarm ended before the end of this process. Code: 12": "Storage process for swarm ended before the end of this process. Code: 12",
|
||||||
"Storage process for swarm ended before the end of this process. Code: 1": "Storage process for swarm ended before the end of this process. Code: 1",
|
"Storage process for swarm ended before the end of this process. Code: 1": "Storage process for swarm ended before the end of this process. Code: 1",
|
||||||
|
@ -162,4 +162,4 @@
|
||||||
"Cannot start {{platform}} node on {{url}}.": "Cannot start {{platform}} node on {{url}}.",
|
"Cannot start {{platform}} node on {{url}}.": "Cannot start {{platform}} node on {{url}}.",
|
||||||
"Storage process for swarm ended before the end of this process. Code: 0": "Storage process for swarm ended before the end of this process. Code: 0",
|
"Storage process for swarm ended before the end of this process. Code: 0": "Storage process for swarm ended before the end of this process. Code: 0",
|
||||||
"error uploading to swarm": "error uploading to swarm"
|
"error uploading to swarm": "error uploading to swarm"
|
||||||
}
|
}
|
||||||
|
|
15
lib/index.js
15
lib/index.js
|
@ -216,13 +216,6 @@ class Embark {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
initTests(options) {
|
|
||||||
this.context = options.context || [constants.contexts.test];
|
|
||||||
let Test = require('./tests/test.js');
|
|
||||||
options.context = this.context;
|
|
||||||
return new Test(options);
|
|
||||||
}
|
|
||||||
|
|
||||||
graph(options) {
|
graph(options) {
|
||||||
this.context = options.context || [constants.contexts.graph];
|
this.context = options.context || [constants.contexts.graph];
|
||||||
options.onlyCompile = true;
|
options.onlyCompile = true;
|
||||||
|
@ -372,14 +365,6 @@ class Embark {
|
||||||
let RunTests = require('./tests/run_tests.js');
|
let RunTests = require('./tests/run_tests.js');
|
||||||
RunTests.run(file);
|
RunTests.run(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// temporary until next refactor
|
|
||||||
Embark.initTests = function(options) {
|
|
||||||
let Test = require('./tests/test.js');
|
|
||||||
options.context = [constants.contexts.test];
|
|
||||||
return new Test(options);
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports = Embark;
|
module.exports = Embark;
|
||||||
|
|
|
@ -51,7 +51,7 @@ process.on('message', function (msg) {
|
||||||
|
|
||||||
if (msg.action === 'compile') {
|
if (msg.action === 'compile') {
|
||||||
solcProcess.compile(msg.jsonObj, (output) => {
|
solcProcess.compile(msg.jsonObj, (output) => {
|
||||||
process.send({result: "compilation", output: output});
|
process.send({result: "compilation-" + msg.id, output: output});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -2,6 +2,7 @@ let utils = require('../../utils/utils.js');
|
||||||
let fs = require('../../core/fs.js');
|
let fs = require('../../core/fs.js');
|
||||||
let currentSolcVersion = require('../../../package.json').dependencies.solc;
|
let currentSolcVersion = require('../../../package.json').dependencies.solc;
|
||||||
const ProcessLauncher = require('../../process/processLauncher');
|
const ProcessLauncher = require('../../process/processLauncher');
|
||||||
|
const uuid = require('uuid/v1');
|
||||||
|
|
||||||
class SolcW {
|
class SolcW {
|
||||||
|
|
||||||
|
@ -49,11 +50,12 @@ class SolcW {
|
||||||
}
|
}
|
||||||
|
|
||||||
compile(jsonObj, done) {
|
compile(jsonObj, done) {
|
||||||
this.solcProcess.once('result', 'compilation', (msg) => {
|
const id = uuid();
|
||||||
|
this.solcProcess.once('result', 'compilation-' + id, (msg) => {
|
||||||
done(JSON.parse(msg.output));
|
done(JSON.parse(msg.output));
|
||||||
});
|
});
|
||||||
|
|
||||||
this.solcProcess.send({action: 'compile', jsonObj: jsonObj});
|
this.solcProcess.send({action: 'compile', jsonObj: jsonObj, id});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,80 +1,96 @@
|
||||||
const utils = require('../utils/utils.js');
|
const async = require('async');
|
||||||
|
const fs = require('fs-extra');
|
||||||
|
const Mocha = require('mocha');
|
||||||
|
const path = require('path');
|
||||||
|
const Test = require('./test');
|
||||||
|
|
||||||
|
function getFilesFromDir(filePath, cb) {
|
||||||
|
fs.readdir(filePath, (err, files) => {
|
||||||
|
if (err) {
|
||||||
|
return cb(err);
|
||||||
|
}
|
||||||
|
const testFiles = files.filter((file) => {
|
||||||
|
// Only keep the .js files
|
||||||
|
// TODO: make this a configuration in embark.json
|
||||||
|
return file.substr(-3) === '.js';
|
||||||
|
}).map((file) => {
|
||||||
|
return path.join(filePath, file);
|
||||||
|
});
|
||||||
|
cb(null, testFiles);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
run: function(filepath) {
|
run: function (filePath) {
|
||||||
const Mocha = require('mocha'),
|
process.env.isTest = true;
|
||||||
fs = require('fs-extra'),
|
let failures = 0;
|
||||||
path = require('path');
|
if (!filePath) {
|
||||||
|
filePath = 'test/';
|
||||||
const mocha = new Mocha();
|
|
||||||
|
|
||||||
if (filepath) {
|
|
||||||
if (filepath.substr(-1) === '/') {
|
|
||||||
// Add each .js file to the mocha instance
|
|
||||||
fs.readdirSync(filepath).filter(function(file){
|
|
||||||
// Only keep the .js files
|
|
||||||
// TODO: make this a configuration in embark.json
|
|
||||||
return file.substr(-3) === '.js';
|
|
||||||
}).forEach(function(file){
|
|
||||||
mocha.addFile(
|
|
||||||
path.join(filepath, file)
|
|
||||||
);
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
mocha.addFile(filepath);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
var testDir = 'test/';
|
|
||||||
|
|
||||||
// Add each .js file to the mocha instance
|
|
||||||
fs.readdirSync(testDir).filter(function(file){
|
|
||||||
// Only keep the .js files
|
|
||||||
// TODO: make this a configuration in embark.json
|
|
||||||
return file.substr(-3) === '.js';
|
|
||||||
}).forEach(function(file){
|
|
||||||
mocha.addFile(
|
|
||||||
path.join(testDir, file)
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let Test = require('./test.js');
|
async.waterfall([
|
||||||
|
function setupGlobalNamespace(next) {
|
||||||
|
// TODO put default config
|
||||||
|
const test = new Test();
|
||||||
|
global.embark = test;
|
||||||
|
global.config = test.config.bind(test);
|
||||||
|
|
||||||
global.assert = require('assert');
|
// TODO: this global here might not be necessary at all
|
||||||
|
global.web3 = global.embark.web3;
|
||||||
|
|
||||||
let configOptions = {
|
global.contract = function (describeName, callback) {
|
||||||
gasPrice: 1
|
return Mocha.describe(describeName, callback);
|
||||||
};
|
};
|
||||||
global.config = function(config) {
|
|
||||||
configOptions = utils.recursiveMerge(configOptions, config);
|
|
||||||
};
|
|
||||||
// TODO: check how to pass the options
|
|
||||||
//global.EmbarkSpec = new Test(options);
|
|
||||||
|
|
||||||
// TODO: this global here might not be necessary at all
|
console.info('Compiling contracts'.cyan);
|
||||||
global.EmbarkSpec = new Test({});
|
test.init(next);
|
||||||
global.web3 = global.EmbarkSpec.web3;
|
},
|
||||||
|
function getFiles(next) {
|
||||||
|
if (filePath.substr(-1) !== '/') {
|
||||||
|
return next(null, [filePath]);
|
||||||
|
}
|
||||||
|
getFilesFromDir(filePath, (err, files) => {
|
||||||
|
if (err) {
|
||||||
|
console.error('Error while reading the directory');
|
||||||
|
return next(err);
|
||||||
|
}
|
||||||
|
next(null, files);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
function executeForAllFiles(files, next) {
|
||||||
|
async.eachLimit(files, 1, (file, eachCb) => {
|
||||||
|
const mocha = new Mocha();
|
||||||
|
mocha.addFile(file);
|
||||||
|
|
||||||
global.contract = function(describeName, callback) {
|
mocha.suite.timeout(0);
|
||||||
return Mocha.describe(describeName, callback);
|
mocha.suite.beforeEach('Wait for deploy', (done) => {
|
||||||
};
|
global.embark.onReady(() => {
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
mocha.run(function(fails) {
|
||||||
|
failures += fails;
|
||||||
|
// Mocha prints the error already
|
||||||
|
eachCb();
|
||||||
|
});
|
||||||
|
}, next);
|
||||||
|
}
|
||||||
|
], (err) => {
|
||||||
|
if (err) {
|
||||||
|
console.error(err);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
if (failures) {
|
||||||
|
console.error(` > Total number of failures: ${failures}`.red.bold);
|
||||||
|
} else {
|
||||||
|
console.log(' > All tests passed'.green.bold);
|
||||||
|
}
|
||||||
|
|
||||||
// Run the tests.
|
|
||||||
let runner = mocha.run(function(failures) {
|
|
||||||
// Clean contracts folder for next test run
|
// Clean contracts folder for next test run
|
||||||
fs.remove('.embark/contracts', (_err) => {
|
fs.remove('.embark/contracts', (_err) => {
|
||||||
process.on('exit', function () {
|
process.exit(failures);
|
||||||
process.exit(failures); // exit with non-zero status if there were failures
|
|
||||||
});
|
|
||||||
process.exit();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
runner.on('suite', function() {
|
|
||||||
global.assert = require('assert');
|
|
||||||
global.EmbarkSpec = new Test({simulatorOptions: configOptions});
|
|
||||||
global.web3 = global.EmbarkSpec.web3;
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,116 +1,193 @@
|
||||||
var async = require('async');
|
const async = require('async');
|
||||||
//require("../utils/debug_util.js")(__filename, async);
|
const Engine = require('../core/engine.js');
|
||||||
var Web3 = require('web3');
|
const TestLogger = require('./test_logger.js');
|
||||||
var Engine = require('../core/engine.js');
|
const Web3 = require('web3');
|
||||||
var TestLogger = require('./test_logger.js');
|
const utils = require('../utils/utils');
|
||||||
|
const constants = require('../constants');
|
||||||
|
const Events = require('../core/events');
|
||||||
|
const cloneDeep = require('clone-deep');
|
||||||
|
|
||||||
var getSimulator = function() {
|
function getSimulator() {
|
||||||
try {
|
try {
|
||||||
var sim = require('ethereumjs-testrpc');
|
return require('ganache-cli');
|
||||||
return sim;
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
const moreInfo = 'For more information see https://github.com/trufflesuite/ganache-cli';
|
||||||
if (e.code === 'MODULE_NOT_FOUND') {
|
if (e.code === 'MODULE_NOT_FOUND') {
|
||||||
console.log(__('Simulator not found; Please install it with "%s"', 'npm install ethereumjs-testrpc --save'));
|
console.error(__('Simulator not found; Please install it with "%s"', 'npm install ganache-cli --save'));
|
||||||
console.log(__('IMPORTANT: if you using a NodeJS version older than 6.9.1 then you need to install an older version of testrpc "%s"', 'npm install ethereumjs-testrpc@2.0 --save'));
|
console.error(moreInfo);
|
||||||
console.log('For more information see https://github.com/ethereumjs/testrpc');
|
throw e;
|
||||||
// TODO: should throw exception instead
|
|
||||||
return process.exit();
|
|
||||||
}
|
}
|
||||||
console.log("==============");
|
console.error("==============");
|
||||||
console.log(__("Tried to load testrpc but an error occurred. This is a problem with testrpc"));
|
console.error(__("Tried to load Ganache CLI (testrpc), but an error occurred. This is a problem with Ganache CLI"));
|
||||||
console.log(__('IMPORTANT: if you using a NodeJS version older than 6.9.1 then you need to install an older version of testrpc "%s". Alternatively install node 6.9.1 and the testrpc 3.0', 'npm install ethereumjs-testrpc@2.0 --save'));
|
console.error(moreInfo);
|
||||||
console.log("==============");
|
console.error("==============");
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
var Test = function(options) {
|
class Test {
|
||||||
this.options = options || {};
|
constructor(options) {
|
||||||
this.simOptions = this.options.simulatorOptions || {};
|
this.options = options || {};
|
||||||
|
this.simOptions = this.options.simulatorOptions || {};
|
||||||
|
this.contracts = {};
|
||||||
|
this.events = new Events();
|
||||||
|
this.ready = true;
|
||||||
|
this.builtContracts = {};
|
||||||
|
|
||||||
this.engine = new Engine({
|
this.web3 = new Web3();
|
||||||
env: this.options.env || 'test',
|
if (this.simOptions.node) {
|
||||||
// TODO: confi will need to detect if this is a obj
|
this.web3.setProvider(new this.web3.providers.HttpProvider(this.simOptions.node));
|
||||||
embarkConfig: this.options.embarkConfig || 'embark.json',
|
} else {
|
||||||
interceptLogs: false
|
this.sim = getSimulator();
|
||||||
});
|
this.web3.setProvider(this.sim.provider(this.simOptions));
|
||||||
|
}
|
||||||
|
|
||||||
this.engine.init({
|
this.engine = new Engine({
|
||||||
logger: new TestLogger({logLevel: 'debug'})
|
env: this.options.env || 'test',
|
||||||
});
|
// TODO: config will need to detect if this is a obj
|
||||||
|
embarkConfig: this.options.embarkConfig || 'embark.json',
|
||||||
|
interceptLogs: false
|
||||||
|
});
|
||||||
|
|
||||||
this.web3 = new Web3();
|
this.engine.init({
|
||||||
|
logger: new TestLogger({logLevel: 'debug'})
|
||||||
if (this.simOptions.node) {
|
});
|
||||||
this.web3.setProvider(new this.web3.providers.HttpProvider(this.simOptions.node));
|
|
||||||
} else {
|
this.versions_default = this.engine.config.contractsConfig.versions;
|
||||||
this.sim = getSimulator();
|
// Reset contract config to nothing to make sure we deploy only what we want
|
||||||
this.web3.setProvider(this.sim.provider(this.simOptions));
|
this.engine.config.contractsConfig = {contracts: {}, versions: this.versions_default};
|
||||||
|
|
||||||
|
this.engine.startService("libraryManager");
|
||||||
|
this.engine.startService("codeRunner");
|
||||||
|
this.engine.startService("web3", {
|
||||||
|
web3: this.web3
|
||||||
|
});
|
||||||
|
this.engine.startService("deployment", {
|
||||||
|
trackContracts: false
|
||||||
|
});
|
||||||
|
this.engine.startService("codeGenerator");
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
Test.prototype.getAccounts = function(cb) {
|
init(callback) {
|
||||||
this.web3.eth.getAccounts(function(err, accounts) {
|
const self = this;
|
||||||
cb(err, accounts);
|
this.engine.contractsManager.build(() => {
|
||||||
});
|
self.builtContracts = cloneDeep(self.engine.contractsManager.contracts);
|
||||||
};
|
callback();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
Test.prototype.deployAll = function(contractsConfig, cb) {
|
onReady(callback) {
|
||||||
var self = this;
|
if (this.ready) {
|
||||||
|
return callback();
|
||||||
async.waterfall([
|
}
|
||||||
function getConfig(callback) {
|
this.events.once('ready', () => {
|
||||||
let _versions_default = self.engine.config.contractsConfig.versions;
|
callback();
|
||||||
self.engine.config.contractsConfig = {contracts: contractsConfig, versions: _versions_default};
|
});
|
||||||
callback();
|
}
|
||||||
|
|
||||||
|
config(options, callback) {
|
||||||
|
if (!callback) {
|
||||||
|
callback = function () {
|
||||||
|
};
|
||||||
|
}
|
||||||
|
if (!options.contracts) {
|
||||||
|
throw new Error(__('No contracts specified in the options'));
|
||||||
|
}
|
||||||
|
this.options = utils.recursiveMerge(this.options, options);
|
||||||
|
this.simOptions = this.options.simulatorOptions || {};
|
||||||
|
this.ready = false;
|
||||||
|
|
||||||
|
// Reset contracts
|
||||||
|
this.engine.contractsManager.contracts = cloneDeep(this.builtContracts);
|
||||||
|
|
||||||
|
this._deploy(options, (err, accounts) => {
|
||||||
|
this.ready = true;
|
||||||
|
this.events.emit('ready');
|
||||||
|
if (err) {
|
||||||
|
console.error(err.red);
|
||||||
|
return callback(err);
|
||||||
|
}
|
||||||
|
callback(null, accounts);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
_deploy(config, callback) {
|
||||||
|
const self = this;
|
||||||
|
async.waterfall([
|
||||||
|
function getConfig(next) {
|
||||||
|
self.engine.config.contractsConfig = {contracts: config.contracts, versions: self.versions_default};
|
||||||
|
self.engine.events.emit(constants.events.contractConfigChanged, self.engine.config.contractsConfig);
|
||||||
|
next();
|
||||||
},
|
},
|
||||||
function startServices(callback) {
|
function deploy(next) {
|
||||||
//{abiType: 'contracts', embarkJS: false}
|
|
||||||
self.engine.startService("libraryManager");
|
|
||||||
self.engine.startService("codeRunner");
|
|
||||||
self.engine.startService("web3", {
|
|
||||||
web3: self.web3
|
|
||||||
});
|
|
||||||
self.engine.startService("deployment", {
|
|
||||||
trackContracts: false
|
|
||||||
});
|
|
||||||
self.engine.startService("codeGenerator");
|
|
||||||
callback();
|
|
||||||
},
|
|
||||||
function deploy(callback) {
|
|
||||||
self.engine.events.on('code-generator-ready', function () {
|
|
||||||
self.engine.events.request('code-contracts-vanila', function(vanillaABI) {
|
|
||||||
callback(null, vanillaABI);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
self.engine.deployManager.gasLimit = 6000000;
|
self.engine.deployManager.gasLimit = 6000000;
|
||||||
self.engine.contractsManager.gasLimit = 6000000;
|
self.engine.contractsManager.gasLimit = 6000000;
|
||||||
self.engine.deployManager.fatalErrors = true;
|
self.engine.deployManager.fatalErrors = true;
|
||||||
self.engine.deployManager.deployOnlyOnConfig = true;
|
self.engine.deployManager.deployOnlyOnConfig = true;
|
||||||
self.engine.events.request('deploy:contracts', function(err) {
|
self.engine.events.request('deploy:contracts', next);
|
||||||
|
},
|
||||||
|
function getAccounts(next) {
|
||||||
|
self.web3.eth.getAccounts(function (err, accounts) {
|
||||||
if (err) {
|
if (err) {
|
||||||
callback(err);
|
return next(err);
|
||||||
}
|
}
|
||||||
|
self.accounts = accounts;
|
||||||
|
self.web3.eth.defaultAccount = accounts[0];
|
||||||
|
next();
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
function createContractObject(next) {
|
||||||
|
async.each(Object.keys(self.engine.contractsManager.contracts), (contractName, eachCb) => {
|
||||||
|
const contract = self.engine.contractsManager.contracts[contractName];
|
||||||
|
if (!self.contracts[contractName]) {
|
||||||
|
self.contracts[contractName] = {};
|
||||||
|
}
|
||||||
|
Object.assign(self.contracts[contractName], new self.web3.eth.Contract(contract.abiDefinition, contract.deployedAddress,
|
||||||
|
{from: self.web3.eth.defaultAccount, gas: 6000000}));
|
||||||
|
eachCb();
|
||||||
|
}, next);
|
||||||
}
|
}
|
||||||
], function(err, result) {
|
], function (err) {
|
||||||
if (err) {
|
|
||||||
console.log(__('terminating due to error'));
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
// this should be part of the waterfall and not just something done at the
|
|
||||||
// end
|
|
||||||
self.web3.eth.getAccounts(function(err, accounts) {
|
|
||||||
if (err) {
|
if (err) {
|
||||||
throw new Error(err);
|
console.log(__('terminating due to error'));
|
||||||
|
return callback(err);
|
||||||
}
|
}
|
||||||
self.web3.eth.defaultAccount = accounts[0];
|
callback();
|
||||||
self.engine.events.request('runcode:eval', result);
|
|
||||||
//cb();
|
|
||||||
cb(accounts);
|
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
};
|
|
||||||
|
require(module) {
|
||||||
|
if (module.startsWith('Embark/contracts/')) {
|
||||||
|
const contractName = module.substr(17);
|
||||||
|
if (this.contracts[contractName]) {
|
||||||
|
return this.contracts[contractName];
|
||||||
|
}
|
||||||
|
let contract = this.engine.contractsManager.contracts[contractName];
|
||||||
|
if (!contract) {
|
||||||
|
const contractNames = Object.keys(this.engine.contractsManager.contracts);
|
||||||
|
// It is probably an instanceof
|
||||||
|
contractNames.find(contrName => {
|
||||||
|
// Find a contract with a similar name
|
||||||
|
if (contractName.indexOf(contrName) > -1) {
|
||||||
|
contract = this.engine.contractsManager.contracts[contrName];
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
// If still nothing, assign bogus one, we will redefine it anyway on deploy
|
||||||
|
if (!contract) {
|
||||||
|
console.warn(__('Could not recognize the contract name "%s"'));
|
||||||
|
console.warn(__('If it is an instance of another contract, it will be reassigned on deploy'));
|
||||||
|
console.warn(__('Otherwise, you can rename the contract to contain the parent contract in the name eg: Token2 for Token'));
|
||||||
|
contract = this.engine.contractsManager.contracts[contractNames[0]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.contracts[contractName] = new this.web3.eth.Contract(contract.abiDefinition, contract.address,
|
||||||
|
{from: this.web3.eth.defaultAccount, gas: 6000000});
|
||||||
|
return this.contracts[contractName];
|
||||||
|
}
|
||||||
|
throw new Error(__('Unknown module %s', module));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = Test;
|
module.exports = Test;
|
||||||
|
|
|
@ -11,7 +11,7 @@ class TestLogger {
|
||||||
|
|
||||||
logFunction() {
|
logFunction() {
|
||||||
this.logs.push(arguments);
|
this.logs.push(arguments);
|
||||||
//console.dir(arguments[0]);
|
// console.log(...arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
contractsState() {
|
contractsState() {
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -33,6 +33,7 @@
|
||||||
"bip39": "^2.5.0",
|
"bip39": "^2.5.0",
|
||||||
"blessed": "^0.1.81",
|
"blessed": "^0.1.81",
|
||||||
"chokidar": "^2.0.3",
|
"chokidar": "^2.0.3",
|
||||||
|
"clone-deep": "^4.0.0",
|
||||||
"colors": "^1.1.2",
|
"colors": "^1.1.2",
|
||||||
"commander": "^2.15.1",
|
"commander": "^2.15.1",
|
||||||
"css-loader": "^0.28.11",
|
"css-loader": "^0.28.11",
|
||||||
|
@ -40,12 +41,12 @@
|
||||||
"ejs": "^2.5.8",
|
"ejs": "^2.5.8",
|
||||||
"eth-ens-namehash": "^2.0.8",
|
"eth-ens-namehash": "^2.0.8",
|
||||||
"eth-lib": "^0.2.8",
|
"eth-lib": "^0.2.8",
|
||||||
"ethereumjs-testrpc": "^6.0.3",
|
|
||||||
"ethereumjs-wallet": "^0.6.0",
|
"ethereumjs-wallet": "^0.6.0",
|
||||||
"file-loader": "^1.1.5",
|
"file-loader": "^1.1.5",
|
||||||
"finalhandler": "^1.1.1",
|
"finalhandler": "^1.1.1",
|
||||||
"follow-redirects": "^1.2.4",
|
"follow-redirects": "^1.2.4",
|
||||||
"fs-extra": "^2.0.0",
|
"fs-extra": "^2.0.0",
|
||||||
|
"ganache-cli": "^6.1.0",
|
||||||
"globule": "^1.1.0",
|
"globule": "^1.1.0",
|
||||||
"hard-source-webpack-plugin": "^0.6.6",
|
"hard-source-webpack-plugin": "^0.6.6",
|
||||||
"http-shutdown": "^1.2.0",
|
"http-shutdown": "^1.2.0",
|
||||||
|
|
|
@ -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,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,87 +1,82 @@
|
||||||
|
/*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]
|
||||||
},
|
},
|
||||||
"Token": {
|
MyToken: {
|
||||||
},
|
instanceOf: "Token"
|
||||||
"SimpleStorage": {
|
},
|
||||||
args: [100]
|
MyToken2: {
|
||||||
},
|
instanceOf: "Token",
|
||||||
"AnotherStorage": {
|
args: [2000]
|
||||||
args: ["$SimpleStorage"]
|
},
|
||||||
},
|
AlreadyDeployedToken: {
|
||||||
"Token": {
|
address: "0xCAFECAFECAFECAFECAFECAFECAFECAFECAFECAFE",
|
||||||
deploy: false,
|
instanceOf: "Token"
|
||||||
args: [1000]
|
},
|
||||||
},
|
Test: {
|
||||||
"MyToken": {
|
onDeploy: ["Test.methods.changeAddress('$MyToken').send()"]
|
||||||
instanceOf: "Token"
|
},
|
||||||
},
|
ContractArgs: {
|
||||||
"MyToken2": {
|
args: {
|
||||||
instanceOf: "Token",
|
initialValue: 123,
|
||||||
args: [2000]
|
_addresses: ["$MyToken2", "$SimpleStorage"]
|
||||||
},
|
|
||||||
"AlreadyDeployedToken": {
|
|
||||||
"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);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -89,7 +89,7 @@
|
||||||
"dom-helpers": {
|
"dom-helpers": {
|
||||||
"version": "3.3.1",
|
"version": "3.3.1",
|
||||||
"resolved": "https://registry.npmjs.org/dom-helpers/-/dom-helpers-3.3.1.tgz",
|
"resolved": "https://registry.npmjs.org/dom-helpers/-/dom-helpers-3.3.1.tgz",
|
||||||
"integrity": "sha512-2Sm+JaYn74OiTM2wHvxJOo3roiq/h25Yi69Fqk269cNUwIXsCvATB6CRSFC9Am/20G2b28hGv/+7NiWydIrPvg=="
|
"integrity": "sha1-/BpOFf/fYN3eA6SAqcD+zoId1KY="
|
||||||
},
|
},
|
||||||
"dotenv": {
|
"dotenv": {
|
||||||
"version": "4.0.0",
|
"version": "4.0.0",
|
||||||
|
@ -229,7 +229,7 @@
|
||||||
"node-fetch": {
|
"node-fetch": {
|
||||||
"version": "1.7.3",
|
"version": "1.7.3",
|
||||||
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-1.7.3.tgz",
|
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-1.7.3.tgz",
|
||||||
"integrity": "sha512-NhZ4CsKx7cYm2vSrBAr2PvFOe6sWDf0UYLRqA6svUYg7+/TSfVAu49jYC4BvQ4Sms9SZgdqGBgroqfDhJdTyKQ==",
|
"integrity": "sha1-mA9vcthSEaU0fGsrwYxbhMPrR+8=",
|
||||||
"requires": {
|
"requires": {
|
||||||
"encoding": "0.1.12",
|
"encoding": "0.1.12",
|
||||||
"is-stream": "1.1.0"
|
"is-stream": "1.1.0"
|
||||||
|
@ -252,7 +252,7 @@
|
||||||
"promise": {
|
"promise": {
|
||||||
"version": "7.3.1",
|
"version": "7.3.1",
|
||||||
"resolved": "https://registry.npmjs.org/promise/-/promise-7.3.1.tgz",
|
"resolved": "https://registry.npmjs.org/promise/-/promise-7.3.1.tgz",
|
||||||
"integrity": "sha512-nolQXZ/4L+bP/UGlkfaIujX9BKxGwmQ9OT4mOt5yvy8iK1h3wqTEJCijzGANTCCl9nWjY41juyAn2K3Q1hLLTg==",
|
"integrity": "sha1-BktyYCsY+Q8pGSuLG8QY/9Hr078=",
|
||||||
"requires": {
|
"requires": {
|
||||||
"asap": "2.0.6"
|
"asap": "2.0.6"
|
||||||
}
|
}
|
||||||
|
@ -289,7 +289,7 @@
|
||||||
"react-bootstrap": {
|
"react-bootstrap": {
|
||||||
"version": "0.32.1",
|
"version": "0.32.1",
|
||||||
"resolved": "https://registry.npmjs.org/react-bootstrap/-/react-bootstrap-0.32.1.tgz",
|
"resolved": "https://registry.npmjs.org/react-bootstrap/-/react-bootstrap-0.32.1.tgz",
|
||||||
"integrity": "sha512-RbfzKUbsukWsToWqGHfCCyMFq9QQI0TznutdyxyJw6dih2NvIne25Mrssg8LZsprqtPpyQi8bN0L0Fx3fUsL8Q==",
|
"integrity": "sha1-YGJMG0ijnXc+9szmQhpPM+zBZrs=",
|
||||||
"requires": {
|
"requires": {
|
||||||
"babel-runtime": "6.26.0",
|
"babel-runtime": "6.26.0",
|
||||||
"classnames": "2.2.5",
|
"classnames": "2.2.5",
|
||||||
|
@ -319,7 +319,7 @@
|
||||||
"react-overlays": {
|
"react-overlays": {
|
||||||
"version": "0.8.3",
|
"version": "0.8.3",
|
||||||
"resolved": "https://registry.npmjs.org/react-overlays/-/react-overlays-0.8.3.tgz",
|
"resolved": "https://registry.npmjs.org/react-overlays/-/react-overlays-0.8.3.tgz",
|
||||||
"integrity": "sha512-h6GT3jgy90PgctleP39Yu3eK1v9vaJAW73GOA/UbN9dJ7aAN4BTZD6793eI1D5U+ukMk17qiqN/wl3diK1Z5LA==",
|
"integrity": "sha1-+tZe6lskMBzKGSoWn13dsLINOsU=",
|
||||||
"requires": {
|
"requires": {
|
||||||
"classnames": "2.2.5",
|
"classnames": "2.2.5",
|
||||||
"dom-helpers": "3.3.1",
|
"dom-helpers": "3.3.1",
|
||||||
|
@ -353,7 +353,7 @@
|
||||||
"regenerator-runtime": {
|
"regenerator-runtime": {
|
||||||
"version": "0.11.1",
|
"version": "0.11.1",
|
||||||
"resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz",
|
"resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz",
|
||||||
"integrity": "sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg=="
|
"integrity": "sha1-vgWtf5v30i4Fb5cmzuUBf78Z4uk="
|
||||||
},
|
},
|
||||||
"setimmediate": {
|
"setimmediate": {
|
||||||
"version": "1.0.5",
|
"version": "1.0.5",
|
||||||
|
@ -412,7 +412,7 @@
|
||||||
"zeppelin-solidity": {
|
"zeppelin-solidity": {
|
||||||
"version": "1.8.0",
|
"version": "1.8.0",
|
||||||
"resolved": "https://registry.npmjs.org/zeppelin-solidity/-/zeppelin-solidity-1.8.0.tgz",
|
"resolved": "https://registry.npmjs.org/zeppelin-solidity/-/zeppelin-solidity-1.8.0.tgz",
|
||||||
"integrity": "sha512-7Mxq6Y7EES0PSLrRF6v0EVYqBVRRo8hFrr7m3jEs69VbbQ5kpANzizeEdbP1/PWKSOmBOg208qP2vSA0FlzFLA==",
|
"integrity": "sha1-BJ/N59rqn8hSEPjG25+M0auKhTo=",
|
||||||
"requires": {
|
"requires": {
|
||||||
"dotenv": "4.0.0",
|
"dotenv": "4.0.0",
|
||||||
"ethjs-abi": "0.2.1"
|
"ethjs-abi": "0.2.1"
|
||||||
|
|
|
@ -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