Skip to content

Commit

Permalink
[Farming] fix tests & update snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
IliaAzhel committed Oct 7, 2024
1 parent ee41e68 commit 41ab42f
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 19 deletions.
1 change: 1 addition & 0 deletions src/farming/.solcover.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const skipFiles = testContracts.map((x) => "test/" + x)

module.exports = {
skipFiles: skipFiles,
configureYulOptimizer: true,
mocha: {
grep: '@skip-on-coverage', // Find everything with this tag
invert: true, // Run the grep's inverse set.
Expand Down
8 changes: 4 additions & 4 deletions src/farming/test/AlgebraFarming.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ describe('AlgebraFarming', () => {
})
)
);
await time.setNextBlockTimestamp(startTime + 1);
await time.setNextBlockTimestamp(startTime + 100);
const trader = actors.traderUser0();
await helpers.makeTickGoFlow({
trader,
Expand Down Expand Up @@ -300,7 +300,7 @@ describe('AlgebraFarming', () => {

const { helpers, createIncentiveResult } = subject;

await time.increaseTo(endTime + 1);
await time.increaseTo(endTime + 100);

const trader = actors.traderUser0();
await helpers.makeTickGoFlow({
Expand Down Expand Up @@ -341,7 +341,7 @@ describe('AlgebraFarming', () => {
const startTime = epoch + 1_000;
const endTime = startTime + duration;

await time.increaseTo(endTime + 1);
await time.increaseTo(endTime + 100);

const trader = actors.traderUser0();
await helpers.makeTickGoFlow({
Expand Down Expand Up @@ -407,7 +407,7 @@ describe('AlgebraFarming', () => {
deadline: (await blockTimestamp()) + 1000,
});

await time.setNextBlockTimestamp(endTime + 1);
await time.setNextBlockTimestamp(endTime + 100);

const trader = actors.traderUser0();
await helpers.makeTickGoFlow({
Expand Down
4 changes: 2 additions & 2 deletions src/farming/test/helpers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@ export class HelperCommands {
},
pluginAddres
);
// @ts-ignore
virtualPoolAddress = (await txResult.wait(1)).logs[4].args['virtualPool'];

// @ts-ignore
virtualPoolAddress = (await txResult.wait()).logs[3].args['virtualPool'];
return {
..._.pick(params, ['poolAddress', 'totalReward', 'bonusReward', 'rewardToken', 'bonusRewardToken']),
nonce,
Expand Down
4 changes: 2 additions & 2 deletions src/farming/test/shared/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,9 @@ export const algebraFixture: () => Promise<AlgebraFixtureType> = async () => {

const fee = FeeAmount.MEDIUM;

await nft.createAndInitializePoolIfNecessary(tokens[0], tokens[1], ZERO_ADDRESS, encodePriceSqrt(1, 1));
await nft.createAndInitializePoolIfNecessary(tokens[0], tokens[1], ZERO_ADDRESS, encodePriceSqrt(1, 1),'0x');

await nft.createAndInitializePoolIfNecessary(tokens[1], tokens[2], ZERO_ADDRESS, encodePriceSqrt(1, 1));
await nft.createAndInitializePoolIfNecessary(tokens[1], tokens[2], ZERO_ADDRESS, encodePriceSqrt(1, 1),'0x');

const pool01 = await factory.poolByPair(tokens[0], tokens[1]);

Expand Down
8 changes: 4 additions & 4 deletions src/farming/test/unit/EternalFarms.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1270,7 +1270,7 @@ describe('unit/EternalFarms', () => {
bonusRewardRate: 50n,
});

await Time.setAndMine(timestamps.startTime + 1);
await Time.setAndMine(timestamps.startTime + 100);

const mintResult = await helpers.mintDepositFarmFlow({
lp: lpUser0,
Expand Down Expand Up @@ -1412,7 +1412,7 @@ describe('unit/EternalFarms', () => {
bonusRewardRate: 50n,
});

await Time.setAndMine(timestamps.startTime + 1);
await Time.setAndMine(timestamps.startTime + 100);

const mintResult = await helpers.mintDepositFarmFlow({
lp: lpUser0,
Expand Down Expand Up @@ -1594,7 +1594,7 @@ describe('unit/EternalFarms', () => {
deadline: (await blockTimestamp()) + 10000,
});

await Time.setAndMine(timestamps.startTime + 1);
await Time.setAndMine(timestamps.startTime + 100);

await context.nft.connect(lpUser0).approveForFarming(tokenId, true, context.farmingCenter);
await context.nft.connect(lpUser0).approveForFarming(tokenIdOut, true, context.farmingCenter);
Expand Down Expand Up @@ -1898,7 +1898,7 @@ describe('unit/EternalFarms', () => {

await erc20Helper.ensureBalancesAndApprovals(lpUser0, [token0, token1], amountDesired, await context.nft.getAddress());

await context.nft.createAndInitializePoolIfNecessary(token0, token1, ZERO_ADDRESS, encodePriceSqrt(1, 1));
await context.nft.createAndInitializePoolIfNecessary(token0, token1, ZERO_ADDRESS, encodePriceSqrt(1, 1), '0x');

const poolAddress = await context.factory.poolByPair(token0, token1);

Expand Down
4 changes: 2 additions & 2 deletions src/farming/test/unit/FarmingCenter.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ describe('unit/FarmingCenter', () => {
bonusRewardRate: 50n,
});

await Time.setAndMine(timestamps.startTime + 1);
await Time.setAndMine(timestamps.startTime + 100);

const mintResultEternal = await helpers.mintDepositFarmFlow({
lp: lpUser0,
Expand Down Expand Up @@ -489,7 +489,7 @@ describe('unit/FarmingCenter', () => {
bonusRewardRate: 50n,
});

await Time.setAndMine(timestamps.startTime + 1);
await Time.setAndMine(timestamps.startTime + 100);

const mintResultEternal = await helpers.mintDepositFarmFlow({
lp: lpUser0,
Expand Down
4 changes: 1 addition & 3 deletions src/farming/test/unit/Multicall.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ describe('unit/Multicall', () => {

multicallFixture = async () => {
const context = await algebraFixture();
const helpers = HelperCommands.fromTestContext(context, actors, provider);

const helpers = HelperCommands.fromTestContext(context, actors, provider);
await erc20Helper.ensureBalancesAndApprovals(multicaller, [context.token0, context.token1], amountDesired, await context.nft.getAddress());

const mintResult = await helpers.mintFlow({
Expand All @@ -66,7 +66,6 @@ describe('unit/Multicall', () => {
totalReward,
await context.eternalFarming.getAddress()
);

await helpers.createIncentiveFlow({
rewardToken: context.rewardToken,
bonusRewardToken: context.bonusRewardToken,
Expand All @@ -77,7 +76,6 @@ describe('unit/Multicall', () => {
rewardRate: 10n,
bonusRewardRate: 50n,
});

await context.nft.connect(multicaller).approveForFarming(tokenId, true, context.farmingCenter);
await context.farmingCenter.connect(multicaller).enterFarming(farmIncentiveKey, tokenId);

Expand Down
4 changes: 2 additions & 2 deletions src/farming/test/unit/__snapshots__/EternalFarms.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

exports[`unit/EternalFarms #claimReward when requesting the full amount has gas cost [ @skip-on-coverage ] 1`] = `60772`;

exports[`unit/EternalFarms #enterFarming works and has gas cost [ @skip-on-coverage ] 1`] = `498913`;
exports[`unit/EternalFarms #enterFarming works and has gas cost [ @skip-on-coverage ] 1`] = `506125`;

exports[`unit/EternalFarms #exitFarming after end time works and has gas cost [ @skip-on-coverage ] 1`] = `171767`;
exports[`unit/EternalFarms #exitFarming after end time works and has gas cost [ @skip-on-coverage ] 1`] = `175750`;

0 comments on commit 41ab42f

Please sign in to comment.