Skip to content

Commit

Permalink
test: unit test fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
naneey committed Oct 9, 2023
1 parent 6170a58 commit a694343
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,7 @@ void transferToEmergencyFund(){
BigInteger emergencyFund = BigInteger.valueOf(10).multiply(ICX);
try (MockedStatic<Context> theMock = Mockito.mockStatic(Context.class)){
theMock.when(() -> Context.call(cpsScore.get(), "isAdmin", Context.getCaller())).thenReturn(true);
tokenScore.invoke(owner,"transferToEmergencyFund",emergencyFund);
tokenScore.invoke(owner,"allocateEmergencyFund",emergencyFund);

theMock.when(() -> Context.call(balanceDollar.get(), "balanceOf", Context.getAddress())).thenReturn(BigInteger.valueOf(100).multiply(ICX));
assertEquals(emergencyFund,tokenScore.call("getEmergencyFund"));
Expand All @@ -726,7 +726,7 @@ void withdrawFromEmergencyFund(){
BigInteger withdrawAmount = BigInteger.valueOf(4).multiply(ICX);
try (MockedStatic<Context> theMock = Mockito.mockStatic(Context.class)){
theMock.when(() -> Context.call(cpsScore.get(), "isAdmin", Context.getCaller())).thenReturn(true);
tokenScore.invoke(owner,"withdrawFromEmergencyFund",withdrawAmount,testing_account.getAddress());
tokenScore.invoke(owner,"withdrawFromEmergencyFund",withdrawAmount,testing_account.getAddress(), "Need fund");

theMock.when(() -> Context.call(balanceDollar.get(), "balanceOf", Context.getAddress())).thenReturn(BigInteger.valueOf(100).multiply(ICX));
assertEquals(BigInteger.valueOf(6).multiply(ICX),tokenScore.call("getEmergencyFund"));
Expand Down

0 comments on commit a694343

Please sign in to comment.