Skip to content

Commit

Permalink
cpsScore and update period fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Swastik47 committed Sep 25, 2024
1 parent 0c190bb commit 5bf3add
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,8 @@ void setCouncilManagers() {

// @Test
// public void testSetRewardPool() {
// setCPSScoreMethod(score_address);

// final String AVAILABLE_BALANCE = "availableBalance";

// String initialFundKey = "INITIAL_FUND";
Expand Down Expand Up @@ -800,6 +802,7 @@ public class RewardVoteTest {

@Test
public void testRewardVote() {
setCPSScoreMethod(score_address);
MockedStatic<Context> contextMock = mockStatic(Context.class);

BigInteger newFunds = BigInteger.valueOf(400).multiply(EXA);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1262,7 +1262,6 @@ public void updatePeriod() {
period.updatePeriodIndex.set(updateIndex + 1);
callScore(getCpfTreasuryScore(), "setRewardPool", "finalFund");
updateProposalsResult();

PeriodUpdate("Period Update State 1/4. Period Updated to Transition Period. " +
"After all the calculations are completed, " +
"Period will change to " + APPLICATION_PERIOD);
Expand Down Expand Up @@ -1294,7 +1293,6 @@ public void updatePeriod() {
burn(proposalFees.get(), null);
proposalFees.set(BigInteger.ZERO);
callScore(getCpfTreasuryScore(), "distributeRewardToFundManagers");

}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,8 @@ void voteProposalMethodReject() {
}

void updatePeriods() {
doNothing().when(scoreSpy).callScore(eq(cpfTreasury), eq("distributeRewardToFundManagers"));
doNothing().when(scoreSpy).callScore(eq(cpfTreasury), eq("setRewardPool"), any());
// 1/4
cpsScore.invoke(owner, "updatePeriod");
// 2/4
Expand Down Expand Up @@ -864,6 +866,7 @@ void updatePeriodAfterProposalVoting() {

doNothing().when(scoreSpy).callScore(eq(cpfTreasury), eq("resetSwapState"));
doReturn(BigInteger.valueOf(15)).when(scoreSpy).getVotingPeriod();

updatePeriods();

Map<String, Object> proposalDetails = getProposalDetailsByHash("Proposal 1");
Expand Down Expand Up @@ -2075,73 +2078,6 @@ void submitProgressReportBeforeDeadline() {
}

//begin
// @Test
// void testhasTwoThirdsMajority(){
// String key="test";

// doReturn(BigInteger.valueOf(15)).when(scoreSpy).getSponsorBondPercentage();
// registerPrepsMethod();


// //need attributes?

// //set flag to true for mock test
// //doReturn(true).when(cpsScore).call(Boolean.class, ((Object) cpfTreasury).get(), "getCouncilFlag");
// // boolean councilFlag = true;
// doReturn(true).when(scoreSpy).getCouncilFlag();

// // sponsor address sponsor voter valid prep ma exist huna paryo
// //votes 3 wota weight 100= constant 100x10=1000

// setMilestoneVotes(key, BigInteger.valueOf(1000), 10);
// setApprovedVotes(key, BigInteger.valueOf(700), 7,true);

// Boolean result = call(Boolean.class, cpsScore.getAddress(), "hasTwoThirdsMajority", key);
// assertTrue(result, "Should meet 2/3 majority");

// contextMock.when(caller()).thenReturn(testingAccount.getAddress());
// setMilestoneVotes(key, BigInteger.valueOf(1000), 10);
// setApprovedVotes(key, BigInteger.valueOf(300), 3, true);

// result = call(Boolean.class, cpsScore.getAddress(), "hasTwoThirdsMajority", key);
// assertFalse(result, "Should meet 2/3 majority");

// //flag to false
// // doReturn(false).when(cpsScore).call(Boolean.class, ((Object) cpfTreasury).get(), "getCouncilFlag");
// // councilFlag = false;
// doReturn(false).when(scoreSpy).getCouncilFlag();

// contextMock.when(caller()).thenReturn(testingAccount1.getAddress());
// setMilestoneVotes(key, BigInteger.valueOf(1000), 10);
// setApprovedVotes(key, BigInteger.valueOf(700), 7, true);

// result = call(Boolean.class, cpsScore.getAddress(), "hasTwoThirdsMajority", key);
// assertTrue(result, "Should meet 2/3 majority");

// contextMock.when(caller()).thenReturn(testingAccount.getAddress());
// setMilestoneVotes(key, BigInteger.valueOf(1000), 10);
// setApprovedVotes(key, BigInteger.valueOf(300), 3, true);

// result = call(Boolean.class, cpsScore.getAddress(), "hasTwoThirdsMajority", key);
// assertFalse(result, "Should meet 2/3 majority");

// }

// private Boolean call(Class<Boolean> returnType, Address address, String method, String key) {
// return Context.call(returnType, address, method, key);
// }

// void setMilestoneVotes(String key, BigInteger totalVotes, int totalVoters) {
// cpsScore.invoke(owner, "setTotalVotes", key, totalVotes, totalVoters, true);
// }

// void setProposalVotes(String key, BigInteger totalVotes, int totalVoters) {
// cpsScore.invoke(owner, "setTotalVotes", key, totalVotes, totalVoters, false);
// }

// void setApprovedVotes(String key, BigInteger approvedVotes, int approveVoters, boolean isMilestone) {
// cpsScore.invoke(owner, "setApprovedVotes", key, approvedVotes, approveVoters, isMilestone);
// }

public class VotingTest {

Expand Down Expand Up @@ -2194,8 +2130,6 @@ public void testVotingProcess() {
Boolean isMajorityAfterThirdVote = (Boolean)cpsScore.call("hasTwoThirdsMajority","Proposal 1", true);
assertTrue(isMajorityAfterThirdVote); // Expecting true
}


}
//end

Expand Down

0 comments on commit 5bf3add

Please sign in to comment.