Skip to content

Commit

Permalink
Fix integration tests for staking pool starting with 1
Browse files Browse the repository at this point in the history
  • Loading branch information
shark0der committed Feb 10, 2023
1 parent 3cf6a69 commit b733d40
Show file tree
Hide file tree
Showing 9 changed files with 89 additions and 88 deletions.
4 changes: 2 additions & 2 deletions test/integration/Cover/createStakingPool.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ describe('createStakingPool', function () {
const stakingPoolCountAfter = await spf.stakingPoolCount();
expect(stakingPoolCountAfter).to.be.equal(stakingPoolCountBefore.add(1));

const stakingPoolAddress = await cover.stakingPool(stakingPoolCountAfter.sub(1));
const stakingPoolAddress = await cover.stakingPool(stakingPoolCountAfter);
const stakingPool = await ethers.getContractAt('StakingPool', stakingPoolAddress);

const managerStakingPoolNFTBalanceBefore = await stakingNFT.balanceOf(manager.address);
Expand Down Expand Up @@ -82,7 +82,7 @@ describe('createStakingPool', function () {
const stakingPoolCountAfter = await spf.stakingPoolCount();
expect(stakingPoolCountAfter).to.be.equal(stakingPoolCountBefore.add(1));

const stakingPoolAddress = await cover.stakingPool(stakingPoolCountAfter.sub(1));
const stakingPoolAddress = await cover.stakingPool(stakingPoolCountAfter);
const stakingPool = await ethers.getContractAt('StakingPool', stakingPoolAddress);

const managerStakingPoolNFTBalanceBefore = await stakingNFT.balanceOf(manager.address);
Expand Down
20 changes: 10 additions & 10 deletions test/integration/Cover/totalActiveCover.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const buyCoverFixture = {

describe('totalActiveCover', function () {
beforeEach(async function () {
const { tk, stakingProducts, stakingPool0 } = this.contracts;
const { tk, stakingProducts, stakingPool1 } = this.contracts;
const { stakingPoolManagers } = this.accounts;

const members = this.accounts.members.slice(0, 5);
Expand All @@ -46,7 +46,7 @@ describe('totalActiveCover', function () {

await stakingProducts
.connect(stakingPoolManagers[0])
.setProducts(await stakingPool0.getPoolId(), [stakedProductParamTemplate]);
.setProducts(await stakingPool1.getPoolId(), [stakedProductParamTemplate]);
});

function calculateFirstTrancheId(lastBlock, period, gracePeriod) {
Expand Down Expand Up @@ -96,7 +96,7 @@ describe('totalActiveCover', function () {
commissionDestination: AddressZero,
ipfsData: '',
},
[{ poolId: 0, coverAmountInAsset: amount.toString() }],
[{ poolId: 1, coverAmountInAsset: amount.toString() }],
{
value: expectedPremium,
},
Expand All @@ -116,18 +116,18 @@ describe('totalActiveCover', function () {

it('expire a cover that had a claim paid out fully', async function () {
const { DEFAULT_PRODUCTS } = this;
const { cover, stakingPool0, as, yc, gv, ybETH } = this.contracts;
const { cover, stakingPool1, as, yc, gv, ybETH } = this.contracts;
const [coverBuyer1, staker1] = this.accounts.members;
const [nonMember1] = this.accounts.nonMembers;
const { BUCKET_SIZE } = this.config;

const { productId, coverAsset, period, gracePeriod, amount, coverId, segmentId, incidentId, assessmentId } =
buyCoverFixture;

expect(await cover.stakingPool(0)).to.be.equal(stakingPool0.address);
expect(await cover.stakingPool(1)).to.be.equal(stakingPool1.address);

// Stake to open up capacity
await stake({ stakingPool: stakingPool0, staker: staker1, period, gracePeriod });
await stake({ stakingPool: stakingPool1, staker: staker1, period, gracePeriod });

// cover buyer gets yield token
await transferYieldToken({ tokenOwner: this.accounts.defaultSender, coverBuyer1, yc, ybETH });
Expand Down Expand Up @@ -188,15 +188,15 @@ describe('totalActiveCover', function () {
it('expire a cover that had a partial claim paid out', async function () {
const { DEFAULT_PRODUCTS } = this;
const { BUCKET_SIZE } = this.config;
const { cover, stakingPool0, as, yc, gv, ybETH } = this.contracts;
const { cover, stakingPool1, as, yc, gv, ybETH } = this.contracts;
const [coverBuyer1, staker1] = this.accounts.members;
const [nonMember1] = this.accounts.nonMembers;

const { productId, coverAsset, period, gracePeriod, amount, coverId, segmentId, incidentId, assessmentId } =
buyCoverFixture;

// Stake to open up capacity
await stake({ stakingPool: stakingPool0, staker: staker1, period, gracePeriod });
await stake({ stakingPool: stakingPool1, staker: staker1, period, gracePeriod });

// cover buyer gets yield token
await transferYieldToken({ tokenOwner: this.accounts.defaultSender, coverBuyer1, yc, ybETH });
Expand Down Expand Up @@ -264,15 +264,15 @@ describe('totalActiveCover', function () {
it('expire a cover that had rejected claim', async function () {
const { DEFAULT_PRODUCTS } = this;
const { BUCKET_SIZE } = this.config;
const { cover, stakingPool0, as, yc, gv, ybETH } = this.contracts;
const { cover, stakingPool1, as, yc, gv, ybETH } = this.contracts;
const [coverBuyer1, staker1, staker2] = this.accounts.members;
const [nonMember1] = this.accounts.nonMembers;

const { productId, coverAsset, period, gracePeriod, coverId, segmentId, incidentId, assessmentId } =
buyCoverFixture;

// Stake to open up capacity
await stake({ stakingPool: stakingPool0, staker: staker1, period, gracePeriod });
await stake({ stakingPool: stakingPool1, staker: staker1, period, gracePeriod });

// cover buyer gets yield token
await transferYieldToken({ tokenOwner: this.accounts.defaultSender, coverBuyer1, yc, ybETH });
Expand Down
60 changes: 30 additions & 30 deletions test/integration/IndividualClaims/submitClaim.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe('submitClaim', function () {

it('submits ETH claim and approves claim', async function () {
const { DEFAULT_PRODUCTS } = this;
const { ic, cover, stakingPool0, as } = this.contracts;
const { ic, cover, stakingPool1, as } = this.contracts;
const [coverBuyer1, staker1, staker2] = this.accounts.members;

// Cover inputs
Expand All @@ -49,7 +49,7 @@ describe('submitClaim', function () {
const amount = parseEther('1');

// Stake to open up capacity
await stake({ stakingPool: stakingPool0, staker: staker1, gracePeriod, period, productId });
await stake({ stakingPool: stakingPool1, staker: staker1, gracePeriod, period, productId });

// Buy Cover
await buyCover({
Expand Down Expand Up @@ -89,7 +89,7 @@ describe('submitClaim', function () {

it('submits partial ETH claim and approves claim', async function () {
const { DEFAULT_PRODUCTS } = this;
const { ic, cover, stakingPool0, as } = this.contracts;
const { ic, cover, stakingPool1, as } = this.contracts;
const [coverBuyer1, staker1, staker2] = this.accounts.members;

// Cover inputs
Expand All @@ -100,7 +100,7 @@ describe('submitClaim', function () {
const amount = parseEther('1');

// Stake to open up capacity
await stake({ stakingPool: stakingPool0, staker: staker1, gracePeriod, period, productId });
await stake({ stakingPool: stakingPool1, staker: staker1, gracePeriod, period, productId });

// Buy Cover
await buyCover({
Expand Down Expand Up @@ -141,7 +141,7 @@ describe('submitClaim', function () {

it('submits ETH claim and rejects claim', async function () {
const { DEFAULT_PRODUCTS } = this;
const { ic, cover, stakingPool0, as } = this.contracts;
const { ic, cover, stakingPool1, as } = this.contracts;
const [coverBuyer1, staker1, staker2, staker3] = this.accounts.members;

// Cover inputs
Expand All @@ -152,7 +152,7 @@ describe('submitClaim', function () {
const amount = parseEther('1');

// Stake to open up capacity
await stake({ stakingPool: stakingPool0, staker: staker1, gracePeriod, period, productId });
await stake({ stakingPool: stakingPool1, staker: staker1, gracePeriod, period, productId });

// Buy Cover
await buyCover({
Expand Down Expand Up @@ -190,7 +190,7 @@ describe('submitClaim', function () {

it('submits partial ETH claim and rejects claim', async function () {
const { DEFAULT_PRODUCTS } = this;
const { ic, cover, stakingPool0, as } = this.contracts;
const { ic, cover, stakingPool1, as } = this.contracts;
const [coverBuyer1, staker1, staker2, staker3] = this.accounts.members;

// Cover inputs
Expand All @@ -201,7 +201,7 @@ describe('submitClaim', function () {
const amount = parseEther('1');

// Stake to open up capacity
await stake({ stakingPool: stakingPool0, staker: staker1, gracePeriod, period, productId });
await stake({ stakingPool: stakingPool1, staker: staker1, gracePeriod, period, productId });

// Buy Cover
await buyCover({
Expand Down Expand Up @@ -239,7 +239,7 @@ describe('submitClaim', function () {

it('submits DAI claim and approves claim', async function () {
const { DEFAULT_PRODUCTS } = this;
const { ic, cover, stakingPool0, as, dai } = this.contracts;
const { ic, cover, stakingPool1, as, dai } = this.contracts;
const [coverBuyer1, staker1, staker2] = this.accounts.members;

// Cover inputs
Expand All @@ -250,7 +250,7 @@ describe('submitClaim', function () {
const amount = parseEther('1');

// Stake to open up capacity
await stake({ stakingPool: stakingPool0, staker: staker1, gracePeriod, period, productId });
await stake({ stakingPool: stakingPool1, staker: staker1, gracePeriod, period, productId });

// cover buyer gets cover asset
await transferCoverAsset({ tokenOwner: this.accounts.defaultSender, coverBuyer: coverBuyer1, asset: dai, cover });
Expand Down Expand Up @@ -292,7 +292,7 @@ describe('submitClaim', function () {

it('submits partial DAI claim and approves claim', async function () {
const { DEFAULT_PRODUCTS } = this;
const { ic, cover, stakingPool0, as, dai } = this.contracts;
const { ic, cover, stakingPool1, as, dai } = this.contracts;
const [coverBuyer1, staker1, staker2] = this.accounts.members;

// Cover inputs
Expand All @@ -303,7 +303,7 @@ describe('submitClaim', function () {
const amount = parseEther('1');

// Stake to open up capacity
await stake({ stakingPool: stakingPool0, staker: staker1, gracePeriod, period, productId });
await stake({ stakingPool: stakingPool1, staker: staker1, gracePeriod, period, productId });

// cover buyer gets cover asset
await transferCoverAsset({ tokenOwner: this.accounts.defaultSender, coverBuyer: coverBuyer1, asset: dai, cover });
Expand Down Expand Up @@ -345,7 +345,7 @@ describe('submitClaim', function () {

it('submits DAI claim and rejects claim', async function () {
const { DEFAULT_PRODUCTS } = this;
const { ic, cover, stakingPool0, as, dai } = this.contracts;
const { ic, cover, stakingPool1, as, dai } = this.contracts;
const [coverBuyer1, staker1, staker2, staker3] = this.accounts.members;

// Cover inputs
Expand All @@ -356,7 +356,7 @@ describe('submitClaim', function () {
const amount = parseEther('1');

// Stake to open up capacity
await stake({ stakingPool: stakingPool0, staker: staker1, gracePeriod, period, productId });
await stake({ stakingPool: stakingPool1, staker: staker1, gracePeriod, period, productId });

// cover buyer gets cover asset
await transferCoverAsset({ tokenOwner: this.accounts.defaultSender, coverBuyer: coverBuyer1, asset: dai, cover });
Expand Down Expand Up @@ -397,7 +397,7 @@ describe('submitClaim', function () {

it('submits partial DAI claim and rejects claim', async function () {
const { DEFAULT_PRODUCTS } = this;
const { ic, cover, stakingPool0, as, dai } = this.contracts;
const { ic, cover, stakingPool1, as, dai } = this.contracts;
const [coverBuyer1, staker1, staker2, staker3] = this.accounts.members;

// Cover inputs
Expand All @@ -408,7 +408,7 @@ describe('submitClaim', function () {
const amount = parseEther('1');

// Stake to open up capacity
await stake({ stakingPool: stakingPool0, staker: staker1, gracePeriod, period, productId });
await stake({ stakingPool: stakingPool1, staker: staker1, gracePeriod, period, productId });

// cover buyer gets cover asset
await transferCoverAsset({ tokenOwner: this.accounts.defaultSender, coverBuyer: coverBuyer1, asset: dai, cover });
Expand Down Expand Up @@ -449,7 +449,7 @@ describe('submitClaim', function () {

it('submits USDC claim and approves claim (token with 6 decimals)', async function () {
const { DEFAULT_PRODUCTS } = this;
const { ic, cover, stakingPool0, as, usdc } = this.contracts;
const { ic, cover, stakingPool1, as, usdc } = this.contracts;
const [coverBuyer1, staker1, staker2] = this.accounts.members;

const usdcDecimals = 6;
Expand All @@ -462,7 +462,7 @@ describe('submitClaim', function () {
const amount = parseUnits('10', usdcDecimals);

// Stake to open up capacity
await stake({ stakingPool: stakingPool0, staker: staker1, gracePeriod, period, productId });
await stake({ stakingPool: stakingPool1, staker: staker1, gracePeriod, period, productId });

// cover buyer gets cover asset
await transferCoverAsset({ tokenOwner: this.accounts.defaultSender, coverBuyer: coverBuyer1, asset: usdc, cover });
Expand Down Expand Up @@ -504,7 +504,7 @@ describe('submitClaim', function () {

it('submits partial USDC claim and approves claim', async function () {
const { DEFAULT_PRODUCTS } = this;
const { ic, cover, stakingPool0, as, usdc } = this.contracts;
const { ic, cover, stakingPool1, as, usdc } = this.contracts;
const [coverBuyer1, staker1, staker2] = this.accounts.members;

const usdcDecimals = 6;
Expand All @@ -517,7 +517,7 @@ describe('submitClaim', function () {
const amount = parseUnits('10', usdcDecimals);

// Stake to open up capacity
await stake({ stakingPool: stakingPool0, staker: staker1, gracePeriod, period, productId });
await stake({ stakingPool: stakingPool1, staker: staker1, gracePeriod, period, productId });

// cover buyer gets cover asset
await transferCoverAsset({ tokenOwner: this.accounts.defaultSender, coverBuyer: coverBuyer1, asset: usdc, cover });
Expand Down Expand Up @@ -559,7 +559,7 @@ describe('submitClaim', function () {

it('submits partial USDC claim and rejects claim', async function () {
const { DEFAULT_PRODUCTS } = this;
const { ic, cover, stakingPool0, as, usdc } = this.contracts;
const { ic, cover, stakingPool1, as, usdc } = this.contracts;
const [coverBuyer1, staker1, staker2, staker3] = this.accounts.members;

const usdcDecimals = 6;
Expand All @@ -572,7 +572,7 @@ describe('submitClaim', function () {
const amount = parseUnits('10', usdcDecimals);

// Stake to open up capacity
await stake({ stakingPool: stakingPool0, staker: staker1, gracePeriod, period, productId });
await stake({ stakingPool: stakingPool1, staker: staker1, gracePeriod, period, productId });

// cover buyer gets cover asset
await transferCoverAsset({ tokenOwner: this.accounts.defaultSender, coverBuyer: coverBuyer1, asset: usdc, cover });
Expand Down Expand Up @@ -613,7 +613,7 @@ describe('submitClaim', function () {

it('multiple partial ETH claims approved on the same cover', async function () {
const { DEFAULT_PRODUCTS } = this;
const { ic, cover, stakingPool0, as } = this.contracts;
const { ic, cover, stakingPool1, as } = this.contracts;
const [coverBuyer1, staker1, staker2] = this.accounts.members;

// Cover inputs
Expand All @@ -624,7 +624,7 @@ describe('submitClaim', function () {
const amount = parseEther('1');

// Stake to open up capacity
await stake({ stakingPool: stakingPool0, staker: staker1, gracePeriod, period, productId });
await stake({ stakingPool: stakingPool1, staker: staker1, gracePeriod, period, productId });

// Buy Cover
await buyCover({
Expand Down Expand Up @@ -733,7 +733,7 @@ describe('submitClaim', function () {

it('multiple partial DAI claims approved on the same cover', async function () {
const { DEFAULT_PRODUCTS } = this;
const { ic, cover, stakingPool0, as, dai } = this.contracts;
const { ic, cover, stakingPool1, as, dai } = this.contracts;
const [coverBuyer1, staker1, staker2] = this.accounts.members;

// Cover inputs
Expand All @@ -744,7 +744,7 @@ describe('submitClaim', function () {
const amount = parseEther('1');

// Stake to open up capacity
await stake({ stakingPool: stakingPool0, staker: staker1, gracePeriod, period, productId });
await stake({ stakingPool: stakingPool1, staker: staker1, gracePeriod, period, productId });

// cover buyer gets cover asset
await transferCoverAsset({ tokenOwner: this.accounts.defaultSender, coverBuyer: coverBuyer1, asset: dai, cover });
Expand Down Expand Up @@ -852,7 +852,7 @@ describe('submitClaim', function () {

it('multiple partial USDC claims approved on the same cover', async function () {
const { DEFAULT_PRODUCTS } = this;
const { ic, cover, stakingPool0, as, usdc } = this.contracts;
const { ic, cover, stakingPool1, as, usdc } = this.contracts;
const [coverBuyer1, staker1, staker2] = this.accounts.members;

const usdcDecimals = 6;
Expand All @@ -865,7 +865,7 @@ describe('submitClaim', function () {
const amount = parseUnits('10', usdcDecimals);

// Stake to open up capacity
await stake({ stakingPool: stakingPool0, staker: staker1, gracePeriod, period, productId });
await stake({ stakingPool: stakingPool1, staker: staker1, gracePeriod, period, productId });

// cover buyer gets cover asset
await transferCoverAsset({ tokenOwner: this.accounts.defaultSender, coverBuyer: coverBuyer1, asset: usdc, cover });
Expand Down Expand Up @@ -973,7 +973,7 @@ describe('submitClaim', function () {

it('multiple partial claims on the same cover with combinations of approved / denied', async function () {
const { DEFAULT_PRODUCTS } = this;
const { ic, cover, stakingPool0, as } = this.contracts;
const { ic, cover, stakingPool1, as } = this.contracts;
const [coverBuyer1, staker1, staker2, staker3] = this.accounts.members;

// Cover inputs
Expand All @@ -984,7 +984,7 @@ describe('submitClaim', function () {
const amount = parseEther('1');

// Stake to open up capacity
await stake({ stakingPool: stakingPool0, staker: staker1, gracePeriod, period, productId });
await stake({ stakingPool: stakingPool1, staker: staker1, gracePeriod, period, productId });

// Buy Cover
await buyCover({
Expand Down
6 changes: 3 additions & 3 deletions test/integration/MCR/updateMCR.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ describe('updateMCR', function () {

// [todo] deal with test once active cover amount measurement is settled
it.skip('increases desiredMCR if totalSumAssured is high enough', async function () {
const { mcr, stakingPool0, cover } = this.contracts;
const { mcr, stakingPool1, cover } = this.contracts;

const [coverHolder, staker1] = this.accounts.members;

Expand All @@ -181,7 +181,7 @@ describe('updateMCR', function () {
const amount = coverAmount;

// Stake to open up capacity
await stake({ stakingPool: stakingPool0, staker: staker1, gracePeriod, period, productId });
await stake({ stakingPool: stakingPool1, staker: staker1, gracePeriod, period, productId });

const expectedPremium = parseEther('1');
await cover.connect(coverHolder).buyCover(
Expand All @@ -198,7 +198,7 @@ describe('updateMCR', function () {
commissionDestination: ethers.constants.AddressZero,
ipfsData: '',
},
[{ poolId: '0', coverAmountInAsset: amount }],
[{ poolId: 1, coverAmountInAsset: amount }],
{ value: expectedPremium },
);

Expand Down
Loading

0 comments on commit b733d40

Please sign in to comment.