Skip to content

Commit

Permalink
Update tests for new restriction on confirmNewHash
Browse files Browse the repository at this point in the history
  • Loading branch information
area committed Jan 14, 2022
1 parent 6121b2c commit 4e8da0f
Show file tree
Hide file tree
Showing 11 changed files with 142 additions and 134 deletions.
16 changes: 12 additions & 4 deletions helpers/test-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,7 @@ export async function advanceMiningCycleNoContest({ colonyNetwork, client, miner
if (client !== undefined) {
await client.addLogContentsToReputationTree();
await client.submitRootHash();
await client.confirmEntry();
} else {
const accounts = await web3GetAccounts();
minerAddress = minerAddress || accounts[5]; // eslint-disable-line no-param-reassign
Expand All @@ -629,8 +630,8 @@ export async function advanceMiningCycleNoContest({ colonyNetwork, client, miner
} catch (err) {
console.log("advanceMiningCycleNoContest error thrown by .submitRootHash", err);
}
await repCycle.confirmNewHash(0, { from: minerAddress });
}
await repCycle.confirmNewHash(0, { from: minerAddress });
}

export async function accommodateChallengeAndInvalidateHashViaTimeout(colonyNetwork, test, client1) {
Expand All @@ -652,8 +653,10 @@ export async function accommodateChallengeAndInvalidateHashViaTimeout(colonyNetw
await forwardTime(SUBMITTER_ONLY_WINDOW + 600, this);

const toInvalidateIdx = idx1.mod(2).eq(1) ? idx1.sub(1) : idx1.add(1);
const accounts = await web3GetAccounts();
const minerAddress = accounts[5];

return repCycle.invalidateHash(round1, toInvalidateIdx);
return repCycle.invalidateHash(round1, toInvalidateIdx, { from: minerAddress });
}

export async function accommodateChallengeAndInvalidateHash(colonyNetwork, test, client1, client2, _errors) {
Expand Down Expand Up @@ -703,7 +706,8 @@ export async function accommodateChallengeAndInvalidateHash(colonyNetwork, test,
}
await forwardTime(SUBMITTER_ONLY_WINDOW + 1, this);

return repCycle.invalidateHash(round1, toInvalidateIdx);
const signingAddress = await client1.realWallet.getAddress();
return repCycle.invalidateHash(round1, toInvalidateIdx, { from: signingAddress });
}

async function navigateChallenge(colonyNetwork, client1, client2, errors) {
Expand Down Expand Up @@ -825,7 +829,11 @@ export async function finishReputationMiningCycle(colonyNetwork, test) {
const disputeRound = await repCycle.getDisputeRound(roundNumber);
const timestamp = disputeRound[0].lastResponseTimestamp;
await forwardTimeTo(parseInt(timestamp, 10) + MINING_CYCLE_DURATION, test);
await repCycle.confirmNewHash(roundNumber);

const accounts = await web3GetAccounts();
const minerAddress = accounts[5];

await repCycle.confirmNewHash(roundNumber, { from: minerAddress });
// But for now, that's okay.
} else {
// We shouldn't get here. If this fires during a test, you haven't finished writing the test.
Expand Down
8 changes: 4 additions & 4 deletions test-chainid/chainid-dependent-behaviour.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,12 @@ contract("Contract Storage", (accounts) => {

await forwardTime(MINING_CYCLE_DURATION / 2 + SUBMITTER_ONLY_WINDOW + MINING_CYCLE_TIMEOUT + 1, this);

await repCycle.invalidateHash(0, 0);
await repCycle.invalidateHash(0, 3);
await repCycle.invalidateHash(0, 0, { from: MINER1 });
await repCycle.invalidateHash(0, 3, { from: MINER1 });

await forwardTime(SUBMITTER_ONLY_WINDOW + 1, this);
const networkBalanceBefore = await clnyToken.balanceOf(colonyNetwork.address);
const tx = await repCycle.confirmNewHash(1);
const tx = await repCycle.confirmNewHash(1, { from: MINER1 });

if (chainId === XDAI || chainId === FORKED_XDAI) {
// tokens should be paid from the network balance
Expand Down Expand Up @@ -155,7 +155,7 @@ contract("Contract Storage", (accounts) => {
await repCycle.submitRootHash("0x12345678", 10, "0x00", 1, { from: MINER1 });

await forwardTime(SUBMITTER_ONLY_WINDOW + 1, this);
const tx = await repCycle.confirmNewHash(0);
const tx = await repCycle.confirmNewHash(0, { from: MINER1 });
await expectNoEvent(tx, "Transfer(address indexed,address indexed,uint256)", [colonyNetwork.address, metaColony.address, 0]);
await expectNoEvent(tx, "Burn(address indexed,uint256)", [colonyNetwork.address, 0]);
});
Expand Down
2 changes: 1 addition & 1 deletion test-gas-costs/gasCosts.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ contract("All", function (accounts) {
});
const repCycle = await getActiveRepCycle(colonyNetwork);
await forwardTime(SUBMITTER_ONLY_WINDOW + 1, this);
await repCycle.confirmNewHash(2);
await repCycle.confirmNewHash(2, { from: STAKER1 });

// withdraw
const clnyToken = await metaColony.getToken();
Expand Down
2 changes: 1 addition & 1 deletion test/contracts-network/reputation-basic-functionality.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ contract("Reputation mining - basic functionality", (accounts) => {

// Cleanup
await forwardTime(SUBMITTER_ONLY_WINDOW + 1, this);
await repCycle.confirmNewHash(0);
await repCycle.confirmNewHash(0, { from: MINER1 });
});
});

Expand Down
2 changes: 1 addition & 1 deletion test/extensions/funding-queue.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ contract("Funding Queues", (accounts) => {
const repCycle = await getActiveRepCycle(colonyNetwork);
await forwardTime(MINING_CYCLE_DURATION + SUBMITTER_ONLY_WINDOW + 1, this);
await repCycle.submitRootHash(rootHash, 0, "0x00", 10, { from: MINER });
await repCycle.confirmNewHash(0);
await repCycle.confirmNewHash(0, { from: MINER });
});

describe("managing the extension", async () => {
Expand Down
4 changes: 2 additions & 2 deletions test/extensions/voting-rep.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ contract("Voting Reputation", (accounts) => {
await forwardTime(MINING_CYCLE_DURATION, this);
await repCycle.submitRootHash(rootHash, 0, "0x00", 10, { from: MINER });
await forwardTime(SUBMITTER_ONLY_WINDOW + 1, this);
await repCycle.confirmNewHash(0);
await repCycle.confirmNewHash(0, { from: MINER });
});

function hashExpenditureSlot(action) {
Expand Down Expand Up @@ -1063,7 +1063,7 @@ contract("Voting Reputation", (accounts) => {
const repCycle = await getActiveRepCycle(colonyNetwork);
await repCycle.submitRootHash(rootHash, 0, "0x00", 10, { from: MINER });
await forwardTime(SUBMITTER_ONLY_WINDOW + 1, this);
await repCycle.confirmNewHash(0);
await repCycle.confirmNewHash(0, { from: MINER });

// Create new motion with new reputation state
const action = await encodeTxData(colony, "mintTokens", [WAD]);
Expand Down
Loading

0 comments on commit 4e8da0f

Please sign in to comment.