11import { expect } from "chai" ;
22import { ethers } from "ethers" ;
33import {
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" ;
1110import {
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
3131import { 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" ;
3833import "@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 ) ;
0 commit comments