Skip to content

Commit dbfa846

Browse files
committed
simple DON version
1 parent 21dcf2d commit dbfa846

File tree

6 files changed

+61
-12
lines changed

6 files changed

+61
-12
lines changed

framework/COMPONENTS.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@ func NewComponent(input *Input) (*Output, error) {
3131
// deploy a docker container(s)
3232
// or deploy a set of smart contracts
3333
34-
input.Out = &Output{...}
34+
input.Out = &Output{
35+
UseCache: true,
36+
// other fields
37+
...
38+
}
3539
return out, nil
3640
}
3741
```
@@ -83,6 +87,7 @@ An example of [composite component](components/don/don.go)
8387
}
8488
8589
return &NodeOut{
90+
UseCache: true,
8691
DockerURL: fmt.Sprintf("http://%s:%s", containerName, in.Node.Port),
8792
HostURL: fmt.Sprintf("http://%s:%s", host, mp.Port()),
8893
}, nil

framework/components/clnode/clnode.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ type Input struct {
2626
type NodeInput struct {
2727
Image string `toml:"image" validate:"required"`
2828
Tag string `toml:"tag" validate:"required"`
29-
PullImage bool `toml:"pull_image"`
30-
Port string `toml:"port" validate:"required"`
29+
PullImage bool `toml:"pull_image" default:"true"`
30+
Port string `toml:"port" validate:"required" default:"6688"`
3131
TestConfigOverrides string `toml:"test_config_overrides"`
3232
UserConfigOverrides string `toml:"user_config_overrides"`
3333
TestSecretsOverrides string `toml:"test_secrets_overrides"`

framework/components/clnode/default.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ fj293fbBnlQ!f9vNs`
1717

1818
const defaultConfigTmpl = `
1919
[Log]
20-
Level = 'info'
20+
Level = 'debug'
2121
2222
[WebServer]
2323
HTTPWriteTimeout = '30s'

framework/components/don/don.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ type Output struct {
1515
Nodes []*clnode.Output `toml:"node"`
1616
}
1717

18-
func NewBasicDON(in *Input, bcOut *blockchain.Output, fakeUrl string) (*Output, error) {
18+
func NewDON(in *Input, bcOut *blockchain.Output, fakeUrl string) (*Output, error) {
1919
if in.Out.UseCache {
2020
return in.Out, nil
2121
}

framework/components/postgres/postgres.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ import (
1111
)
1212

1313
type Input struct {
14-
Image string `toml:"image" validate:"required"`
15-
Tag string `toml:"tag" validate:"required"`
16-
PullImage bool `toml:"pull_image"`
17-
User string `toml:"user" validate:"required"`
18-
Password string `toml:"password" validate:"required"`
19-
Database string `toml:"database" validate:"required"`
20-
Port string `toml:"port" validate:"required"`
14+
Image string `toml:"image" validate:"required" default:"postgres"`
15+
Tag string `toml:"tag" validate:"required" default:"15.6"`
16+
PullImage bool `toml:"pull_image" default:"true"`
17+
User string `toml:"user" validate:"required" default:"chainlink"`
18+
Password string `toml:"password" validate:"required" default:"thispasswordislongenough"`
19+
Database string `toml:"database" validate:"required" default:"chainlink"`
20+
Port string `toml:"port" validate:"required" default:"5432"`
2121
Out *Output `toml:"out"`
2222
}
2323

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package simple_don
2+
3+
import (
4+
"github.com/smartcontractkit/chainlink-testing-framework/framework/components/blockchain"
5+
"github.com/smartcontractkit/chainlink-testing-framework/framework/components/clnode"
6+
)
7+
8+
type Input struct {
9+
Nodes int `toml:"nodes" validate:"required"`
10+
*clnode.Input
11+
Out *Output `toml:"out"`
12+
}
13+
14+
type Output struct {
15+
UseCache bool `toml:"use_cache"`
16+
Nodes []*clnode.Output `toml:"node"`
17+
}
18+
19+
func NewSimpleDON(in *Input, bcOut *blockchain.Output, fakeUrl string) (*Output, error) {
20+
if in.Out.UseCache {
21+
return in.Out, nil
22+
}
23+
nodeOuts := make([]*clnode.Output, 0)
24+
for i := 0; i < in.Nodes; i++ {
25+
net, err := clnode.NewNetworkCfgOneNetworkAllNodes(bcOut)
26+
if err != nil {
27+
return nil, err
28+
}
29+
in.Input.Node.TestConfigOverrides = net
30+
in.Input.DataProviderURL = fakeUrl
31+
in.Input.Out = nil
32+
o, err := clnode.NewNode(in.Input)
33+
if err != nil {
34+
return nil, err
35+
}
36+
nodeOuts = append(nodeOuts, o)
37+
}
38+
out := &Output{
39+
UseCache: true,
40+
Nodes: nodeOuts,
41+
}
42+
in.Out = out
43+
return out, nil
44+
}

0 commit comments

Comments
 (0)