From aa5efab6f9446f626d5dd45a8b993d8c85f23495 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Sat, 8 Jul 2017 12:39:53 -0400 Subject: [PATCH] update tests --- lib/contracts/abi.js | 2 -- test/abi.js | 4 ++-- test/compiler.js | 5 +++-- test/contracts.js | 29 ++++++++++++++++++++++++++++- 4 files changed, 33 insertions(+), 7 deletions(-) diff --git a/lib/contracts/abi.js b/lib/contracts/abi.js index 5bc53a5c..7ec51da3 100644 --- a/lib/contracts/abi.js +++ b/lib/contracts/abi.js @@ -5,8 +5,6 @@ class ABIGenerator { this.storageConfig = options.storageConfig || {}; this.communicationConfig = options.communicationConfig || {}; this.contractsManager = options.contractsManager; - this.rpcHost = options.blockchainConfig && options.blockchainConfig.rpcHost; - this.rpcPort = options.blockchainConfig && options.blockchainConfig.rpcPort; this.plugins = options.plugins; this.events = options.events; } diff --git a/test/abi.js b/test/abi.js index c542a1bd..c0b3d94f 100644 --- a/test/abi.js +++ b/test/abi.js @@ -7,10 +7,10 @@ let assert = require('assert'); describe('embark.ABIGenerator', function() { this.timeout(0); 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() { - 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); }); diff --git a/test/compiler.js b/test/compiler.js index c829b09e..c492eada 100644 --- a/test/compiler.js +++ b/test/compiler.js @@ -1,15 +1,16 @@ /*globals describe, it*/ let Compiler = require('../lib/contracts/compiler.js'); let TestLogger = require('../lib/core/test_logger.js'); +let File = require('../lib/core/file.js'); let assert = require('assert'); let fs = require('fs'); 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() { - let compiler = new Compiler({logger: new TestLogger({})}); + let compiler = new Compiler({logger: new TestLogger({}), solcVersion: '0.4.11'}); describe('#compile_solidity', function() { this.timeout(0); diff --git a/test/contracts.js b/test/contracts.js index 211eabe5..1679e326 100644 --- a/test/contracts.js +++ b/test/contracts.js @@ -1,11 +1,12 @@ /*globals describe, it*/ let ContractsManager = require('../lib/contracts/contracts.js'); let Logger = require('../lib/core/logger.js'); +let File = require('../lib/core/file.js'); let assert = require('assert'); let fs = require('fs'); 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() { @@ -17,6 +18,19 @@ describe('embark.Contratcs', function() { readFile('test/contracts/token.sol') ], contractsConfig: { + "versions": { + "web3.js": "0.19.1", + "solc": "0.4.11" + }, + "deployment": { + "host": "localhost", + "port": 8545, + "type": "rpc" + }, + "dappConnection": [ + "$WEB3", + "localhost:8545" + ], "gas": "auto", "contracts": { "Token": { @@ -76,6 +90,19 @@ describe('embark.Contratcs', function() { readFile('test/contracts/token_storage.sol') ], contractsConfig: { + "versions": { + "web3.js": "0.19.1", + "solc": "0.4.11" + }, + "deployment": { + "host": "localhost", + "port": 8545, + "type": "rpc" + }, + "dappConnection": [ + "$WEB3", + "localhost:8545" + ], "gas": "auto", "contracts": { "TokenStorage": {