Skip to content

Commit

Permalink
chore: fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
yohanelly95 committed Sep 24, 2024
1 parent 5b5607d commit d1d7c3a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
26 changes: 13 additions & 13 deletions test/AssignCollectionsRandomly.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ describe('AssignCollectionsRandomly', function () {

describe('razor', async () => {
it('Assign Collections Randomly End to End Flow', async () => {
await network.provider.send('evm_setNextBlockTimestamp', [2625097600]);
await network.provider.send('evm_setNextBlockTimestamp', [2625095600]);

/* ///////////////////////////////////////////////////////////////
SETUP
Expand Down Expand Up @@ -201,27 +201,28 @@ describe('AssignCollectionsRandomly', function () {
await assertRevert(blockManager.connect(signers[19]).finalizeDispute(epoch, 0, collectionIndexInBlock), 'Block proposed with same medians');

// Give Sorted and FinaliseDispute on non-revealed asset
await blockManager.giveSorted(epoch, 3, [400]);
await blockManager.giveSorted(epoch, 0, [100]);
collectionIndexInBlock = await getCollectionIdPositionInBlock(epoch, await blockManager.sortedProposedBlockIds(epoch, 0),
signers[0], blockManager, collectionManager);
await assertRevert(blockManager.finalizeDispute(epoch, 0, collectionIndexInBlock), 'Invalid dispute');

// disputeForProposedCollectionIds
await assertRevert(blockManager.disputeCollectionIdShouldBePresent(epoch, 0, 2), 'Dispute: ID present only');
await assertRevert(blockManager.disputeCollectionIdShouldBePresent(epoch, 0, 3), 'Dispute: ID present only');
await assertRevert(blockManager.disputeCollectionIdShouldBePresent(epoch, 0, 5), 'Dispute: ID present only');
await assertRevert(blockManager.disputeCollectionIdShouldBePresent(epoch, 0, 6), 'Dispute: ID present only');
await assertRevert(blockManager.disputeCollectionIdShouldBePresent(epoch, 0, 4), 'Dispute: ID present only');
await assertRevert(blockManager.disputeCollectionIdShouldBePresent(epoch, 0, 5), 'Dispute: ID should be absent');
await assertRevert(blockManager.disputeCollectionIdShouldBePresent(epoch, 0, 6), 'Dispute: ID should be absent');
await assertRevert(blockManager.disputeCollectionIdShouldBePresent(epoch, 0, 7), 'Dispute: ID present only');
await assertRevert(blockManager.disputeCollectionIdShouldBePresent(epoch, 0, 1), 'Dispute: ID present only');
await assertRevert(blockManager.disputeCollectionIdShouldBePresent(epoch, 0, 4), 'Dispute: ID should be absent');
await assertRevert(blockManager.disputeCollectionIdShouldBePresent(epoch, 0, 1), 'Dispute: ID should be absent');

await assertRevert(blockManager.disputeCollectionIdShouldBeAbsent(epoch, 0, 2, 0), 'Dispute: ID should be present');
await assertRevert(blockManager.disputeCollectionIdShouldBeAbsent(epoch, 0, 3, 0), 'Dispute: ID should be present');
await assertRevert(blockManager.disputeCollectionIdShouldBeAbsent(epoch, 0, 5, 0), 'Dispute: ID should be present');
await assertRevert(blockManager.disputeCollectionIdShouldBeAbsent(epoch, 0, 6, 0), 'Dispute: ID should be present');
await assertRevert(blockManager.disputeCollectionIdShouldBeAbsent(epoch, 0, 4, 0), 'Dispute: ID should be present');
await assertRevert(blockManager.disputeCollectionIdShouldBeAbsent(epoch, 0, 5, 0), 'Dispute: ID absent only');
await assertRevert(blockManager.disputeCollectionIdShouldBeAbsent(epoch, 0, 6, 0), 'Dispute: ID absent only');
await assertRevert(blockManager.disputeCollectionIdShouldBeAbsent(epoch, 0, 7, 0), 'Dispute: ID should be present');
await assertRevert(blockManager.disputeCollectionIdShouldBeAbsent(epoch, 0, 1, 0), 'Dispute: ID should be present');
await assertRevert(blockManager.disputeCollectionIdShouldBeAbsent(epoch, 0, 4, 0), 'Dispute: ID absent only');
await assertRevert(blockManager.disputeCollectionIdShouldBeAbsent(epoch, 0, 1, 0), 'Dispute: ID absent only');

// the id itself doesnt exist
await assertRevert(blockManager.disputeOnOrderOfIds(epoch, 0, 1, 0), 'index1 not greater than index0 0');
await assertRevert(blockManager.disputeOnOrderOfIds(epoch, 0, 0, 1), 'ID at i0 not gt than of i1');
Expand Down Expand Up @@ -295,11 +296,10 @@ describe('AssignCollectionsRandomly', function () {
await restoreSnapshot(snapshotId);
snapshotId = await takeSnapshot();
// additional 2
await adhocPropose(signers[1], [1, 2, 4, 5, 6, 7], [100, 200, 400, 500, 600, 700], stakeManager, blockManager, voteManager);
await adhocPropose(signers[1], [1, 2, 8, 5, 6, 7], [100, 200, 800, 500, 600, 700], stakeManager, blockManager, voteManager);
await mineToNextState();
const epoch = await getEpoch();

await blockManager.disputeCollectionIdShouldBeAbsent(epoch, 0, 4, 2);
await blockManager.disputeCollectionIdShouldBeAbsent(epoch, 0, 8, 2);
const blockIndexToBeConfirmed = await blockManager.blockIndexToBeConfirmed();
const block = await blockManager.getProposedBlock(epoch, 0);
expect(blockIndexToBeConfirmed).to.eq(-1);
Expand Down
2 changes: 1 addition & 1 deletion test/helpers/InternalEngine.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ const proposeWithDeviation = async (signer, deviation, stakeManager, blockManage
}
}
}
// console.log('propose', idsRevealedThisEpoch, mediansValues);

await blockManager.connect(signer).propose(epoch,
idsRevealedThisEpoch,
mediansValues,
Expand Down
2 changes: 2 additions & 0 deletions test/helpers/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const calculateDisputesData = async (collectionId, voteManager, stakeManager, ep
median = sortedValues[i];
}
}

return {
median, totalInfluenceRevealed, sortedValues,
};
Expand Down Expand Up @@ -295,6 +296,7 @@ const adhocPropose = async (signer, ids, medians, stakeManager, blockManager, vo
const staker = await stakeManager.getStaker(stakerID);
const { biggestStake, biggestStakerId } = await getBiggestStakeAndId(stakeManager, voteManager); (stakeManager);
const iteration = await getIteration(voteManager, stakeManager, staker, biggestStake);

await blockManager.connect(signer).propose(getEpoch(),
ids,
medians,
Expand Down

0 comments on commit d1d7c3a

Please sign in to comment.