Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: remove defaultGanacheOptions #30728

Merged
merged 3 commits into from
Mar 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions test/e2e/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -531,17 +531,7 @@ const PRIVATE_KEY_TWO =
const ACCOUNT_1 = '0x5cfe73b6021e818b776b421b1c4db2474086a7e1';
const ACCOUNT_2 = '0x09781764c08de8ca82e156bbf156a3ca217c7950';

const defaultGanacheOptions = {
accounts: [
{
secretKey: PRIVATE_KEY,
balance: convertETHToHexGwei(DEFAULT_GANACHE_ETH_BALANCE_DEC),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is '25ETH' to the account corresponding to the default SRP (both ganache and anvil), so it can be removed, as it's in the node class level, and adding this to a spec has no effect

},
],
};

const defaultGanacheOptionsForType2Transactions = {
...defaultGanacheOptions,
// EVM version that supports type 2 transactions (EIP1559)
hardfork: 'london',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: You might be able to remove this one as well right now. The default hardfork in ganache already supports type2 transactions.

Copy link
Contributor Author

@seaona seaona Mar 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good observation !! So at the time the Ganache class was defined, it was set as hardfork: 'muirGlacier', as default, so the majority of specs are using that, unless specifically passing the london flag. In Anvil I also set the same hardfork as default, as several of specs were breaking otherwise, as were relying to type 1 (gas checks and conf screen). We could change that and use london as default in the class, as I guess most of the cases should use type 2 now, so it makes more sense.
I'll take a note on that, if that make sense I can update it in a separate PR, as this change might need some other spec tweaks? I'll wait on your feedback, thank you in advance 🙏

Copy link
Contributor Author

@seaona seaona Mar 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ Added a task here for me to address this next: https://github.com/MetaMask/MetaMask-planning/issues/4368

};
Expand Down Expand Up @@ -956,7 +946,6 @@ module.exports = {
switchToOrOpenDapp,
connectToDapp,
multipleGanacheOptions,
defaultGanacheOptions,
defaultGanacheOptionsForType2Transactions,
multipleGanacheOptionsForType2Transactions,
sendTransaction,
Expand Down
5 changes: 2 additions & 3 deletions test/e2e/json-rpc/eth_newBlockFilter.spec.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { strict as assert } from 'assert';
import { defaultGanacheOptions, withFixtures } from '../helpers';
import { withFixtures } from '../helpers';
import { loginWithBalanceValidation } from '../page-objects/flows/login.flow';
import FixtureBuilder from '../fixture-builder';
import { Driver } from '../webdriver/driver';

describe('eth_newBlockFilter', function () {
const ganacheOptions: typeof defaultGanacheOptions & { blockTime: number } = {
const ganacheOptions: { blockTime: number } = {
blockTime: 0.1,
...defaultGanacheOptions,
};
it('executes a new block filter call', async function () {
await withFixtures(
Expand Down
2 changes: 0 additions & 2 deletions test/e2e/json-rpc/wallet_addEthereumChain.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import FixtureBuilder from '../fixture-builder';
import { Driver } from '../webdriver/driver';
import {
withFixtures,
defaultGanacheOptions,
openDapp,
unlockWallet,
WINDOW_TITLES,
Expand Down Expand Up @@ -479,7 +478,6 @@ describe('Add Ethereum Chain', function () {
fixtures: new FixtureBuilder()
.withPermissionControllerConnectedToTestDappWithChains(['0x539'])
.build(),
localNodeOptions: defaultGanacheOptions,
title: this.test?.fullTitle(),
},
async ({ driver }: { driver: Driver }) => {
Expand Down
3 changes: 1 addition & 2 deletions test/e2e/tests/confirmations/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { TransactionEnvelopeType } from '@metamask/transaction-controller';
import FixtureBuilder from '../../fixture-builder';
import {
defaultGanacheOptions,
defaultGanacheOptionsForType2Transactions,
withFixtures,
} from '../../helpers';
Expand Down Expand Up @@ -44,7 +43,7 @@ export function withTransactionEnvelopeTypeFixtures(
.build(),
localNodeOptions:
transactionEnvelopeType === TransactionEnvelopeType.legacy
? defaultGanacheOptions
? {}
: defaultGanacheOptionsForType2Transactions,
...(smartContract && { smartContract }),
...(mocks && { testSpecificMock: mocks }),
Expand Down
13 changes: 0 additions & 13 deletions test/e2e/tests/metrics/metametrics-persistence.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,12 @@ const { strict: assert } = require('assert');
const FixtureBuilder = require('../../fixture-builder');
const {
withFixtures,
generateGanacheOptions,
defaultGanacheOptions,
unlockWallet,
genRandInitBal,
getCleanAppState,
} = require('../../helpers');

describe('MetaMetrics ID persistence', function () {
it('MetaMetrics ID should persist when the user opts-out and then opts-in again of MetaMetrics collection', async function () {
const { initialBalanceInHex } = genRandInitBal();

const initialMetaMetricsId = 'test-metrics-id';

await withFixtures(
Expand All @@ -23,14 +18,6 @@ describe('MetaMetrics ID persistence', function () {
participateInMetaMetrics: true,
})
.build(),
localNodeOptions: generateGanacheOptions({
accounts: [
{
secretKey: defaultGanacheOptions.accounts[0].secretKey,
balance: initialBalanceInHex,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no reason at all to start with a random balance, as this is not checked in the test, which we just check metric related topics, so we can remove it safely

},
],
}),
title: this.test.fullTitle(),
},
async ({ driver }) => {
Expand Down
2 changes: 0 additions & 2 deletions test/e2e/tests/multichain/asset-picker-send.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { Context } from 'mocha';
import { CHAIN_IDS } from '../../../../shared/constants/network';
import FixtureBuilder from '../../fixture-builder';
import {
defaultGanacheOptions,
openActionMenuAndStartSendFlow,
unlockWallet,
withFixtures,
Expand All @@ -17,7 +16,6 @@ describe('AssetPickerSendFlow', function () {
const fixtures = {
fixtures: new FixtureBuilder({ inputChainId: chainId }).build(),
localNodeOptions: {
...defaultGanacheOptions,
chainId: parseInt(chainId, 16),
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@ import TransactionConfirmation from '../../page-objects/pages/confirmations/rede
import { Driver } from '../../webdriver/driver';
import { DEFAULT_FIXTURE_ACCOUNT } from '../../constants';
import FixtureBuilder from '../../fixture-builder';
import {
withFixtures,
defaultGanacheOptions,
WINDOW_TITLES,
} from '../../helpers';
import { withFixtures, WINDOW_TITLES } from '../../helpers';

describe('Request Queuing', function () {
// TODO: add a new spec which checks that after revoking and connecting again
Expand All @@ -22,9 +18,6 @@ describe('Request Queuing', function () {
.withPermissionControllerConnectedToTestDapp()
.withSelectedNetworkControllerPerDomain()
.build(),
localNodeOptions: {
...defaultGanacheOptions,
},
title: this.test?.fullTitle(),
},
async ({ driver }: { driver: Driver }) => {
Expand Down
3 changes: 1 addition & 2 deletions test/e2e/tests/tokens/add-token-using-search.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { MockedEndpoint, Mockttp } from 'mockttp';
import { defaultGanacheOptions, withFixtures } from '../../helpers';
import { withFixtures } from '../../helpers';
import FixtureBuilder from '../../fixture-builder';
import { CHAIN_IDS } from '../../../../shared/constants/network';
import AssetListPage from '../../page-objects/pages/home/asset-list';
Expand Down Expand Up @@ -48,7 +48,6 @@ describe('Add existing token using search', function () {
})
.build(),
localNodeOptions: {
...defaultGanacheOptions,
chainId: parseInt(CHAIN_IDS.BSC, 16),
},
title: this.test?.fullTitle(),
Expand Down
7 changes: 1 addition & 6 deletions test/e2e/tests/tokens/token-details.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@ import { Context } from 'mocha';
import { CHAIN_IDS } from '../../../../shared/constants/network';
import { formatCurrency } from '../../../../ui/helpers/utils/confirm-tx.util';
import FixtureBuilder from '../../fixture-builder';
import {
defaultGanacheOptions,
unlockWallet,
withFixtures,
} from '../../helpers';
import { unlockWallet, withFixtures } from '../../helpers';
import { Driver } from '../../webdriver/driver';
import HomePage from '../../page-objects/pages/home/homepage';
import AssetListPage from '../../page-objects/pages/home/asset-list';
Expand All @@ -26,7 +22,6 @@ describe('Token Details', function () {
const fixtures = {
fixtures: new FixtureBuilder({ inputChainId: chainId }).build(),
localNodeOptions: {
...defaultGanacheOptions,
chainId: parseInt(chainId, 16),
},
};
Expand Down
7 changes: 1 addition & 6 deletions test/e2e/tests/tokens/token-list.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@ import { zeroAddress } from 'ethereumjs-util';
import { Browser } from 'selenium-webdriver';
import { CHAIN_IDS } from '../../../../shared/constants/network';
import FixtureBuilder from '../../fixture-builder';
import {
defaultGanacheOptions,
unlockWallet,
withFixtures,
} from '../../helpers';
import { unlockWallet, withFixtures } from '../../helpers';
import { Driver } from '../../webdriver/driver';
import HomePage from '../../page-objects/pages/home/homepage';
import AssetListPage from '../../page-objects/pages/home/asset-list';
Expand All @@ -30,7 +26,6 @@ describe('Token List', function () {
const fixtures = {
fixtures: new FixtureBuilder({ inputChainId: chainId }).build(),
localNodeOptions: {
...defaultGanacheOptions,
chainId: parseInt(chainId, 16),
},
};
Expand Down
8 changes: 1 addition & 7 deletions test/e2e/tests/tokens/token-sort.spec.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import { Context } from 'mocha';
import { CHAIN_IDS } from '../../../../shared/constants/network';
import FixtureBuilder from '../../fixture-builder';
import {
defaultGanacheOptions,
unlockWallet,
withFixtures,
largeDelayMs,
} from '../../helpers';
import { unlockWallet, withFixtures, largeDelayMs } from '../../helpers';
import { Driver } from '../../webdriver/driver';
import HomePage from '../../page-objects/pages/home/homepage';
import AssetListPage from '../../page-objects/pages/home/asset-list';
Expand All @@ -19,7 +14,6 @@ describe('Token List Sorting', function () {
const testFixtures = {
fixtures: new FixtureBuilder({ inputChainId: mainnetChainId }).build(),
localNodeOptions: {
...defaultGanacheOptions,
chainId: parseInt(mainnetChainId, 16),
},
};
Expand Down
Loading