-
Notifications
You must be signed in to change notification settings - Fork 1.6k
/
don_evm_chain.go
81 lines (64 loc) · 2.62 KB
/
don_evm_chain.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
70
71
72
73
74
75
76
77
78
79
80
81
package testsetups
import (
"testing"
"github.com/rs/zerolog"
"github.com/stretchr/testify/require"
"github.com/smartcontractkit/chainlink-testing-framework/blockchain"
ctfClient "github.com/smartcontractkit/chainlink-testing-framework/client"
e "github.com/smartcontractkit/chainlink-testing-framework/k8s/environment"
"github.com/smartcontractkit/chainlink-testing-framework/k8s/pkg/helm/chainlink"
"github.com/smartcontractkit/chainlink-testing-framework/k8s/pkg/helm/ethereum"
"github.com/smartcontractkit/chainlink-testing-framework/k8s/pkg/helm/mockserver"
mockservercfg "github.com/smartcontractkit/chainlink-testing-framework/k8s/pkg/helm/mockserver-cfg"
"github.com/smartcontractkit/chainlink/integration-tests/client"
"github.com/smartcontractkit/chainlink/integration-tests/contracts"
)
type DonChain struct {
conf *DonChainConfig
EVMClient blockchain.EVMClient
EVMNetwork *blockchain.EVMNetwork
ContractDeployer contracts.ContractDeployer
LinkTokenContract contracts.LinkToken
ChainlinkNodes []*client.ChainlinkK8sClient
Mockserver *ctfClient.MockserverClient
l zerolog.Logger
}
type DonChainConfig struct {
T *testing.T
Env *e.Environment
EVMNetwork *blockchain.EVMNetwork
EthereumProps *ethereum.Props
ChainlinkValues map[string]interface{}
}
func NewDonChain(conf *DonChainConfig, logger zerolog.Logger) *DonChain {
return &DonChain{
conf: conf,
EVMNetwork: conf.EVMNetwork,
l: logger,
}
}
func (s *DonChain) Deploy() {
var err error
s.conf.Env.AddHelm(mockservercfg.New(nil)).
AddHelm(mockserver.New(nil)).
AddHelm(ethereum.New(s.conf.EthereumProps)).
AddHelm(chainlink.New(0, s.conf.ChainlinkValues))
err = s.conf.Env.Run()
require.NoError(s.conf.T, err)
s.initializeClients()
}
func (s *DonChain) initializeClients() {
var err error
network := *s.conf.EVMNetwork
s.EVMClient, err = blockchain.NewEVMClient(network, s.conf.Env, s.l)
require.NoError(s.conf.T, err, "Connecting to blockchain nodes shouldn't fail")
s.ContractDeployer, err = contracts.NewContractDeployer(s.EVMClient, s.l)
require.NoError(s.conf.T, err)
s.ChainlinkNodes, err = client.ConnectChainlinkNodes(s.conf.Env)
require.NoError(s.conf.T, err, "Connecting to chainlink nodes shouldn't fail")
s.Mockserver, err = ctfClient.ConnectMockServer(s.conf.Env)
require.NoError(s.conf.T, err, "Creating mockserver clients shouldn't fail")
s.EVMClient.ParallelTransactions(true)
s.LinkTokenContract, err = s.ContractDeployer.DeployLinkTokenContract()
require.NoError(s.conf.T, err, "Deploying Link Token Contract shouldn't fail")
}