Skip to content
Open
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
12 changes: 7 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,11 @@ jobs:
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1

- name: Clean up potential stale Xvfb locks (Cypress e2e tests)
- name: Clean stale Xvfb locks
run: |
sudo rm -f /tmp/.X*-lock
sudo rm -f /tmp/.X11-unix/X*
sudo rm -f /tmp/.X-lock /tmp/.X11-unix/X || true

- name: Install Cypress dependencies
- name: Install Cypress system dependencies
run: |
sudo apt-get update
sudo apt-get install -y libgtk2.0-0 libgtk-3-0 libgbm-dev libnotify-dev libnss3 libxss1 libasound2 libxtst6 xauth xvfb
Expand All @@ -52,5 +51,8 @@ jobs:
- name: Install Cypress (if not cached already)
run: pnpm cypress install

- name: Run tests
- name: Run unit, smoke & e2e tests
run: pnpm test
env:
TERM: xterm
CI: true
2 changes: 1 addition & 1 deletion apps/dapp/.env.mainnet
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ VITE_APP_PORT=5175 # different from other .envs to allow parallel testing on dif
VITE_APP_HOST=localhost
VITE_APP_URL=${VITE_APP_PROTOCOL}://${VITE_APP_HOST}:${VITE_APP_PORT}

VITE_ENABLE_AUTOSIGNING_WALLET=true
VITE_ENABLE_AUTOSIGNING_WALLET=false

VITE_WALLETCONNECT_PROJECT_ID=29c1aa1528d4ed7ffe54ee450b483393

Expand Down
2 changes: 1 addition & 1 deletion apps/dapp/.env.testnet
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ VITE_APP_URL=${VITE_APP_PROTOCOL}://${VITE_APP_HOST}:${VITE_APP_PORT}

VITE_WALLETCONNECT_PROJECT_ID=29c1aa1528d4ed7ffe54ee450b483393

VITE_ENABLE_AUTOSIGNING_WALLET=true
VITE_ENABLE_AUTOSIGNING_WALLET=false

# The Projects Access token
VITE_FLEEK_APPLICATION_CLIENT_ID=client_CE9s3vI4sng7GU2HQgJB
Expand Down
32 changes: 21 additions & 11 deletions apps/dapp/cypress/constants.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
const BASE_URL = Cypress.env("VITE_APP_URL");

// Mainnet chain ID for mainnet build testing
const blastSepoliaChainId = "168587773";
import { LAUNCH_LOT_ID } from "./create-fixtures";

// Testnet chain ID for testnet build testing
const baseChainId = "8453";
const BASE_URL = Cypress.env("VITE_APP_URL");

const LAUNCH_ID =
Cypress.env("VITE_TESTNET") === "true" ? blastSepoliaChainId : baseChainId;
const BASE_SEPOLIA_CHAIN_ID = "84532";

