From 1f13c98469bed3eee21013d8e77258aa6a136013 Mon Sep 17 00:00:00 2001 From: Christophe Date: Fri, 28 Jun 2024 15:05:11 +0000 Subject: [PATCH] test: add integration test for arbGasInfo --- src/actions/arbGasInfo.integration.test.ts | 46 ++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 src/actions/arbGasInfo.integration.test.ts diff --git a/src/actions/arbGasInfo.integration.test.ts b/src/actions/arbGasInfo.integration.test.ts new file mode 100644 index 00000000..017cddf7 --- /dev/null +++ b/src/actions/arbGasInfo.integration.test.ts @@ -0,0 +1,46 @@ +import { describe, it, expect } from 'vitest'; +import { getNitroTestnodePrivateKeyAccounts } from '../testHelpers'; +import { createPublicClient, http } from 'viem'; +import { nitroTestnodeL3 } from '../chains'; +import { getGasAccountingParams } from './getGasAccountingParams'; +import { getMinimumGasPrice } from './getMinimumGasPrice'; +import { getParentBaseFeeEstimate } from './getParentBaseFeeEstimate'; +import { getParentRewardRate } from './getParentRewardRate'; +import { getParentRewardRecipient } from './getParentRewardRecipient'; + +const client = createPublicClient({ + chain: nitroTestnodeL3, + transport: http(), +}); + +const testnodeAccounts = getNitroTestnodePrivateKeyAccounts(); +const l3RollupOwner = testnodeAccounts.l3RollupOwner; + +describe('ArbGasInfo Getters', () => { + it('getGasAccountingParams successfully fetches gas accounting parameters', async () => { + const result = await getGasAccountingParams(client); + expect(result).toMatchInlineSnapshot(` + { + "gasPoolMax": 32000000n, + "maxTxGasLimit": 32000000n, + "speedLimitPerSecond": 7000000n, + } + `); + }); + it('getMinimumGasPrice successfully fetches minimum gas price', async () => { + const result = await getMinimumGasPrice(client); + expect(result).toMatchInlineSnapshot(`100000000n`); + }); + it('getParentBaseFeeEstimate successfully fetches parent base fee estimate', async () => { + const result = await getParentBaseFeeEstimate(client); + expect(Number(result)).gte(0); + }); + it('getParentRewardRate successfully fetches parent reward rate', async () => { + const result = await getParentRewardRate(client); + expect(result).toMatchInlineSnapshot(`10n`); + }); + it('getParentRewardRecipient successfully fetches parent reward recipient', async () => { + const result = await getParentRewardRecipient(client); + expect(result).toEqual(l3RollupOwner.address); + }); +});