Skip to content

Commit

Permalink
improve tests
Browse files Browse the repository at this point in the history
  • Loading branch information
plusminushalf committed Mar 31, 2024
1 parent fd5ee1b commit ae42be3
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 17 deletions.
27 changes: 18 additions & 9 deletions packages/permissionless-test/ep-0.6/bundlerActions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import dotenv from "dotenv"
import {
BundlerClient,
ENTRYPOINT_ADDRESS_V06,
ENTRYPOINT_ADDRESS_V07,
UserOperation,
WaitForUserOperationReceiptTimeoutError,
createBundlerClient,
createSmartAccountClient,
Expand Down Expand Up @@ -40,6 +38,7 @@ import {
getEntryPoint,
getEoaWalletClient,
getPimlicoBundlerClient,
getPimlicoPaymasterClient,
getPrivateKeyAccount,
getPublicClient,
getSignerToSimpleSmartAccount,
Expand Down Expand Up @@ -93,8 +92,6 @@ describe("BUNDLER ACTIONS", () => {
test("Estimate user operation gas", async () => {
const publicClient = getPublicClient()

const eoaWalletClient = getEoaWalletClient()

const simpleAccount = await signerToSimpleSmartAccount(publicClient, {
signer: privateKeyToAccount(
process.env.TEST_PRIVATE_KEY as Address
Expand All @@ -104,21 +101,33 @@ describe("BUNDLER ACTIONS", () => {
index: 3n
})

const paymasterClient = getPimlicoPaymasterClient()
const pimlicoBundlerClient = getPimlicoBundlerClient()

const smartAccountClient = createSmartAccountClient({
account: simpleAccount,
chain: getTestingChain(),
bundlerTransport: http(`${process.env.BUNDLER_RPC_HOST}`)
bundlerTransport: http(`${process.env.BUNDLER_RPC_HOST}`),
middleware: {
gasPrice: async () => {
const gasPrices =
await pimlicoBundlerClient.getUserOperationGasPrice()
return gasPrices.fast
},
sponsorUserOperation: paymasterClient.sponsorUserOperation
}
})

await eoaWalletClient.sendTransaction({
to: simpleAccount.address,
value: parseEther("1")
})
// await eoaWalletClient.sendTransaction({
// to: simpleAccount.address,
// value: parseEther("1")
// })

const response = await smartAccountClient.sendTransaction({
to: zeroAddress,
value: 0n
})
console.log(`Transaction hash: ${response}`)
}, 100000)

test("Sending user operation", async () => {
Expand Down
28 changes: 20 additions & 8 deletions packages/permissionless-test/ep-0.7/bundlerActions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ import {
getBundlerClient,
getEntryPoint,
getEoaWalletClient,
getPimlicoBundlerClient,
getPimlicoPaymasterClient,
getPrivateKeyAccount,
getPublicClient,
getSignerToSimpleSmartAccount,
Expand Down Expand Up @@ -91,8 +93,6 @@ describe("BUNDLER ACTIONS", () => {
test("Estimate user operation gas", async () => {
const publicClient = getPublicClient()

const eoaWalletClient = getEoaWalletClient()

const simpleAccount = await signerToSimpleSmartAccount(publicClient, {
signer: privateKeyToAccount(
process.env.TEST_PRIVATE_KEY as Address
Expand All @@ -102,22 +102,34 @@ describe("BUNDLER ACTIONS", () => {
index: 3n
})

// const paymasterClient = getPimlicoPaymasterClient()
const pimlicoBundlerClient = getPimlicoBundlerClient()

const smartAccountClient = createSmartAccountClient({
account: simpleAccount,
chain: getTestingChain(),
bundlerTransport: http(`${process.env.BUNDLER_RPC_HOST}`)
bundlerTransport: http(`${process.env.BUNDLER_RPC_HOST}`),
middleware: {
gasPrice: async () => {
const gasPrices =
await pimlicoBundlerClient.getUserOperationGasPrice()
return gasPrices.fast
}
// sponsorUserOperation: paymasterClient.sponsorUserOperation
}
})

await eoaWalletClient.sendTransaction({
to: simpleAccount.address,
value: parseEther("1")
})
// await eoaWalletClient.sendTransaction({
// to: simpleAccount.address,
// value: parseEther("1")
// })

const response = await smartAccountClient.sendTransaction({
to: zeroAddress,
value: 0n
})
})
console.log(`Transaction hash: ${response}`)
}, 100000)

test("Sending user operation", async () => {
const publicClient = getPublicClient()
Expand Down

0 comments on commit ae42be3

Please sign in to comment.