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

Commit 3f0fbb5

Browse files
committed
fix signer for correct nonce
1 parent e7c57b9 commit 3f0fbb5

File tree

4 files changed

+46
-52
lines changed

4 files changed

+46
-52
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: 17 additions & 26 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) {
@@ -1281,22 +1275,24 @@ describe("Fast Market Order Business Logic -- CCTP to CCTP", function (this: Moc
12811275
// Prepare usdc for the auction.
12821276
const usdc = IERC20__factory.connect(engineEnv.tokenAddress, initialBidder);
12831277
await mintNativeUsdc(usdc, await initialBidder.getAddress(), initialDeposit);
1284-
await usdc.approve(engine.address, initialDeposit);
1278+
await usdc
1279+
.approve(engine.address, initialDeposit)
1280+
.then((tx) => mineWait(engineProvider, tx));
12851281

12861282
let failedGracefully = false;
12871283
const receipt = await engine
12881284
.connect(initialBidder.provider!)
12891285
.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))
1286+
.then(async (txReq) => await initialBidder.sendTransaction(txReq))
12951287
.catch((err) => {
12961288
const error = errorDecoder(err);
12971289
if (error.selector == "ErrDeadlineExceeded") {
12981290
failedGracefully = true;
12991291
}
1292+
1293+
// We got a failed transaction so we need to
1294+
// reset the NonceManagers local tracker
1295+
initialBidder.reset();
13001296
});
13011297

13021298
expect(failedGracefully).is.true;
@@ -1319,15 +1315,10 @@ describe("Fast Market Order Business Logic -- CCTP to CCTP", function (this: Moc
13191315
const usdc = IERC20__factory.connect(engineEnv.tokenAddress, engineProvider);
13201316
const feeRecipientBefore = await usdc.balanceOf(engineEnv.feeRecipient!);
13211317

1322-
await sleep(1);
1323-
13241318
const receipt = await engine
13251319
.connect(initialBidder.provider!)
13261320
.executeSlowOrderAndRedeem(fastVaa, params)
1327-
.then(async (txReq) => {
1328-
//txReq.nonce = await initialBidder.getNonce("pending");
1329-
return initialBidder.sendTransaction(txReq);
1330-
})
1321+
.then((txReq) => initialBidder.sendTransaction(txReq))
13311322
.then((tx) => mineWait(engineProvider, tx))
13321323
.catch((err) => {
13331324
console.log(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)