decred.org/dcrdex@v1.0.5/server/asset/zcl/live_test.go (about) 1 //go:build zcllive 2 3 // go test -v -tags zcllive -run UTXOStats 4 // ----------------------------------- 5 // Grab the most recent block and iterate it's outputs, taking account of 6 // how many UTXOs are found, how many are of an unknown type, etc. 7 // 8 // go test -v -tags zcllive -run P2SHStats 9 // ----------------------------------------- 10 // For each output in the last block, check it's previous outpoint to see if 11 // it's a P2SH or P2WSH. If so, takes statistics on the script types, including 12 // for the redeem script. 13 // 14 // go test -v -tags zcllive -run LiveFees 15 // ------------------------------------------ 16 // Test that fees rates are parsed without error and that a few historical fee 17 // rates are correct 18 19 package zcl 20 21 import ( 22 "context" 23 "fmt" 24 "os" 25 "testing" 26 27 "decred.org/dcrdex/dex" 28 "decred.org/dcrdex/server/asset" 29 "decred.org/dcrdex/server/asset/btc" 30 ) 31 32 var ( 33 zcl *ZECBackend 34 ctx context.Context 35 ) 36 37 func TestMain(m *testing.M) { 38 // Wrap everything for defers. 39 doIt := func() int { 40 logger := dex.StdOutLogger("ZECTEST", dex.LevelTrace) 41 be, err := NewBackend(&asset.BackendConfig{ 42 AssetID: BipID, 43 Logger: logger, 44 Net: dex.Mainnet, 45 }) 46 if err != nil { 47 fmt.Printf("NewBackend error: %v\n", err) 48 return 1 49 } 50 51 var ok bool 52 zcl, ok = be.(*ZECBackend) 53 if !ok { 54 fmt.Printf("Could not cast asset.Backend to *ZECBackend") 55 return 1 56 } 57 58 ctx, cancel := context.WithCancel(context.Background()) 59 wg, err := zcl.Connect(ctx) 60 if err != nil { 61 fmt.Printf("Connect failed: %v", err) 62 return 1 63 } 64 defer wg.Wait() 65 defer cancel() 66 67 return m.Run() 68 } 69 70 os.Exit(doIt()) 71 } 72 73 func TestUTXOStats(t *testing.T) { 74 btc.LiveUTXOStats(zcl.Backend, t) 75 } 76 77 func TestP2SHStats(t *testing.T) { 78 btc.LiveP2SHStats(zcl.Backend, t, 50) 79 } 80 81 func TestLiveFees(t *testing.T) { 82 btc.LiveFeeRates(zcl.Backend, t, map[string]uint64{ 83 "597c3975f2445da89a9097a2d9131e5d76c476d248d6a1c277d93b1299c63b68": 1, 84 // "90c2fbb3636e5bd8d35fc17202bfe86935fad3e8244e736f9b267c8d0ad14f90": 4631, 85 }) 86 }