From 8146d982fb6b583b5592a6263ce965bd8fd8c83e Mon Sep 17 00:00:00 2001 From: jxom Date: Thu, 17 Oct 2024 10:53:34 +1100 Subject: [PATCH] chore: tweaks --- src/actions/wallet/sendTransaction.test.ts | 14 ++++++++++- src/actions/wallet/writeContract.test.ts | 28 ++++++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/src/actions/wallet/sendTransaction.test.ts b/src/actions/wallet/sendTransaction.test.ts index 0c4d597b52..162af9689a 100644 --- a/src/actions/wallet/sendTransaction.test.ts +++ b/src/actions/wallet/sendTransaction.test.ts @@ -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 @@ -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, diff --git a/src/actions/wallet/writeContract.test.ts b/src/actions/wallet/writeContract.test.ts index bcc7ee0a2a..1535d2de01 100644 --- a/src/actions/wallet/writeContract.test.ts +++ b/src/actions/wallet/writeContract.test.ts @@ -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({ @@ -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()