decred.org/dcrdex@v1.0.5/client/asset/firo/regnet_test.go (about)

     1  //go:build harness
     2  
     3  package firo
     4  
     5  // Regnet tests expect the Firo test harness to be running.
     6  //
     7  // Sim harness info:
     8  // The harness has four nodes: alpha, beta, gamma and delta with one wallet
     9  // per node. All wallets have confirmed UTXOs. The alpha wallet has only
    10  // coinbase outputs.
    11  
    12  import (
    13  	"context"
    14  	"fmt"
    15  	"testing"
    16  	"time"
    17  
    18  	"decred.org/dcrdex/client/asset/btc/livetest"
    19  	"decred.org/dcrdex/dex"
    20  )
    21  
    22  var (
    23  	tLotSize uint64 = 1e6
    24  	tFIRO           = &dex.Asset{
    25  		ID:         136,
    26  		Symbol:     "firo",
    27  		Version:    version,
    28  		MaxFeeRate: 20,
    29  		SwapConf:   1,
    30  	}
    31  )
    32  
    33  // Run harness with NOMINER="1"
    34  func TestWallet(t *testing.T) {
    35  	livetest.Run(t, &livetest.Config{
    36  		NewWallet: NewWallet,
    37  		LotSize:   tLotSize,
    38  		Asset:     tFIRO,
    39  		SplitTx:   true,
    40  		FirstWallet: &livetest.WalletName{
    41  			WalletType: walletTypeRPC,
    42  			Node:       "alpha",
    43  		},
    44  		SecondWallet: &livetest.WalletName{
    45  			WalletType: walletTypeRPC,
    46  			Node:       "gamma",
    47  		},
    48  	})
    49  }
    50  
    51  // Tests only mainnet, testnet is expected to return -1 normally
    52  func TestFetchExternalFee(t *testing.T) {
    53  	ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
    54  	defer cancel()
    55  	rate, err := externalFeeRate(ctx, dex.Mainnet)
    56  	if err != nil {
    57  		t.Fatal(err)
    58  	}
    59  	fmt.Printf("External fee rate fetched:: %d sat/B\n", rate)
    60  }
    61  func TestExternalFeeRate(t *testing.T) {
    62  	fetchRateWithTimeout(t, dex.Mainnet)
    63  	fetchRateWithTimeout(t, dex.Testnet)
    64  }
    65  
    66  func fetchRateWithTimeout(t *testing.T, net dex.Network) {
    67  	ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
    68  	defer cancel()
    69  	feeRate, err := externalFeeRate(ctx, net)
    70  	if err != nil {
    71  		t.Fatalf("error fetching %s fees: %v", net, err)
    72  	}
    73  	fmt.Printf("##### Fee rate fetched for %s! %d Sats/B \n", net, feeRate)
    74  }