Skip to content

Commit

Permalink
finish tests for new cut function
Browse files Browse the repository at this point in the history
  • Loading branch information
SamBorisov committed Jun 6, 2024
1 parent ef06804 commit 1326145
Show file tree
Hide file tree
Showing 3 changed files with 363 additions and 4 deletions.
2 changes: 1 addition & 1 deletion test/LiquidityToken/LiquidityToken.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ describe("LiquidityToken", async function () {
});
});

describe("Permit()", async function () {
describe("permit()", async function () {
it("Should be able to transfer to the user with a permit", async () => {
const amount = 1000;
const { token } = await loadFixture(initializeFixture);
Expand Down
36 changes: 35 additions & 1 deletion test/RewardPool/RewardPool.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { loadFixture, time } from "@nomicfoundation/hardhat-network-helpers";
import * as hre from "hardhat";
import { expect } from "chai";

import { DAY, EPOCHS_YEAR, ERRORS, VESTING_DURATION_WEEKS, WEEK } from "../constants";
import { EPOCHS_YEAR, DAY, ERRORS, VESTING_DURATION_WEEKS, WEEK, DEADLINE } from "../constants";
import {
calculateExpectedReward,
commitEpoch,
Expand All @@ -13,6 +13,7 @@ import {
getDelegatorPositionReward,
getValidatorReward,
retrieveRPSData,
getPermitSignature,
} from "../helper";

export function RunStakeFunctionsByValidatorSet(): void {
Expand Down Expand Up @@ -502,6 +503,39 @@ export function RunVestedDelegateClaimTests(): void {
expect(await validatorSet.withdrawable(vestManager.address), "withdrawable").to.eq(0);
});

it("should return when unused position using permit", async function () {
const { validatorSet, rewardPool, liquidToken, vestManager, vestManagerOwner, delegatedValidator } =
await loadFixture(this.fixtures.weeklyVestedDelegationFixture);

const delegatedAmount = await rewardPool.delegationOf(delegatedValidator.address, vestManager.address);
// ensure is active position
expect(await rewardPool.isActiveDelegatePosition(delegatedValidator.address, vestManager.address), "isActive").to
.be.true;

const { v, r, s } = await getPermitSignature(
vestManagerOwner,
liquidToken,
vestManager.address,
delegatedAmount,
DEADLINE
);
await vestManager.cutVestedDelegatePositionWithPermit(
delegatedValidator.address,
delegatedAmount,
DEADLINE,
v,
r,
s
);

// check reward
expect(
await rewardPool.getRawDelegatorReward(delegatedValidator.address, vestManager.address),
"getRawDelegatorReward"
).to.be.eq(0);
expect(await validatorSet.withdrawable(vestManager.address), "withdrawable").to.eq(0);
});

it("should revert when wrong rps index is provided", async function () {
const { systemValidatorSet, validatorSet, rewardPool, vestManager, delegatedValidator } = await loadFixture(
this.fixtures.weeklyVestedDelegationFixture
Expand Down
Loading

0 comments on commit 1326145

Please sign in to comment.