Skip to content

Commit

Permalink
feat: cleaner wait in gas price test
Browse files Browse the repository at this point in the history
  • Loading branch information
cytadela8 committed Oct 25, 2024
1 parent 630e951 commit 37c08c8
Showing 1 changed file with 4 additions and 15 deletions.
19 changes: 4 additions & 15 deletions core/tests/ts-integration/tests/fees.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { TestContextOwner, TestMaster } from '../src';
import * as zksync from 'zksync-ethers';
import * as ethers from 'ethers';
import { DataAvailabityMode, Token } from '../src/types';
import { SYSTEM_CONTEXT_ADDRESS, getTestContract } from '../src/helpers';
import { SYSTEM_CONTEXT_ADDRESS, getTestContract, waitForNewL1Batch, anyTransaction } from '../src/helpers';
import { loadConfig, shouldLoadConfigFromFile } from 'utils/build/file-configs';
import { logsTestPath } from 'utils/build/logs';
import { sleep } from 'utils/build';
Expand Down Expand Up @@ -248,23 +248,16 @@ testFees('Test fees', function () {
});

test('Test gas price expected value', async () => {
const receiver = ethers.Wallet.createRandom().address;
const l1GasPrice = 2_000_000_000n; /// set to 2 gwei
await mainNodeSpawner.killAndSpawnMainNode({
newL1GasPrice: l1GasPrice,
newPubdataPrice: l1GasPrice
});

const doTxToReceiver = () =>
alice.sendTransaction({
to: receiver,
value: BigInt(1)
});

//wait 1 miniblock so the multiplier gets updated
await doTxToReceiver().then((tx) => tx.wait(1));
// wait for new batch so gas price is updated with new config set above
await waitForNewL1Batch(alice);

const receipt = await doTxToReceiver().then((tx) => tx.wait());
const receipt = await anyTransaction(alice);

const feeParams = await alice._providerL2().getFeeParams();
const feeConfig = feeParams.V2.config;
Expand All @@ -285,10 +278,6 @@ testFees('Test fees', function () {
const expectedConvertedGasPrice =
(expectedETHGasPrice * conversionRatio.numerator) / conversionRatio.denominator;

console.log('feeParams', feeParams);
console.log('receipt', receipt);
console.log('gas price', await alice._providerL2().getGasPrice());
console.log(await alice._providerL2().getFeeParams());
expect(receipt.gasPrice).toBe(BigInt(expectedConvertedGasPrice));
});

Expand Down

0 comments on commit 37c08c8

Please sign in to comment.