Skip to content

Commit

Permalink
fix: testing env (#165)
Browse files Browse the repository at this point in the history
  • Loading branch information
VGabriel45 authored Jan 9, 2025
1 parent 8f76a15 commit 9714916
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/sdk/clients/createBicoPaymasterClient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
createSmartAccountClient
} from "./createSmartAccountClient"

describe.skip("bico.paymaster", async () => {
describe("bico.paymaster", async () => {
// describe.runIf(paymasterTruthy())("bico.paymaster", async () => {
let network: NetworkConfig

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
http,
type Account,
type Address,
type Chain,
type LocalAccount,
Expand All @@ -16,7 +17,13 @@ import { beforeAll, describe, expect, test } from "vitest"
import { CounterAbi } from "../../../test/__contracts/abi/CounterAbi"
import { testAddresses } from "../../../test/callDatas"
import { toNetwork } from "../../../test/testSetup"
import type { NetworkConfig } from "../../../test/testUtils"
import {
type NetworkConfig,
fundAndDeployClients,
getTestAccount,
toTestClient
} from "../../../test/testUtils"
import type { Signer } from "../../account"
import { type NexusAccount, toNexusAccount } from "../../account/toNexusAccount"
import { safeMultiplier } from "../../account/utils/Utils"
import {
Expand Down Expand Up @@ -47,12 +54,11 @@ describe("modules.smartSessions.enable.mode.dx", async () => {

let chain: Chain
let bundlerUrl: string
let paymasterUrl: undefined | string
let walletClient: WalletClient

// Test utils
let publicClient: PublicClient // testClient not available on public testnets
let eoaAccount: PrivateKeyAccount
let eoaAccount: Account
let recipientAddress: Address
let nexusAccountAddress: Address
let nexusAccount: NexusAccount
Expand All @@ -66,18 +72,19 @@ describe("modules.smartSessions.enable.mode.dx", async () => {
const index = 2n

beforeAll(async () => {
network = await toNetwork("TESTNET_FROM_ENV_VARS")
network = await toNetwork("BESPOKE_ANVIL_NETWORK_FORKING_BASE_SEPOLIA")

chain = network.chain
bundlerUrl = network.bundlerUrl
paymasterUrl = network.paymasterUrl
eoaAccount = network.account as PrivateKeyAccount
eoaAccount = getTestAccount(0)

sessionKeyAccount = privateKeyToAccount(generatePrivateKey()) // Generally belongs to the dapp
sessionPublicKey = getAddress(sessionKeyAccount.address)

recipientAddress = "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045" // vitalik.eth

const testClient = toTestClient(chain, getTestAccount(5))

walletClient = createWalletClient({
account: eoaAccount,
chain,
Expand Down Expand Up @@ -106,6 +113,8 @@ describe("modules.smartSessions.enable.mode.dx", async () => {
transport: http(),
bundlerTransport: http(bundlerUrl)
})

await fundAndDeployClients(testClient, [nexusClient])
})

test("full smart sessions enable mode example", async () => {
Expand All @@ -122,7 +131,8 @@ describe("modules.smartSessions.enable.mode.dx", async () => {
const installReceipt = await nexusClient.waitForUserOperationReceipt({
hash: opHash
})
expect(installReceipt.success).toBe("true")
console.log(installReceipt)
expect(installReceipt.success).toBe(true)
}

const session: Session = {
Expand Down Expand Up @@ -216,13 +226,13 @@ describe("modules.smartSessions.enable.mode.dx", async () => {
hash: userOpHash
})

expect(receipt.success).toBe("true")
expect(receipt.success).toBe(true)
})

test("should all a user to grant permission using enable mode by default", async () => {
const sessionsModule = toSmartSessionsValidator({
account: nexusClient.account,
signer: eoaAccount
signer: eoaAccount as Signer
})

const isInstalled = await nexusClient.isModuleInstalled({
Expand All @@ -236,7 +246,7 @@ describe("modules.smartSessions.enable.mode.dx", async () => {
const installReceipt = await nexusClient.waitForUserOperationReceipt({
hash: opHash
})
expect(installReceipt.success).toBe("true")
expect(installReceipt.success).toBe(true)
}

// Extend the Nexus client with smart session creation actions
Expand Down Expand Up @@ -282,7 +292,7 @@ describe("modules.smartSessions.enable.mode.dx", async () => {
const smartSessionNexusClient = await createSmartAccountClient({
index,
accountAddress: usersSessionData.granter,
signer: eoaAccount,
signer: eoaAccount as Signer,
chain,
transport: http(),
bundlerTransport: http(bundlerUrl)
Expand Down Expand Up @@ -329,6 +339,6 @@ describe("modules.smartSessions.enable.mode.dx", async () => {
hash: userOpHash
})

expect(receipt.success).toBe("true")
expect(receipt.success).toBe(true)
})
})
4 changes: 4 additions & 0 deletions src/test/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ export default defineConfig({
statements: 80
}
},
sequence: {
shuffle: false,
concurrent: false
},
include: ["./src/test/**/*.test.ts", "./src/sdk/**/*.test.ts"],
globalSetup: join(__dirname, "globalSetup.ts"),
environment: "node",
Expand Down

0 comments on commit 9714916

Please sign in to comment.