update tests

This commit is contained in:
Iuri Matias 2017-07-08 12:39:53 -04:00
parent 32a2b7c518
commit aa5efab6f9
4 changed files with 33 additions and 7 deletions

View File

@ -5,8 +5,6 @@ class ABIGenerator {
this.storageConfig = options.storageConfig || {}; this.storageConfig = options.storageConfig || {};
this.communicationConfig = options.communicationConfig || {}; this.communicationConfig = options.communicationConfig || {};
this.contractsManager = options.contractsManager; this.contractsManager = options.contractsManager;
this.rpcHost = options.blockchainConfig && options.blockchainConfig.rpcHost;
this.rpcPort = options.blockchainConfig && options.blockchainConfig.rpcPort;
this.plugins = options.plugins; this.plugins = options.plugins;
this.events = options.events; this.events = options.events;
} }

View File

@ -7,10 +7,10 @@ let assert = require('assert');
describe('embark.ABIGenerator', function() { describe('embark.ABIGenerator', function() {
this.timeout(0); this.timeout(0);
describe('#generateProvider', function() { describe('#generateProvider', function() {
let generator = new ABIGenerator({blockchainConfig: {rpcHost: 'somehost', rpcPort: '1234'}, contractsManager: {}}); let generator = new ABIGenerator({contractsConfig: {"dappConnection": [ "$WEB3", "http://somehost:1234" ] }, contractsManager: {}});
it('should generate code to connect to a provider', function() { it('should generate code to connect to a provider', function() {
var providerCode = "\nvar whenEnvIsLoaded = function(cb) {\n if (typeof document !== 'undefined' && document !== null) {\n document.addEventListener('DOMContentLoaded', cb);\n } else {\n cb();\n }\n}\nwhenEnvIsLoaded(function() {\nif (typeof web3 !== 'undefined' && typeof Web3 !== 'undefined') {\n\tweb3 = new Web3(web3.currentProvider);\n} else if (typeof Web3 !== 'undefined') {\n\tweb3 = new Web3(new Web3.providers.HttpProvider(\"http://somehost:1234\"));\n}\nweb3.eth.defaultAccount = web3.eth.accounts[0];\n})" var providerCode = "\nvar whenEnvIsLoaded = function(cb) {\n if (typeof document !== 'undefined' && document !== null) {\n document.addEventListener('DOMContentLoaded', cb);\n } else {\n cb();\n }\n}\nwhenEnvIsLoaded(function() {\nif (typeof web3 !== 'undefined' && typeof Web3 !== 'undefined') {\n\tweb3 = new Web3(web3.currentProvider);\n} else if (typeof Web3 !== 'undefined' && !web3.isConnected()) {\n\tweb3 = new Web3(new Web3.providers.HttpProvider(\"http://somehost:1234\"));\n}\nweb3.eth.defaultAccount = web3.eth.accounts[0];\n})";
assert.equal(generator.generateProvider(), providerCode); assert.equal(generator.generateProvider(), providerCode);
}); });

View File

@ -1,15 +1,16 @@
/*globals describe, it*/ /*globals describe, it*/
let Compiler = require('../lib/contracts/compiler.js'); let Compiler = require('../lib/contracts/compiler.js');
let TestLogger = require('../lib/core/test_logger.js'); let TestLogger = require('../lib/core/test_logger.js');
let File = require('../lib/core/file.js');
let assert = require('assert'); let assert = require('assert');
let fs = require('fs'); let fs = require('fs');
let readFile = function(file) { let readFile = function(file) {
return {filename: file, content: fs.readFileSync(file).toString()}; return new File({filename: file, type: 'dapp_file', path: file});
}; };
describe('embark.Compiler', function() { describe('embark.Compiler', function() {
let compiler = new Compiler({logger: new TestLogger({})}); let compiler = new Compiler({logger: new TestLogger({}), solcVersion: '0.4.11'});
describe('#compile_solidity', function() { describe('#compile_solidity', function() {
this.timeout(0); this.timeout(0);

View File

@ -1,11 +1,12 @@
/*globals describe, it*/ /*globals describe, it*/
let ContractsManager = require('../lib/contracts/contracts.js'); let ContractsManager = require('../lib/contracts/contracts.js');
let Logger = require('../lib/core/logger.js'); let Logger = require('../lib/core/logger.js');
let File = require('../lib/core/file.js');
let assert = require('assert'); let assert = require('assert');
let fs = require('fs'); let fs = require('fs');
let readFile = function(file) { let readFile = function(file) {
return {filename: file, content: fs.readFileSync(file).toString()}; return new File({filename: file, type: 'dapp_file', path: file});
}; };
describe('embark.Contratcs', function() { describe('embark.Contratcs', function() {
@ -17,6 +18,19 @@ describe('embark.Contratcs', function() {
readFile('test/contracts/token.sol') readFile('test/contracts/token.sol')
], ],
contractsConfig: { contractsConfig: {
"versions": {
"web3.js": "0.19.1",
"solc": "0.4.11"
},
"deployment": {
"host": "localhost",
"port": 8545,
"type": "rpc"
},
"dappConnection": [
"$WEB3",
"localhost:8545"
],
"gas": "auto", "gas": "auto",
"contracts": { "contracts": {
"Token": { "Token": {
@ -76,6 +90,19 @@ describe('embark.Contratcs', function() {
readFile('test/contracts/token_storage.sol') readFile('test/contracts/token_storage.sol')
], ],
contractsConfig: { contractsConfig: {
"versions": {
"web3.js": "0.19.1",
"solc": "0.4.11"
},
"deployment": {
"host": "localhost",
"port": 8545,
"type": "rpc"
},
"dappConnection": [
"$WEB3",
"localhost:8545"
],
"gas": "auto", "gas": "auto",
"contracts": { "contracts": {
"TokenStorage": { "TokenStorage": {