github.com/0chain/gosdk@v1.17.11/core/node/node_test.go (about) 1 package node 2 3 import ( 4 "testing" 5 6 "github.com/stretchr/testify/assert" 7 ) 8 9 func TestNodeHolder_Success(t *testing.T) { 10 type fields struct { 11 nodes []string 12 consensus int 13 } 14 type args struct { 15 id string 16 } 17 type res struct { 18 res []string 19 } 20 tests := []struct { 21 name string 22 fields fields 23 args args 24 res res 25 }{ 26 {name: "init", fields: struct { 27 nodes []string 28 consensus int 29 }{nodes: []string{"1", "2", "3", "4", "5"}, consensus: 5}, args: struct{ id string }{id: "1"}, 30 res: struct{ res []string }{res: []string{"1", "2", "3", "4", "5"}}}, 31 {name: "pull up", fields: struct { 32 nodes []string 33 consensus int 34 }{nodes: []string{"1", "2", "3", "4", "5"}, consensus: 5}, args: struct{ id string }{id: "5"}, 35 res: struct{ res []string }{res: []string{"5", "1", "2", "3", "4"}}}, 36 } 37 for _, tt := range tests { 38 t.Run(tt.name, func(t *testing.T) { 39 h := NewHolder(tt.fields.nodes, tt.fields.consensus) 40 h.Success(tt.args.id) 41 42 assert.Equal(t, tt.res.res, h.Healthy()) 43 }) 44 } 45 } 46 47 //func TestNodeHolder_GetHardForkRound(t *testing.T) { 48 // holder := NewHolder([]string{"https://dev2.zus.network/sharder01", 49 // "https://dev3.zus.network/sharder01", "https://dev1.zus.network/sharder01"}, 2) 50 // round, err := holder.GetHardForkRound("apollo") 51 // if err != nil { 52 // t.Error(err) 53 // } 54 // 55 // assert.Equal(t, 206000, round) 56 //}