From 90312600b2fb703dff6529c00a324dd9ab71e54a Mon Sep 17 00:00:00 2001 From: Daniel Kronovet Date: Thu, 21 Dec 2023 13:04:17 -0800 Subject: [PATCH] First pass at updating reputation tests --- test/reputation-system/client-calculations.js | 6 +- .../client-core-functionality.js | 8 +-- .../client-sync-functionality.js | 14 ++--- .../dispute-resolution-misbehaviour.js | 60 +++++++++---------- .../disputes-over-child-reputation.js | 56 ++++++++--------- test/reputation-system/happy-paths.js | 37 +++++------- .../root-hash-submissions.js | 20 +++---- .../types-of-disagreement.js | 40 +++++++------ 8 files changed, 114 insertions(+), 127 deletions(-) diff --git a/test/reputation-system/client-calculations.js b/test/reputation-system/client-calculations.js index e91328a339..6936c20f86 100644 --- a/test/reputation-system/client-calculations.js +++ b/test/reputation-system/client-calculations.js @@ -1,8 +1,9 @@ +/* globals ethers */ + const path = require("path"); const BN = require("bn.js"); const chai = require("chai"); const bnChai = require("bn-chai"); -const { ethers } = require("ethers"); const { TruffleLoader } = require("../../packages/package-utils"); const { UINT256_MAX, DEFAULT_STAKE, INITIAL_FUNDING } = require("../../helpers/constants"); @@ -29,7 +30,6 @@ let colonyNetwork; let metaColony; let clnyToken; let goodClient; -const realProviderPort = process.env.SOLIDITY_COVERAGE ? 8555 : 8545; const setupNewNetworkInstance = async (MINER1, MINER2) => { colonyNetwork = await setupColonyNetwork(); @@ -50,7 +50,7 @@ const setupNewNetworkInstance = async (MINER1, MINER2) => { await colonyNetwork.initialiseReputationMining(); await colonyNetwork.startNextCycle(); - goodClient = new ReputationMinerTestWrapper({ loader, realProviderPort, useJsTree, minerAddress: MINER1 }); + goodClient = new ReputationMinerTestWrapper({ loader, provider: ethers.provider, useJsTree, minerAddress: MINER1 }); }; process.env.SOLIDITY_COVERAGE diff --git a/test/reputation-system/client-core-functionality.js b/test/reputation-system/client-core-functionality.js index 37f6849056..8548c9f2cd 100644 --- a/test/reputation-system/client-core-functionality.js +++ b/test/reputation-system/client-core-functionality.js @@ -1,4 +1,4 @@ -/* globals artifacts */ +/* globals artifacts, ethers */ const path = require("path"); const request = require("async-request"); @@ -27,8 +27,6 @@ const loader = new TruffleLoader({ contractRoot: path.resolve(__dirname, "..", "..", "artifacts", "contracts"), }); -const realProviderPort = process.env.SOLIDITY_COVERAGE ? 8555 : 8545; - process.env.SOLIDITY_COVERAGE ? contract.skip : contract("Reputation mining - client core functionality", (accounts) => { @@ -55,7 +53,7 @@ process.env.SOLIDITY_COVERAGE const lock = await tokenLocking.getUserLock(clnyToken.address, MINER1); expect(lock.balance).to.eq.BN(DEFAULT_STAKE); - reputationMiner = new ReputationMinerTestWrapper({ loader, minerAddress: MINER1, realProviderPort, useJsTree: true }); + reputationMiner = new ReputationMinerTestWrapper({ loader, minerAddress: MINER1, provider: ethers.provider, useJsTree: true }); }); beforeEach(async () => { @@ -75,7 +73,7 @@ process.env.SOLIDITY_COVERAGE const adapter = new TestAdapter(); - client = new ReputationMinerClient({ loader, realProviderPort, minerAddress: MINER1, useJsTree: true, auto: false, adapter }); + client = new ReputationMinerClient({ loader, provider: ethers.provider, minerAddress: MINER1, useJsTree: true, auto: false, adapter }); await client.initialise(colonyNetwork.address, 1); }); diff --git a/test/reputation-system/client-sync-functionality.js b/test/reputation-system/client-sync-functionality.js index 56a944d939..9803b8fad0 100644 --- a/test/reputation-system/client-sync-functionality.js +++ b/test/reputation-system/client-sync-functionality.js @@ -1,4 +1,4 @@ -/* globals artifacts */ +/* globals artifacts, ethers */ const path = require("path"); const chai = require("chai"); @@ -26,8 +26,8 @@ const loader = new TruffleLoader({ contractRoot: path.resolve(__dirname, "..", "..", "artifacts", "contracts"), }); -const realProviderPort = process.env.SOLIDITY_COVERAGE ? 8555 : 8545; const useJsTree = true; +const { provider } = ethers; process.env.SOLIDITY_COVERAGE ? contract.skip @@ -53,8 +53,8 @@ process.env.SOLIDITY_COVERAGE const clnyAddress = await metaColony.getToken(); clnyToken = await Token.at(clnyAddress); - reputationMiner1 = new ReputationMinerTestWrapper({ loader, minerAddress: MINER1, realProviderPort, useJsTree }); - reputationMiner2 = new ReputationMinerTestWrapper({ loader, minerAddress: MINER2, realProviderPort, useJsTree }); + reputationMiner1 = new ReputationMinerTestWrapper({ loader, minerAddress: MINER1, provider, useJsTree }); + reputationMiner2 = new ReputationMinerTestWrapper({ loader, minerAddress: MINER2, provider, useJsTree }); }); beforeEach(async () => { @@ -178,7 +178,7 @@ process.env.SOLIDITY_COVERAGE await reputationMiner2.sync(startingBlockNumber); // And load a state on a client that's not using the JS Tree - const reputationMiner3 = new ReputationMinerTestWrapper({ loader, minerAddress: MINER2, realProviderPort, useJsTree: !useJsTree }); + const reputationMiner3 = new ReputationMinerTestWrapper({ loader, minerAddress: MINER2, provider, useJsTree: !useJsTree }); await reputationMiner3.initialise(colonyNetwork.address); await reputationMiner3.loadState(savedHash); await reputationMiner3.sync(startingBlockNumber); @@ -232,7 +232,7 @@ process.env.SOLIDITY_COVERAGE it("should be able to download a sqlite file containing the latest state", async () => { const adapter = new TestAdapter(); - const client = new ReputationMinerClient({ loader, realProviderPort, minerAddress: MINER1, useJsTree: true, auto: false, adapter }); + const client = new ReputationMinerClient({ loader, provider, minerAddress: MINER1, useJsTree: true, auto: false, adapter }); await client.initialise(colonyNetwork.address, 1); await fundColonyWithTokens(metaColony, clnyToken, INITIAL_FUNDING.muln(100)); @@ -258,7 +258,7 @@ process.env.SOLIDITY_COVERAGE const reputationMiner3 = new ReputationMinerTestWrapper({ loader, minerAddress: MINER1, - realProviderPort, + provider, useJsTree: true, dbPath: fileName, }); diff --git a/test/reputation-system/dispute-resolution-misbehaviour.js b/test/reputation-system/dispute-resolution-misbehaviour.js index 0648547fb4..11140528b6 100644 --- a/test/reputation-system/dispute-resolution-misbehaviour.js +++ b/test/reputation-system/dispute-resolution-misbehaviour.js @@ -1,10 +1,9 @@ -/* globals artifacts, BigInt */ +/* globals artifacts, BigInt, ethers */ const path = require("path"); const BN = require("bn.js"); const chai = require("chai"); const bnChai = require("bn-chai"); -const { ethers } = require("ethers"); const { TruffleLoader } = require("../../packages/package-utils"); const { @@ -56,6 +55,7 @@ const loader = new TruffleLoader({ }); const useJsTree = true; +const { provider } = ethers; let colonyNetwork; let metaColony; @@ -63,8 +63,6 @@ let clnyToken; let localSkillId; let goodClient; -const realProviderPort = process.env.SOLIDITY_COVERAGE ? 8555 : 8545; - const setupNewNetworkInstance = async (MINER1, MINER2) => { colonyNetwork = await setupColonyNetwork(); ({ metaColony, clnyToken } = await setupMetaColonyWithLockedCLNYToken(colonyNetwork)); @@ -84,7 +82,7 @@ const setupNewNetworkInstance = async (MINER1, MINER2) => { await colonyNetwork.initialiseReputationMining(); await colonyNetwork.startNextCycle(); - goodClient = new ReputationMinerTestWrapper({ loader, realProviderPort, useJsTree, minerAddress: MINER1 }); + goodClient = new ReputationMinerTestWrapper({ loader, provider, useJsTree, minerAddress: MINER1 }); }; contract("Reputation Mining - disputes resolution misbehaviour", (accounts) => { @@ -131,7 +129,7 @@ contract("Reputation Mining - disputes resolution misbehaviour", (accounts) => { // invalidateHash => confirmNewHash describe("when dispute flow order is not kept", () => { it("should prevent a user from jumping ahead during dispute resolution", async () => { - const badClient = new MaliciousReputationMinerExtraRep({ loader, realProviderPort, useJsTree, minerAddress: MINER2 }, 1, 0xfffffffff); + const badClient = new MaliciousReputationMinerExtraRep({ loader, provider, useJsTree, minerAddress: MINER2 }, 1, 0xfffffffff); await badClient.initialise(colonyNetwork.address); await advanceMiningCycleNoContest({ colonyNetwork, test: this }); @@ -202,7 +200,7 @@ contract("Reputation Mining - disputes resolution misbehaviour", (accounts) => { }); it("should prevent a user from attempting to defend a DisputedEntry beyond the size of a round.", async () => { - const badClient = new MaliciousReputationMinerExtraRep({ loader, realProviderPort, useJsTree, minerAddress: MINER2 }, 1, 0xfffffffff); + const badClient = new MaliciousReputationMinerExtraRep({ loader, provider, useJsTree, minerAddress: MINER2 }, 1, 0xfffffffff); await badClient.initialise(colonyNetwork.address); await advanceMiningCycleNoContest({ colonyNetwork, test: this }); @@ -280,9 +278,9 @@ contract("Reputation Mining - disputes resolution misbehaviour", (accounts) => { await goodClient.saveCurrentState(); const savedHash = await goodClient.reputationTree.getRootHash(); - const badClient = new MaliciousReputationMinerExtraRep({ loader, realProviderPort, useJsTree, minerAddress: MINER2 }, 1, 0xfffffffff); + const badClient = new MaliciousReputationMinerExtraRep({ loader, provider, useJsTree, minerAddress: MINER2 }, 1, 0xfffffffff); await badClient.initialise(colonyNetwork.address); - const badClient2 = new MaliciousReputationMinerExtraRep({ loader, realProviderPort, useJsTree, minerAddress: MINER3 }, 1, 0xffffffffff); + const badClient2 = new MaliciousReputationMinerExtraRep({ loader, provider, useJsTree, minerAddress: MINER3 }, 1, 0xffffffffff); await badClient2.initialise(colonyNetwork.address); await badClient.loadState(savedHash); @@ -339,7 +337,7 @@ contract("Reputation Mining - disputes resolution misbehaviour", (accounts) => { const clients = await Promise.all( accountsForTest.map(async (addr, index) => { const client = new MaliciousReputationMinerExtraRep( - { loader, realProviderPort, useJsTree, minerAddress: addr }, + { loader, provider, useJsTree, minerAddress: addr }, accountsForTest.length - index, index, ); @@ -559,7 +557,7 @@ contract("Reputation Mining - disputes resolution misbehaviour", (accounts) => { await goodClient.saveCurrentState(); const savedHash = await goodClient.reputationTree.getRootHash(); - const badClient = new MaliciousReputationMinerExtraRep({ loader, realProviderPort, useJsTree, minerAddress: MINER2 }, 5, 0xfffffffff); + const badClient = new MaliciousReputationMinerExtraRep({ loader, provider, useJsTree, minerAddress: MINER2 }, 5, 0xfffffffff); await badClient.initialise(colonyNetwork.address); await badClient.loadState(savedHash); @@ -634,7 +632,7 @@ contract("Reputation Mining - disputes resolution misbehaviour", (accounts) => { await giveUserCLNYTokensAndStake(colonyNetwork, MINER2, DEFAULT_STAKE); await giveUserCLNYTokensAndStake(colonyNetwork, MINER3, DEFAULT_STAKE); - const badClient = new MaliciousReputationMinerExtraRep({ loader, realProviderPort, useJsTree, minerAddress: MINER2 }, 1, 0xfffffffff); + const badClient = new MaliciousReputationMinerExtraRep({ loader, provider, useJsTree, minerAddress: MINER2 }, 1, 0xfffffffff); await badClient.initialise(colonyNetwork.address); await advanceMiningCycleNoContest({ colonyNetwork, test: this }); @@ -671,7 +669,7 @@ contract("Reputation Mining - disputes resolution misbehaviour", (accounts) => { it(`should not allow miners to respond immediately during a dispute, but they should be able to some time before the end of the window`, async function gateTest() { - const badClient = new MaliciousReputationMinerExtraRep({ loader, realProviderPort, useJsTree, minerAddress: MINER2 }, 1, 0xfffffffff); + const badClient = new MaliciousReputationMinerExtraRep({ loader, provider, useJsTree, minerAddress: MINER2 }, 1, 0xfffffffff); await badClient.initialise(colonyNetwork.address); await giveUserCLNYTokensAndStake(colonyNetwork, MINER2, DEFAULT_STAKE); @@ -784,7 +782,7 @@ contract("Reputation Mining - disputes resolution misbehaviour", (accounts) => { describe("when miner misbehaving during confirmJustificationRootHash stage", async () => { it("should prevent a user from confirming a JRH they can't prove is correct", async () => { - const badClient = new MaliciousReputationMinerExtraRep({ loader, realProviderPort, useJsTree, minerAddress: MINER2 }, 1, 0xfffffffff); + const badClient = new MaliciousReputationMinerExtraRep({ loader, provider, useJsTree, minerAddress: MINER2 }, 1, 0xfffffffff); await badClient.initialise(colonyNetwork.address); await advanceMiningCycleNoContest({ colonyNetwork, test: this }); @@ -830,7 +828,7 @@ contract("Reputation Mining - disputes resolution misbehaviour", (accounts) => { describe("when miner misbehaving during respondToBinarySearchForChallenge stage", async () => { it("should fail to respondToBinarySearchForChallenge if not consistent with JRH", async () => { - const badClient = new MaliciousReputationMinerExtraRep({ loader, realProviderPort, useJsTree, minerAddress: MINER2 }, 1, 0xfffffffff); + const badClient = new MaliciousReputationMinerExtraRep({ loader, provider, useJsTree, minerAddress: MINER2 }, 1, 0xfffffffff); await badClient.initialise(colonyNetwork.address); await advanceMiningCycleNoContest({ colonyNetwork, test: this }); @@ -862,7 +860,7 @@ contract("Reputation Mining - disputes resolution misbehaviour", (accounts) => { it("incorrectly confirming a binary search result should fail", async () => { await advanceMiningCycleNoContest({ colonyNetwork, test: this }); - const badClient = new MaliciousReputationMinerExtraRep({ loader, realProviderPort, useJsTree, minerAddress: MINER2 }, 3, 0xffffffffffff); + const badClient = new MaliciousReputationMinerExtraRep({ loader, provider, useJsTree, minerAddress: MINER2 }, 3, 0xffffffffffff); await badClient.initialise(colonyNetwork.address); const repCycle = await getActiveRepCycle(colonyNetwork); @@ -919,10 +917,10 @@ contract("Reputation Mining - disputes resolution misbehaviour", (accounts) => { const nLogEntries = await repCycle.getReputationUpdateLogLength(); expect(nLogEntries).to.eq.BN(5); - const badClient = new MaliciousReputationMinerExtraRep({ loader, minerAddress: MINER2, realProviderPort, useJsTree }, 14, 0xffffffffffff); + const badClient = new MaliciousReputationMinerExtraRep({ loader, minerAddress: MINER2, provider, useJsTree }, 14, 0xffffffffffff); await badClient.initialise(colonyNetwork.address); - const badClient2 = new MaliciousReputationMinerWrongResponse({ loader, minerAddress: MINER1, realProviderPort, useJsTree }, 14, 123456); + const badClient2 = new MaliciousReputationMinerWrongResponse({ loader, minerAddress: MINER1, provider, useJsTree }, 14, 123456); await badClient2.initialise(colonyNetwork.address); await submitAndForwardTimeToDispute([goodClient, badClient], this); @@ -976,10 +974,10 @@ contract("Reputation Mining - disputes resolution misbehaviour", (accounts) => { const nLogEntries = await repCycle.getReputationUpdateLogLength(); expect(nLogEntries).to.eq.BN(9); - const badClient = new MaliciousReputationMinerExtraRep({ loader, minerAddress: MINER2, realProviderPort, useJsTree }, 30, 0xffffffffffff); + const badClient = new MaliciousReputationMinerExtraRep({ loader, minerAddress: MINER2, provider, useJsTree }, 30, 0xffffffffffff); await badClient.initialise(colonyNetwork.address); - const badClient2 = new MaliciousReputationMinerWrongResponse({ loader, minerAddress: MINER1, realProviderPort, useJsTree }, 17, 123456); + const badClient2 = new MaliciousReputationMinerWrongResponse({ loader, minerAddress: MINER1, provider, useJsTree }, 17, 123456); await badClient2.initialise(colonyNetwork.address); await submitAndForwardTimeToDispute([goodClient, badClient], this); @@ -1014,13 +1012,13 @@ contract("Reputation Mining - disputes resolution misbehaviour", (accounts) => { await advanceMiningCycleNoContest({ colonyNetwork, test: this }); - const badClient = new MaliciousReputationMinerExtraRep({ loader, realProviderPort, useJsTree, minerAddress: MINER2 }, 24, 0xfffffffff); + const badClient = new MaliciousReputationMinerExtraRep({ loader, provider, useJsTree, minerAddress: MINER2 }, 24, 0xfffffffff); await badClient.initialise(colonyNetwork.address); - const badClient2 = new MaliciousReputationMinerWrongResponse({ loader, minerAddress: MINER1, realProviderPort, useJsTree }, 4, 123456); + const badClient2 = new MaliciousReputationMinerWrongResponse({ loader, minerAddress: MINER1, provider, useJsTree }, 4, 123456); await badClient2.initialise(colonyNetwork.address); - const badClient3 = new MaliciousReputationMinerWrongResponse({ loader, minerAddress: MINER1, realProviderPort, useJsTree }, 6, 123456); + const badClient3 = new MaliciousReputationMinerWrongResponse({ loader, minerAddress: MINER1, provider, useJsTree }, 6, 123456); await badClient3.initialise(colonyNetwork.address); await submitAndForwardTimeToDispute([goodClient, badClient], this); @@ -1053,7 +1051,7 @@ contract("Reputation Mining - disputes resolution misbehaviour", (accounts) => { it("should fail to respondToChallenge if any part of the key or hashedKey is wrong", async () => { await advanceMiningCycleNoContest({ colonyNetwork, test: this }); - const badClient = new MaliciousReputationMinerExtraRep({ loader, realProviderPort, useJsTree, minerAddress: MINER2 }, 3, 0xffffffffffff); + const badClient = new MaliciousReputationMinerExtraRep({ loader, provider, useJsTree, minerAddress: MINER2 }, 3, 0xffffffffffff); await badClient.initialise(colonyNetwork.address); const repCycle = await getActiveRepCycle(colonyNetwork); @@ -1144,7 +1142,7 @@ contract("Reputation Mining - disputes resolution misbehaviour", (accounts) => { }); it("should fail to respondToChallenge if binary search for challenge is not complete yet", async () => { - const badClient = new MaliciousReputationMinerExtraRep({ loader, realProviderPort, useJsTree, minerAddress: MINER2 }, 1, 0xfffffffff); + const badClient = new MaliciousReputationMinerExtraRep({ loader, provider, useJsTree, minerAddress: MINER2 }, 1, 0xfffffffff); await badClient.initialise(colonyNetwork.address); await advanceMiningCycleNoContest({ colonyNetwork, test: this }); @@ -1212,15 +1210,11 @@ contract("Reputation Mining - disputes resolution misbehaviour", (accounts) => { await goodClient.addLogContentsToReputationTree(); - const badClient = new MaliciousReputationMinerExtraRep( - { loader, realProviderPort, useJsTree, minerAddress: MINER2 }, - args.badClient1Argument, - 10, - ); + const badClient = new MaliciousReputationMinerExtraRep({ loader, provider, useJsTree, minerAddress: MINER2 }, args.badClient1Argument, 10); await badClient.initialise(colonyNetwork.address); const badClient2 = new MaliciousReputationMinerWrongProofLogEntry( - { loader, realProviderPort, useJsTree, minerAddress: MINER3 }, + { loader, provider, useJsTree, minerAddress: MINER3 }, args.badClient2Argument, ); await badClient2.initialise(colonyNetwork.address); @@ -1257,7 +1251,7 @@ contract("Reputation Mining - disputes resolution misbehaviour", (accounts) => { describe("when miner misbehaving during confirmNewHash stage", async () => { it("should only allow the last hash standing to be confirmed", async () => { - const badClient = new MaliciousReputationMinerExtraRep({ loader, realProviderPort, useJsTree, minerAddress: MINER2 }, 1, 0xfffffffff); + const badClient = new MaliciousReputationMinerExtraRep({ loader, provider, useJsTree, minerAddress: MINER2 }, 1, 0xfffffffff); await badClient.initialise(colonyNetwork.address); await advanceMiningCycleNoContest({ colonyNetwork, test: this }); @@ -1283,7 +1277,7 @@ contract("Reputation Mining - disputes resolution misbehaviour", (accounts) => { const repCycle = await getActiveRepCycle(colonyNetwork); - const badClient = new MaliciousReputationMinerExtraRep({ loader, realProviderPort, useJsTree, minerAddress: MINER2 }, 1, 0xfffffffff); + const badClient = new MaliciousReputationMinerExtraRep({ loader, provider, useJsTree, minerAddress: MINER2 }, 1, 0xfffffffff); await badClient.initialise(colonyNetwork.address); await goodClient.addLogContentsToReputationTree(); await badClient.addLogContentsToReputationTree(); diff --git a/test/reputation-system/disputes-over-child-reputation.js b/test/reputation-system/disputes-over-child-reputation.js index f4674414ab..f30f16b875 100644 --- a/test/reputation-system/disputes-over-child-reputation.js +++ b/test/reputation-system/disputes-over-child-reputation.js @@ -1,3 +1,5 @@ +/* globals ethers */ + const path = require("path"); const chai = require("chai"); const bnChai = require("bn-chai"); @@ -42,13 +44,13 @@ const loader = new TruffleLoader({ }); const useJsTree = true; +const { provider } = ethers; let colonyNetwork; let metaColony; let clnyToken; let localSkillId; let goodClient; -const realProviderPort = process.env.SOLIDITY_COVERAGE ? 8555 : 8545; const setupNewNetworkInstance = async (MINER1, MINER2) => { colonyNetwork = await setupColonyNetwork(); @@ -69,7 +71,7 @@ const setupNewNetworkInstance = async (MINER1, MINER2) => { await colonyNetwork.initialiseReputationMining(); await colonyNetwork.startNextCycle(); - goodClient = new ReputationMinerTestWrapper({ loader, realProviderPort, useJsTree, minerAddress: MINER1 }); + goodClient = new ReputationMinerTestWrapper({ loader, provider, useJsTree, minerAddress: MINER1 }); }; contract("Reputation Mining - disputes over child reputation", (accounts) => { @@ -143,7 +145,7 @@ contract("Reputation Mining - disputes over child reputation", (accounts) => { expect(nLogEntries).to.eq.BN(9); const badClient = new MaliciousReputationMinerClaimNoOriginReputation( - { loader, realProviderPort, useJsTree, minerAddress: MINER2 }, + { loader, provider, useJsTree, minerAddress: MINER2 }, 50, // Passing in update number for colony wide skillId: 5, user: 0 1, ); @@ -198,7 +200,7 @@ contract("Reputation Mining - disputes over child reputation", (accounts) => { assert.equal(nLogEntries.toNumber(), 9); const badClient = new MaliciousReputationMinerClaimNoUserChildReputation( - { loader, realProviderPort, useJsTree, minerAddress: MINER2 }, + { loader, provider, useJsTree, minerAddress: MINER2 }, 46, // Passing in update number for colony wide skillId: 5, user: 0 1, ); @@ -254,7 +256,7 @@ contract("Reputation Mining - disputes over child reputation", (accounts) => { assert.equal(nLogEntries.toNumber(), 9); const badClient = new MaliciousReputationMinerExtraRep( - { loader, realProviderPort, useJsTree, minerAddress: MINER2 }, + { loader, provider, useJsTree, minerAddress: MINER2 }, 35, // Passing in update number for colony wide skillId: 5, user: 0 "0xfffffffffffffffffffffff", ); @@ -301,12 +303,12 @@ contract("Reputation Mining - disputes over child reputation", (accounts) => { assert.equal(nLogEntries.toNumber(), 5); const badClient = new MaliciousReputationMinerExtraRep( - { loader, realProviderPort, useJsTree, minerAddress: MINER2 }, + { loader, provider, useJsTree, minerAddress: MINER2 }, 26, // Passing in update number for colony wide skillId: 5, user: 0 "0xfffffffffffffffffffffff", ); - const badClient2 = new MaliciousReputationMinerWrongResponse({ loader, minerAddress: MINER1, realProviderPort, useJsTree }, 15, 123456); + const badClient2 = new MaliciousReputationMinerWrongResponse({ loader, minerAddress: MINER1, provider, useJsTree }, 15, 123456); await badClient2.initialise(colonyNetwork.address); // Moving the state to the bad client @@ -375,12 +377,12 @@ contract("Reputation Mining - disputes over child reputation", (accounts) => { assert.equal(nLogEntries.toNumber(), 9); const badClient = new MaliciousReputationMinerExtraRep( - { loader, realProviderPort, useJsTree, minerAddress: MINER2 }, + { loader, provider, useJsTree, minerAddress: MINER2 }, 40, // Passing in update number for colony wide skillId: 5, user: 0 "0xfffffffffffffffffffffff", ); - const badClient2 = new MaliciousReputationMinerWrongResponse({ loader, minerAddress: MINER1, realProviderPort, useJsTree }, 18, 123456); + const badClient2 = new MaliciousReputationMinerWrongResponse({ loader, minerAddress: MINER1, provider, useJsTree }, 18, 123456); await badClient2.initialise(colonyNetwork.address); // Moving the state to the bad client @@ -456,21 +458,21 @@ contract("Reputation Mining - disputes over child reputation", (accounts) => { expect(nLogEntries).to.eq.BN(5); const badClientWrongSkill = new MaliciousReputationMinerClaimWrongOriginReputation( - { loader, realProviderPort, useJsTree, minerAddress: MINER2 }, + { loader, provider, useJsTree, minerAddress: MINER2 }, 31, // Passing in update number for skillId: 5, user: 9f485401a3c22529ab6ea15e2ebd5a8ca54a5430 30, "skillId", ); const badClientWrongColony = new MaliciousReputationMinerClaimWrongOriginReputation( - { loader, realProviderPort, useJsTree, minerAddress: MINER3 }, + { loader, provider, useJsTree, minerAddress: MINER3 }, 31, // Passing in update number for skillId: 5, user: 9f485401a3c22529ab6ea15e2ebd5a8ca54a5430 30, "colonyAddress", ); const badClientWrongUser = new MaliciousReputationMinerClaimWrongOriginReputation( - { loader, realProviderPort, useJsTree, minerAddress: MINER4 }, + { loader, provider, useJsTree, minerAddress: MINER4 }, 31, // Passing in update number for skillId: 5, user: 9f485401a3c22529ab6ea15e2ebd5a8ca54a5430 30, "userAddress", @@ -537,7 +539,7 @@ contract("Reputation Mining - disputes over child reputation", (accounts) => { expect(nLogEntries).to.eq.BN(5); const badClient = new MaliciousReputationMinerExtraRep( - { loader, minerAddress: MINER2, realProviderPort, useJsTree }, + { loader, minerAddress: MINER2, provider, useJsTree }, 34, // Passing in colony wide update number for skillId: 4, user: 0 "0xfffffffffffffffffffffff", ); @@ -609,7 +611,7 @@ contract("Reputation Mining - disputes over child reputation", (accounts) => { expect(nLogEntries).to.eq.BN(5); const badClient = new MaliciousReputationMinerGlobalOriginNotChildOrigin( - { loader, minerAddress: MINER2, realProviderPort, useJsTree }, + { loader, minerAddress: MINER2, provider, useJsTree }, 29, // Passing in update number for skillId: 5, user: 0000000000000000000000000000000000000000 ); @@ -654,7 +656,7 @@ contract("Reputation Mining - disputes over child reputation", (accounts) => { expect(nLogEntries).to.eq.BN(5); const badClient = new MaliciousReputationMinerExtraRep( - { loader, minerAddress: MINER2, realProviderPort, useJsTree }, + { loader, minerAddress: MINER2, provider, useJsTree }, 31, // Passing in update number for skillId: 5, user: 9f485401a3c22529ab6ea15e2ebd5a8ca54a5430 "0xf", ); @@ -700,7 +702,7 @@ contract("Reputation Mining - disputes over child reputation", (accounts) => { expect(nLogEntries).to.eq.BN(5); const badClient = new MaliciousReputationMinerExtraRep( - { loader, minerAddress: MINER2, realProviderPort, useJsTree }, + { loader, minerAddress: MINER2, provider, useJsTree }, 31, // Passing in update number for skillId: 5, user: 9f485401a3c22529ab6ea15e2ebd5a8ca54a5430 "4800000000000", ); @@ -739,7 +741,7 @@ contract("Reputation Mining - disputes over child reputation", (accounts) => { const nLogEntries = await repCycle.getReputationUpdateLogLength(); expect(nLogEntries).to.eq.BN(5); const badClient = new MaliciousReputationMinerExtraRep( - { loader, minerAddress: MINER2, realProviderPort, useJsTree }, + { loader, minerAddress: MINER2, provider, useJsTree }, 21, // Passing in update number for skillId: 5, user: 9f485401a3c22529ab6ea15e2ebd5a8ca54a5430 "0xffffffffffffffff", ); @@ -786,7 +788,7 @@ contract("Reputation Mining - disputes over child reputation", (accounts) => { expect(nLogEntries).to.eq.BN(5); const badClient = new MaliciousReputationMinerExtraRep( - { loader, minerAddress: MINER2, realProviderPort, useJsTree }, + { loader, minerAddress: MINER2, provider, useJsTree }, 30, // Passing in colony wide update number for skillId: 4, user: 0 "0xffff", ); @@ -832,7 +834,7 @@ contract("Reputation Mining - disputes over child reputation", (accounts) => { expect(nLogEntries).to.eq.BN(5); const badClient = new MaliciousReputationMinerExtraRep( - { loader, minerAddress: MINER2, realProviderPort, useJsTree }, + { loader, minerAddress: MINER2, provider, useJsTree }, 30, // Passing in update number for skillId: 5, user: 0 "0xfffffffffff", ); @@ -884,7 +886,7 @@ contract("Reputation Mining - disputes over child reputation", (accounts) => { assert.equal(nLogEntries.toNumber(), 5); const badClient = new MaliciousReputationMinerExtraRep( - { loader, minerAddress: MINER2, realProviderPort, useJsTree }, + { loader, minerAddress: MINER2, provider, useJsTree }, 37, // Passing in update number for skillId: 5, user: 0 "0xfffffffffffffffffffffff", ); @@ -936,7 +938,7 @@ contract("Reputation Mining - disputes over child reputation", (accounts) => { await advanceMiningCycleNoContest({ colonyNetwork, test: this, client: goodClient }); await goodClient.saveCurrentState(); - const badClient = new MaliciousReputationMinerExtraRep({ loader, realProviderPort, useJsTree, minerAddress: MINER2 }, 28, 0xfffffffff); + const badClient = new MaliciousReputationMinerExtraRep({ loader, provider, useJsTree, minerAddress: MINER2 }, 28, 0xfffffffff); // The update log should contain the person being rewarded for the previous // update cycle, and reputation updates for one task completion (manager, worker (domain and skill), evaluator); @@ -946,17 +948,17 @@ contract("Reputation Mining - disputes over child reputation", (accounts) => { expect(nLogEntries).to.eq.BN(5); const badClientWrongSkill = new MaliciousReputationMinerClaimWrongChildReputation( - { loader, realProviderPort, useJsTree, minerAddress: MINER1 }, + { loader, provider, useJsTree, minerAddress: MINER1 }, "skillId", ); const badClientWrongColony = new MaliciousReputationMinerClaimWrongChildReputation( - { loader, realProviderPort, useJsTree, minerAddress: MINER1 }, + { loader, provider, useJsTree, minerAddress: MINER1 }, "colonyAddress", ); const badClientWrongUser = new MaliciousReputationMinerClaimWrongChildReputation( - { loader, realProviderPort, useJsTree, minerAddress: MINER1 }, + { loader, provider, useJsTree, minerAddress: MINER1 }, "userAddress", ); @@ -1020,7 +1022,7 @@ contract("Reputation Mining - disputes over child reputation", (accounts) => { expect(nLogEntries).to.eq.BN(5); const badClient = new MaliciousReputationMinerExtraRep( - { loader, minerAddress: MINER2, realProviderPort, useJsTree }, + { loader, minerAddress: MINER2, provider, useJsTree }, 32, // Passing in colony wide update number for skillId: 5, user: 0 "0xfffffffff", ); @@ -1073,13 +1075,13 @@ contract("Reputation Mining - disputes over child reputation", (accounts) => { expect(nLogEntries).to.eq.BN(5); const badClient = new MaliciousReputationMinerExtraRep( - { loader, realProviderPort, useJsTree, minerAddress: MINER2 }, + { loader, provider, useJsTree, minerAddress: MINER2 }, 25, // Passing in update number for skillId: 1, user: 0 "0xfffffffff", ); const badClient2 = new MaliciousReputationMinerExtraRep( - { loader, realProviderPort, useJsTree, minerAddress: MINER3 }, + { loader, provider, useJsTree, minerAddress: MINER3 }, 28, // Passing in update number for skillId: 5, user: 9f485401a3c22529ab6ea15e2ebd5a8ca54a5430 "0xfffffffff", ); diff --git a/test/reputation-system/happy-paths.js b/test/reputation-system/happy-paths.js index 090355b0a0..4e59f1fd38 100644 --- a/test/reputation-system/happy-paths.js +++ b/test/reputation-system/happy-paths.js @@ -1,8 +1,7 @@ -/* globals artifacts */ +/* globals artifacts, ethers */ const path = require("path"); const BN = require("bn.js"); -const { ethers } = require("ethers"); const chai = require("chai"); const bnChai = require("bn-chai"); @@ -57,13 +56,13 @@ const loader = new TruffleLoader({ }); const useJsTree = true; +const { provider } = ethers; let colonyNetwork; let metaColony; let clnyToken; let localSkillId; let goodClient; -const realProviderPort = process.env.SOLIDITY_COVERAGE ? 8555 : 8545; const setupNewNetworkInstance = async (MINER1, MINER2) => { colonyNetwork = await setupColonyNetwork(); @@ -94,7 +93,7 @@ const setupNewNetworkInstance = async (MINER1, MINER2) => { await colonyNetwork.initialiseReputationMining(); await colonyNetwork.startNextCycle(); - goodClient = new ReputationMinerTestWrapper({ loader, realProviderPort, useJsTree, minerAddress: MINER1 }); + goodClient = new ReputationMinerTestWrapper({ loader, provider, useJsTree, minerAddress: MINER1 }); }; contract("Reputation Mining - happy paths", (accounts) => { @@ -163,11 +162,7 @@ contract("Reputation Mining - happy paths", (accounts) => { accounts.slice(3, 11).map(async (addr, index) => { const entryToFalsify = 7 - index; const amountToFalsify = index; // NB The first client is 'bad', but told to get the calculation wrong by 0, so is actually good. - const client = new MaliciousReputationMinerExtraRep( - { loader, realProviderPort, useJsTree, minerAddress: addr }, - entryToFalsify, - amountToFalsify, - ); + const client = new MaliciousReputationMinerExtraRep({ loader, provider, useJsTree, minerAddress: addr }, entryToFalsify, amountToFalsify); // Each client will get a different reputation update entry wrong by a different amount, apart from the first one which // will submit a correct hash. await client.initialise(colonyNetwork.address); @@ -251,7 +246,7 @@ contract("Reputation Mining - happy paths", (accounts) => { // Complete two reputation cycles to process the log await advanceMiningCycleNoContest({ colonyNetwork, test: this }); - goodClient = new ReputationMinerTestWrapper({ loader, realProviderPort, useJsTree: false, minerAddress: MINER1 }); + goodClient = new ReputationMinerTestWrapper({ loader, provider, useJsTree: false, minerAddress: MINER1 }); await goodClient.initialise(colonyNetwork.address); await goodClient.resetDB(); @@ -259,7 +254,7 @@ contract("Reputation Mining - happy paths", (accounts) => { }); it("should allow submitted hashes to go through multiple responses to a challenge", async () => { - const badClient = new MaliciousReputationMinerExtraRep({ loader, realProviderPort, useJsTree, minerAddress: MINER2 }, 1, 0xfffffffff); + const badClient = new MaliciousReputationMinerExtraRep({ loader, provider, useJsTree, minerAddress: MINER2 }, 1, 0xfffffffff); await badClient.initialise(colonyNetwork.address); await giveUserCLNYTokensAndStake(colonyNetwork, MINER2, DEFAULT_STAKE); @@ -295,7 +290,7 @@ contract("Reputation Mining - happy paths", (accounts) => { await setupClaimedExpenditure({ colonyNetwork, colony: metaColony, skillId: localSkillId, worker: MINER1 }); await setupClaimedExpenditure({ colonyNetwork, colony: metaColony, skillId: localSkillId, worker: MINER2 }); - const badClient = new MaliciousReputationMinerExtraRep({ loader, realProviderPort, useJsTree, minerAddress: MINER2 }, 29, 0xffffffffffff); + const badClient = new MaliciousReputationMinerExtraRep({ loader, provider, useJsTree, minerAddress: MINER2 }, 29, 0xffffffffffff); await badClient.initialise(colonyNetwork.address); // Send rep to 0 @@ -325,7 +320,7 @@ contract("Reputation Mining - happy paths", (accounts) => { await setupClaimedExpenditure({ colonyNetwork, colony: metaColony, skillId: localSkillId, worker: MINER1 }); await setupClaimedExpenditure({ colonyNetwork, colony: metaColony, skillId: localSkillId, worker: MINER2 }); - const badClient = new MaliciousReputationMinerExtraRep({ loader, realProviderPort, useJsTree, minerAddress: MINER2 }, 31, 0xffffffffffff); + const badClient = new MaliciousReputationMinerExtraRep({ loader, provider, useJsTree, minerAddress: MINER2 }, 31, 0xffffffffffff); await badClient.initialise(colonyNetwork.address); // Manager, evaluator, worker @@ -356,11 +351,7 @@ contract("Reputation Mining - happy paths", (accounts) => { const bigPayout = new BN("10").pow(new BN("38")); - const badClient = new MaliciousReputationMinerExtraRep( - { loader, realProviderPort, useJsTree, minerAddress: MINER2 }, - 29, - bigPayout.muln(2).neg(), - ); + const badClient = new MaliciousReputationMinerExtraRep({ loader, provider, useJsTree, minerAddress: MINER2 }, 29, bigPayout.muln(2).neg()); await badClient.initialise(colonyNetwork.address); let repCycle = await getActiveRepCycle(colonyNetwork); @@ -400,7 +391,7 @@ contract("Reputation Mining - happy paths", (accounts) => { await giveUserCLNYTokensAndStake(colonyNetwork, MINER2, DEFAULT_STAKE); await advanceMiningCycleNoContest({ colonyNetwork, test: this }); - const badClient = new MaliciousReputationMinerExtraRep({ loader, realProviderPort, useJsTree, minerAddress: MINER2 }, 1, new BN("10")); + const badClient = new MaliciousReputationMinerExtraRep({ loader, provider, useJsTree, minerAddress: MINER2 }, 1, new BN("10")); await badClient.initialise(colonyNetwork.address); const skillId = localSkillId; @@ -803,7 +794,7 @@ contract("Reputation Mining - happy paths", (accounts) => { expect(nInactiveLogEntries).to.eq.BN(13); // Skill 4 - const badClient = new MaliciousReputationMinerExtraRep({ loader, realProviderPort, useJsTree, minerAddress: MINER2 }, 40, 0xfffffffff); + const badClient = new MaliciousReputationMinerExtraRep({ loader, provider, useJsTree, minerAddress: MINER2 }, 40, 0xfffffffff); await badClient.initialise(colonyNetwork.address); await submitAndForwardTimeToDispute([goodClient, badClient], this); @@ -866,7 +857,7 @@ contract("Reputation Mining - happy paths", (accounts) => { await giveUserCLNYTokensAndStake(colonyNetwork, MINER2, DEFAULT_STAKE); await advanceMiningCycleNoContest({ colonyNetwork, test: this }); - const badClient = new MaliciousReputationMinerExtraRep({ loader, realProviderPort, useJsTree, minerAddress: MINER2 }, 1, new BN("10")); + const badClient = new MaliciousReputationMinerExtraRep({ loader, provider, useJsTree, minerAddress: MINER2 }, 1, new BN("10")); await badClient.initialise(colonyNetwork.address); const skillId = new BN(1); @@ -940,9 +931,9 @@ contract("Reputation Mining - happy paths", (accounts) => { }); it("a miner using delegated mining should be able to go through the whole process", async () => { - const badClient = new MaliciousReputationMinerExtraRep({ loader, realProviderPort, useJsTree, minerAddress: MINER2 }, 1, 0xfffffffff); + const badClient = new MaliciousReputationMinerExtraRep({ loader, provider, useJsTree, minerAddress: MINER2 }, 1, 0xfffffffff); await badClient.initialise(colonyNetwork.address); - const delegatedClient = new ReputationMinerTestWrapper({ loader, realProviderPort, useJsTree, minerAddress: WORKER }); + const delegatedClient = new ReputationMinerTestWrapper({ loader, provider, useJsTree, minerAddress: WORKER }); await colonyNetwork.setMiningDelegate(WORKER, true, { from: MINER1 }); await delegatedClient.initialise(colonyNetwork.address); await advanceMiningCycleNoContest({ colonyNetwork, test: this }); diff --git a/test/reputation-system/root-hash-submissions.js b/test/reputation-system/root-hash-submissions.js index cc78fb0c37..4b69c0ccf2 100644 --- a/test/reputation-system/root-hash-submissions.js +++ b/test/reputation-system/root-hash-submissions.js @@ -1,6 +1,6 @@ -/* globals artifacts */ +/* globals artifacts, ethers */ + const BN = require("bn.js"); -const { ethers } = require("ethers"); const path = require("path"); const chai = require("chai"); const bnChai = require("bn-chai"); @@ -48,8 +48,8 @@ const loader = new TruffleLoader({ contractRoot: path.resolve(__dirname, "..", "..", "artifacts", "contracts"), }); -const realProviderPort = process.env.SOLIDITY_COVERAGE ? 8555 : 8545; const useJsTree = true; +const { provider } = ethers; let colonyNetwork; let tokenLocking; @@ -73,13 +73,13 @@ const setupNewNetworkInstance = async (MINER1, MINER2, MINER3, MINER4) => { await colonyNetwork.initialiseReputationMining(); await colonyNetwork.startNextCycle(); - goodClient = new ReputationMinerTestWrapper({ loader, minerAddress: MINER1, realProviderPort, useJsTree }); + goodClient = new ReputationMinerTestWrapper({ loader, minerAddress: MINER1, provider, useJsTree }); // Mess up the second calculation. There will always be one if giveUserCLNYTokens has been called. - badClient = new MaliciousReputationMinerExtraRep({ loader, minerAddress: MINER2, realProviderPort, useJsTree }, 1, 0xfffffffff); + badClient = new MaliciousReputationMinerExtraRep({ loader, minerAddress: MINER2, provider, useJsTree }, 1, 0xfffffffff); // Mess up the second calculation in a different way - badClient2 = new MaliciousReputationMinerExtraRep({ loader, minerAddress: MINER3, realProviderPort, useJsTree }, 1, 0xeeeeeeeee); + badClient2 = new MaliciousReputationMinerExtraRep({ loader, minerAddress: MINER3, provider, useJsTree }, 1, 0xeeeeeeeee); // And one test needs a third bad client... - badClient3 = new MaliciousReputationMinerExtraRep({ loader, minerAddress: MINER4, realProviderPort, useJsTree }, 1, 0xddddddddd); + badClient3 = new MaliciousReputationMinerExtraRep({ loader, minerAddress: MINER4, provider, useJsTree }, 1, 0xddddddddd); }; contract("Reputation mining - root hash submissions", (accounts) => { @@ -574,7 +574,7 @@ contract("Reputation mining - root hash submissions", (accounts) => { await badClient.initialise(colonyNetwork.address); await advanceMiningCycleNoContest({ colonyNetwork, test: this }); - const goodClient2 = new ReputationMinerTestWrapper({ loader, realProviderPort, useJsTree, minerAddress: MINER3 }); + const goodClient2 = new ReputationMinerTestWrapper({ loader, provider, useJsTree, minerAddress: MINER3 }); await goodClient2.initialise(colonyNetwork.address); await forwardTime(MINING_CYCLE_DURATION / 2, this); @@ -624,7 +624,7 @@ contract("Reputation mining - root hash submissions", (accounts) => { const user3MiningBalanceBefore = await colonyNetwork.getMiningStake(MINER3); // We want badClient2 to submit the same hash as badClient for this test. - badClient2 = new MaliciousReputationMinerExtraRep({ loader, minerAddress: MINER3, realProviderPort, useJsTree }, 1, "0xfffffffff"); + badClient2 = new MaliciousReputationMinerExtraRep({ loader, minerAddress: MINER3, provider, useJsTree }, 1, "0xfffffffff"); badClient2.initialise(colonyNetwork.address); await forwardTime(MINING_CYCLE_DURATION / 2, this); @@ -688,7 +688,7 @@ contract("Reputation mining - root hash submissions", (accounts) => { expect(userMiningBalance3.amount, "Mining stake was not docked properly").to.eq.BN(new BN(user3MiningBalanceBefore.amount).sub(MIN_STAKE)); // Reset badClient2 to its default behaviour. - badClient2 = new MaliciousReputationMinerExtraRep({ loader, minerAddress: MINER3, realProviderPort, useJsTree }, 1, "0xeeeeeeeee"); + badClient2 = new MaliciousReputationMinerExtraRep({ loader, minerAddress: MINER3, provider, useJsTree }, 1, "0xeeeeeeeee"); }); it("should reward all stakers if they submitted the agreed new hash", async () => { diff --git a/test/reputation-system/types-of-disagreement.js b/test/reputation-system/types-of-disagreement.js index eb132d0b39..4218d1a95f 100644 --- a/test/reputation-system/types-of-disagreement.js +++ b/test/reputation-system/types-of-disagreement.js @@ -1,3 +1,5 @@ +/* globals ethers */ + const path = require("path"); const BN = require("bn.js"); const { toBN } = require("web3-utils"); @@ -46,13 +48,13 @@ const loader = new TruffleLoader({ }); const useJsTree = true; +const { provider } = ethers; let colonyNetwork; let metaColony; let clnyToken; let localSkillId; let goodClient; -const realProviderPort = process.env.SOLIDITY_COVERAGE ? 8555 : 8545; const setupNewNetworkInstance = async (MINER1, MINER2) => { colonyNetwork = await setupColonyNetwork(); @@ -66,7 +68,7 @@ const setupNewNetworkInstance = async (MINER1, MINER2) => { await colonyNetwork.initialiseReputationMining(); await colonyNetwork.startNextCycle(); - goodClient = new ReputationMinerTestWrapper({ loader, realProviderPort, useJsTree, minerAddress: MINER1 }); + goodClient = new ReputationMinerTestWrapper({ loader, provider, useJsTree, minerAddress: MINER1 }); }; contract("Reputation Mining - types of disagreement", (accounts) => { @@ -101,7 +103,7 @@ contract("Reputation Mining - types of disagreement", (accounts) => { describe("when there is a dispute over reputation root hash", () => { it("should cope when a new reputation is correctly added and an extra reputation is added elsewhere at the same time", async () => { await fundColonyWithTokens(metaColony, clnyToken); - const badClient = new MaliciousReputationMinerAddNewReputation({ loader, minerAddress: MINER2, realProviderPort, useJsTree }, 3); + const badClient = new MaliciousReputationMinerAddNewReputation({ loader, minerAddress: MINER2, provider, useJsTree }, 3); await badClient.initialise(colonyNetwork.address); await advanceMiningCycleNoContest({ colonyNetwork, test: this }); @@ -117,7 +119,7 @@ contract("Reputation Mining - types of disagreement", (accounts) => { }); it("should allow a user to confirm a submitted JRH with proofs for a submission", async () => { - const badClient = new MaliciousReputationMinerExtraRep({ loader, realProviderPort, useJsTree, minerAddress: MINER2 }, 1, 0xfffffffff); + const badClient = new MaliciousReputationMinerExtraRep({ loader, provider, useJsTree, minerAddress: MINER2 }, 1, 0xfffffffff); await badClient.initialise(colonyNetwork.address); await fundColonyWithTokens(metaColony, clnyToken); @@ -171,7 +173,7 @@ contract("Reputation Mining - types of disagreement", (accounts) => { await advanceMiningCycleNoContest({ colonyNetwork, test: this }); await advanceMiningCycleNoContest({ colonyNetwork, test: this, client: goodClient }); - const badClient = new MaliciousReputationMinerExtraRep({ loader, realProviderPort, useJsTree, minerAddress: MINER2 }, 0, 0xfffffffff); + const badClient = new MaliciousReputationMinerExtraRep({ loader, provider, useJsTree, minerAddress: MINER2 }, 0, 0xfffffffff); await badClient.initialise(colonyNetwork.address); await goodClient.saveCurrentState(); @@ -202,7 +204,7 @@ contract("Reputation Mining - types of disagreement", (accounts) => { const nInactiveLogEntries = await repCycle.getReputationUpdateLogLength(); expect(nInactiveLogEntries).to.eq.BN(13); - const badClient = new MaliciousReputationMinerExtraRep({ loader, realProviderPort, useJsTree, minerAddress: MINER2 }, 12, 0xfffffffff); + const badClient = new MaliciousReputationMinerExtraRep({ loader, provider, useJsTree, minerAddress: MINER2 }, 12, 0xfffffffff); await badClient.initialise(colonyNetwork.address); await submitAndForwardTimeToDispute([goodClient, badClient], this); @@ -352,7 +354,7 @@ contract("Reputation Mining - types of disagreement", (accounts) => { const nInactiveLogEntries = await repCycle.getReputationUpdateLogLength(); expect(nInactiveLogEntries).to.eq.BN(13); - const badClient = new MaliciousReputationMinerExtraRep({ loader, realProviderPort, useJsTree, minerAddress: MINER2 }, 27, 0xfffffffff); + const badClient = new MaliciousReputationMinerExtraRep({ loader, provider, useJsTree, minerAddress: MINER2 }, 27, 0xfffffffff); await badClient.initialise(colonyNetwork.address); await submitAndForwardTimeToDispute([goodClient, badClient], this); @@ -398,7 +400,7 @@ contract("Reputation Mining - types of disagreement", (accounts) => { const nInactiveLogEntries = await repCycle.getReputationUpdateLogLength(); expect(nInactiveLogEntries).to.eq.BN(13); - const badClient = new MaliciousReputationMinerClaimNew({ loader, realProviderPort, useJsTree, minerAddress: MINER2 }, 20); + const badClient = new MaliciousReputationMinerClaimNew({ loader, provider, useJsTree, minerAddress: MINER2 }, 20); await badClient.initialise(colonyNetwork.address); await submitAndForwardTimeToDispute([goodClient, badClient], this); @@ -424,7 +426,7 @@ contract("Reputation Mining - types of disagreement", (accounts) => { const nInactiveLogEntries = await repCycle.getReputationUpdateLogLength(); expect(nInactiveLogEntries).to.eq.BN(5); - const badClient = new MaliciousReputationMinerWrongNLeaves({ loader, realProviderPort, useJsTree, minerAddress: MINER2 }, 8); + const badClient = new MaliciousReputationMinerWrongNLeaves({ loader, provider, useJsTree, minerAddress: MINER2 }, 8); await badClient.initialise(colonyNetwork.address); await submitAndForwardTimeToDispute([goodClient, badClient], this); @@ -440,7 +442,7 @@ contract("Reputation Mining - types of disagreement", (accounts) => { it("where the number of leaves has been incremented incorrectly when adding a new reputation", async () => { await advanceMiningCycleNoContest({ colonyNetwork, test: this }); - const badClient = new MaliciousReputationMinerWrongNLeaves2({ loader, realProviderPort, useJsTree, minerAddress: MINER2 }, 3, 1); + const badClient = new MaliciousReputationMinerWrongNLeaves2({ loader, provider, useJsTree, minerAddress: MINER2 }, 3, 1); await badClient.initialise(colonyNetwork.address); await advanceMiningCycleNoContest({ colonyNetwork, test: this }); @@ -465,7 +467,7 @@ contract("Reputation Mining - types of disagreement", (accounts) => { const nInactiveLogEntries = await repCycle.getReputationUpdateLogLength(); expect(nInactiveLogEntries).to.eq.BN(5); - const badClient = new MaliciousReputationMinerWrongNLeaves2({ loader, realProviderPort, useJsTree, minerAddress: MINER2 }, 8, 1); + const badClient = new MaliciousReputationMinerWrongNLeaves2({ loader, provider, useJsTree, minerAddress: MINER2 }, 8, 1); await badClient.initialise(colonyNetwork.address); await submitAndForwardTimeToDispute([goodClient, badClient], this); @@ -490,7 +492,7 @@ contract("Reputation Mining - types of disagreement", (accounts) => { const nInactiveLogEntries = await repCycle.getReputationUpdateLogLength(); expect(nInactiveLogEntries).to.eq.BN(5); - const badClient = new MaliciousReputationMinerWrongJRH({ loader, realProviderPort, useJsTree, minerAddress: MINER2 }, 8); + const badClient = new MaliciousReputationMinerWrongJRH({ loader, provider, useJsTree, minerAddress: MINER2 }, 8); await badClient.initialise(colonyNetwork.address); await submitAndForwardTimeToDispute([goodClient, badClient], this); @@ -514,7 +516,7 @@ contract("Reputation Mining - types of disagreement", (accounts) => { const nInactiveLogEntries = await repCycle.getReputationUpdateLogLength(); expect(nInactiveLogEntries).to.eq.BN(5); - const badClient = new MaliciousReputationMinerWrongJRH({ loader, realProviderPort, useJsTree, minerAddress: MINER2 }, 500000); + const badClient = new MaliciousReputationMinerWrongJRH({ loader, provider, useJsTree, minerAddress: MINER2 }, 500000); await badClient.initialise(colonyNetwork.address); await submitAndForwardTimeToDispute([goodClient, badClient], this); @@ -542,7 +544,7 @@ contract("Reputation Mining - types of disagreement", (accounts) => { expect(nInactiveLogEntries).to.eq.BN(5); const badClient = new MaliciousReputationMinerWrongJRHRightNLeaves( - { loader, realProviderPort, useJsTree, minerAddress: MINER2 }, + { loader, provider, useJsTree, minerAddress: MINER2 }, [500000], [1, 11, 10, 9, 8], ); @@ -576,7 +578,7 @@ contract("Reputation Mining - types of disagreement", (accounts) => { const nInactiveLogEntries = await repCycle.getReputationUpdateLogLength(); expect(nInactiveLogEntries).to.eq.BN(13); - const badClient = new MaliciousReputationMinerWrongJRH({ loader, realProviderPort, useJsTree, minerAddress: MINER2 }, 35); + const badClient = new MaliciousReputationMinerWrongJRH({ loader, provider, useJsTree, minerAddress: MINER2 }, 35); await badClient.initialise(colonyNetwork.address); await submitAndForwardTimeToDispute([goodClient, badClient], this); @@ -600,7 +602,7 @@ contract("Reputation Mining - types of disagreement", (accounts) => { const nInactiveLogEntries = await repCycle.getReputationUpdateLogLength(); expect(nInactiveLogEntries).to.eq.BN(13); - const badClient = new MaliciousReputationMinerWrongUID({ loader, realProviderPort, useJsTree, minerAddress: MINER2 }, 15, 0xfffffffff); + const badClient = new MaliciousReputationMinerWrongUID({ loader, provider, useJsTree, minerAddress: MINER2 }, 15, 0xfffffffff); await badClient.initialise(colonyNetwork.address); await submitAndForwardTimeToDispute([goodClient, badClient], this); @@ -646,7 +648,7 @@ contract("Reputation Mining - types of disagreement", (accounts) => { const nInactiveLogEntries = await repCycle.getReputationUpdateLogLength(); expect(nInactiveLogEntries).to.eq.BN(13); - const badClient = new MaliciousReputationMinerReuseUID({ loader, realProviderPort, useJsTree, minerAddress: MINER2 }, 3, 1); + const badClient = new MaliciousReputationMinerReuseUID({ loader, provider, useJsTree, minerAddress: MINER2 }, 3, 1); await badClient.initialise(colonyNetwork.address); await submitAndForwardTimeToDispute([goodClient, badClient], this); @@ -663,7 +665,7 @@ contract("Reputation Mining - types of disagreement", (accounts) => { let repCycle = await getActiveRepCycle(colonyNetwork); - const badClient = new MaliciousReputationMinerExtraRep({ loader, realProviderPort, useJsTree, minerAddress: MINER2 }, 1, 0xfffffffff); + const badClient = new MaliciousReputationMinerExtraRep({ loader, provider, useJsTree, minerAddress: MINER2 }, 1, 0xfffffffff); await badClient.initialise(colonyNetwork.address); await submitAndForwardTimeToDispute([goodClient, badClient], this); @@ -734,7 +736,7 @@ contract("Reputation Mining - types of disagreement", (accounts) => { expect(nLogEntries).to.eq.BN(5); const badClient = new MaliciousReputationMinerExtraRep( - { loader, realProviderPort, useJsTree, minerAddress: MINER2 }, + { loader, provider, useJsTree, minerAddress: MINER2 }, 20, toBN("170141183460469231731687302715884105727").mul(toBN(-1)), );