4646 testAddressC = common .HexToAddress ("2b84C791b79Ee37De042AD2ffF1A253c3ce9bc27" )
4747
4848 ethGases = dexeth .VersionedGases [0 ]
49- tokenGases = dexeth .Tokens [testTokenID ].NetTokens [dex .Simnet ].SwapContracts [0 ].Gas
49+ tokenGases = dexeth .Tokens [simnetTokenID ].NetTokens [dex .Simnet ].SwapContracts [0 ].Gas
5050
5151 tETH = & dex.Asset {
5252 ID : 60 ,
6969 }
7070
7171 tToken = & dex.Asset {
72- ID : testTokenID ,
72+ ID : simnetTokenID ,
7373 Symbol : "dextt.eth" ,
7474 Version : 0 ,
7575 SwapSize : tokenGases .Swap ,
@@ -628,19 +628,15 @@ func tassetWallet(assetID uint32) (asset.Wallet, *assetWallet, *testNode, contex
628628 assetID : BipID ,
629629 atomize : dexeth .WeiToGwei ,
630630 }
631- testTokenID , found := dex .BipSymbolID ("dextt.eth" )
632- if ! found {
633- panic ("could not find test token ID" )
634- }
635631 w = & TokenWallet {
636632 assetWallet : aw ,
637633 cfg : & tokenWalletConfig {},
638634 parent : node .tokenParent ,
639- token : dexeth .Tokens [testTokenID ],
635+ token : dexeth .Tokens [simnetTokenID ],
640636 }
641637 aw .wallets = map [uint32 ]* assetWallet {
642- testTokenID : aw ,
643- BipID : node .tokenParent ,
638+ simnetTokenID : aw ,
639+ BipID : node .tokenParent ,
644640 }
645641 }
646642
@@ -734,7 +730,7 @@ func TestBalance(t *testing.T) {
734730 for _ , test := range tests {
735731 var assetID uint32 = BipID
736732 if test .token {
737- assetID = testTokenID
733+ assetID = simnetTokenID
738734 }
739735
740736 _ , eth , node , shutdown := tassetWallet (assetID )
@@ -847,7 +843,7 @@ func TestFeeRate(t *testing.T) {
847843
848844func TestRefund (t * testing.T ) {
849845 t .Run ("eth" , func (t * testing.T ) { testRefund (t , BipID ) })
850- t .Run ("token" , func (t * testing.T ) { testRefund (t , testTokenID ) })
846+ t .Run ("token" , func (t * testing.T ) { testRefund (t , simnetTokenID ) })
851847}
852848
853849func testRefund (t * testing.T , assetID uint32 ) {
@@ -870,7 +866,7 @@ func testRefund(t *testing.T, assetID uint32) {
870866 dexeth .VersionedGases [1 ] = gasesV1
871867 defer delete (dexeth .VersionedGases , 1 )
872868 } else {
873- tokenContracts := dexeth .Tokens [testTokenID ].NetTokens [dex .Simnet ].SwapContracts
869+ tokenContracts := dexeth .Tokens [simnetTokenID ].NetTokens [dex .Simnet ].SwapContracts
874870 tc := * tokenContracts [0 ]
875871 tc .Gas = * gasesV1
876872 tokenContracts [1 ] = & tc
@@ -1030,7 +1026,7 @@ func (b *badCoin) Value() uint64 {
10301026
10311027func TestFundOrderReturnCoinsFundingCoins (t * testing.T ) {
10321028 t .Run ("eth" , func (t * testing.T ) { testFundOrderReturnCoinsFundingCoins (t , BipID ) })
1033- t .Run ("token" , func (t * testing.T ) { testFundOrderReturnCoinsFundingCoins (t , testTokenID ) })
1029+ t .Run ("token" , func (t * testing.T ) { testFundOrderReturnCoinsFundingCoins (t , simnetTokenID ) })
10341030}
10351031
10361032func testFundOrderReturnCoinsFundingCoins (t * testing.T , assetID uint32 ) {
@@ -1446,7 +1442,7 @@ func TestPreSwap(t *testing.T) {
14461442 var assetID uint32 = BipID
14471443 assetCfg := tETH
14481444 if test .token {
1449- assetID = testTokenID
1445+ assetID = simnetTokenID
14501446 assetCfg = tToken
14511447 }
14521448
@@ -1502,7 +1498,7 @@ func TestPreSwap(t *testing.T) {
15021498
15031499func TestSwap (t * testing.T ) {
15041500 t .Run ("eth" , func (t * testing.T ) { testSwap (t , BipID ) })
1505- t .Run ("token" , func (t * testing.T ) { testSwap (t , testTokenID ) })
1501+ t .Run ("token" , func (t * testing.T ) { testSwap (t , simnetTokenID ) })
15061502}
15071503
15081504func testSwap (t * testing.T , assetID uint32 ) {
@@ -1781,7 +1777,7 @@ func TestPreRedeem(t *testing.T) {
17811777 }
17821778
17831779 // Token
1784- w , _ , node , shutdown2 := tassetWallet (testTokenID )
1780+ w , _ , node , shutdown2 := tassetWallet (simnetTokenID )
17851781 defer shutdown2 ()
17861782
17871783 form .AssetConfig = tToken
@@ -1799,7 +1795,7 @@ func TestPreRedeem(t *testing.T) {
17991795
18001796func TestRedeem (t * testing.T ) {
18011797 t .Run ("eth" , func (t * testing.T ) { testRedeem (t , BipID ) })
1802- t .Run ("token" , func (t * testing.T ) { testRedeem (t , testTokenID ) })
1798+ t .Run ("token" , func (t * testing.T ) { testRedeem (t , simnetTokenID ) })
18031799}
18041800
18051801func testRedeem (t * testing.T , assetID uint32 ) {
@@ -1809,7 +1805,7 @@ func testRedeem(t *testing.T, assetID uint32) {
18091805 // Test with a non-zero contract version to ensure it makes it into the receipt
18101806 contractVer := uint32 (1 )
18111807 dexeth .VersionedGases [1 ] = ethGases // for dexeth.RedeemGas(..., 1)
1812- tokenContracts := dexeth .Tokens [testTokenID ].NetTokens [dex .Simnet ].SwapContracts
1808+ tokenContracts := dexeth .Tokens [simnetTokenID ].NetTokens [dex .Simnet ].SwapContracts
18131809 tokenContracts [1 ] = tokenContracts [0 ]
18141810 defer delete (dexeth .VersionedGases , 1 )
18151811 defer delete (tokenContracts , 1 )
@@ -2474,7 +2470,7 @@ func TestMaxOrder(t *testing.T) {
24742470 var assetID uint32 = BipID
24752471 dexAsset := tETH
24762472 if test .token {
2477- assetID = testTokenID
2473+ assetID = simnetTokenID
24782474 }
24792475
24802476 w , _ , node , shutdown := tassetWallet (assetID )
@@ -2562,7 +2558,7 @@ func packRedeemDataV0(redemptions []*dexeth.Redemption) ([]byte, error) {
25622558
25632559func TestAuditContract (t * testing.T ) {
25642560 t .Run ("eth" , func (t * testing.T ) { testAuditContract (t , BipID ) })
2565- t .Run ("token" , func (t * testing.T ) { testAuditContract (t , testTokenID ) })
2561+ t .Run ("token" , func (t * testing.T ) { testAuditContract (t , simnetTokenID ) })
25662562}
25672563
25682564func testAuditContract (t * testing.T , assetID uint32 ) {
@@ -3148,7 +3144,7 @@ func TestLocktimeExpired(t *testing.T) {
31483144
31493145func TestFindRedemption (t * testing.T ) {
31503146 t .Run ("eth" , func (t * testing.T ) { testFindRedemption (t , BipID ) })
3151- t .Run ("token" , func (t * testing.T ) { testFindRedemption (t , testTokenID ) })
3147+ t .Run ("token" , func (t * testing.T ) { testFindRedemption (t , simnetTokenID ) })
31523148}
31533149
31543150func testFindRedemption (t * testing.T , assetID uint32 ) {
@@ -3290,7 +3286,7 @@ func testFindRedemption(t *testing.T, assetID uint32) {
32903286
32913287func TestRefundReserves (t * testing.T ) {
32923288 t .Run ("eth" , func (t * testing.T ) { testRefundReserves (t , BipID ) })
3293- t .Run ("token" , func (t * testing.T ) { testRefundReserves (t , testTokenID ) })
3289+ t .Run ("token" , func (t * testing.T ) { testRefundReserves (t , simnetTokenID ) })
32943290}
32953291
32963292func testRefundReserves (t * testing.T , assetID uint32 ) {
@@ -3318,7 +3314,7 @@ func testRefundReserves(t *testing.T, assetID uint32) {
33183314 feeWallet = node .tokenParent
33193315 assetV0 = * tToken
33203316 assetV1 = * tToken
3321- tokenContracts := dexeth .Tokens [testTokenID ].NetTokens [dex .Simnet ].SwapContracts
3317+ tokenContracts := dexeth .Tokens [simnetTokenID ].NetTokens [dex .Simnet ].SwapContracts
33223318 gasesV0 = & tokenGases
33233319 tc := * tokenContracts [0 ]
33243320 tc .Gas = * gasesV1
@@ -3385,7 +3381,7 @@ func testRefundReserves(t *testing.T, assetID uint32) {
33853381
33863382func TestRedemptionReserves (t * testing.T ) {
33873383 t .Run ("eth" , func (t * testing.T ) { testRedemptionReserves (t , BipID ) })
3388- t .Run ("token" , func (t * testing.T ) { testRedemptionReserves (t , testTokenID ) })
3384+ t .Run ("token" , func (t * testing.T ) { testRedemptionReserves (t , simnetTokenID ) })
33893385}
33903386
33913387func testRedemptionReserves (t * testing.T , assetID uint32 ) {
@@ -3413,7 +3409,7 @@ func testRedemptionReserves(t *testing.T, assetID uint32) {
34133409 feeWallet = node .tokenParent
34143410 assetV0 = * tToken
34153411 assetV1 = * tToken
3416- tokenContracts := dexeth .Tokens [testTokenID ].NetTokens [dex .Simnet ].SwapContracts
3412+ tokenContracts := dexeth .Tokens [simnetTokenID ].NetTokens [dex .Simnet ].SwapContracts
34173413 gasesV0 = & tokenGases
34183414 tc := * tokenContracts [0 ]
34193415 tc .Gas = * gasesV1
@@ -3517,7 +3513,7 @@ func TestReconfigure(t *testing.T) {
35173513
35183514func TestSend (t * testing.T ) {
35193515 t .Run ("eth" , func (t * testing.T ) { testSend (t , BipID ) })
3520- t .Run ("token" , func (t * testing.T ) { testSend (t , testTokenID ) })
3516+ t .Run ("token" , func (t * testing.T ) { testSend (t , simnetTokenID ) })
35213517}
35223518
35233519func testSend (t * testing.T , assetID uint32 ) {
@@ -3602,7 +3598,7 @@ func testSend(t *testing.T, assetID uint32) {
36023598
36033599func TestConfirmRedemption (t * testing.T ) {
36043600 t .Run ("eth" , func (t * testing.T ) { testConfirmRedemption (t , BipID ) })
3605- t .Run ("token" , func (t * testing.T ) { testConfirmRedemption (t , testTokenID ) })
3601+ t .Run ("token" , func (t * testing.T ) { testConfirmRedemption (t , simnetTokenID ) })
36063602}
36073603
36083604func testConfirmRedemption (t * testing.T , assetID uint32 ) {
@@ -4458,7 +4454,7 @@ func TestMarshalMonitoredTx(t *testing.T) {
44584454
44594455func TestEstimateSendTxFee (t * testing.T ) {
44604456 t .Run ("eth" , func (t * testing.T ) { testEstimateSendTxFee (t , BipID ) })
4461- t .Run ("token" , func (t * testing.T ) { testEstimateSendTxFee (t , testTokenID ) })
4457+ t .Run ("token" , func (t * testing.T ) { testEstimateSendTxFee (t , simnetTokenID ) })
44624458}
44634459
44644460func testEstimateSendTxFee (t * testing.T , assetID uint32 ) {
@@ -4542,7 +4538,7 @@ func testEstimateSendTxFee(t *testing.T, assetID uint32) {
45424538// contract (that require more gas) are added.
45434539func TestMaxSwapRedeemLots (t * testing.T ) {
45444540 t .Run ("eth" , func (t * testing.T ) { testMaxSwapRedeemLots (t , BipID ) })
4545- t .Run ("token" , func (t * testing.T ) { testMaxSwapRedeemLots (t , testTokenID ) })
4541+ t .Run ("token" , func (t * testing.T ) { testMaxSwapRedeemLots (t , simnetTokenID ) })
45464542}
45474543
45484544func testMaxSwapRedeemLots (t * testing.T , assetID uint32 ) {
@@ -4837,6 +4833,42 @@ func TestReceiptCache(t *testing.T) {
48374833
48384834}
48394835
4836+ func TestGoodNonce (t * testing.T ) {
4837+ mRPC := new (multiRPCClient )
4838+ tests := []struct {
4839+ name string
4840+ nonce uint64
4841+ want bool
4842+ wait bool
4843+ }{{
4844+ name : "ok initiation" ,
4845+ nonce : 0 ,
4846+ want : true ,
4847+ }, {
4848+ name : "ok larger" ,
4849+ nonce : 1 ,
4850+ want : true ,
4851+ }, {
4852+ name : "same nonce" ,
4853+ nonce : 1 ,
4854+ // Uncomment for full tests.
4855+ // }, {
4856+ // name: "ok after expiration",
4857+ // nonce: 1,
4858+ // wait: true,
4859+ // want: true,
4860+ }}
4861+ for _ , test := range tests {
4862+ if test .wait {
4863+ time .Sleep (time .Minute + time .Second )
4864+ }
4865+ got := mRPC .goodNonce (test .nonce )
4866+ if test .want != got {
4867+ t .Fatalf ("%q: wanted %v got %v" , test .name , test .want , got )
4868+ }
4869+ }
4870+ }
4871+
48404872func parseRecoveryID (c asset.Coin ) []byte {
48414873 return c .(asset.RecoveryCoin ).RecoveryID ()
48424874}
0 commit comments