@@ -2,10 +2,10 @@ import { describe, expect, test, vi } from 'vitest'
22
33import { accounts } from '~test/src/constants.js'
44import { maxUint256 } from '~viem/constants/number.js'
5- import { Delegation } from '../../../contracts/generated.js'
5+ import { Delegation , ErrorsExample } from '../../../contracts/generated.js'
66import { getSmartAccounts_07 } from '../../../test/src/account-abstraction.js'
77import { anvilMainnet } from '../../../test/src/anvil.js'
8- import { deploy } from '../../../test/src/utils.js'
8+ import { deploy , deployErrorExample } from '../../../test/src/utils.js'
99import { generatePrivateKey } from '../../accounts/generatePrivateKey.js'
1010import { privateKeyToAccount } from '../../accounts/privateKeyToAccount.js'
1111import {
@@ -327,6 +327,24 @@ test('no chain', async () => {
327327 ` )
328328} )
329329
330+ describe ( 'args: throwOnReceiptRevert' , async ( ) => {
331+ await setup ( )
332+
333+ const { contractAddress } = await deployErrorExample ( )
334+
335+ await expect ( ( ) =>
336+ sendTransactionSync ( client , {
337+ account : sourceAccount . address ,
338+ data : encodeFunctionData ( {
339+ abi : ErrorsExample . abi ,
340+ functionName : 'revertWrite' ,
341+ } ) ,
342+ throwOnReceiptRevert : true ,
343+ to : contractAddress ! ,
344+ } ) ,
345+ ) . rejects . toThrow ( 'The receipt marked the transaction as "reverted".' )
346+ } )
347+
330348describe ( 'args: gasPrice' , ( ) => {
331349 test ( 'sends transaction' , async ( ) => {
332350 await setup ( )
@@ -1460,6 +1478,25 @@ describe('local account', () => {
14601478 ) . toBe ( 40 )
14611479 } )
14621480 } )
1481+
1482+ test ( 'args: throwOnReceiptRevert' , async ( ) => {
1483+ await setup ( )
1484+
1485+ const { contractAddress } = await deployErrorExample ( )
1486+
1487+ await expect ( ( ) =>
1488+ sendTransactionSync ( client , {
1489+ account : privateKeyToAccount ( sourceAccount . privateKey ) ,
1490+ data : encodeFunctionData ( {
1491+ abi : ErrorsExample . abi ,
1492+ functionName : 'revertWrite' ,
1493+ } ) ,
1494+ gas : 100_000n ,
1495+ throwOnReceiptRevert : true ,
1496+ to : contractAddress ! ,
1497+ } ) ,
1498+ ) . rejects . toThrow ( 'The receipt marked the transaction as "reverted".' )
1499+ } )
14631500} )
14641501
14651502describe ( 'smart account' , async ( ) => {
0 commit comments