diff --git a/e2e_test/js-tests/test_ethers_tx.mjs b/e2e_test/js-tests/test_ethers_tx.mjs index 3faf2d9cdf..979150af9f 100644 --- a/e2e_test/js-tests/test_ethers_tx.mjs +++ b/e2e_test/js-tests/test_ethers_tx.mjs @@ -12,7 +12,7 @@ describe("ethers.js send tx", () => { value: 1, }); const receipt = await tx.wait(); - }).timeout(10_000); + }).timeout(20_000); }); describe("ethers.js compatibility tests with state", () => { @@ -32,7 +32,7 @@ describe("ethers.js compatibility tests with state", () => { assert.notEqual(feeData.maxFeePerGas, null); assert.notEqual(feeData.maxPriorityFeePerGas, null); assert.notEqual(feeData.gasPrice, null); - }); + }).timeout(5_000);; it("block has gasLimit", async () => { const fullBlock = await provider.send("eth_getBlockByNumber", [ diff --git a/e2e_test/js-tests/test_viem_tx.mjs b/e2e_test/js-tests/test_viem_tx.mjs index a15dd8cf1b..e42c7ba793 100644 --- a/e2e_test/js-tests/test_viem_tx.mjs +++ b/e2e_test/js-tests/test_viem_tx.mjs @@ -21,7 +21,6 @@ const testNonceBump = async ( shouldReplace, ) => { const syncBarrierRequest = await walletClient.prepareTransactionRequest({ - to: "0x00000000000000000000000000000000DeaDBeef", value: 2, gas: 22000, @@ -189,15 +188,22 @@ describe("viem send tx", () => { assert.equal(receipt.status, "success", "receipt status 'failure'"); }).timeout(10_000); - it.skip("send overlapping nonce tx in different currencies", async () => { - const priceBump = 1.1; + // The goal is this test is to ensure that fee currencies are correctly + // taken into account when performing tx replacements. As such we want the + // prices that we use for the failed and successful tx replacements to be + // close to the threshold value, such that an invalid currency conversion is + // more liable to result in a failure. + it("send overlapping nonce tx in different currencies", async () => { + // Note the threshold for a price bump to be accepted is 10%, i.e >= oldPrice * 1.1 + const priceBump = 1.1; // minimum bump percentage to replace a transaction + const priceNearBump = 1.09; // slightly lower percentage than the price bump const rate = await getRate(process.env.FEE_CURRENCY); // Native to FEE_CURRENCY const nativeCap = 30_000_000_000; const bumpCurrencyCap = rate.toFeeCurrency(BigInt(Math.round(nativeCap * priceBump))); const failToBumpCurrencyCap = rate.toFeeCurrency(BigInt( - Math.round(nativeCap * priceBump) - 1, + Math.round(nativeCap * priceNearBump) )); const tokenCurrency = process.env.FEE_CURRENCY; const nativeCurrency = null; @@ -220,7 +226,7 @@ describe("viem send tx", () => { const currencyCap = 60_000_000_000; const bumpNativeCap = rate.toNative(BigInt(Math.round(currencyCap * priceBump))); const failToBumpNativeCap = rate.toNative(BigInt( - Math.round(currencyCap * priceBump) - 1, + Math.round(currencyCap * priceNearBump) )); await testNonceBump( currencyCap, @@ -236,7 +242,7 @@ describe("viem send tx", () => { nativeCurrency, false, ); - }).timeout(40_000); + }).timeout(60_000); it("send tx with unregistered fee currency", async () => { const request = await walletClient.prepareTransactionRequest({ @@ -263,7 +269,7 @@ describe("viem send tx", () => { } }).timeout(10_000); - it.skip("send fee currency tx with just high enough gas price", async () => { + it("send fee currency tx with just high enough gas price", async () => { // The idea of this test is to check that the fee currency is taken into // account by the server. We do this by using a fee currency that has a // value greater than celo, so that the base fee in fee currency becomes a @@ -302,8 +308,8 @@ describe("viem send tx", () => { }); const receipt = await publicClient.waitForTransactionReceipt({ hash }); assert.equal(receipt.status, "success", "receipt status 'failure'"); - assert.isAtMost(receipt.effectiveGasPrice, maxFeePerGas, "effective gas price is too high"); - assert.isAbove(receipt.effectiveGasPrice, Number(maxFeePerGas) * 0.7, "effective gas price is too low"); + assert.isAtMost(Number(receipt.effectiveGasPrice), Number(maxFeePerGas), "effective gas price is too high"); + assert.isAbove(Number(receipt.effectiveGasPrice), Number(maxFeePerGas) * 0.7, "effective gas price is too low"); }).timeout(10_000); });