Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
describe("artifactor + require", function() {
var Example;
var accounts;
var abi;
var binary;
var network_id;
var artifactor;
var provider = TestRPC.provider();
var web3 = new Web3();
web3.setProvider(provider)
before(function(done) {
web3.version.getNetwork(function(err, id) {
if (err) return done(err);
network_id = id;
done();
});
});
before(function(done) {
this.timeout(10000);
// Compile first
var result = solc.compile(fs.readFileSync("./test/Example.sol", {encoding: "utf8"}), 1);
const assert = require('assert');
const path = require('path');
const ganache = require('ganache-cli');
const BigNumber = require('bignumber.js');
const Web3 = require('web3');
const web3 = new Web3(ganache.provider());
const ProjectList = require(path.resolve(__dirname, '../compiled/ProjectList.json'));
const Project = require(path.resolve(__dirname, '../compiled/Project.json'));
let accounts;
let projectList;
let project;
describe('Project Contract', () => {
// 1. 每次跑单测时需要部署全新的合约实例,起到隔离的作用
beforeEach(async () => {
// 1.1 拿到 ganache 本地测试网络的账号
accounts = await web3.eth.getAccounts();
// 1.2 部署 ProjectList 合约
projectList = await new web3.eth.Contract(JSON.parse(ProjectList.interface))
.deploy({ data: ProjectList.bytecode })
replInstance.displayPrompt()
}
});
}
},
function(contracts){
context.parasol.executeDeployed(contracts)
addressbook.add(contracts);
});
docs(contractDocs)
}
}
if (program.dev || !process.argv.slice(2).length) { // Default argument
if (fs.existsSync("./parasol.js")) {
var provider = ganache.provider(config.dev)
provider.ganache = true;
var web3 = new Web3(provider);
logger.success('Ethereum development network running on port ' + config.dev.port)
web3.eth.getAccounts().then(function(accounts){
replInstance = repl.start({ prompt: 'parasol> '.bold.cyan, useGlobal:true, ignoreUndefined:true, useColors:true });
replInstance.defineCommand('help', {
action: function(){
console.log(literals.dev)
replInstance.displayPrompt()
}
})
replInstance.defineCommand('recompile', {
action: function(){
compile(web3, accounts, "dev")
}
})
);
process.exit(0);
}
let deployerWallet = ethers.Wallet.createRandom();
let solverWallet = ethers.Wallet.createRandom();
let challengerWallet = ethers.Wallet.createRandom();
const accounts = [
{ secretKey: deployerWallet.privateKey, balance: ethers.constants.MaxUint256 },
{ secretKey: solverWallet.privateKey, balance: ethers.constants.MaxUint256 },
{ secretKey: challengerWallet.privateKey, balance: ethers.constants.MaxUint256 },
];
const provider = ganache.provider({ locked: false, accounts: accounts, gasLimit: GAS_LIMIT });
global.provider = provider;
// yes, we need a new Web3Provider. Otherwise we get duplicate events -.-
deployerWallet = deployerWallet.connect(new ethers.providers.Web3Provider(provider));
solverWallet = solverWallet.connect(new ethers.providers.Web3Provider(provider));
challengerWallet = challengerWallet.connect(new ethers.providers.Web3Provider(provider));
// faster unit tests :)
solverWallet.provider.pollingInterval = 30;
challengerWallet.provider.pollingInterval = 30;
const timeout = 10;
const taskPeriod = 100000;
const challengePeriod = 10000;
const bondAmount = 1;
const maxExecutionDepth = 10;
public static createProvider(options?: SandboxOptions) {
const provider = ganache.provider(options);
provider.setMaxListeners(999999); // hide MaxListenersExceededWarning produced by ganache provider.
return provider;
}
const fs = require('fs');
const path = require('path');
const solc = require('solc');
const ganache = require('ganache-cli');
const Web3 = require('web3');
const chalk = require('chalk');
const provider = ganache.provider();
const web3 = new Web3(provider);
// let accounts;
// let myContract;
// let origContract;
// let newContract;
const getAccounts = () => {
return new Promise((resolve, reject) => {
resolve(web3.eth.getAccounts());
});
};
const testDeploy = accounts => {
return new Promise((resolve, reject) => {
let contract = new web3.eth.Contract(JSON.parse(interface))
.deploy({
export async function createNewBlockchain() {
const web3 = new Web3(ganache.provider(), undefined, {
transactionConfirmationBlocks: 1,
});
const accounts = await web3.eth.getAccounts();
return { web3, accounts };
}
before("Create Provider", async function() {
provider = Ganache.provider({seed: "debugger", gasLimit: 7000000});
web3 = new Web3(provider);
});
import * as ganache from 'ganache-cli'
import Web3 from 'web3'
import { Contract } from 'web3/types'
import Voting from '../../src/contracts/voting'
import { VOTING_ABI, ONE_ETHER, ONE_GWEI } from '../../src/constants'
import { Return } from '../../src/@types'
import {
deploy,
readBytecode,
call,
transact,
} from '../../src/helpers'
const provider:any = ganache.provider(),
w3 = new Web3(provider),
toBN = w3.utils.toBN,
marketTokenAddress = '0x931D387731bBbC988B312206c74F77D004D6B84b',
p11rAddress = '0x931D387731bBbC988B312206c74F77D004D6B84b',
reserveAddress = '0x931D387731bBbC988B312206c74F77D004D6B84b',
datatrustAddress = '0x931D387731bBbC988B312206c74F77D004D6B84b',
listingAddress = '0x931D387731bBbC988B312206c74F77D004D6B84b'
let voting:Voting,
accounts:string[],
deployed:Contract
describe('Voting', () => {
beforeAll(async () => {
accounts = await w3.eth.getAccounts()
web3.eth.getAccounts.then(accounts => {
var upstreamNetwork = config.network;
var upstreamConfig = config.networks[upstreamNetwork];
var forkedNetwork = config.network + "-fork";
config.networks[forkedNetwork] = {
network_id: config.network_id,
provider: TestRPC.provider({
fork: config.provider,
unlocked_accounts: accounts
}),
from: config.from
}
config.network = forkedNetwork;
callback();
}).catch(callback);
},