Skip to content

Commit 3754868

Browse files
committed
test: update to latest rundler for use with prool
1 parent c1bdf87 commit 3754868

20 files changed

+761
-145
lines changed

.github/workflows/on-pull-request.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ jobs:
9090
with:
9191
repo: alchemyplatform/rundler
9292
platform: linux
93-
tag: v0.2.2
93+
tag: v0.8.2
9494
cache: enable
9595

9696
- name: Build Libraries

.vitest/globalSetup.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
cleanupRundler,
99
downloadLatestRundlerRelease,
1010
isRundlerInstalled,
11-
} from "./src/rundler";
11+
} from "./src/rundler/binary";
1212

1313
export default async function () {
1414
if (!isCi && !(await isRundlerInstalled(rundlerBinaryPath))) {
@@ -20,7 +20,7 @@ export default async function () {
2020
const shutdown = instance.start();
2121

2222
return shutdown;
23-
}),
23+
})
2424
);
2525

2626
return async () => {

.vitest/setupTests.ts

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,29 @@ import fetch from "node-fetch";
55
import { setAutomine } from "viem/actions";
66
import { beforeAll } from "vitest";
77
import { poolId } from "./src/constants.js";
8-
import { local060Instance, local070Instance } from "./src/instances.js";
8+
import { localInstance } from "./src/instances.js";
99
import { paymaster060 } from "./src/paymaster/paymaster060.js";
1010
import { paymaster070 } from "./src/paymaster/paymaster070.js";
1111

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

1515
beforeAll(async () => {
16-
const client060 = local060Instance.getClient();
17-
const client070 = local070Instance.getClient();
18-
await setAutomine(client060, true);
19-
await setAutomine(client070, true);
16+
const client = localInstance.getClient();
17+
await setAutomine(client, true);
2018

21-
await paymaster060.deployPaymasterContract(client060);
22-
await paymaster070.deployPaymasterContract(client070);
19+
await paymaster060.deployPaymasterContract(client);
20+
await paymaster070.deployPaymasterContract(client);
2321
}, 60_000);
2422

2523
afterEach(() => {
2624
onTestFailed(async () => {
2725
console.log(`Logs for failed test [${poolId()}]:`);
28-
console.log(await local060Instance.getLogs("anvil"));
29-
console.log(await local060Instance.getLogs("bundler"));
30-
31-
console.log(await local070Instance.getLogs("anvil"));
32-
console.log(await local070Instance.getLogs("bundler"));
26+
console.log(await localInstance.getLogs("anvil"));
27+
console.log(await localInstance.getLogs("bundler"));
3328
});
3429
});
3530

3631
afterAll(async () => {
37-
await local060Instance.restart();
38-
await local070Instance.restart();
32+
await localInstance.restart();
3933
});

.vitest/src/instances.ts

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,40 +3,28 @@ dotenv.config();
33

44
import getPort from "get-port";
55
import { createServer } from "prool";
6-
import { anvil, rundler } from "prool/instances";
6+
import { anvil } from "prool/instances";
77
import { createClient, http, type Chain, type ClientConfig } from "viem";
88
import { localhost } from "viem/chains";
99
import { split } from "../../aa-sdk/core/src/transport/split";
1010
import { poolId, rundlerBinaryPath } from "./constants";
1111
import { paymasterTransport } from "./paymaster/transport";
12+
import { rundler } from "./rundler/instance";
1213

13-
export const local060Instance = defineInstance({
14+
export const localInstance = defineInstance({
1415
chain: localhost,
1516
forkBlockNumber: 6381303,
1617
forkUrl:
1718
process.env.VITEST_SEPOLIA_FORK_URL ??
1819
"https://ethereum-sepolia-rpc.publicnode.com",
19-
entryPointVersion: "0.6.0",
2020
anvilPort: 8545,
2121
bundlerPort: 8645,
2222
});
2323

24-
export const local070Instance = defineInstance({
25-
chain: localhost,
26-
forkBlockNumber: 8168190,
27-
forkUrl:
28-
process.env.VITEST_SEPOLIA_FORK_URL ??
29-
"https://ethereum-sepolia-rpc.publicnode.com",
30-
entryPointVersion: "0.7.0",
31-
anvilPort: 8345,
32-
bundlerPort: 8445,
33-
});
34-
3524
type DefineInstanceParams = {
3625
chain: Chain;
3726
forkUrl: string;
3827
forkBlockNumber?: number;
39-
entryPointVersion: "0.6.0" | "0.7.0";
4028
anvilPort: number;
4129
bundlerPort: number;
4230
useLocalRunningInstance?: boolean;
@@ -59,7 +47,6 @@ function defineInstance(params: DefineInstanceParams) {
5947
const {
6048
anvilPort,
6149
bundlerPort,
62-
entryPointVersion,
6350
forkUrl,
6451
forkBlockNumber,
6552
chain: chain_,
@@ -145,7 +132,6 @@ function defineInstance(params: DefineInstanceParams) {
145132
rundler(
146133
{
147134
binary: rundlerBinaryPath,
148-
entryPointVersion,
149135
nodeHttp: `http://127.0.0.1:${anvilPort}/${key}`,
150136
rpc: {
151137
api: "eth,rundler,debug",

.vitest/src/rundler.ts renamed to .vitest/src/rundler/binary.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export async function cleanupRundler(rundlerPath: string) {
2222

2323
export async function downloadLatestRundlerRelease(
2424
filePath: string,
25-
version = "v0.2.2",
25+
version = "v0.8.2",
2626
) {
2727
const repoUrl =
2828
"https://api.github.com/repos/alchemyplatform/rundler/releases";

.vitest/src/rundler/instance.test.ts

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import getPort from "get-port";
2+
import { createServer } from "prool";
3+
import { anvil } from "prool/instances";
4+
import { rundler, type RundlerParameters } from "./instance";
5+
6+
describe("instance: 'rundler'", async () => {
7+
const port = await getPort();
8+
9+
beforeAll(async () => {
10+
console.log("starting anvil");
11+
await anvil({ port }).start();
12+
});
13+
14+
test("request: /{id}", async () => {
15+
const server = createServer({
16+
instance: rundler(rundlerOptions({ port })),
17+
});
18+
const stop = await server.start();
19+
const { port: port_2 } = server.address()!;
20+
const response = await fetch(`http://localhost:${port_2}/1`, {
21+
body: JSON.stringify({
22+
method: "eth_supportedEntryPoints",
23+
params: [],
24+
id: 0,
25+
jsonrpc: "2.0",
26+
}),
27+
headers: {
28+
"Content-Type": "application/json",
29+
},
30+
method: "POST",
31+
});
32+
expect(response.status).toBe(200);
33+
expect(await response.json()).toMatchInlineSnapshot(`
34+
{
35+
"id": 0,
36+
"jsonrpc": "2.0",
37+
"result": [
38+
"0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",
39+
"0x0000000071727De22E5E9d8BAf0edAc6f37da032",
40+
],
41+
}
42+
`);
43+
await stop();
44+
});
45+
});
46+
47+
export const rundlerOptions = ({
48+
port,
49+
}: {
50+
port: number;
51+
}): RundlerParameters => ({
52+
nodeHttp: `http://localhost:${port}`,
53+
builder: {
54+
privateKeys: [
55+
"0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80",
56+
"0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d",
57+
],
58+
},
59+
});

0 commit comments

Comments
 (0)