Skip to content

Commit

Permalink
Revert "chore: workflow"
Browse files Browse the repository at this point in the history
This reverts commit 109b353.
  • Loading branch information
joepegler committed Aug 23, 2024
1 parent b7eabfc commit 9bba424
Show file tree
Hide file tree
Showing 11 changed files with 610 additions and 21 deletions.
1 change: 0 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@ jobs:
steps:
- uses: actions/checkout@v4


- name: Build
uses: ./.github/actions/build
2 changes: 0 additions & 2 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4


- run: git config --global user.email "gh@runner.com"
- run: git config --global user.name "gh-runner"

Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,12 @@
"dev": "bun link && concurrently \"bun run esm:watch\" \"bun run cjs:watch\" \"bun run esm:watch:aliases\" \"bun run cjs:watch:aliases\"",
"build": "bun run clean && bun run build:cjs && bun run build:esm && bun run build:types",
"clean": "rimraf ./dist/_esm ./dist/_cjs ./dist/_types ./dist/tsconfig",
"test": "vitest -c ./tests/vitest.config.ts",
"test:watch": "bun run test dev",
"test": "vitest dev -c ./tests/vitest.config.ts",
"playground": "RUN_PLAYGROUND=true bun run test -t=Playground",
"playground:watch": "RUN_PLAYGROUND=true bun run test -t=Playground --watch",
"test:watch": "bun run test --watch",
"test:coverage": "CI=true vitest -c ./tests/vitest.config.ts --coverage",
"test:ci": "CI=true vitest -c ./tests/vitest.config.ts",
"size": "size-limit",
"docs": "typedoc --tsconfig ./tsconfig/tsconfig.esm.json",
"docs:deploy": "bun run docs && gh-pages -d docs",
Expand Down
8 changes: 1 addition & 7 deletions tests/globalSetup.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
import { type NetworkConfig, initNetwork, killAllNetworks } from "./test.utils"

export async function setup({ provide }) {
const network = await initNetwork()
const { bundlerInstance, instance, ...serializeableConfig } = network
provide("globalNetwork", serializeableConfig)
}
import { type NetworkConfig, killAllNetworks } from "./test.utils"

