1
1
import { expect } from "chai" ;
2
2
import { ethers } from "ethers" ;
3
3
import {
4
- EvmTokenRouter ,
5
4
EvmMatchingEngine ,
6
- errorDecoder ,
7
- OrderResponse ,
5
+ EvmTokenRouter ,
8
6
MessageDecoder ,
7
+ OrderResponse ,
8
+ errorDecoder ,
9
9
} from "../src" ;
10
- import { IERC20__factory } from "../src/types" ;
11
10
import {
12
11
ChainType ,
13
- parseLiquidityLayerEnvFile ,
14
12
CircleAttester ,
15
13
GuardianNetwork ,
16
14
LOCALHOSTS ,
@@ -20,21 +18,18 @@ import {
20
18
ValidNetwork ,
21
19
WALLET_PRIVATE_KEYS ,
22
20
burnAllUsdc ,
23
- mineWait ,
24
21
mine ,
25
- mintNativeUsdc ,
26
22
mineToGracePeriod ,
27
23
mineToPenaltyPeriod ,
24
+ mineWait ,
25
+ mintNativeUsdc ,
26
+ parseLiquidityLayerEnvFile ,
28
27
tryNativeToUint8Array ,
29
28
} from "../src/testing" ;
29
+ import { IERC20__factory } from "../src/types" ;
30
30
31
31
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" ;
38
33
import "@wormhole-foundation/sdk-evm" ;
39
34
40
35
// Cannot send a fast market order from the matching engine chain.
@@ -330,7 +325,7 @@ describe("Fast Market Order Business Logic -- CCTP to CCTP", function (this: Moc
330
325
await mintNativeUsdc ( usdc , playerAddress , initialDeposit , false ) ;
331
326
await usdc . approve ( engine . address , initialDeposit ) ;
332
327
333
- // sleep because otherwise nonce collisions (??)
328
+ // give it time to hit the mempool
334
329
await sleep ( 1 ) ;
335
330
336
331
bids [ i ] . balance = await usdc . balanceOf ( playerAddress ) ;
@@ -725,6 +720,7 @@ describe("Fast Market Order Business Logic -- CCTP to CCTP", function (this: Moc
725
720
await mintNativeUsdc ( usdc , playerAddress , initialDeposit , false ) ;
726
721
await usdc . approve ( engine . address , initialDeposit ) ;
727
722
723
+ // give it time to hit the mempool
728
724
await sleep ( 1 ) ;
729
725
730
726
bids [ i ] . balance = await usdc . balanceOf ( playerAddress ) ;
@@ -1163,7 +1159,6 @@ describe("Fast Market Order Business Logic -- CCTP to CCTP", function (this: Moc
1163
1159
) ;
1164
1160
} ) ;
1165
1161
} ) ;
1166
-
1167
1162
describe ( `No Auction - Deadline Exceeded` , ( ) => {
1168
1163
before ( `From Network -- Mint USDC` , async ( ) => {
1169
1164
if ( fromEnv . chainId == MATCHING_ENGINE_CHAIN ) {
@@ -1281,22 +1276,24 @@ describe("Fast Market Order Business Logic -- CCTP to CCTP", function (this: Moc
1281
1276
// Prepare usdc for the auction.
1282
1277
const usdc = IERC20__factory . connect ( engineEnv . tokenAddress , initialBidder ) ;
1283
1278
await mintNativeUsdc ( usdc , await initialBidder . getAddress ( ) , initialDeposit ) ;
1284
- await usdc . approve ( engine . address , initialDeposit ) ;
1279
+ await usdc
1280
+ . approve ( engine . address , initialDeposit )
1281
+ . then ( ( tx ) => mineWait ( engineProvider , tx ) ) ;
1285
1282
1286
1283
let failedGracefully = false ;
1287
1284
const receipt = await engine
1288
1285
. connect ( initialBidder . provider ! )
1289
1286
. 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 ) )
1295
1288
. catch ( ( err ) => {
1296
1289
const error = errorDecoder ( err ) ;
1297
1290
if ( error . selector == "ErrDeadlineExceeded" ) {
1298
1291
failedGracefully = true ;
1299
1292
}
1293
+
1294
+ // We got a failed transaction so we need to
1295
+ // reset the NonceManagers local tracker
1296
+ initialBidder . reset ( ) ;
1300
1297
} ) ;
1301
1298
1302
1299
expect ( failedGracefully ) . is . true ;
@@ -1319,15 +1316,10 @@ describe("Fast Market Order Business Logic -- CCTP to CCTP", function (this: Moc
1319
1316
const usdc = IERC20__factory . connect ( engineEnv . tokenAddress , engineProvider ) ;
1320
1317
const feeRecipientBefore = await usdc . balanceOf ( engineEnv . feeRecipient ! ) ;
1321
1318
1322
- await sleep ( 1 ) ;
1323
-
1324
1319
const receipt = await engine
1325
1320
. connect ( initialBidder . provider ! )
1326
1321
. executeSlowOrderAndRedeem ( fastVaa , params )
1327
- . then ( async ( txReq ) => {
1328
- //txReq.nonce = await initialBidder.getNonce("pending");
1329
- return initialBidder . sendTransaction ( txReq ) ;
1330
- } )
1322
+ . then ( ( txReq ) => initialBidder . sendTransaction ( txReq ) )
1331
1323
. then ( ( tx ) => mineWait ( engineProvider , tx ) )
1332
1324
. catch ( ( err ) => {
1333
1325
console . log ( err ) ;
0 commit comments