From 0787aced97e70e439aa96e0b7dea272044d7a93a Mon Sep 17 00:00:00 2001 From: Kevin Ingersoll Date: Tue, 1 Aug 2023 19:24:59 +0100 Subject: [PATCH] add test (but it doesn't work yet) --- src/utils/transaction/prepareRequest.test.ts | 36 ++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/utils/transaction/prepareRequest.test.ts b/src/utils/transaction/prepareRequest.test.ts index 10c696e93b..5064acdce0 100644 --- a/src/utils/transaction/prepareRequest.test.ts +++ b/src/utils/transaction/prepareRequest.test.ts @@ -70,6 +70,42 @@ describe('prepareRequest', () => { `) }) + test('zero base fee', async () => { + await setup() + await setNextBlockBaseFeePerGas(testClient, { + baseFeePerGas: 0n, + }) + + const { + maxFeePerGas, + nonce: _nonce, + ...rest + } = await prepareRequest(walletClient, { + account: privateKeyToAccount(sourceAccount.privateKey), + to: targetAccount.address, + value: parseEther('1'), + }) + expect(maxFeePerGas).toEqual(0n) + expect(rest).toMatchInlineSnapshot(` + { + "account": { + "address": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", + "publicKey": "0x048318535b54105d4a7aae60c08fc45f9687181b4fdfc625bd1a753fa7397fed753547f11ca8696646f2f3acb08e31016afac23e630c5d11f59f61fef57b0d2aa5", + "signMessage": [Function], + "signTransaction": [Function], + "signTypedData": [Function], + "source": "privateKey", + "type": "local", + }, + "from": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", + "gas": 21000n, + "maxPriorityFeePerGas": 1500000000n, + "to": "0x70997970c51812dc3a010c7d01b50e0d17dc79c8", + "value": 1000000000000000000n, + } + `) + }) + test('legacy fees', async () => { await setup()