diff --git a/src/ui/utils/sendTransaction.ts b/src/ui/utils/sendTransaction.ts index 5bfc36da12a..22f33f5cef8 100644 --- a/src/ui/utils/sendTransaction.ts +++ b/src/ui/utils/sendTransaction.ts @@ -257,6 +257,10 @@ export const sendTransaction = async ({ ? (await Browser.storage.local.get('DEBUG_OTHER_CHAIN_GAS_USD_LIMIT')) .DEBUG_OTHER_CHAIN_GAS_USD_LIMIT || 5 : 5; + const DEBUG_SIMULATION_FAILED = process.env.DEBUG + ? (await Browser.storage.local.get('DEBUG_SIMULATION_FAILED')) + .DEBUG_SIMULATION_FAILED + : false; // generate tx with gas const transaction: Tx = { @@ -272,7 +276,10 @@ export const sendTransaction = async ({ let failedCode; let canUseGasAccount: boolean = false; - if (!preExecResult?.balance_change?.success) { + // random simulation failed for test + if (DEBUG_SIMULATION_FAILED && Math.random() > 0.5) { + failedCode = FailedCode.SimulationFailed; + } else if (!preExecResult?.balance_change?.success) { failedCode = FailedCode.SimulationFailed; } else if (isGasNotEnough) { // native gas not enough check gasAccount