Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reorganize test runner #154

Merged
merged 8 commits into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions scripts/integrationTests/smokeTest1/auctionEnd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ import { getAccount } from "../../utils/helpers/common";
import { getOptionRoundFacade } from "../../utils/helpers/setup";
import assert from "assert";
import { Constants } from "../../utils/facades/types";
import {
getLiquidityProviderAccounts,
getOptionBidderAccounts,
} from "../../utils/helpers/accounts";
import { TestRunner } from "../../utils/facades/TestRunner";

export const smokeTest = async ({
provider,
vaultFacade,
constants,
getLPLockedBalanceAll,
getLPUnlockedBalanceAll,
endAuctionBystander,
getLiquidityProviderAccounts,
}: TestRunner) => {
const optionRoundFacade = await getOptionRoundFacade(
provider,
Expand All @@ -35,15 +35,14 @@ export const smokeTest = async ({
`Expected:Auctioning\nReceived:${state.activeVariant()}`
);

const liquidityProviderAccounts = getLiquidityProviderAccounts(provider, 2);
const optionBidderAccounts = getOptionBidderAccounts(provider, 3);
const liquidityProviderAccounts = getLiquidityProviderAccounts(2);

await vaultFacade.endAuctionBystander(provider);
await endAuctionBystander();

const lpUnlockedBalances = await vaultFacade.getLPUnlockedBalanceAll(
const lpUnlockedBalances = await getLPUnlockedBalanceAll(
liquidityProviderAccounts
);
const lpLockedBalances = await vaultFacade.getLPLockedBalanceAll(
const lpLockedBalances = await getLPLockedBalanceAll(
liquidityProviderAccounts
);
const totalPremiums = await optionRoundFacade.getTotalPremiums();
Expand Down
26 changes: 15 additions & 11 deletions scripts/integrationTests/smokeTest1/auctionOpen.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import assert from "assert";
import { DepositArgs, WithdrawArgs } from "../../utils/facades/types";
import { getLiquidityProviderAccounts } from "../../utils/helpers/accounts";
import { TestRunner } from "../../utils/facades/TestRunner";
import { LibraryError } from "starknet";

Expand All @@ -11,8 +10,13 @@ export const smokeTest = async ({
vaultFacade: vault,
ethFacade: eth,
constants: { depositAmount },
getLPUnlockedBalanceAll,
depositAll,
withdrawAll,
getBalancesAll,
getLiquidityProviderAccounts
}: TestRunner) => {
const liquidityProviderAccounts = getLiquidityProviderAccounts(provider, 2);
const liquidityProviderAccounts = getLiquidityProviderAccounts(2);

//Approve A for depositing
await eth.approval({
Expand All @@ -21,9 +25,9 @@ export const smokeTest = async ({
spender: vault.vaultContract.address,
});

const ethBalancesBefore = await eth.getBalancesAll(liquidityProviderAccounts);
const ethBalancesBefore = await getBalancesAll(liquidityProviderAccounts);

const lpUnlockedBalancesBefore = await vault.getLPUnlockedBalanceAll(
const lpUnlockedBalancesBefore = await getLPUnlockedBalanceAll(
liquidityProviderAccounts
);
//Deposits
Expand All @@ -43,13 +47,13 @@ export const smokeTest = async ({
},
];

await vault.depositAll(depositAllArgs);
await depositAll(depositAllArgs);
//Debug

const lpUnlockedBalancesAfter = await vault.getLPUnlockedBalanceAll(
const lpUnlockedBalancesAfter = await getLPUnlockedBalanceAll(
liquidityProviderAccounts
);
const ethBalancesAfter = await eth.getBalancesAll(liquidityProviderAccounts);
const ethBalancesAfter = await getBalancesAll(liquidityProviderAccounts);

//Asserts
//1) Check liquidity for A has increased by depositAmount
Expand Down Expand Up @@ -78,13 +82,13 @@ export const smokeTest = async ({
amount: BigInt(depositAmount) / BigInt(2),
},
];
await vault.withdrawAll(withdrawAllData);
await withdrawAll(withdrawAllData);

const lpUnlockedBalancesAfterWithdraw = await vault.getLPUnlockedBalanceAll(
const lpUnlockedBalancesAfterWithdraw = await getLPUnlockedBalanceAll(
liquidityProviderAccounts
);

const ethBalancesAfterWithdraw = await eth.getBalancesAll(
const ethBalancesAfterWithdraw = await getBalancesAll(
liquidityProviderAccounts
);

Expand All @@ -99,7 +103,7 @@ export const smokeTest = async ({
assert(error.message !== "Should have reverted");
}

const lpUnlockedBalancesAfterWithdraw2 = await vault.getLPUnlockedBalanceAll(
const lpUnlockedBalancesAfterWithdraw2 = await getLPUnlockedBalanceAll(
liquidityProviderAccounts
);
//Asserts
Expand Down
29 changes: 15 additions & 14 deletions scripts/integrationTests/smokeTest1/auctionStart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,22 @@ import { getOptionRoundFacade } from "../../utils/helpers/setup";
import assert from "assert";
import {
ApprovalArgs,
Constants,
PlaceBidArgs,
} from "../../utils/facades/types";
import { mineNextBlock } from "../../utils/katana";
import {
getLiquidityProviderAccounts,
getOptionBidderAccounts,
} from "../../utils/helpers/accounts";
import { TestRunner } from "../../utils/facades/TestRunner";

export const smokeTest = async ({
provider,
vaultFacade,
ethFacade,
constants,
getLPUnlockedBalanceAll,
getLPLockedBalanceAll,
getBalancesAll,
approveAll,
startAuctionBystander,
getLiquidityProviderAccounts,
getOptionBidderAccounts
}: TestRunner) => {
const optionRoundFacade = await getOptionRoundFacade(
provider,
Expand All @@ -37,20 +38,20 @@ export const smokeTest = async ({
const stateAfter: any =
await optionRoundFacade.optionRoundContract.get_state();

const liquidityProviderAccounts = getLiquidityProviderAccounts(provider, 2);
const optionBidderAccounts = getOptionBidderAccounts(provider, 2);
const liquidityProviderAccounts = getLiquidityProviderAccounts(2);
const optionBidderAccounts = getOptionBidderAccounts(2);

assert(
stateAfter.activeVariant() === "Open",
`Expected:Open\nReceived:${stateAfter.activeVariant()}`
);

await vaultFacade.startAuctionBystander(provider, constants);
await startAuctionBystander(constants);

const unlockedBalances = await vaultFacade.getLPUnlockedBalanceAll(
const unlockedBalances = await getLPUnlockedBalanceAll(
liquidityProviderAccounts
);
const lockedBalances = await vaultFacade.getLPLockedBalanceAll(
const lockedBalances = await getLPLockedBalanceAll(
liquidityProviderAccounts
);
const totalLockedAmount = await vaultFacade.getTotalLocked();
Expand Down Expand Up @@ -79,15 +80,15 @@ export const smokeTest = async ({
spender: optionRoundFacade.optionRoundContract.address,
},
];
await ethFacade.approveAll(approveAllData);
await approveAll(approveAllData);
await mineNextBlock(provider.channel.nodeUrl);

//Place bids according to story script
const reservePrice = await optionRoundFacade.getReservePrice();
const totalOptionAvailable =
await optionRoundFacade.getTotalOptionsAvailable();

const ethBalancesBefore = await ethFacade.getBalancesAll(
const ethBalancesBefore = await getBalancesAll(
optionBidderAccounts
);

Expand All @@ -110,7 +111,7 @@ export const smokeTest = async ({
];
await optionRoundFacade.placeBidsAll(placeBidsData);

const ethBalancesAfter = await ethFacade.getBalancesAll(optionBidderAccounts);
const ethBalancesAfter = await getBalancesAll(optionBidderAccounts);

const bidArrays = await optionRoundFacade.getBidsForAll(optionBidderAccounts);

Expand Down
13 changes: 6 additions & 7 deletions scripts/integrationTests/smokeTest1/exerciseOptions.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@

import { getOptionRoundFacade } from "../../utils/helpers/setup";
import assert from "assert";
import { getOptionBidderAccounts } from "../../utils/helpers/accounts";
import { TestRunner } from "../../utils/facades/TestRunner";
import { ExerciseOptionArgs } from "../../utils/facades/types";


export const smokeTest = async ({
provider,
vaultFacade,
constants: { depositAmount },
ethFacade,
getBalancesAll,
getOptionBidderAccounts
}: TestRunner) => {
const optionRoundFacade = await getOptionRoundFacade(
provider,
vaultFacade.vaultContract,
true
);

const optionBidderAccounts = getOptionBidderAccounts(provider, 3);
const optionBidderAccounts = getOptionBidderAccounts(3);

const ethBalancesBefore = await ethFacade.getBalancesAll(
const ethBalancesBefore = await getBalancesAll(
optionBidderAccounts
);

Expand All @@ -30,7 +29,7 @@ export const smokeTest = async ({
await optionRoundFacade.exerciseOptionsAll(exerciseOptionsAllArgs);


const ethBalancesAfter = await ethFacade.getBalancesAll(optionBidderAccounts);
const ethBalancesAfter = await getBalancesAll(optionBidderAccounts);
const totalPayout = await optionRoundFacade.getTotalPayout();

checkpoint1({
Expand All @@ -40,7 +39,7 @@ export const smokeTest = async ({
});

await optionRoundFacade.exerciseOptionsAll(exerciseOptionsAllArgs);
const ethBalancesAfterTwice = await ethFacade.getBalancesAll(
const ethBalancesAfterTwice = await getBalancesAll(
optionBidderAccounts
);

Expand Down
16 changes: 8 additions & 8 deletions scripts/integrationTests/smokeTest1/optionSettle.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import { getAccount } from "../../utils/helpers/common";
import { getOptionRoundFacade } from "../../utils/helpers/setup";
import assert from "assert";
import {
getLiquidityProviderAccounts,
getOptionBidderAccounts,
} from "../../utils/helpers/accounts";
import { TestRunner } from "../../utils/facades/TestRunner";
import { eth, LibraryError } from "starknet";

Expand All @@ -13,14 +9,18 @@ export const smokeTest = async ({
vaultFacade,
constants: { depositAmount },
ethFacade,
getLPUnlockedBalanceAll,
settleOptionRoundBystander,
getLiquidityProviderAccounts,
getOptionBidderAccounts
}: TestRunner) => {
const optionRoundFacade = await getOptionRoundFacade(
provider,
vaultFacade.vaultContract
);

const liquidityProviderAccounts = getLiquidityProviderAccounts(provider, 2);
const optionBidderAccounts = getOptionBidderAccounts(provider, 3);
const liquidityProviderAccounts = getLiquidityProviderAccounts(2);

const devAccount = getAccount("dev", provider);

try {
Expand Down Expand Up @@ -67,13 +67,13 @@ export const smokeTest = async ({
totalPremiums,
});

await vaultFacade.settleOptionRoundBystander(provider);
await settleOptionRoundBystander();


const stateAfter: any =
await optionRoundFacade.optionRoundContract.get_state();

const lpUnlockedBalances = await vaultFacade.getLPUnlockedBalanceAll(
const lpUnlockedBalances = await getLPUnlockedBalanceAll(
liquidityProviderAccounts
);
const totalPayout = await optionRoundFacade.getTotalPayout();
Expand Down
12 changes: 5 additions & 7 deletions scripts/integrationTests/smokeTest1/refundBid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,14 @@ import {
getOptionRoundFacade,
} from "../../utils/helpers/setup";
import assert from "assert";
import {
getOptionBidderAccounts,
} from "../../utils/helpers/accounts";
import { TestRunner } from "../../utils/facades/TestRunner";
import { ERC20Facade } from "../../utils/facades/erc20Facade";

export const smokeTest = async ({
provider,
vaultFacade: vault,
ethFacade: eth,
getBalancesAll,
getOptionBidderAccounts
}: TestRunner) => {
const optionRoundFacade = await getOptionRoundFacade(
provider,
Expand All @@ -28,9 +26,9 @@ export const smokeTest = async ({
const totalOptionAvailable =
await optionRoundFacade.getTotalOptionsAvailable();
const reservePrice = await optionRoundFacade.getReservePrice();
const optionBidderAccounts = getOptionBidderAccounts(provider, 3);
const optionBidderAccounts = getOptionBidderAccounts(3);

const balancesBefore = await eth.getBalancesAll(optionBidderAccounts);
const balancesBefore = await getBalancesAll(optionBidderAccounts);

try {
await optionRoundFacade.refundUnusedBids({
Expand All @@ -44,7 +42,7 @@ export const smokeTest = async ({
} catch (err) {
console.log("Error while refunding the unused bids", err);
}
const balancesAfter = await eth.getBalancesAll(optionBidderAccounts);
const balancesAfter = await getBalancesAll(optionBidderAccounts);

checkpoint1({
balancesBefore,
Expand Down
2 changes: 1 addition & 1 deletion scripts/simulationTests/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ async function simulationTesting(testRunner: TestRunner) {

const simulationSheets = plugMarketData(simulationMarketData,inputSheets);
const simulationParams = generateSimulationParams(
testRunner.provider,
testRunner,
simulationSheets
);

Expand Down
Loading
Loading