wip fixes
This commit is contained in:
parent
962a9c5b11
commit
92c8f00ba8
|
@ -37,12 +37,13 @@ var Blockchain = function(options) {
|
|||
whisper: (this.blockchainConfig.whisper === undefined) || this.blockchainConfig.whisper,
|
||||
maxpeers: ((this.blockchainConfig.maxpeers === 0) ? 0 : (this.blockchainConfig.maxpeers || 25)),
|
||||
bootnodes: this.blockchainConfig.bootnodes || "",
|
||||
rpcApi: (this.blockchainConfig.rpcApi || ['eth', 'web3', 'net', 'debug']),
|
||||
rpcApi: (this.blockchainConfig.rpcApi || ['eth', 'web3', 'net', 'debug', 'pubsub']),
|
||||
wsRPC: (this.blockchainConfig.wsRPC === undefined) || this.blockchainConfig.wsRPC,
|
||||
wsHost: this.blockchainConfig.wsHost || 'localhost',
|
||||
wsPort: this.blockchainConfig.wsPort || 8546,
|
||||
wsOrigins: this.blockchainConfig.wsOrigins || false,
|
||||
wsApi: (this.blockchainConfig.wsApi || ['eth', 'web3', 'net', 'shh', 'debug']),
|
||||
// wsApi: (this.blockchainConfig.wsApi || ['eth', 'web3', 'net', 'shh', 'debug']),
|
||||
wsApi: (this.blockchainConfig.wsApi || ['eth', 'web3', 'net', 'shh', 'debug', 'pubsub']),
|
||||
vmdebug: this.blockchainConfig.vmdebug || false,
|
||||
targetGasLimit: this.blockchainConfig.targetGasLimit || false,
|
||||
syncMode: this.blockchainConfig.syncMode,
|
||||
|
|
|
@ -1,6 +1,12 @@
|
|||
const ProviderEngine = require('embark-web3-provider-engine');
|
||||
const RpcSubprovider = require('embark-web3-provider-engine/subproviders/rpc');
|
||||
const WsSubprovider = require('embark-web3-provider-engine/subproviders/websocket');
|
||||
const CacheSubprovider = require('embark-web3-provider-engine/subproviders/cache.js');
|
||||
const FixtureSubprovider = require('embark-web3-provider-engine/subproviders/fixture.js');
|
||||
const FilterSubprovider = require('embark-web3-provider-engine/subproviders/filters.js');
|
||||
const VmSubprovider = require('embark-web3-provider-engine/subproviders/vm.js');
|
||||
const NonceSubprovider = require('embark-web3-provider-engine/subproviders/nonce-tracker.js');
|
||||
const SubscriptionSubprovider = require('embark-web3-provider-engine/subproviders/subscriptions');
|
||||
const async = require('async');
|
||||
const AccountParser = require('./accountParser');
|
||||
const fundAccount = require('./fundAccount');
|
||||
|
@ -26,11 +32,18 @@ class Provider extends ProviderEngine {
|
|||
startWeb3Provider(callback) {
|
||||
const self = this;
|
||||
|
||||
// cache layer
|
||||
// self.addProvider(new CacheSubprovider())
|
||||
|
||||
// self.addProvider(new NonceSubprovider())
|
||||
|
||||
if (this.type === 'rpc') {
|
||||
self.addProvider(new RpcSubprovider({
|
||||
rpcUrl: self.web3Endpoint
|
||||
}));
|
||||
} else if (this.type === 'ws') {
|
||||
console.log('USing ws');
|
||||
self.addProvider(new SubscriptionSubprovider());
|
||||
self.addProvider(new WsSubprovider({
|
||||
rpcUrl: self.web3Endpoint,
|
||||
origin: this.blockchainConfig.wsOrigins.split(',')[0]
|
||||
|
@ -40,17 +53,19 @@ class Provider extends ProviderEngine {
|
|||
}
|
||||
|
||||
|
||||
|
||||
// network connectivity error
|
||||
self.on('error', (err) => {
|
||||
console.log('ERR', JSON.stringify(err));
|
||||
// report connectivity errors as trace due to polling
|
||||
self.logger.trace('web3 provider error: ', err);
|
||||
self.logger.trace('stopping web3 provider due to error');
|
||||
|
||||
|
||||
// prevent continuous polling errors
|
||||
self.engine.stop();
|
||||
self.stop();
|
||||
});
|
||||
|
||||
self.web3.setProvider(self);
|
||||
self.web3.setProvider(self);
|
||||
self.start();
|
||||
|
||||
self.accounts = AccountParser.parseAccountsConfig(self.accountsConfig, self.web3, self.logger);
|
||||
|
|
|
@ -44,6 +44,7 @@ class Test {
|
|||
}
|
||||
|
||||
initWeb3Provider(callback) {
|
||||
const self = this;
|
||||
if (this.provider) {
|
||||
this.provider.stop();
|
||||
}
|
||||
|
@ -63,13 +64,30 @@ class Test {
|
|||
web3Endpoint: endpoint
|
||||
};
|
||||
console.info(`Connecting to node at ${endpoint}`.cyan);
|
||||
|
||||
return utils.pingEndpoint(host, port, type, protocol, this.engine.config.blockchainConfig.wsOrigins.split(',')[0], (err) => {
|
||||
if (err) {
|
||||
console.error(`Error connecting to the node, there might be an error in ${endpoint}`.red);
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
/*const ProviderEngine = require('embark-web3-provider-engine');
|
||||
const WsSubprovider = require('embark-web3-provider-engine/subproviders/websocket');
|
||||
const SubscriptionSubprovider = require('embark-web3-provider-engine/subproviders/subscriptions');
|
||||
const engine = new ProviderEngine();
|
||||
self.web3 = new Web3(engine);
|
||||
|
||||
engine.addProvider(new SubscriptionSubprovider());
|
||||
engine.addProvider(new WsSubprovider({
|
||||
rpcUrl: endpoint,
|
||||
origin: self.engine.config.blockchainConfig.wsOrigins.split(',')[0]
|
||||
}));
|
||||
|
||||
engine.start();
|
||||
return callback();*/
|
||||
|
||||
this.provider = new Provider(providerOptions);
|
||||
return this.provider.startWeb3Provider(callback);
|
||||
this.provider.startWeb3Provider(callback);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -18,13 +18,13 @@
|
|||
"wsPort": 8546,
|
||||
"proxy": true
|
||||
},
|
||||
"privateNet": {
|
||||
"privatenet": {
|
||||
"enabled": true,
|
||||
"networkType": "custom",
|
||||
"networkId": "1337",
|
||||
"isDev": false,
|
||||
"genesisBlock": "config/privateNet/genesis.json",
|
||||
"datadir": ".embark/privateNet/datadir",
|
||||
"genesisBlock": "config/privatenet/genesis.json",
|
||||
"datadir": ".embark/privatenet/datadir",
|
||||
"mineWhenNeeded": true,
|
||||
"nodiscover": true,
|
||||
"maxpeers": 0,
|
||||
|
@ -32,7 +32,7 @@
|
|||
"rpcPort": 8545,
|
||||
"rpcCorsDomain": "auto",
|
||||
"account": {
|
||||
"password": "config/privateNet/password"
|
||||
"password": "config/privatenet/password"
|
||||
},
|
||||
"targetGasLimit": 8000000,
|
||||
"wsOrigins": "auto",
|
||||
|
@ -67,13 +67,5 @@
|
|||
"account": {
|
||||
"password": "config/livenet/password"
|
||||
}
|
||||
},
|
||||
"privatenet": {
|
||||
"networkType": "custom",
|
||||
"rpcHost": "localhost",
|
||||
"rpcPort": 8545,
|
||||
"datadir": "yourdatadir",
|
||||
"networkId": "123",
|
||||
"bootnodes": ""
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,11 @@ const SimpleStorage = require('Embark/contracts/SimpleStorage');
|
|||
let accounts;
|
||||
|
||||
config({
|
||||
deployment: {
|
||||
type: 'ws',
|
||||
host: 'localhost',
|
||||
port: '8546'
|
||||
},
|
||||
contracts: {
|
||||
"SimpleStorage": {
|
||||
args: [100],
|
||||
|
@ -38,14 +43,20 @@ contract("SimpleStorage", function () {
|
|||
});
|
||||
|
||||
it('listens to events', function (done) {
|
||||
SimpleStorage.once('EventOnSet2', async function(error, _result){
|
||||
assert.strictEqual(error, null);
|
||||
SimpleStorage.once('EventOnSet2', function(error, _result){
|
||||
console.log('error', error);
|
||||
console.log('result', _result);
|
||||
|
||||
/*assert.strictEqual(error, null);
|
||||
let result = await SimpleStorage.methods.get().call();
|
||||
assert.strictEqual(parseInt(result, 10), 150);
|
||||
done();
|
||||
assert.strictEqual(parseInt(result, 10), 150);*/
|
||||
done(error);
|
||||
});
|
||||
|
||||
SimpleStorage.methods.set2(150, 100).send();
|
||||
console.log('TEST');
|
||||
SimpleStorage.methods.set2(150, 100).send(() => {
|
||||
console.log('Done');
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue