Skip to content

Commit

Permalink
increase e2e test timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
kyscott18 committed Nov 18, 2024
1 parent e47316c commit 7b156ea
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 75 deletions.
78 changes: 41 additions & 37 deletions packages/core/src/_test/e2e/erc20/erc20.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,55 +35,59 @@ const cliOptions = {
logFormat: "pretty",
};

test("erc20", async (context) => {
const port = await getFreePort();
test(
"erc20",
async (context) => {
const port = await getFreePort();

const cleanup = await start({
cliOptions: {
...cliOptions,
command: "start",
port,
},
});
const cleanup = await start({
cliOptions: {
...cliOptions,
command: "start",
port,
},
});

await simulate({
erc20Address: context.erc20.address,
factoryAddress: context.factory.address,
});
await simulate({
erc20Address: context.erc20.address,
factoryAddress: context.factory.address,
});

await waitForIndexedBlock(port, "mainnet", 8);
await waitForIndexedBlock(port, "mainnet", 8);

const response = await postGraphql(
port,
`
const response = await postGraphql(
port,
`
accounts {
items {
address
balance
}
}
`,
);

expect(response.status).toBe(200);
const body = (await response.json()) as any;
expect(body.errors).toBe(undefined);
const accounts = body.data.accounts.items;
expect(accounts[0]).toMatchObject({
address: zeroAddress,
balance: (-2 * 10 ** 18).toString(),
});
expect(accounts[1]).toMatchObject({
address: BOB.toLowerCase(),
balance: (2 * 10 ** 18).toString(),
});
expect(accounts[2]).toMatchObject({
address: ALICE.toLowerCase(),
balance: "0",
});
);

await cleanup();
});
expect(response.status).toBe(200);
const body = (await response.json()) as any;
expect(body.errors).toBe(undefined);
const accounts = body.data.accounts.items;
expect(accounts[0]).toMatchObject({
address: zeroAddress,
balance: (-2 * 10 ** 18).toString(),
});
expect(accounts[1]).toMatchObject({
address: BOB.toLowerCase(),
balance: (2 * 10 ** 18).toString(),
});
expect(accounts[2]).toMatchObject({
address: ALICE.toLowerCase(),
balance: "0",
});

await cleanup();
},
{ timeout: 15_000 },
);

const isPglite = !!process.env.DATABASE_URL;

Expand Down
80 changes: 42 additions & 38 deletions packages/core/src/_test/e2e/factory/factory.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,24 @@ const cliOptions = {
logFormat: "pretty",
};

test("factory", async (context) => {
const port = await getFreePort();
test(
"factory",
async (context) => {
const port = await getFreePort();

const cleanup = await start({
cliOptions: {
...cliOptions,
command: "start",
port,
},
});
const cleanup = await start({
cliOptions: {
...cliOptions,
command: "start",
port,
},
});

await waitForIndexedBlock(port, "mainnet", 5);
await waitForIndexedBlock(port, "mainnet", 5);

let response = await postGraphql(
port,
`
let response = await postGraphql(
port,
`
swapEvents {
items {
id
Expand All @@ -57,28 +59,28 @@ test("factory", async (context) => {
}
}
`,
);
);

expect(response.status).toBe(200);
let body = (await response.json()) as any;
expect(body.errors).toBe(undefined);
let swapEvents = body.data.swapEvents.items;
expect(response.status).toBe(200);
let body = (await response.json()) as any;
expect(body.errors).toBe(undefined);
let swapEvents = body.data.swapEvents.items;

expect(swapEvents).toHaveLength(1);
expect(swapEvents[0]).toMatchObject({
id: expect.any(String),
from: ALICE.toLowerCase(),
to: ALICE.toLowerCase(),
pair: context.factory.pair.toLowerCase(),
});
expect(swapEvents).toHaveLength(1);
expect(swapEvents[0]).toMatchObject({
id: expect.any(String),
from: ALICE.toLowerCase(),
to: ALICE.toLowerCase(),
pair: context.factory.pair.toLowerCase(),
});

await simulatePairSwap(context.factory.pair);
await simulatePairSwap(context.factory.pair);

await waitForIndexedBlock(port, "mainnet", 6);
await waitForIndexedBlock(port, "mainnet", 6);

response = await postGraphql(
port,
`
response = await postGraphql(
port,
`
swapEvents {
items {
id
Expand All @@ -88,14 +90,16 @@ test("factory", async (context) => {
}
}
`,
);
);

expect(response.status).toBe(200);
body = (await response.json()) as any;
expect(body.errors).toBe(undefined);
swapEvents = body.data.swapEvents.items;
expect(response.status).toBe(200);
body = (await response.json()) as any;
expect(body.errors).toBe(undefined);
swapEvents = body.data.swapEvents.items;

expect(swapEvents).toHaveLength(2);
expect(swapEvents).toHaveLength(2);

await cleanup();
});
await cleanup();
},
{ timeout: 15_000 },
);

0 comments on commit 7b156ea

Please sign in to comment.