2016-10-15 19:54:19 +00:00
|
|
|
/*globals describe, it*/
|
2018-04-17 19:07:00 +00:00
|
|
|
const Config = require('../lib/core/config.js');
|
|
|
|
const Plugins = require('../lib/core/plugins.js');
|
|
|
|
const assert = require('assert');
|
2018-10-18 12:37:28 +00:00
|
|
|
const TestLogger = require('../lib/utils/test_logger');
|
2018-04-30 05:56:43 +00:00
|
|
|
const Events = require('../lib/core/events');
|
2016-10-15 19:54:19 +00:00
|
|
|
|
2018-04-17 19:07:00 +00:00
|
|
|
describe('embark.Config', function () {
|
2017-03-29 15:37:30 +00:00
|
|
|
let config = new Config({
|
2016-10-15 19:54:19 +00:00
|
|
|
env: 'myenv',
|
2018-04-30 05:56:43 +00:00
|
|
|
configDir: './test/test1/config/',
|
|
|
|
events: new Events()
|
2016-10-15 19:54:19 +00:00
|
|
|
});
|
2017-01-29 06:28:01 +00:00
|
|
|
config.plugins = new Plugins({plugins: {}});
|
2018-04-17 19:07:00 +00:00
|
|
|
config.logger = new TestLogger({});
|
2016-10-15 19:54:19 +00:00
|
|
|
|
2018-04-17 19:07:00 +00:00
|
|
|
describe('#loadBlockchainConfigFile', function () {
|
|
|
|
it('should load blockchain config correctly', function () {
|
2016-10-15 19:54:19 +00:00
|
|
|
config.loadBlockchainConfigFile();
|
2017-03-29 15:37:30 +00:00
|
|
|
let expectedConfig = {
|
2017-03-01 04:40:40 +00:00
|
|
|
"enabled": true,
|
2016-10-15 19:54:19 +00:00
|
|
|
"networkType": "custom",
|
|
|
|
"genesisBlock": "config/development/genesis.json",
|
|
|
|
"datadir": ".embark/development/datadir",
|
2018-06-27 18:44:01 +00:00
|
|
|
"isDev": false,
|
2016-10-15 19:54:19 +00:00
|
|
|
"mineWhenNeeded": true,
|
|
|
|
"nodiscover": true,
|
2018-11-06 19:31:52 +00:00
|
|
|
"proxy": true,
|
2016-10-15 19:54:19 +00:00
|
|
|
"rpcHost": "localhost",
|
|
|
|
"rpcPort": 8545,
|
|
|
|
"rpcCorsDomain": "http://localhost:8000",
|
2018-04-30 12:07:37 +00:00
|
|
|
"wsOrigins": "auto",
|
2016-10-15 19:54:19 +00:00
|
|
|
"account": {
|
|
|
|
"password": "config/development/password"
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
assert.deepEqual(config.blockchainConfig, expectedConfig);
|
|
|
|
});
|
2018-09-25 09:27:41 +00:00
|
|
|
|
|
|
|
it('should convert Ether units', function () {
|
|
|
|
let expectedConfig = {
|
|
|
|
"enabled": true,
|
|
|
|
"networkType": "custom",
|
|
|
|
"genesisBlock": "config/development/genesis.json",
|
|
|
|
"datadir": ".embark/development/datadir",
|
|
|
|
"isDev": false,
|
|
|
|
"targetGasLimit": "300000",
|
|
|
|
"gasPrice": "8000000",
|
|
|
|
"mineWhenNeeded": true,
|
|
|
|
"nodiscover": true,
|
2018-11-06 19:31:52 +00:00
|
|
|
"proxy": true,
|
2018-09-25 09:27:41 +00:00
|
|
|
"rpcHost": "localhost",
|
|
|
|
"rpcPort": 8545,
|
|
|
|
"rpcCorsDomain": "http://localhost:8000",
|
|
|
|
"wsOrigins": "auto",
|
|
|
|
"account": {
|
|
|
|
"password": "config/development/password",
|
|
|
|
"balance": "3000000000000000000"
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
let config = new Config({
|
|
|
|
env: 'unitenv',
|
|
|
|
configDir: './test/test1/config/',
|
|
|
|
events: new Events()
|
|
|
|
});
|
|
|
|
config.plugins = new Plugins({plugins: {}});
|
|
|
|
config.logger = new TestLogger({});
|
|
|
|
config.loadBlockchainConfigFile();
|
|
|
|
|
|
|
|
assert.deepEqual(config.blockchainConfig, expectedConfig);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should accept unitless gas values', function () {
|
|
|
|
let expectedConfig = {
|
|
|
|
"enabled": true,
|
|
|
|
"networkType": "custom",
|
|
|
|
"genesisBlock": "config/development/genesis.json",
|
|
|
|
"datadir": ".embark/development/datadir",
|
|
|
|
"isDev": false,
|
|
|
|
"targetGasLimit": "20000000",
|
|
|
|
"gasPrice": "8000000",
|
|
|
|
"mineWhenNeeded": true,
|
|
|
|
"nodiscover": true,
|
2018-11-06 19:31:52 +00:00
|
|
|
"proxy": true,
|
2018-09-25 09:27:41 +00:00
|
|
|
"rpcHost": "localhost",
|
|
|
|
"rpcPort": 8545,
|
|
|
|
"rpcCorsDomain": "http://localhost:8000",
|
|
|
|
"wsOrigins": "auto",
|
|
|
|
"account": {
|
|
|
|
"password": "config/development/password",
|
|
|
|
"balance": "3000000000000000000"
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
let config = new Config({
|
|
|
|
env: 'unitlessenv',
|
|
|
|
configDir: './test/test1/config/',
|
|
|
|
events: new Events()
|
|
|
|
});
|
|
|
|
config.plugins = new Plugins({plugins: {}});
|
|
|
|
config.logger = new TestLogger({});
|
|
|
|
config.loadBlockchainConfigFile();
|
|
|
|
|
|
|
|
assert.deepEqual(config.blockchainConfig, expectedConfig);
|
|
|
|
});
|
2016-10-15 19:54:19 +00:00
|
|
|
});
|
|
|
|
|
2018-04-17 19:07:00 +00:00
|
|
|
describe('#loadContractsConfigFile', function () {
|
|
|
|
it('should load contract config correctly', function () {
|
|
|
|
config.loadContractsConfigFile();
|
|
|
|
let expectedConfig = {
|
2018-10-29 16:28:49 +00:00
|
|
|
versions: {'web3': '1.0.0-beta', solc: '0.4.25'},
|
2018-09-25 09:27:41 +00:00
|
|
|
deployment: {host: 'localhost', port: 8545, type: 'rpc', "accounts": [{"mnemonic": "12 word mnemonic", "balance": "5000000000"}]},
|
2018-04-17 19:07:00 +00:00
|
|
|
dappConnection: ['$WEB3', 'localhost:8545'],
|
2018-09-25 09:27:41 +00:00
|
|
|
"gas": "400000",
|
2018-04-17 19:07:00 +00:00
|
|
|
"contracts": {
|
|
|
|
"SimpleStorage": {
|
|
|
|
"args": [100],
|
2018-09-25 09:27:41 +00:00
|
|
|
"gas": "123000",
|
|
|
|
"gasPrice": "1000"
|
2018-04-17 19:07:00 +00:00
|
|
|
},
|
|
|
|
"Token": {
|
|
|
|
"args": [200]
|
2016-10-15 19:54:19 +00:00
|
|
|
}
|
2018-04-17 19:07:00 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
assert.deepEqual(config.contractsConfig, expectedConfig);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2018-04-18 13:07:39 +00:00
|
|
|
describe('#loadExternalContractsFiles', function () {
|
2018-04-18 16:09:42 +00:00
|
|
|
it('should create the right list of files and download', function () {
|
2018-04-18 13:07:39 +00:00
|
|
|
config.contractsFiles = [];
|
|
|
|
config.contractsConfig.contracts = [
|
|
|
|
{
|
|
|
|
file: 'https://github.com/embark-framework/embark/blob/master/test_app/app/contracts/simple_storage.sol'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
file: 'github.com/status-im/contracts/contracts/identity/ERC725.sol'
|
|
|
|
}
|
|
|
|
];
|
2018-04-18 16:09:42 +00:00
|
|
|
const expected = [
|
|
|
|
{
|
2018-04-19 19:13:41 +00:00
|
|
|
"filename": ".embark/contracts/embark-framework/embark/master/test_app/app/contracts/simple_storage.sol",
|
2018-04-18 16:09:42 +00:00
|
|
|
"type": "http",
|
|
|
|
"path": "https://raw.githubusercontent.com/embark-framework/embark/master/test_app/app/contracts/simple_storage.sol",
|
2018-10-02 10:32:54 +00:00
|
|
|
"pluginPath": '',
|
|
|
|
"importRemappings": [],
|
2018-04-18 16:09:42 +00:00
|
|
|
"basedir": "",
|
2018-09-14 16:00:04 +00:00
|
|
|
"resolver": undefined,
|
2018-09-14 12:12:47 +00:00
|
|
|
"downloadedImports": false,
|
|
|
|
"storageConfig": null,
|
|
|
|
"ipfsUrl": null
|
2018-04-18 16:09:42 +00:00
|
|
|
},
|
|
|
|
{
|
2018-04-19 19:13:41 +00:00
|
|
|
"filename": ".embark/contracts/status-im/contracts/master/contracts/identity/ERC725.sol",
|
2018-04-18 16:09:42 +00:00
|
|
|
"type": "http",
|
|
|
|
"path": "https://raw.githubusercontent.com/status-im/contracts/master/contracts/identity/ERC725.sol",
|
2018-10-02 10:32:54 +00:00
|
|
|
"pluginPath": '',
|
|
|
|
"importRemappings": [],
|
2018-04-18 16:09:42 +00:00
|
|
|
"basedir": "",
|
2018-09-14 16:00:04 +00:00
|
|
|
"resolver": undefined,
|
2018-09-14 12:12:47 +00:00
|
|
|
"downloadedImports": false,
|
|
|
|
"storageConfig": null,
|
|
|
|
"ipfsUrl": null
|
2018-04-18 16:09:42 +00:00
|
|
|
}
|
|
|
|
];
|
|
|
|
config.loadExternalContractsFiles();
|
|
|
|
assert.deepEqual(config.contractsFiles, expected);
|
2018-04-18 13:07:39 +00:00
|
|
|
});
|
|
|
|
});
|
2016-10-15 19:54:19 +00:00
|
|
|
});
|