Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
startTestnet() {
log('> Starting testnet...')
ganache.server({
accounts: config.accounts,
// debug: true,
// logger: console,
// verbose: true,
})
.listen(config.portTestnet, (err) => {
if (err) {
log('Error starting Ganache:', err)
process.exit(1)
}
})
},
for (let i = 0; i < web3.eth.accounts.wallet.length; i++) {
ganacheAccounts.push({
balance: '0x100000000000000000000',
secretKey: web3.eth.accounts.wallet[i].privateKey,
})
}
// For all provider options, see: https://github.com/trufflesuite/ganache-cli#library
const providerOptions = {
accounts: ganacheAccounts,
gasLimit: '0x7A1200',
locked: false,
logger: { log },
}
// If we are given an HttpProvider, use a ganache server instead of as a local library
if (config.testHttpProviderPort !== undefined) {
es.ganacheServer = ganache.server(providerOptions)
await _startGanacheServer(es.ganacheServer, config.testHttpProviderPort)
web3.setProvider(
new Web3.providers.HttpProvider(
'http://localhost:' + config.testHttpProviderPort
)
)
} else {
// No port given, so run as local library
web3.setProvider(ganache.provider(providerOptions))
web3.currentProvider.setMaxListeners(300) // TODO: Remove this as it is squashing errors. See https://github.com/ethereum/web3.js/issues/1648
}
}
import * as testrpc from 'ganache-cli';
import * as _ from 'lodash';
import { constants } from '../src/utils/constants';
import { utils } from '../src/utils/utils';
const opts = {
accounts: constants.TESTRPC_ACCOUNTS,
logger: console,
};
const server = testrpc.server(opts);
server.listen(constants.TESTRPC_PORT, (err: any, result: any) => {
if (err) {
utils.consoleLog(err);
return;
}
const state = result ? result : server.provider.manager.state;
utils.consoleLog('');
utils.consoleLog('Available Accounts');
utils.consoleLog('==================');
const accounts = state.accounts;
const addresses = _.keys(accounts);
before(async () => {
ganache = Ganache.server({
gasLimit: 6700000,
total_accounts: 10,
});
ganache.listen(8545, '127.0.0.1');
web3 = new Web3('http://localhost:8545');
accounts = await web3.eth.getAccounts();
adminProject1 = accounts[2];
adminProject2 = accounts[3];
const deployment = await deployLP(web3);
giver1 = deployment.giver1;
vault = deployment.vault;
liquidPledging = deployment.liquidPledging;
liquidPledgingState = deployment.liquidPledgingState;
beforeEach(() => {
server = ganache.server()
server.listen(9000)
ganacheOptions = server.ganacheProvider.options
})
constructor(options: GanacheOptions) {
super();
this._config = options;
this._port = options.port || 8545;
this._ganache = ganache.server(this._config);
this._ganache.on('error', err => this.emit('error', err.message));
}
get listening(): boolean {
beforeAll(() => {
server = ganache.server({
ws:true,
accounts: users,
})
server.listen(8555)
provider = new Web3.providers.WebsocketProvider('ws://localhost:8555')
web3 = new Web3(provider)
})
module.exports = function ({ unlockedAccounts }) {
const ganache = require("ganache-cli");
const server = ganache.server({
fork: process.env.GANACHE_FORK_URL,
unlocked_accounts: unlockedAccounts,
hardfork: 'constantinople',
network_id: 999
});
return new Promise((resolve, reject) => {
server.listen('8546', function(err, blockchain) {
if (err) { reject(err) }
if (blockchain) { resolve(blockchain) }
})
})
}
const run = (inPort, inLogger, forkParams, gasPrice, gasLimit, mnemonic, generate, networkId, unlock, secure) => {
if (mnemonic && generate) {
generateAccounts(mnemonic, generate);
}
if (typeof unlock == "string") {
unlock = [unlock];
}
port = (inPort) ? inPort : setup.defaultPort;
fork = (forkParams) ? forkParams : setup.forkParams;
gasPrice = (gasPrice) ? ethers.utils.hexlify(gasPrice) : setup.gasPrice;
gasLimit = (gasLimit) ? ethers.utils.hexlify(gasLimit) : setup.gasLimit;
const server = ganache.server({
accounts: setup.accounts,
logger: inLogger,
fork,
gasPrice,
gasLimit,
network_id: networkId,
unlocked_accounts: unlock,
secure: secure
});
server.listen(port, ganacheServerListenCallback);
};
const ganacheServerListenCallback = (err, blockchain) => {
beforeAll(() => {
server = ganache.server({ws:true})
server.listen(8559)
provider = new Web3.providers.WebsocketProvider('ws://localhost:8559')
web3 = new Web3(provider)
})