Skip to content

Commit

Permalink
add e2e
Browse files Browse the repository at this point in the history
  • Loading branch information
mouseless0x committed Oct 12, 2024
1 parent 763be85 commit 1702401
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 3 deletions.
1 change: 1 addition & 0 deletions scripts/config.local.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"entrypoints": "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789,0x0000000071727De22E5E9d8BAf0edAc6f37da032",
"entrypoint-simulation-contract": "0xBbe8A301FbDb2a4CD58c4A37c262ecef8f889c47",
"enable-debug-endpoints": true,
"code-override-support": true,
"expiration-check": false,
"safe-mode": false,
"api-version": "v1,v2",
Expand Down
3 changes: 1 addition & 2 deletions src/rpc/estimation/gasEstimationsV06.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ import {
type PublicClient,
decodeErrorResult,
encodeFunctionData,
toHex,
slice
toHex
} from "viem"
import { z } from "zod"
import type { SimulateHandleOpResult } from "./types"
Expand Down
2 changes: 1 addition & 1 deletion src/types/contracts/EntryPointSimulations06.ts

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions test/e2e/alto-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@
"mempool-max-parallel-ops": 10,
"mempool-max-queued-ops": 10,
"enforce-unique-senders-per-bundle": false,
"code-override-support": true,
"enable-instant-bundling-endpoint": true
}
31 changes: 31 additions & 0 deletions test/e2e/tests/eth_estimateUserOperationGas.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import type { EntryPointVersion } from "viem/account-abstraction"
import { beforeEach, describe, expect, test } from "vitest"
import { beforeEachCleanUp, getSmartAccountClient } from "../src/utils"
import {
decodeRevert,
getRevertCall,
deployRevertingContract
} from "../src/revertingContract"
import { Address, BaseError, ContractFunctionRevertedError } from "viem"

describe.each([
{
Expand All @@ -12,7 +18,10 @@ describe.each([
])(
"$entryPointVersion supports eth_estimateUserOperationGas",
({ entryPointVersion }) => {
let revertingContract: Address

beforeEach(async () => {
revertingContract = await deployRevertingContract()
await beforeEachCleanUp()
})

Expand Down Expand Up @@ -113,5 +122,27 @@ describe.each([
expect(estimation.paymasterPostOpGasLimit).toBe(0n)
expect(estimation.paymasterVerificationGasLimit).toBe(0n)
})

test.only("Should throw revert reason if simulation reverted during callphase", async () => {
const smartAccountClient = await getSmartAccountClient({
entryPointVersion
})

try {
await smartAccountClient.estimateUserOperationGas({
calls: [
{
to: revertingContract,
data: getRevertCall("foobar"),
value: 0n
}
]
})
} catch (e: any) {
expect(e).toBeInstanceOf(BaseError)
const err = e.walk()
expect(err.reason).toEqual("foobar")
}
})
}
)

0 comments on commit 1702401

Please sign in to comment.