Skip to content

Commit

Permalink
Use ganache accounts for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
elenadimitrova committed Jul 28, 2020
1 parent 0526249 commit 487030b
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 65 deletions.
2 changes: 1 addition & 1 deletion deployment/999_benchmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class Benchmark {
this.accounts = this.signers.map((s) => s._address);
this.config = config;

this.testManager = new TestManager(this.accounts);
this.testManager = new TestManager();

this.GuardianManagerWrapper = await this.deployer.wrapDeployedContract(GuardianManager, config.modules.GuardianManager);
this.LockManagerWrapper = await this.deployer.wrapDeployedContract(LockManager, config.modules.LockManager);
Expand Down
32 changes: 0 additions & 32 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,11 @@
"@uniswap/v2-core": "^1.0.1",
"ajv": "^6.10.0",
"aws-sdk": "^2.521.0",
"bip39": "^3.0.2",
"bn-chai": "^1.0.1",
"bn.js": "^5.1.1",
"chai": "^4.2.0",
"cli-table2": "^0.2.0",
"dotenv": "^6.2.0",
"ethereumjs-wallet": "^0.6.3",
"etherlime-argent": "2.3.5",
"etherlime-lib": "1.1.3",
"ethers": "^4.0.28",
Expand Down
2 changes: 1 addition & 1 deletion test/recoveryManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const WRONG_SIGNATURE_NUMBER_REVERT_MSG = "RM: Wrong number of signatures";
const INVALID_SIGNATURES_REVERT_MSG = "RM: Invalid signatures";

contract("RecoveryManager", (accounts) => {
const manager = new TestManager(accounts);
const manager = new TestManager();

const owner = accounts[1].signer;
const guardian1 = accounts[2].signer;
Expand Down
30 changes: 1 addition & 29 deletions utils/test-manager.js
Original file line number Diff line number Diff line change
@@ -1,43 +1,15 @@
const etherlime = require("etherlime-lib");
const ethers = require("ethers");
const ps = require("ps-node");
const hdkey = require("ethereumjs-wallet/hdkey");
const bip39 = require("bip39");
const { signOffchain, bigNumberify, ETH_TOKEN } = require("./utilities.js");

const USE_ETHERLIME_GANACHE_MNEMONIC = true;

// this is the same mnemonic as that used by ganache-cli --deterministic
// this mnemonic will not be used if `USE_ETHERLIME_GANACHE_MNEMONIC` is set to `true`
const MNEMONIC = "myth like bonus scare over problem client lizard pioneer submit female collect";

class TestManager {
constructor(_accounts = null, network = "ganache", deployer) {
constructor(network = "ganache", deployer) {
this.network = network;
this.accounts = _accounts || this.loadAccounts();
global.accounts = this.accounts;
this.deployer = deployer || this.newDeployer();
this.provider = this.deployer.provider;
}

loadAccounts() { // eslint-disable-line class-methods-use-this
if (USE_ETHERLIME_GANACHE_MNEMONIC) return global.accounts;

// ignore (global) accounts loaded from cli-commands/ganache/setup.json
// and instead generate accounts matching those used by ganache-cli in determistic mode
const hdWallet = hdkey.fromMasterSeed(bip39.mnemonicToSeedSync(MNEMONIC));
const localNodeProvider = new ethers.providers.JsonRpcProvider("http://localhost:8545");
const accounts = [];
for (let i = 0; i < 10; i += 1) {
const privKey = hdWallet.derivePath(`m/44'/60'/0'/0/${i}`).getWallet().getPrivateKeyString();
accounts.push({
secretKey: privKey,
signer: new ethers.Wallet(privKey, localNodeProvider),
});
}
return accounts;
}

newDeployer() {
const defaultConfigs = {
gasLimit: bigNumberify(20700000),
Expand Down

0 comments on commit 487030b

Please sign in to comment.