MCPcopy Create free account
hub / github.com/DOSNetwork/core / TestDialToEth

Function TestDialToEth

onchain/eth_helpers_test.go:23–54  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

21}
22
23func TestDialToEth(t *testing.T) {
24 urls = []string{"http://123.123.123.123", "http://18.236.117.126:8545"}
25 var clients []*ethclient.Client
26 ctx := context.Background()
27 outc := DialToEth(ctx, urls)
28 for client := range outc {
29 clients = append(clients, client)
30 }
31 if len(clients) != len(urls) {
32 t.Errorf("Dial success count, got: %d, want: %d.", len(clients), len(urls)-1)
33 }
34
35 //Check to see if client is really working by getting networkID
36 count := 0
37 for _, client := range clients {
38 id, err := client.NetworkID(ctx)
39 //i/o timeout
40 if err != nil {
41 fmt.Println("NetworkID err ", err)
42 client.Close()
43 } else {
44 if ID != id.Uint64() {
45 t.Errorf("ID incorrect, got: %d, want: %d.", id.Uint64(), ID)
46 }
47 count++
48 }
49 }
50 if count != len(urls)-1 {
51 t.Errorf("Dial count, got: %d, want: %d.", count, len(urls)-1)
52 }
53 fmt.Println("TestDialToEth pass")
54}
55
56func TestDialWS(t *testing.T) {
57 urls = []string{"ws://18.236.117.126:8546", "ws:18.236.115.126:8546"}

Callers

nothing calls this directly

Calls 3

DialToEthFunction · 0.85
Uint64Method · 0.80
CloseMethod · 0.45

Tested by

no test coverage detected