-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Copy pathsolana_node_commands_test.go
69 lines (61 loc) · 2.09 KB
/
solana_node_commands_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package cmd_test
import (
"testing"
"github.com/pelletier/go-toml/v2"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/smartcontractkit/chainlink-relay/pkg/utils"
solcfg "github.com/smartcontractkit/chainlink-solana/pkg/solana/config"
"github.com/smartcontractkit/chainlink/v2/core/chains/solana"
"github.com/smartcontractkit/chainlink/v2/core/cmd"
"github.com/smartcontractkit/chainlink/v2/core/internal/cltest"
"github.com/smartcontractkit/chainlink/v2/core/internal/testutils/solanatest"
"github.com/smartcontractkit/chainlink/v2/core/services/chainlink"
)
func solanaStartNewApplication(t *testing.T, cfgs ...*solana.SolanaConfig) *cltest.TestApplication {
for i := range cfgs {
cfgs[i].SetDefaults()
}
return startNewApplicationV2(t, func(c *chainlink.Config, s *chainlink.Secrets) {
c.Solana = cfgs
c.EVM = nil
})
}
// TODO fix https://smartcontract-it.atlassian.net/browse/BCF-2114
func TestClient_IndexSolanaNodes(t *testing.T) {
t.Parallel()
id := solanatest.RandomChainID()
node1 := solcfg.Node{
Name: ptr("first"),
URL: utils.MustParseURL("https://solana1.example"),
}
node2 := solcfg.Node{
Name: ptr("second"),
URL: utils.MustParseURL("https://solana2.example"),
}
chain := solana.SolanaConfig{
ChainID: &id,
Nodes: solana.SolanaNodes{&node1, &node2},
}
app := solanaStartNewApplication(t, &chain)
client, r := app.NewClientAndRenderer()
require.Nil(t, cmd.NewSolanaNodeClient(client).IndexNodes(cltest.EmptyCLIContext()))
require.NotEmpty(t, r.Renders)
nodes := *r.Renders[0].(*cmd.SolanaNodePresenters)
require.Len(t, nodes, 2)
n1 := nodes[0]
n2 := nodes[1]
assert.Equal(t, id, n1.ChainID)
assert.Equal(t, *node1.Name, n1.ID)
assert.Equal(t, *node1.Name, n1.Name)
wantConfig, err := toml.Marshal(node1)
require.NoError(t, err)
assert.Equal(t, string(wantConfig), n1.Config)
assert.Equal(t, id, n2.ChainID)
assert.Equal(t, *node2.Name, n2.ID)
assert.Equal(t, *node2.Name, n2.Name)
wantConfig2, err := toml.Marshal(node2)
require.NoError(t, err)
assert.Equal(t, string(wantConfig2), n2.Config)
assertTableRenders(t, r)
}