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

     1  //go:build harness
     2  
     3  package bch
     4  
     5  // Regnet tests expect the BCH test harness to be running.
     6  //
     7  // Sim harness info:
     8  // The harness has three wallets, alpha, beta, and gamma.
     9  // All three wallets have confirmed UTXOs.
    10  // The beta wallet has only coinbase outputs.
    11  // The alpha wallet has coinbase outputs too, but has sent some to the gamma
    12  //   wallet, so also has some change outputs.
    13  // The gamma wallet has regular transaction outputs of varying size and
    14  // confirmation count. Value:Confirmations =
    15  // 10:8, 18:7, 5:6, 7:5, 1:4, 15:3, 3:2, 25:1
    16  
    17  import (
    18  	"context"
    19  	"fmt"
    20  	"testing"
    21  	"time"
    22  
    23  	"decred.org/dcrdex/client/asset/btc/livetest"
    24  	"decred.org/dcrdex/dex"
    25  )
    26  
    27  var (
    28  	tLotSize  uint64 = 1e6
    29  	tRateStep uint64 = 10
    30  	tBCH             = &dex.Asset{
    31  		ID:         2,
    32  		Symbol:     "bch",
    33  		Version:    version,
    34  		MaxFeeRate: 10,
    35  		SwapConf:   1,
    36  	}
    37  )
    38  
    39  func TestWallet(t *testing.T) {
    40  	livetest.Run(t, &livetest.Config{
    41  		NewWallet: NewWallet,
    42  		LotSize:   tLotSize,
    43  		Asset:     tBCH,
    44  	})
    45  }
    46  
    47  func TestExternalFeeRate(t *testing.T) {
    48  	fetchRateWithTimeout(t, dex.Mainnet)
    49  	fetchRateWithTimeout(t, dex.Testnet)
    50  }
    51  
    52  func fetchRateWithTimeout(t *testing.T, net dex.Network) {
    53  	ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
    54  	defer cancel()
    55  	feeRate, err := externalFeeRate(ctx, net)
    56  	if err != nil {
    57  		t.Fatalf("error fetching %s fees: %v", net, err)
    58  	}
    59  	fmt.Printf("##### Fee rate fetched for %s! %d Sats/vB \n", net, feeRate)
    60  }