From d1d7c3af32774372f034e3a7163925ece0887c61 Mon Sep 17 00:00:00 2001 From: yohanelly95 Date: Tue, 24 Sep 2024 13:48:38 +0530 Subject: [PATCH] chore: fix test --- test/AssignCollectionsRandomly.js | 26 +++++++++++++------------- test/helpers/InternalEngine.js | 2 +- test/helpers/utils.js | 2 ++ 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/test/AssignCollectionsRandomly.js b/test/AssignCollectionsRandomly.js index 26f90786..47f961f0 100644 --- a/test/AssignCollectionsRandomly.js +++ b/test/AssignCollectionsRandomly.js @@ -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 @@ -201,7 +201,7 @@ 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'); @@ -209,19 +209,20 @@ describe('AssignCollectionsRandomly', function () { // 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'); @@ -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); diff --git a/test/helpers/InternalEngine.js b/test/helpers/InternalEngine.js index 041fb08f..de193999 100644 --- a/test/helpers/InternalEngine.js +++ b/test/helpers/InternalEngine.js @@ -224,7 +224,7 @@ const proposeWithDeviation = async (signer, deviation, stakeManager, blockManage } } } - // console.log('propose', idsRevealedThisEpoch, mediansValues); + await blockManager.connect(signer).propose(epoch, idsRevealedThisEpoch, mediansValues, diff --git a/test/helpers/utils.js b/test/helpers/utils.js index 6adcecab..3314130e 100644 --- a/test/helpers/utils.js +++ b/test/helpers/utils.js @@ -47,6 +47,7 @@ const calculateDisputesData = async (collectionId, voteManager, stakeManager, ep median = sortedValues[i]; } } + return { median, totalInfluenceRevealed, sortedValues, }; @@ -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,