Skip to content

Commit

Permalink
chore: tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
jxom committed Oct 16, 2024
1 parent 9759cd7 commit 8146d98
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/actions/wallet/sendTransaction.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ describe('args: chain', async () => {
`)
})

test('behavior: nullish account, transport supports `wallet_sendTransaction`', async () => {
test('behavior: transport supports `wallet_sendTransaction`', async () => {
await setup()

const request = client.request
Expand All @@ -617,6 +617,18 @@ describe('args: chain', async () => {
return request(parameters)
}

expect(
await sendTransaction(client, {
account: sourceAccount.address,
to: targetAccount.address,
value: 0n,
}),
).toBeDefined()
})

test('behavior: nullish account', async () => {
await setup()

expect(
await sendTransaction(client, {
account: null,
Expand Down
28 changes: 28 additions & 0 deletions src/actions/wallet/writeContract.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { getTransactionReceipt } from '../public/getTransactionReceipt.js'
import { simulateContract } from '../public/simulateContract.js'
import { mine } from '../test/mine.js'
import { writeContract } from './writeContract.js'
import { InvalidInputRpcError } from '../../errors/rpc.js'

const client = anvilMainnet.getClient().extend(walletActions)
const clientWithAccount = anvilMainnet.getClient({
Expand Down Expand Up @@ -462,6 +463,33 @@ test('w/ simulateContract (client chain mismatch)', async () => {
`)
})

test('behavior: transport supports `wallet_sendTransaction`', async () => {
const request = client.request
client.request = (parameters: any) => {
if (parameters.method === 'eth_sendTransaction')
throw new InvalidInputRpcError(new Error())
return request(parameters)
}

expect(
await writeContract(client, {
...wagmiContractConfig,
account: accounts[0].address,
functionName: 'mint',
}),
).toBeDefined()
})

test('behavior: nullish account', async () => {
expect(
await writeContract(client, {
...wagmiContractConfig,
functionName: 'mint',
account: null,
}),
).toBeDefined()
})

describe('behavior: contract revert', () => {
test('revert', async () => {
const { contractAddress } = await deployErrorExample()
Expand Down

0 comments on commit 8146d98

Please sign in to comment.