embark/lib/test.js

35 lines
971 B
JavaScript
Raw Normal View History

2016-05-23 16:00:54 -04:00
try {
var ethersim = require('ethersim');
} catch(e) {
var ethersim = false;
}
2015-10-09 10:57:30 -04:00
var web3 = require('web3');
Test = function(contractFiles, blockchainFile, contractFile, _env) {
2016-05-23 16:00:54 -04:00
if (ethersim === false) {
console.log('EtherSim not found; Please install it with "npm install ethersim --save"');
console.log('For more information see https://github.com/iurimatias/ethersim');
exit();
}
2015-10-12 10:50:52 -04:00
this.env = _env || 'development';
this.web3 = web3;
this.web3.setProvider(ethersim.web3Provider());
this.contractFiles = contractFiles;
2015-10-09 10:57:30 -04:00
2015-10-12 10:50:52 -04:00
Embark.init(this.web3);
Embark.blockchainConfig.loadConfigFile(blockchainFile);
Embark.contractsConfig.loadConfigFile(contractFile);
2015-10-09 10:57:30 -04:00
2015-10-12 10:50:52 -04:00
Embark.contractsConfig.init(this.contractFiles, this.env);
}
2015-10-09 10:57:30 -04:00
2015-10-12 10:50:52 -04:00
Test.prototype.deployAll = function(cb) {
Embark.deployContracts('development', this.contractFiles, "/tmp/abi.js", "chains.json", false, false, function(abi) {
2015-10-09 10:57:30 -04:00
eval(abi);
cb();
});
}
module.exports = Test;