1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

Fix isMainnet propType error (#12951)

A propType error was showing up during e2e tests with a `testDev`
build. It was caused by `process.env.IN_TEST` being treated as a
boolean, when in fact it is either the string `'true'` or a boolean.

`IN_TEST` has been updated to always be a boolean. `loose-envify` has
no trouble injecting boolean values, so there's no reason to treat this
as a string.
This commit is contained in:
Mark Stacey 2021-12-02 14:46:46 -03:30 committed by GitHub
parent fac68980e0
commit 7226357422
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 10 additions and 13 deletions

View File

@ -56,7 +56,7 @@ const openMetamaskTabsIDs = {};
const requestAccountTabIds = {}; const requestAccountTabIds = {};
// state persistence // state persistence
const inTest = process.env.IN_TEST === 'true'; const inTest = process.env.IN_TEST;
const localStore = inTest ? new ReadOnlyNetworkStore() : new LocalStore(); const localStore = inTest ? new ReadOnlyNetworkStore() : new LocalStore();
let versionedData; let versionedData;

View File

@ -10,7 +10,7 @@ import {
import { PollingBlockTracker } from 'eth-block-tracker'; import { PollingBlockTracker } from 'eth-block-tracker';
import { SECOND } from '../../../../shared/constants/time'; import { SECOND } from '../../../../shared/constants/time';
const inTest = process.env.IN_TEST === 'true'; const inTest = process.env.IN_TEST;
const blockTrackerOpts = inTest ? { pollingInterval: SECOND } : {}; const blockTrackerOpts = inTest ? { pollingInterval: SECOND } : {};
const getTestMiddlewares = () => { const getTestMiddlewares = () => {
return inTest ? [createEstimateGasDelayTestMiddleware()] : []; return inTest ? [createEstimateGasDelayTestMiddleware()] : [];

View File

@ -33,7 +33,7 @@ const env = process.env.METAMASK_ENV;
const fetchWithTimeout = getFetchWithTimeout(SECOND * 30); const fetchWithTimeout = getFetchWithTimeout(SECOND * 30);
let defaultProviderConfigOpts; let defaultProviderConfigOpts;
if (process.env.IN_TEST === 'true') { if (process.env.IN_TEST) {
defaultProviderConfigOpts = { defaultProviderConfigOpts = {
type: NETWORK_TYPE_RPC, type: NETWORK_TYPE_RPC,
rpcUrl: 'http://localhost:8545', rpcUrl: 'http://localhost:8545',

View File

@ -779,7 +779,7 @@ function getEnvironmentVariables({ buildType, devMode, testing }) {
METAMASK_VERSION: version, METAMASK_VERSION: version,
METAMASK_BUILD_TYPE: buildType, METAMASK_BUILD_TYPE: buildType,
NODE_ENV: devMode ? ENVIRONMENT.DEVELOPMENT : ENVIRONMENT.PRODUCTION, NODE_ENV: devMode ? ENVIRONMENT.DEVELOPMENT : ENVIRONMENT.PRODUCTION,
IN_TEST: testing ? 'true' : false, IN_TEST: testing,
PUBNUB_SUB_KEY: process.env.PUBNUB_SUB_KEY || '', PUBNUB_SUB_KEY: process.env.PUBNUB_SUB_KEY || '',
PUBNUB_PUB_KEY: process.env.PUBNUB_PUB_KEY || '', PUBNUB_PUB_KEY: process.env.PUBNUB_PUB_KEY || '',
CONF: devMode ? metamaskrc : {}, CONF: devMode ? metamaskrc : {},

View File

@ -29,7 +29,7 @@ const EditGasFeePopover = () => {
className="edit-gas-fee-popover" className="edit-gas-fee-popover"
> >
<> <>
{process.env.IN_TEST === 'true' ? null : <LoadingHeartBeat />} {process.env.IN_TEST ? null : <LoadingHeartBeat />}
<div className="edit-gas-fee-popover__wrapper"> <div className="edit-gas-fee-popover__wrapper">
<div className="edit-gas-fee-popover__content"> <div className="edit-gas-fee-popover__content">
{balanceError && ( {balanceError && (

View File

@ -261,7 +261,7 @@ export default function EditGasPopover({
<EditGasDisplayEducation /> <EditGasDisplayEducation />
) : ( ) : (
<> <>
{process.env.IN_TEST === 'true' ? null : <LoadingHeartBeat />} {process.env.IN_TEST ? null : <LoadingHeartBeat />}
<EditGasDisplay <EditGasDisplay
showEducationButton={showEducationButton} showEducationButton={showEducationButton}
warning={warning} warning={warning}

View File

@ -32,7 +32,7 @@ export const getMessage = (localeCode, localeMessages, key, substitutions) => {
); );
Sentry.captureException(missingMessageErrors[key]); Sentry.captureException(missingMessageErrors[key]);
log.error(missingMessageErrors[key]); log.error(missingMessageErrors[key]);
if (process.env.IN_TEST === 'true') { if (process.env.IN_TEST) {
throw missingMessageErrors[key]; throw missingMessageErrors[key];
} }
} }

View File

@ -68,7 +68,7 @@ const EIP_1559_V2_ENABLED =
process.env.EIP_1559_V2 === true || process.env.EIP_1559_V2 === 'true'; process.env.EIP_1559_V2 === true || process.env.EIP_1559_V2 === 'true';
const renderHeartBeatIfNotInTest = () => const renderHeartBeatIfNotInTest = () =>
process.env.IN_TEST === 'true' ? null : <LoadingHeartBeat />; process.env.IN_TEST ? null : <LoadingHeartBeat />;
export default class ConfirmTransactionBase extends Component { export default class ConfirmTransactionBase extends Component {
static contextTypes = { static contextTypes = {

View File

@ -17,8 +17,7 @@ import TransactionDetailItem from '../../../components/app/transaction-detail-it
import UserPreferencedCurrencyDisplay from '../../../components/app/user-preferenced-currency-display'; import UserPreferencedCurrencyDisplay from '../../../components/app/user-preferenced-currency-display';
import { useGasFeeContext } from '../../../contexts/gasFee'; import { useGasFeeContext } from '../../../contexts/gasFee';
const HeartBeat = () => const HeartBeat = () => (process.env.IN_TEST ? null : <LoadingHeartBeat />);
process.env.IN_TEST === 'true' ? null : <LoadingHeartBeat />;
const GasDetailsItem = ({ const GasDetailsItem = ({
hexMaximumTransactionFee, hexMaximumTransactionFee,

View File

@ -22,9 +22,7 @@ const mapStateToProps = (state) => {
const showSearchTabCustomNetwork = const showSearchTabCustomNetwork =
useTokenDetection && Boolean(Object.keys(tokenList).length); useTokenDetection && Boolean(Object.keys(tokenList).length);
const showSearchTab = const showSearchTab =
getIsMainnet(state) || getIsMainnet(state) || showSearchTabCustomNetwork || process.env.IN_TEST;
showSearchTabCustomNetwork ||
process.env.IN_TEST === 'true';
return { return {
identities, identities,
mostRecentOverviewPage: getMostRecentOverviewPage(state), mostRecentOverviewPage: getMostRecentOverviewPage(state),