Skip to content

Commit 72b9d8a

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

20 files changed

+776
-147
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: 1 addition & 1 deletion
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))) {

.vitest/setupTests.ts

Lines changed: 9 additions & 15 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);
23-
}, 60_000);
19+
await paymaster060.deployPaymasterContract(client);
20+
await paymaster070.deployPaymasterContract(client);
21+
}, 10_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: 5 additions & 19 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,
15-
forkBlockNumber: 6381303,
16+
forkBlockNumber: 8168190,
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,13 +132,12 @@ 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",
152138
},
153139
},
154-
{ messageBuffer: 1000 },
140+
{ messageBuffer: 10 },
155141
),
156142
port: bundlerPort,
157143
});

.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: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import getPort from "get-port";
2+
import { createServer } from "prool";
3+
import { anvil } from "prool/instances";
4+
import { rundlerBinaryPath } from "../constants";
5+
import { rundler, type RundlerParameters } from "./instance";
6+
7+
describe("instance: 'rundler'", async () => {
8+
const port = await getPort();
9+
10+
beforeAll(async () => {
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+
21+
const response = await fetch(`http://localhost:${port_2}/1`, {
22+
body: JSON.stringify({
23+
method: "eth_supportedEntryPoints",
24+
params: [],
25+
id: 0,
26+
jsonrpc: "2.0",
27+
}),
28+
headers: {
29+
"Content-Type": "application/json",
30+
},
31+
method: "POST",
32+
});
33+
expect(response.status).toBe(200);
34+
expect(await response.json()).toMatchInlineSnapshot(`
35+
{
36+
"id": 0,
37+
"jsonrpc": "2.0",
38+
"result": [
39+
"0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",
40+
"0x0000000071727De22E5E9d8BAf0edAc6f37da032",
41+
],
42+
}
43+
`);
44+
await stop();
45+
});
46+
});
47+
48+
export const rundlerOptions = ({
49+
port,
50+
}: {
51+
port: number;
52+
}): RundlerParameters => ({
53+
binary: rundlerBinaryPath,
54+
nodeHttp: `http://localhost:${port}`,
55+
rpc: {
56+
api: "eth,rundler,debug",
57+
},
58+
signer: {
59+
privateKeys: [
60+
"0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80",
61+
"0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d",
62+
],
63+
},
64+
});

0 commit comments

Comments
 (0)