-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetEstimateGasError.test.ts
46 lines (38 loc) · 1.37 KB
/
getEstimateGasError.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import { expect, test } from 'vitest'
import { address } from '~test/src/constants.js'
import { parseAccount } from '../../accounts/utils/parseAccount.js'
import { BaseError } from '../../errors/base.js'
import { RpcRequestError } from '../../errors/request.js'
import { TransactionRejectedRpcError } from '../../errors/rpc.js'
import { getEstimateGasError } from './getEstimateGasError.js'
test('default', () => {
const error = new BaseError('Unknown error')
const result = getEstimateGasError(error, {
account: parseAccount(address.vitalik),
})
expect(result).toMatchInlineSnapshot(`
[EstimateGasExecutionError: Unknown error
Estimate Gas Arguments:
from: 0xd8da6bf26964af9d7eed9e03e53415d37aa96045
Version: [email protected]]
`)
})
test('default', () => {
const error = new TransactionRejectedRpcError(
new RpcRequestError({
body: {},
error: { code: -32003, message: 'fee cap higher than 2\^256-1' },
url: '',
}),
)
const result = getEstimateGasError(error, {
account: parseAccount(address.vitalik),
})
expect(result).toMatchInlineSnapshot(`
[EstimateGasExecutionError: The fee cap (\`maxFeePerGas\`) cannot be higher than the maximum allowed value (2^256-1).
Estimate Gas Arguments:
from: 0xd8da6bf26964af9d7eed9e03e53415d37aa96045
Details: fee cap higher than 2^256-1
Version: [email protected]]
`)
})