Skip to content

test: update to latest rundler for use with prool #1643

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

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 1 addition & 1 deletion .github/workflows/on-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ jobs:
with:
repo: alchemyplatform/rundler
platform: linux
tag: v0.2.2
tag: v0.8.2
cache: enable

- name: Build Libraries
Expand Down
2 changes: 1 addition & 1 deletion .vitest/globalSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
cleanupRundler,
downloadLatestRundlerRelease,
isRundlerInstalled,
} from "./src/rundler";
} from "./src/rundler/binary";

export default async function () {
if (!isCi && !(await isRundlerInstalled(rundlerBinaryPath))) {
Expand Down
24 changes: 9 additions & 15 deletions .vitest/setupTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,29 @@ import fetch from "node-fetch";
import { setAutomine } from "viem/actions";
import { beforeAll } from "vitest";
import { poolId } from "./src/constants.js";
import { local060Instance, local070Instance } from "./src/instances.js";
import { localInstance } from "./src/instances.js";
import { paymaster060 } from "./src/paymaster/paymaster060.js";
import { paymaster070 } from "./src/paymaster/paymaster070.js";

// @ts-expect-error this does exist but ts is not liking it
global.fetch = fetch;

beforeAll(async () => {
const client060 = local060Instance.getClient();
const client070 = local070Instance.getClient();
await setAutomine(client060, true);
await setAutomine(client070, true);
const client = localInstance.getClient();
await setAutomine(client, true);

await paymaster060.deployPaymasterContract(client060);
await paymaster070.deployPaymasterContract(client070);
}, 60_000);
await paymaster060.deployPaymasterContract(client);
await paymaster070.deployPaymasterContract(client);
}, 10_000);

afterEach(() => {
onTestFailed(async () => {
console.log(`Logs for failed test [${poolId()}]:`);
console.log(await local060Instance.getLogs("anvil"));
console.log(await local060Instance.getLogs("bundler"));

console.log(await local070Instance.getLogs("anvil"));
console.log(await local070Instance.getLogs("bundler"));
console.log(await localInstance.getLogs("anvil"));
console.log(await localInstance.getLogs("bundler"));
});
});

afterAll(async () => {
await local060Instance.restart();
await local070Instance.restart();
await localInstance.restart();
});
24 changes: 5 additions & 19 deletions .vitest/src/instances.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,28 @@ dotenv.config();

import getPort from "get-port";
import { createServer } from "prool";
import { anvil, rundler } from "prool/instances";
import { anvil } from "prool/instances";
import { createClient, http, type Chain, type ClientConfig } from "viem";
import { localhost } from "viem/chains";
import { split } from "../../aa-sdk/core/src/transport/split";
import { poolId, rundlerBinaryPath } from "./constants";
import { paymasterTransport } from "./paymaster/transport";
import { rundler } from "./rundler/instance";

export const local060Instance = defineInstance({
export const localInstance = defineInstance({
chain: localhost,
forkBlockNumber: 6381303,
forkBlockNumber: 8168190,
forkUrl:
process.env.VITEST_SEPOLIA_FORK_URL ??
"https://ethereum-sepolia-rpc.publicnode.com",
entryPointVersion: "0.6.0",
anvilPort: 8545,
bundlerPort: 8645,
});

export const local070Instance = defineInstance({
chain: localhost,
forkBlockNumber: 8168190,
forkUrl:
process.env.VITEST_SEPOLIA_FORK_URL ??
"https://ethereum-sepolia-rpc.publicnode.com",
entryPointVersion: "0.7.0",
anvilPort: 8345,
bundlerPort: 8445,
});

type DefineInstanceParams = {
chain: Chain;
forkUrl: string;
forkBlockNumber?: number;
entryPointVersion: "0.6.0" | "0.7.0";
anvilPort: number;
bundlerPort: number;
useLocalRunningInstance?: boolean;
Expand All @@ -59,7 +47,6 @@ function defineInstance(params: DefineInstanceParams) {
const {
anvilPort,
bundlerPort,
entryPointVersion,
forkUrl,
forkBlockNumber,
chain: chain_,
Expand Down Expand Up @@ -145,13 +132,12 @@ function defineInstance(params: DefineInstanceParams) {
rundler(
{
binary: rundlerBinaryPath,
entryPointVersion,
nodeHttp: `http://127.0.0.1:${anvilPort}/${key}`,
rpc: {
api: "eth,rundler,debug",
},
},
{ messageBuffer: 1000 },
{ messageBuffer: 10 },
),
port: bundlerPort,
});
Expand Down
2 changes: 1 addition & 1 deletion .vitest/src/rundler.ts → .vitest/src/rundler/binary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export async function cleanupRundler(rundlerPath: string) {

export async function downloadLatestRundlerRelease(
filePath: string,
version = "v0.2.2",
version = "v0.8.2",
) {
const repoUrl =
"https://api.github.com/repos/alchemyplatform/rundler/releases";
Expand Down
64 changes: 64 additions & 0 deletions .vitest/src/rundler/instance.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import getPort from "get-port";
import { createServer } from "prool";
import { anvil } from "prool/instances";
import { rundlerBinaryPath } from "../constants";
import { rundler, type RundlerParameters } from "./instance";

describe("instance: 'rundler'", async () => {
const port = await getPort();

beforeAll(async () => {
await anvil({ port }).start();
});

test("request: /{id}", async () => {
const server = createServer({
instance: rundler(rundlerOptions({ port })),
});
const stop = await server.start();
const { port: port_2 } = server.address()!;

const response = await fetch(`http://localhost:${port_2}/1`, {
body: JSON.stringify({
method: "eth_supportedEntryPoints",
params: [],
id: 0,
jsonrpc: "2.0",
}),
headers: {
"Content-Type": "application/json",
},
method: "POST",
});
expect(response.status).toBe(200);
expect(await response.json()).toMatchInlineSnapshot(`
{
"id": 0,
"jsonrpc": "2.0",
"result": [
"0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",
"0x0000000071727De22E5E9d8BAf0edAc6f37da032",
],
}
`);
await stop();
});
});

export const rundlerOptions = ({
port,
}: {
port: number;
}): RundlerParameters => ({
binary: rundlerBinaryPath,
nodeHttp: `http://localhost:${port}`,
rpc: {
api: "eth,rundler,debug",
},
signer: {
privateKeys: [
"0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80",
"0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d",
],
},
});
Loading
Loading