Skip to content
This repository was archived by the owner on Jun 16, 2025. It is now read-only.

Commit 828bb00

Browse files
committed
fix signer for correct nonce
1 parent e7c57b9 commit 828bb00

File tree

4 files changed

+45
-49
lines changed

4 files changed

+45
-49
lines changed

evm/ts/src/error.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export function errorDecoder(ethersError: any): DecodedErr {
1313
const { data } = ethersError;
1414

1515
if (!data || data.length < 10 || data.substring(0, 2) != "0x") {
16-
throw new Error("data not custom error");
16+
throw ethersError;
1717
}
1818

1919
const selector = data.substring(0, 10);

evm/ts/src/testing/utils.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ export async function mineToPenaltyPeriod(
5656

5757
export async function mineWait(provider: ethers.JsonRpcProvider, tx: ethers.TransactionResponse) {
5858
await mine(provider);
59-
return tx.wait();
59+
// 1 is default confirms, 5000ms timeout to prevent hanging forever.
60+
return await tx.wait(1, 5000);
6061
}
6162

6263
export async function mintNativeUsdc(
@@ -66,7 +67,7 @@ export async function mintNativeUsdc(
6667
mineBlock: boolean = true,
6768
) {
6869
if (!usdc.runner) {
69-
throw new Error("provider must be a StaticJsonRpcProvider");
70+
throw new Error("provider must be a JsonRpcProvider");
7071
}
7172

7273
const provider = usdc.runner.provider as ethers.JsonRpcProvider;

evm/ts/tests/04__fastMarketOrder.ts

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
import { expect } from "chai";
22
import { ethers } from "ethers";
33
import {
4-
EvmTokenRouter,
54
EvmMatchingEngine,
6-
errorDecoder,
7-
OrderResponse,
5+
EvmTokenRouter,
86
MessageDecoder,
7+
OrderResponse,
8+
errorDecoder,
99
} from "../src";
10-
import { IERC20__factory } from "../src/types";
1110
import {
1211
ChainType,
13-
parseLiquidityLayerEnvFile,
1412
CircleAttester,
1513
GuardianNetwork,
1614
LOCALHOSTS,
@@ -20,21 +18,18 @@ import {
2018
ValidNetwork,
2119
WALLET_PRIVATE_KEYS,
2220
burnAllUsdc,
23-
mineWait,
2421
mine,
25-
mintNativeUsdc,
2622
mineToGracePeriod,
2723
mineToPenaltyPeriod,
24+
mineWait,
25+
mintNativeUsdc,
26+
parseLiquidityLayerEnvFile,
2827
tryNativeToUint8Array,
2928
} from "../src/testing";
29+
import { IERC20__factory } from "../src/types";
3030

3131
import { toChainId } from "@wormhole-foundation/sdk-base";
32-
import {
33-
deserialize,
34-
keccak256,
35-
serializePayload,
36-
toUniversal,
37-
} from "@wormhole-foundation/sdk-definitions";
32+
import { deserialize, keccak256, toUniversal } from "@wormhole-foundation/sdk-definitions";
3833
import "@wormhole-foundation/sdk-evm";
3934

4035
// Cannot send a fast market order from the matching engine chain.
@@ -1163,7 +1158,6 @@ describe("Fast Market Order Business Logic -- CCTP to CCTP", function (this: Moc
11631158
);
11641159
});
11651160
});
1166-
11671161
describe(`No Auction - Deadline Exceeded`, () => {
11681162
before(`From Network -- Mint USDC`, async () => {
11691163
if (fromEnv.chainId == MATCHING_ENGINE_CHAIN) {
@@ -1283,15 +1277,14 @@ describe("Fast Market Order Business Logic -- CCTP to CCTP", function (this: Moc
12831277
await mintNativeUsdc(usdc, await initialBidder.getAddress(), initialDeposit);
12841278
await usdc.approve(engine.address, initialDeposit);
12851279

1280+
await mine(engineProvider);
1281+
await sleep(1);
1282+
12861283
let failedGracefully = false;
12871284
const receipt = await engine
12881285
.connect(initialBidder.provider!)
12891286
.placeInitialBid(fastVaa, fastOrder.maxFee)
1290-
.then(async (txReq) => {
1291-
txReq.nonce = await initialBidder.getNonce("pending");
1292-
return initialBidder.sendTransaction(txReq);
1293-
})
1294-
.then((tx) => mineWait(engineProvider, tx))
1287+
.then(async (txReq) => await initialBidder.sendTransaction(txReq))
12951288
.catch((err) => {
12961289
const error = errorDecoder(err);
12971290
if (error.selector == "ErrDeadlineExceeded") {
@@ -1319,14 +1312,14 @@ describe("Fast Market Order Business Logic -- CCTP to CCTP", function (this: Moc
13191312
const usdc = IERC20__factory.connect(engineEnv.tokenAddress, engineProvider);
13201313
const feeRecipientBefore = await usdc.balanceOf(engineEnv.feeRecipient!);
13211314

1322-
await sleep(1);
1323-
13241315
const receipt = await engine
13251316
.connect(initialBidder.provider!)
13261317
.executeSlowOrderAndRedeem(fastVaa, params)
13271318
.then(async (txReq) => {
1328-
//txReq.nonce = await initialBidder.getNonce("pending");
1329-
return initialBidder.sendTransaction(txReq);
1319+
txReq.nonce = await initialBidder.getNonce();
1320+
// use `signer` here since the NonceManager fudges up nonce
1321+
// because of the prior test's failed transaction
1322+
return await initialBidder.signer.sendTransaction(txReq);
13301323
})
13311324
.then((tx) => mineWait(engineProvider, tx))
13321325
.catch((err) => {

evm/ts/tests/run_integration_test.sh

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,33 +8,35 @@ LOGS=$ROOT/.anvil
88
mkdir -p $LOGS
99

1010
pgrep anvil > /dev/null
11+
1112
if [ $? -eq 0 ]; then
1213
echo "anvil already running, run 'pkill anvil' if you want to stop it to reset state"
13-
else
14-
echo "starting anvil"
15-
16-
# Avalanche (ME and CCTP).
17-
anvil --port 8547 \
18-
-m "myth like bonus scare over problem client lizard pioneer submit female collect" \
19-
--no-mining \
20-
--fork-url $AVALANCHE_RPC > $LOGS/avalanche.log &
21-
22-
# Ethereum (CCTP).
23-
anvil --port 8548 \
24-
-m "myth like bonus scare over problem client lizard pioneer submit female collect" \
25-
--no-mining \
26-
--fork-url $ETHEREUM_RPC > $LOGS/ethereum.log &
27-
28-
# Base (CCTP).
29-
anvil --port 8549 \
30-
-m "myth like bonus scare over problem client lizard pioneer submit female collect" \
31-
--no-mining \
32-
--fork-url $BASE_RPC > $LOGS/base.log &
33-
34-
# Chill.
35-
sleep 2
14+
exit 1
3615
fi
3716

17+
echo "starting anvil"
18+
19+
# Avalanche (ME and CCTP).
20+
anvil --port 8547 \
21+
-m "myth like bonus scare over problem client lizard pioneer submit female collect" \
22+
--no-mining \
23+
--fork-url $AVALANCHE_RPC > $LOGS/avalanche.log &
24+
25+
# Ethereum (CCTP).
26+
anvil --port 8548 \
27+
-m "myth like bonus scare over problem client lizard pioneer submit female collect" \
28+
--no-mining \
29+
--fork-url $ETHEREUM_RPC > $LOGS/ethereum.log &
30+
31+
# Base (CCTP).
32+
anvil --port 8549 \
33+
-m "myth like bonus scare over problem client lizard pioneer submit female collect" \
34+
--no-mining \
35+
--fork-url $BASE_RPC > $LOGS/base.log &
36+
37+
# Chill.
38+
sleep 2
39+
3840

3941
# Double-check number of anvil instances.
4042
if [ "$( pgrep anvil | wc -l )" -ne 3 ]; then

0 commit comments

Comments
 (0)