export async function teardown() {
await killAllNetworks()
Expand Down
115 changes: 115 additions & 0 deletions tests/instances/account.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
import {
http,
type Account,
type Chain,
type Hex,
type WalletClient,
createWalletClient
} from "viem"
import { afterAll, beforeAll, describe, expect, test } from "vitest"
import {
type NexusSmartAccount,
type NexusSmartAccountConfig,
createSmartAccountClient
} from "../../src/account"
import {
fundAndDeploy,
getTestAccount,
killNetwork,
toTestClient
} from "../test.utils"
import type {
MasterClient,
NetworkConfig,
NetworkConfigWithBundler
} from "../test.utils"
import { type TestFileNetworkType, aaTest, toNetwork } from "../testSetup"

const NETWORK_TYPE: TestFileNetworkType = "LOCAL"

describe("account", () => {
let network: NetworkConfig
let chain: Chain
let bundlerUrl: string
let testClient: MasterClient
let account: Account
let recipientAccount: Account
let walletClient: WalletClient
let recipientWalletClient: WalletClient
let smartAccount: NexusSmartAccount
let recipientSmartAccount: NexusSmartAccount
let smartAccountAddress: Hex
let recipientSmartAccountAddress: Hex

beforeAll(async () => {
network = await toNetwork(NETWORK_TYPE)

const testConfig: Partial<NexusSmartAccountConfig> = {
factoryAddress: network.deployment.k1FactoryAddress,
k1ValidatorAddress: network.deployment.k1ValidatorAddress
}

chain = network.chain
bundlerUrl = network.bundlerUrl

account = getTestAccount(2)
recipientAccount = getTestAccount(3)

walletClient = createWalletClient({
account,
chain,
transport: http()
})

recipientWalletClient = createWalletClient({
account: recipientAccount,
chain,
transport: http()
})

testClient = toTestClient(chain, getTestAccount())

smartAccount = await createSmartAccountClient({
signer: walletClient,
bundlerUrl,
chain,
...testConfig
})

recipientSmartAccount = await createSmartAccountClient({
signer: recipientWalletClient,
bundlerUrl,
chain,
...testConfig
})

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

test("should have account addresses", async () => {
const addresses = await Promise.all([
account.address,
smartAccount.getAddress(),
recipientAccount.address,
recipientSmartAccount.getAddress()
])
expect(addresses.every(Boolean)).to.be.true
expect(addresses).toStrictEqual([
"0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC",
"0x2915317448Dd00158361dcBB47eacF26f774DdA8", // Sender smart account
"0x90F79bf6EB2c4f870365E785982E1f101E93b906",
"0x89028E0fD7Af7F864878e0209118DF6A9229A9Ce" // Recipient smart account
])
})

test("should", async () => {
const counterAddress = network.deployment.counterAddress
const byteCode = await testClient.getBytecode({ address: counterAddress })
expect(byteCode).toBeTruthy()
})
})
111 changes: 111 additions & 0 deletions tests/instances/bundler.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
import {
http,
type Account,
type Chain,
type Hex,
type WalletClient,
createWalletClient
} from "viem"
import { afterAll, beforeAll, describe, expect, test } from "vitest"
import {
type NexusSmartAccount,
type NexusSmartAccountConfig,
createSmartAccountClient
} from "../../src/account"
import {
fundAndDeploy,
getTestAccount,
killNetwork,
toTestClient
} from "../test.utils"
import type { MasterClient, NetworkConfig } from "../test.utils"
import { type TestFileNetworkType, toNetwork } from "../testSetup"

const NETWORK_TYPE: TestFileNetworkType = "LOCAL"

describe("bundler", () => {
let network: NetworkConfig
let chain: Chain
let bundlerUrl: string
let testClient: MasterClient
let account: Account
let recipientAccount: Account
let walletClient: WalletClient
let recipientWalletClient: WalletClient
let smartAccount: NexusSmartAccount
let recipientSmartAccount: NexusSmartAccount
let smartAccountAddress: Hex
let recipientSmartAccountAddress: Hex

beforeAll(async () => {
network = await toNetwork(NETWORK_TYPE)

const testConfig: Partial<NexusSmartAccountConfig> = {
factoryAddress: network.deployment.k1FactoryAddress,
k1ValidatorAddress: network.deployment.k1ValidatorAddress
}

chain = network.chain
bundlerUrl = network.bundlerUrl

account = getTestAccount(2)
recipientAccount = getTestAccount(3)

walletClient = createWalletClient({
account,
chain,
transport: http()
})

recipientWalletClient = createWalletClient({
account: recipientAccount,
chain,
transport: http()
})

testClient = toTestClient(chain, getTestAccount())

smartAccount = await createSmartAccountClient({
signer: walletClient,
bundlerUrl,
chain,
...testConfig
})

recipientSmartAccount = await createSmartAccountClient({
signer: recipientWalletClient,
bundlerUrl,
chain,
...testConfig
})

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

test("should have account addresses", async () => {
const addresses = await Promise.all([
account.address,
smartAccount.getAddress(),
recipientAccount.address,
recipientSmartAccount.getAddress()
])
expect(addresses.every(Boolean)).to.be.true
expect(addresses).toStrictEqual([
"0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC",
"0x2915317448Dd00158361dcBB47eacF26f774DdA8", // Sender smart account
"0x90F79bf6EB2c4f870365E785982E1f101E93b906",
"0x89028E0fD7Af7F864878e0209118DF6A9229A9Ce" // Recipient smart account
])
})

test("should check bytecode at Counter contract", async () => {
const counterAddress = network.deployment.counterAddress
const byteCode = await testClient.getBytecode({ address: counterAddress })
expect(byteCode).toBeTruthy()
})
})
111 changes: 111 additions & 0 deletions tests/instances/hook.module.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
import {
http,
type Account,
type Chain,
type Hex,
type WalletClient,
createWalletClient
} from "viem"
import { afterAll, beforeAll, describe, expect, test } from "vitest"
import {
type NexusSmartAccount,
type NexusSmartAccountConfig,
createSmartAccountClient
} from "../../src/account"
import {
fundAndDeploy,
getTestAccount,
killNetwork,
toTestClient
} from "../test.utils"
import type { MasterClient, NetworkConfig } from "../test.utils"
import { type TestFileNetworkType, toNetwork } from "../testSetup"

const NETWORK_TYPE: TestFileNetworkType = "LOCAL"

describe("hook.module", () => {
let network: NetworkConfig
let chain: Chain
let bundlerUrl: string
let testClient: MasterClient
let account: Account
let recipientAccount: Account
let walletClient: WalletClient
let recipientWalletClient: WalletClient
let smartAccount: NexusSmartAccount
let recipientSmartAccount: NexusSmartAccount
let smartAccountAddress: Hex
let recipientSmartAccountAddress: Hex

beforeAll(async () => {
network = await toNetwork(NETWORK_TYPE)

const testConfig: Partial<NexusSmartAccountConfig> = {
factoryAddress: network.deployment.k1FactoryAddress,
k1ValidatorAddress: network.deployment.k1ValidatorAddress
}

chain = network.chain
bundlerUrl = network.bundlerUrl

account = getTestAccount(2)
recipientAccount = getTestAccount(3)

walletClient = createWalletClient({
account,
chain,
transport: http()
})

recipientWalletClient = createWalletClient({
account: recipientAccount,
chain,
transport: http()
})

testClient = toTestClient(chain, getTestAccount())

smartAccount = await createSmartAccountClient({
signer: walletClient,
bundlerUrl,
chain,
...testConfig
})

recipientSmartAccount = await createSmartAccountClient({
signer: recipientWalletClient,
bundlerUrl,
chain,
...testConfig
})

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

test("should have account addresses", async () => {
const addresses = await Promise.all([
account.address,
smartAccount.getAddress(),
recipientAccount.address,
recipientSmartAccount.getAddress()
])
expect(addresses.every(Boolean)).to.be.true
expect(addresses).toStrictEqual([
"0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC",
"0x2915317448Dd00158361dcBB47eacF26f774DdA8", // Sender smart account
"0x90F79bf6EB2c4f870365E785982E1f101E93b906",
"0x89028E0fD7Af7F864878e0209118DF6A9229A9Ce" // Recipient smart account
])
})

test("should check bytecode at Counter contract", async () => {
const counterAddress = network.deployment.counterAddress
const byteCode = await testClient.getBytecode({ address: counterAddress })
expect(byteCode).toBeTruthy()
})
})
Loading

0 comments on commit 9bba424

Please sign in to comment.