const URLS = {
HOME: `${BASE_URL}/#/`,
CREATE_LAUNCH: `${BASE_URL}/#/create/auction`,
CREATE_LAUNCH: (params?: unknown) =>
`${BASE_URL}/#/create/auction?data=${JSON.stringify(params)}`,
CURATOR: `${BASE_URL}/#/curator`,
CURATORS: `${BASE_URL}/#/curators`,
REFERRALS: `${BASE_URL}/#/refer`,
LAUNCH: `${BASE_URL}/#/${LAUNCH_ID}/0`,
LAUNCH: (
chainId: string = BASE_SEPOLIA_CHAIN_ID,
lotId: string = LAUNCH_LOT_ID,
) => `${BASE_URL}/#/${chainId}/${lotId}`,

/** TESTNET ONLY PAGES */
FAUCET: `${BASE_URL}/#/faucet`,
Expand Down Expand Up @@ -44,6 +43,7 @@ const QUERIES = {
DEPLOY_BUTTON: testId("deploy-button"),
},
MINT: {
ADDRESS_FIELD: testId("mint-address"),
AMOUNT_FIELD: testId("mint-amount"),
MINT_BUTTON: testId("mint-button"),
SUCCESS_MESSAGE: testId("mint-success-message"),
Expand Down Expand Up @@ -73,10 +73,20 @@ const QUERIES = {
SUBMIT_BUTTON: testId("create-launch-submit-button"),
SUCCESS_BUTTON: testId("create-launch-success-button"),
},
VIEW_LAUNCH: {
AUCTION_BID_CARD: testId("auction-bid-card"),
AMOUNT_INPUT: testId("bid-amount-input"),
PRICE_INPUT: testId("bid-price-input"),
BID_SUBMIT_BUTTON: testId("bid-submit-button"),
TX_DIALOG: testId("tx-dialog"),
TX_DIALOG_TITLE: testId("tx-dialog-title"),
TX_DIALOG_TRIGGER_BUTTON: testId("tx-dialog-trigger-button"),
TX_DIALOG_CONFIRM_BUTTON: testId("tx-dialog-confirm-button"),
},
};

const TIME = {
TRANSACTION_TIMEOUT: 20 * 1000,
TXN_TIMEOUT: 20 * 1000,
};

export { URLS, QUERIES, TIME };
105 changes: 102 additions & 3 deletions apps/dapp/cypress/create-fixtures.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,68 @@
import { URLS } from "./constants";
import { QUERIES, URLS, TIME } from "./constants";

const ONE_WEEK_IN_MS = 7 * 24 * 60 * 60 * 1000;
const FIVE_MINS_IN_MS = 5 * 60 * 1000;

/**
* These constants are generated deterministically by forking base sepolia at the configured block number.
* If you change the block number, the state will be differnt, so you will need to update these constants.
* To do that easily, just run ./scripts/create-test-fixtures.sh and the tests below will fail with
* To do that, just run ./scripts/create-test-fixtures.sh and the tests below will fail with
* the correct addresses you need to update.
*/
export const PAYOUT_TOKEN_ADDRESS =
"0x493f79a2839ef984a78f7ff7002e1901e93aa2d3";
export const QUOTE_TOKEN_ADDRESS = "0x8e7e3e449a6a5d36c810fc692ce26a1e862abb66";
export const QUOTE_TOKEN_ADDRESS = "0x4c9d75fbdf764d05df654340a48f85bc0216f8ab";

/**
* These parameters are used to create a test launch in the fixture setup.
* This launch is merged into the chain state which is used for the tests.
*/
export const LAUNCH_PARAMS = {
minFillPercent: [50],
auctionType: "FPBA",
// Auctions start date must be set in the future
start: new Date(new Date().getTime() + FIVE_MINS_IN_MS).toISOString(),
dtlProceedsPercent: [100],
baselineFloorReservesPercent: [50],
baselineFloorRangeGap: "0",
baselineAnchorTickU: "0",
baselineAnchorTickWidth: "10",
name: "fpb-bid-test",
tagline: "fpb-bid-test-tagline",
projectLogo: "http://test.com/logo",
projectBanner: "http://test.com/banner",
website: "http://test.com/web",
discord: "http://test.com/discord",
twitter: "http://test.com/x",
farcaster: "http://test.com/warp",
description: "fpb-bid-test-description",
payoutToken: {
decimals: 18,
symbol: "AXIS",
name: "Test payout token",
address: PAYOUT_TOKEN_ADDRESS,
chainId: 84532,
totalSupply: "100000",
logoURI: "http://test.com/token-logo",
},
quoteToken: {
name: "USD Coin",
symbol: "USDC",
logoURI:
"https://storage.bondprotocol.finance/6e41a561-e275-4698-bc36-548d30a80e96-bucket/USDC.png",
decimals: 18,
address: QUOTE_TOKEN_ADDRESS,
mintable: true,
chainId: 84532,
},
capacity: "10000",
deadline: new Date(new Date().getTime() + ONE_WEEK_IN_MS).toISOString(), //"2025-04-02T23:00:00.000Z",
payoutTokenBalance: "100000",
price: "1",
};

// The last lot id for the forked state is 34 (created by the fixture setup)
export const LAUNCH_LOT_ID = "34";
/**
* This is not a test suite itself, but is used to create fixtures for the e2e tests.
* This script executes the first time the local anvil rpc fork is started (from scripts/local-rpc.sh).
Expand Down Expand Up @@ -39,4 +92,50 @@ describe("test fixture setup", () => {
},
);
});

it("mints the quote token for bidding with", () => {
cy.visit(URLS.HOME);
cy.connectWallet();

cy.mintToken(QUOTE_TOKEN_ADDRESS);
});

it("creates a launch to test bidding", () => {
cy.visit(URLS.HOME);
cy.connectWallet();

cy.visit(URLS.CREATE_LAUNCH(LAUNCH_PARAMS));

const { CREATE_LAUNCH } = QUERIES;

// hack: the create auction form updates balance asynchronously and isn't retriggering validation
// so the form thinks the payout token balance is invalid when it's actually valid
cy.get(CREATE_LAUNCH.CAPACITY_FIELD).clear().type(LAUNCH_PARAMS.capacity);

// View launch preview
cy.get(CREATE_LAUNCH.DEPLOY_BUTTON).click();

// Open transaction dialog
cy.get(CREATE_LAUNCH.CREATE_BUTTON).click();

// Approve payout token spend
cy.get(CREATE_LAUNCH.SUBMIT_BUTTON, {
timeout: TIME.TXN_TIMEOUT,
}).click();

// Give the txn chance to complete before pressing the submit button again
cy.contains("Deploy your Auction", {
timeout: TIME.TXN_TIMEOUT,
}).should("exist");

// hack
cy.wait(3000);

// Upload launch metadata to IPFS and sign transaction
cy.get(CREATE_LAUNCH.SUBMIT_BUTTON).click();

cy.contains("View your Launch", {
timeout: TIME.TXN_TIMEOUT,
}).should("exist");
});
});
1 change: 1 addition & 0 deletions apps/dapp/cypress/cypress.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ declare namespace Cypress {
shouldRenderPageWithId(id: string): Chainable<void>;
connectWallet(): Chainable<void>;
deployToken(symbol: string, name: string): Chainable<string | undefined>;
mintToken(address: string, amount?: string): Chainable<string | undefined>;
deployTokenAndMint(
symbol: string,
name: string,
Expand Down
48 changes: 48 additions & 0 deletions apps/dapp/cypress/e2e/fixed-price-launch/bid.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { URLS, QUERIES, TIME } from "../../constants";

const { VIEW_LAUNCH } = QUERIES;

describe("fixed price launch", () => {
it("makes a bid", () => {
cy.visit(URLS.HOME);
cy.connectWallet();

cy.visit(URLS.LAUNCH());

cy.get("body").then(($body) => {
if ($body.text().includes("SWITCH TO")) {
cy.get("button")
.contains(/SWITCH TO/i)
.click();
}
});

// Type 1000 as the bid amount
cy.get(VIEW_LAUNCH.AMOUNT_INPUT).clear().type("1000");

// Approve spend
cy.get(VIEW_LAUNCH.BID_SUBMIT_BUTTON).click();

// Wait for approval txn confirmation
cy.get(VIEW_LAUNCH.BID_SUBMIT_BUTTON, { timeout: TIME.TXN_TIMEOUT }).should(
"have.text",
"BID",
);

// Cypress can be too fast with async React rerenders changing DOM
cy.wait(500);

// Trigger transaction dialog
cy.get(VIEW_LAUNCH.BID_SUBMIT_BUTTON).click();

// Submit bid
cy.get(VIEW_LAUNCH.TX_DIALOG_CONFIRM_BUTTON, {
timeout: TIME.TXN_TIMEOUT,
}).click();

// Wait for bid txn confirmation
cy.get(VIEW_LAUNCH.TX_DIALOG_TITLE, {
timeout: TIME.TXN_TIMEOUT,
}).should("have.text", "Transaction Confirmed");
});
});
11 changes: 7 additions & 4 deletions apps/dapp/cypress/e2e/fixed-price-launch/create.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ describe("fixed price launch", () => {
cy.visit(URLS.HOME);
cy.connectWallet();

cy.visit(URLS.CREATE_LAUNCH);
cy.visit(URLS.CREATE_LAUNCH());

// Fill in the initial text fields
cy.get(CREATE_LAUNCH.NAME_FIELD).type("Test Launch");
Expand Down Expand Up @@ -70,19 +70,22 @@ describe("fixed price launch", () => {

// Approve payout token spend
cy.get(CREATE_LAUNCH.SUBMIT_BUTTON, {
timeout: TIME.TRANSACTION_TIMEOUT,
timeout: TIME.TXN_TIMEOUT,
}).click();

// Give the txn chance to complete before pressing the submit button again
cy.contains("Deploy your Auction", {
timeout: TIME.TRANSACTION_TIMEOUT,
timeout: TIME.TXN_TIMEOUT,
}).should("exist");

// hack
cy.wait(3000);

// Upload launch metadata to IPFS and sign transaction
cy.get(CREATE_LAUNCH.SUBMIT_BUTTON).click();

cy.contains("View your Launch", {
timeout: TIME.TRANSACTION_TIMEOUT,
timeout: TIME.TXN_TIMEOUT,
}).should("exist");
});
});
9 changes: 6 additions & 3 deletions apps/dapp/cypress/smoke.cy.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/// <reference types="cypress" />

import { URLS } from "./constants";
const isTestnet = Cypress.env("VITE_TESTNET") === "true";

// These tests just ensure that none of the pages have been inadvertently broken by any code changes
describe("smoke tests", () => {
Expand All @@ -10,7 +11,7 @@ describe("smoke tests", () => {
});

it("renders create launch page", () => {
cy.visit(URLS.CREATE_LAUNCH);
cy.visit(URLS.CREATE_LAUNCH());
cy.shouldRenderPageWithId("__AXIS_CREATE_LAUNCH_PAGE__");
});

Expand All @@ -25,11 +26,13 @@ describe("smoke tests", () => {
});

it("renders launch page", () => {
cy.visit(URLS.LAUNCH);
const [mainnetChainId, testnetChainId] = ["8453", "84532"];
const chainId = isTestnet ? testnetChainId : mainnetChainId;
cy.visit(URLS.LAUNCH(chainId));
cy.shouldRenderPageWithId("__AXIS_LAUNCH_PAGE__");
});

if (Cypress.env("VITE_TESTNET") === "true") {
if (isTestnet) {
it("renders faucet page", () => {
cy.visit(URLS.FAUCET);
cy.shouldRenderPageWithId("__AXIS_FAUCET_PAGE__");
Expand Down
2,076 changes: 1,858 additions & 218 deletions apps/dapp/cypress/state.json

Large diffs are not rendered by default.

22 changes: 19 additions & 3 deletions apps/dapp/cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Cypress.Commands.add("deployToken", (symbol: string, name: string) => {
cy.get(DEPLOY.TOKEN_NAME_FIELD).clear().type(name);
cy.get(DEPLOY.TOKEN_SYMBOL_FIELD).clear().type(symbol);
cy.get(DEPLOY.DEPLOY_BUTTON).click();
cy.get(DEPLOY.SUCCESS_MESSAGE, { timeout: TIME.TRANSACTION_TIMEOUT }).should(
cy.get(DEPLOY.SUCCESS_MESSAGE, { timeout: TIME.TXN_TIMEOUT }).should(
"be.visible",
);

Expand All @@ -33,6 +33,22 @@ Cypress.Commands.add("deployToken", (symbol: string, name: string) => {
.then((tokenAddress) => tokenAddress);
});

Cypress.Commands.add(
"mintToken",
(address: string, amount: string = "100000") => {
const { MINT } = QUERIES;

cy.visit(URLS.DEPLOY);

cy.get(MINT.ADDRESS_FIELD).clear().type(address);
cy.get(MINT.AMOUNT_FIELD).clear().type(amount);
cy.get(MINT.MINT_BUTTON).click();
cy.get(MINT.SUCCESS_MESSAGE, { timeout: TIME.TXN_TIMEOUT }).should(
"be.visible",
);
},
);

Cypress.Commands.add(
"deployTokenAndMint",
(symbol: string, name: string, amount: string = "100000") => {
Expand All @@ -43,12 +59,12 @@ Cypress.Commands.add(
cy.get(DEPLOY.TOKEN_SYMBOL_FIELD).clear().type(symbol);
cy.get(DEPLOY.DEPLOY_BUTTON).click();
cy.get(DEPLOY.SUCCESS_MESSAGE, {
timeout: TIME.TRANSACTION_TIMEOUT,
timeout: TIME.TXN_TIMEOUT,
}).should("be.visible");

cy.get(MINT.AMOUNT_FIELD).clear().type(amount);
cy.get(MINT.MINT_BUTTON).click();
cy.get(MINT.SUCCESS_MESSAGE, { timeout: TIME.TRANSACTION_TIMEOUT }).should(
cy.get(MINT.SUCCESS_MESSAGE, { timeout: TIME.TXN_TIMEOUT }).should(
"be.visible",
);

Expand Down
Loading
Loading