Skip to content

Commit

Permalink
chore: fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
joepegler committed Aug 27, 2024
1 parent 823d8ed commit 301f17b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
10 changes: 1 addition & 9 deletions tests/instances/account.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,7 @@ import {
type Transaction,
createSmartAccountClient
} from "../../src/account"
import {
getTestAccount,
killNetwork,
toTestClient,
topUp,
writeToFile
} from "../test.utils"
import { getTestAccount, killNetwork, toTestClient, topUp } from "../test.utils"
import type { MasterClient, NetworkConfig } from "../test.utils"
import { type TestFileNetworkType, toNetwork } from "../testSetup"

Expand Down Expand Up @@ -77,8 +71,6 @@ describe("account", () => {
testClient.getBytecode({ address: contracts.k1ValidatorFactory.address }),
testClient.getBytecode({ address: contracts.k1Validator.address })
])
const [k1ValidatorFactory, k1Validator] = byteCodes
writeToFile("byteCodes.json", { k1ValidatorFactory, k1Validator })
expect(byteCodes.every(Boolean)).toBe(true)
})

Expand Down
18 changes: 16 additions & 2 deletions tests/instances/bundler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
createWalletClient
} from "viem"
import { afterAll, beforeAll, describe, expect, test } from "vitest"
import contracts from "../../src/__contracts"
import {
type NexusSmartAccount,
type Transaction,
Expand All @@ -24,11 +25,14 @@ describe("bundler", () => {
// Nexus Config
let chain: Chain
let bundlerUrl: string
let factoryAddress: Hex
let k1ValidatorAddress: Hex
let walletClient: WalletClient

// Test utils
let testClient: MasterClient
let account: Account
let recipientAccount: Account
let smartAccount: NexusSmartAccount
let smartAccountAddress: Hex

Expand All @@ -39,6 +43,7 @@ describe("bundler", () => {
bundlerUrl = network.bundlerUrl

account = getTestAccount(0)
recipientAccount = getTestAccount(3)

walletClient = createWalletClient({
account,
Expand All @@ -55,11 +60,20 @@ describe("bundler", () => {
})

smartAccountAddress = await smartAccount.getAddress()
// await fundAndDeploy(testClient, smartAccount)
})
afterAll(async () => {
await killNetwork([network.rpcPort, network.bundlerPort])
})

test("byteCodes", async () => {
const byteCodes = await Promise.all([
testClient.getBytecode({ address: contracts.k1ValidatorFactory.address }),
testClient.getBytecode({ address: contracts.k1Validator.address })
])
expect(byteCodes.every(Boolean)).toBe(true)
})

test("topUp", async () => {
const total = await testClient.getBalance({
address: testClient.account.address
Expand All @@ -81,15 +95,15 @@ describe("bundler", () => {
])
})

test("should send eth", async () => {
test("send eth", async () => {
const tx: Transaction = {
to: account.address,
value: 1n
}

const { wait } = await smartAccount.sendTransaction(tx)

const { success } = await wait()
const { success, receipt } = await wait()

expect(success).toBe(true)
})
Expand Down
2 changes: 1 addition & 1 deletion tests/test.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -378,4 +378,4 @@ const deployContracts = async (rpcPort: number): Promise<void> => {
}

export const sleep = (ms: number) =>
new Promise((resolve) => setTimeout(resolve, ms))
new Promise((resolve) => setTimeout(resolve, ms))

0 comments on commit 301f17b

Please sign in to comment.