From c84d3450225306abbb39b4e7d6d82424341df2be Mon Sep 17 00:00:00 2001 From: Georgios Konstantopoulos Date: Wed, 26 May 2021 21:54:08 +0300 Subject: [PATCH] test: adds test that gas estimation is deterministic (#962) * test: adds test that gas estimation is deterministic * chore: yarn lint --- integration-tests/test/rpc.spec.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/integration-tests/test/rpc.spec.ts b/integration-tests/test/rpc.spec.ts index 5d9c7e441f5d..a65dcab5dfdf 100644 --- a/integration-tests/test/rpc.spec.ts +++ b/integration-tests/test/rpc.spec.ts @@ -317,6 +317,22 @@ describe('Basic RPC tests', () => { }) describe('eth_estimateGas (returns the fee)', () => { + it('gas estimation is deterministic', async () => { + let lastEstimate: BigNumber + for (let i = 0; i < 10; i++) { + const estimate = await l2Provider.estimateGas({ + to: DEFAULT_TRANSACTION.to, + value: 0, + }) + + if (i > 0) { + expect(lastEstimate).to.be.eq(estimate) + } + + lastEstimate = estimate + } + }) + it('should return a gas estimate for txs with empty data', async () => { const estimate = await l2Provider.estimateGas({ to: DEFAULT_TRANSACTION.to,