Skip to content

Commit

Permalink
fix: resolve broken tests
Browse files Browse the repository at this point in the history
  • Loading branch information
whoabuddy committed Sep 1, 2023
1 parent b094079 commit e7ee0d5
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Clarinet.toml
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ path = "contracts/proposals/ccip014-pox-3-v2.clar"
clarity_version = 2
epoch = 2.4

[contracts.ccip017]
[contracts.ccip017-extend-sunset-period]
path = "contracts/proposals/ccip017-extend-direct-execute-sunset-period.clar"
clarity_version = 2
epoch = 2.4
Expand Down
67 changes: 55 additions & 12 deletions tests/proposals/ccip017-extend-direct-execute-sunset-period.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -500,21 +500,44 @@ Clarinet.test({
ccd007CityStacking.getCurrentRewardCycle().result.expectUint(5);

// act

// execute yes and no vote
// user 1 has more voting power
const votingBlock = chain.mineBlock([ccip017ExtendDirectExecuteSunsetPeriod.voteOnProposal(user1, false), ccip017ExtendDirectExecuteSunsetPeriod.voteOnProposal(user2, true)]);

// assert

// overall totals
assertEquals(ccip017ExtendDirectExecuteSunsetPeriod.getVoteTotals().result.expectSome().expectTuple(), { noTotal: types.uint(938), noVotes: types.uint(1), yesTotal: types.uint(469), yesVotes: types.uint(1) });
assertEquals(ccip017ExtendDirectExecuteSunsetPeriod.getVoteTotals().result.expectSome().expectTuple(), {
noTotal: types.uint(941),
noVotes: types.uint(1),
yesTotal: types.uint(470),
yesVotes: types.uint(1),
});

// user 1
assertEquals(ccd007CityStacking.getStacker(mia.cityId, cycleId, user1Id).result.expectTuple(), { claimable: types.uint(0), stacked: types.uint(500) });
assertEquals(ccip017ExtendDirectExecuteSunsetPeriod.getVoterInfo(user1Id).result.expectSome().expectTuple(), { mia: types.uint(438), nyc: types.uint(500), total: types.uint(938), vote: types.bool(false) });

assertEquals(ccd007CityStacking.getStacker(mia.cityId, cycleId, user1Id).result.expectTuple(), {
claimable: types.uint(0),
stacked: types.uint(500),
});
assertEquals(ccip017ExtendDirectExecuteSunsetPeriod.getVoterInfo(user1Id).result.expectSome().expectTuple(), {
mia: types.uint(441),
nyc: types.uint(500),
total: types.uint(941),
vote: types.bool(false),
});

// user 2
assertEquals(ccd007CityStacking.getStacker(mia.cityId, cycleId, user2Id).result.expectTuple(), { claimable: types.uint(0), stacked: types.uint(250) });
assertEquals(ccip017ExtendDirectExecuteSunsetPeriod.getVoterInfo(user2Id).result.expectSome().expectTuple(), { mia: types.uint(219), nyc: types.uint(250), total: types.uint(469), vote: types.bool(true) });
assertEquals(ccd007CityStacking.getStacker(mia.cityId, cycleId, user2Id).result.expectTuple(), {
claimable: types.uint(0),
stacked: types.uint(250),
});
assertEquals(ccip017ExtendDirectExecuteSunsetPeriod.getVoterInfo(user2Id).result.expectSome().expectTuple(), {
mia: types.uint(220),
nyc: types.uint(250),
total: types.uint(470),
vote: types.bool(true),
});

// act

Expand All @@ -524,19 +547,39 @@ Clarinet.test({
// assert

// overall totals
assertEquals(ccip017ExtendDirectExecuteSunsetPeriod.getVoteTotals().result.expectSome().expectTuple(), { noTotal: types.uint(469), noVotes: types.uint(1), yesTotal: types.uint(938), yesVotes: types.uint(1) });
assertEquals(ccip017ExtendDirectExecuteSunsetPeriod.getVoteTotals().result.expectSome().expectTuple(), {
noTotal: types.uint(470),
noVotes: types.uint(1),
yesTotal: types.uint(941),
yesVotes: types.uint(1),
});
// user 1
assertEquals(ccd007CityStacking.getStacker(mia.cityId, cycleId, user1Id).result.expectTuple(), { claimable: types.uint(0), stacked: types.uint(500) });
assertEquals(ccip017ExtendDirectExecuteSunsetPeriod.getVoterInfo(user1Id).result.expectSome().expectTuple(), { mia: types.uint(438), nyc: types.uint(500), total: types.uint(938), vote: types.bool(true) });
assertEquals(ccd007CityStacking.getStacker(mia.cityId, cycleId, user1Id).result.expectTuple(), {
claimable: types.uint(0),
stacked: types.uint(500),
});
assertEquals(ccip017ExtendDirectExecuteSunsetPeriod.getVoterInfo(user1Id).result.expectSome().expectTuple(), {
mia: types.uint(441),
nyc: types.uint(500),
total: types.uint(941),
vote: types.bool(true),
});
// user 2
assertEquals(ccd007CityStacking.getStacker(mia.cityId, cycleId, user2Id).result.expectTuple(), { claimable: types.uint(0), stacked: types.uint(250) });
assertEquals(ccip017ExtendDirectExecuteSunsetPeriod.getVoterInfo(user2Id).result.expectSome().expectTuple(), { mia: types.uint(219), nyc: types.uint(250), total: types.uint(469), vote: types.bool(false) });
assertEquals(ccd007CityStacking.getStacker(mia.cityId, cycleId, user2Id).result.expectTuple(), {
claimable: types.uint(0),
stacked: types.uint(250),
});
assertEquals(ccip017ExtendDirectExecuteSunsetPeriod.getVoterInfo(user2Id).result.expectSome().expectTuple(), {
mia: types.uint(220),
nyc: types.uint(250),
total: types.uint(470),
vote: types.bool(false),
});

// execute ccip-017
const block = passProposal(chain, accounts, PROPOSALS.CCIP_017);

// assert
//console.log(`\nexecute block:\n${JSON.stringify(block, null, 2)}`);
block.receipts[2].result.expectOk().expectUint(3);
},
});
2 changes: 1 addition & 1 deletion utils/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const PROPOSALS = {
CCIP_013: ADDRESS.concat(".ccip013-migration"),
CCIP_014: ADDRESS.concat(".ccip014-pox-3"),
CCIP_014_V2: ADDRESS.concat(".ccip014-pox-3-v2"),
CCIP_017: ADDRESS.concat(".ccip017"),
CCIP_017: ADDRESS.concat(".ccip017-extend-sunset-period"),
TEST_CCD001_DIRECT_EXECUTE_001: ADDRESS.concat(".test-ccd001-direct-execute-001"),
TEST_CCD001_DIRECT_EXECUTE_002: ADDRESS.concat(".test-ccd001-direct-execute-002"),
TEST_CCD001_DIRECT_EXECUTE_003: ADDRESS.concat(".test-ccd001-direct-execute-003"),
Expand Down

0 comments on commit e7ee0d5

Please sign in to comment.