Skip to content

Commit 44b041b

Browse files
committed
finalize
1 parent d931474 commit 44b041b

File tree

4 files changed

+182
-11
lines changed

4 files changed

+182
-11
lines changed
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,106 @@
11
# Node
2+
3+
Here we provide *full* configuration parameters for `Node`
4+
5+
<div class="warning">
6+
Here we provide full configuration reference, if you want to copy and run it, please remove all .out fields before!
7+
</div>
8+
9+
10+
## Configuration
11+
```toml
12+
[cl_node]
13+
# Optional URL for fake data provider URL
14+
# usually set up in test with local mock server
15+
data_provider_url = "http://example.com"
16+
17+
[cl_node.db]
18+
# PostgreSQL image version and tag
19+
image = "postgres:15.6"
20+
# Pulls the image every time if set to 'true', used like that in CI. Can be set to 'false' to speed up local runs
21+
pull_image = true
22+
23+
[cl_node.node]
24+
# A list of paths to capability binaries
25+
capabilities = ["./capability_1", "./capability_2"]
26+
# Default capabilities directory inside container
27+
capabilities_container_dir = "/home/capabilities"
28+
# Image to use, you can either provide "image" or "docker_file" + "docker_ctx" fields
29+
image = "public.ecr.aws/chainlink/chainlink:v2.17.0"
30+
# Path to your Chainlink Dockerfile
31+
docker_file = "../../core/chainlink.Dockerfile"
32+
# Path to docker context that should be used to build from
33+
docker_ctx = "../.."
34+
# Optional name for image we build, default is "ctftmp"
35+
docker_image_name = "ctftmp"
36+
# Pulls the image every time if set to 'true', used like that in CI. Can be set to 'false' to speed up local runs
37+
pull_image = true
38+
# Overrides Chainlink node TOML configuration
39+
# can be multiline, see example
40+
user_config_overrides = """
41+
[Log]
42+
level = 'info'
43+
"""
44+
# Overrides Chainlink node secrets TOML configuration
45+
# you can only add fields, overriding existing fields is prohibited by Chainlink node
46+
user_secrets_overrides = """
47+
[AnotherSecret]
48+
mySecret = 'a'
49+
"""
50+
51+
# Outputs are the results of deploying a component that can be used by another component
52+
[cl_node.out]
53+
# If 'use_cache' equals 'true' we skip component setup when we run the test and return the outputs
54+
use_cache = true
55+
# Describes deployed or external Chainlink node
56+
[cl_node.out.node]
57+
# Host Docker URLs the test uses
58+
# in case of using external component you can replace these URLs with another deployment
59+
p2p_url = "http://127.0.0.1:32812"
60+
url = "http://127.0.0.1:32847"
61+
62+
# Describes deployed or external Chainlink node
63+
[cl_node.out.postgresql]
64+
# PostgreSQL connection string
65+
# in case of using external database can be overriden
66+
url = "postgresql://chainlink:[email protected]:32846/chainlink?sslmode=disable"
67+
```
68+
69+
## Usage
70+
```golang
71+
package yourpackage_test
72+
73+
import (
74+
"fmt"
75+
"github.com/smartcontractkit/chainlink-testing-framework/framework"
76+
"github.com/smartcontractkit/chainlink-testing-framework/framework/components/blockchain"
77+
"github.com/smartcontractkit/chainlink-testing-framework/framework/components/clnode"
78+
"github.com/stretchr/testify/require"
79+
"testing"
80+
)
81+
82+
type Step2Cfg struct {
83+
BlockchainA *blockchain.Input `toml:"blockchain_a" validate:"required"`
84+
CLNode *clnode.Input `toml:"cl_node" validate:"required"`
85+
}
86+
87+
func TestMe(t *testing.T) {
88+
in, err := framework.Load[Step2Cfg](t)
89+
require.NoError(t, err)
90+
91+
bc, err := blockchain.NewBlockchainNetwork(in.BlockchainA)
92+
require.NoError(t, err)
93+
94+
networkCfg, err := clnode.NewNetworkCfgOneNetworkAllNodes(bc)
95+
require.NoError(t, err)
96+
in.CLNode.Node.TestConfigOverrides = networkCfg
97+
98+
output, err := clnode.NewNodeWithDB(in.CLNode)
99+
require.NoError(t, err)
100+
101+
t.Run("test something", func(t *testing.T) {
102+
fmt.Printf("node url: %s\n", output.Node.HostURL)
103+
require.NotEmpty(t, output.Node.HostURL)
104+
})
105+
}
106+
```

book/src/framework/components/chainlink/nodeset.md

Lines changed: 56 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,45 @@
11
# NodeSet
22

3+
Here we provide *full* configuration parameters for `NodeSet`
4+
5+
<div class="warning">
6+
Here we provide full configuration reference, if you want to copy and run it, please remove all .out fields before!
7+
</div>
8+
39
## Configuration
10+
11+
This component requires some Blockchain to be deployed, add this to config
12+
```toml
13+
[blockchain_a]
14+
# Blockchain node type, can be "anvil" or "geth"
15+
type = "anvil"
16+
# Chain ID
17+
chain_id = "31337"
18+
# Anvil command line params, ex.: docker_cmd_params = ['--block-time=1', '...']
19+
docker_cmd_params = []
20+
# Docker image and tag
21+
image = "f4hrenh9it/foundry:latest"
22+
# External port to expose
23+
port = "8545"
24+
# Pulls the image every time if set to 'true', used like that in CI. Can be set to 'false' to speed up local runs
25+
pull_image = false
26+
27+
# Outputs are the results of deploying a component that can be used by another component
28+
[blockchain_a.out]
29+
chain_id = "31337"
30+
# If 'use_cache' equals 'true' we skip component setup when we run the test and return the outputs
31+
use_cache = true
32+
33+
[[blockchain_a.out.nodes]]
34+
# URLs to access the node(s) inside docker network, used by other components
35+
docker_internal_http_url = "http://anvil-14411:8545"
36+
docker_internal_ws_url = "ws://anvil-14411:8545"
37+
# URLs to access the node(s) on your host machine or in CI
38+
http_url = "http://127.0.0.1:33955"
39+
ws_url = "ws://127.0.0.1:33955"
40+
```
41+
42+
Then configure NodeSet
443
```toml
544
[nodeset]
645
# amount of Chainlink nodes to spin up
@@ -13,7 +52,7 @@
1352
[[nodeset.node_specs]]
1453
# Optional URL for fake data provider URL
1554
# usually set up in test with local mock server
16-
data_provider_url = ""
55+
data_provider_url = "http://example.com"
1756

1857
[nodeset.node_specs.db]
1958
# PostgreSQL image version and tag
@@ -79,27 +118,39 @@
79118

80119
## Usage
81120
```golang
82-
package yourpackage_test
121+
package capabilities_test
83122

84123
import (
85-
"fmt"
86124
"github.com/smartcontractkit/chainlink-testing-framework/framework"
125+
"github.com/smartcontractkit/chainlink-testing-framework/framework/components/blockchain"
126+
"github.com/smartcontractkit/chainlink-testing-framework/framework/components/fake"
87127
ns "github.com/smartcontractkit/chainlink-testing-framework/framework/components/simple_node_set"
88128
"github.com/stretchr/testify/require"
89129
"testing"
90130
)
91131

92132
type Config struct {
133+
BlockchainA *blockchain.Input `toml:"blockchain_a" validate:"required"`
134+
MockerDataProvider *fake.Input `toml:"data_provider" validate:"required"`
93135
NodeSet *ns.Input `toml:"nodeset" validate:"required"`
94136
}
95137

96-
func TestNodeSet(t *testing.T) {
138+
func TestMe(t *testing.T) {
97139
in, err := framework.Load[Config](t)
98140
require.NoError(t, err)
99141

142+
bc, err := blockchain.NewBlockchainNetwork(in.BlockchainA)
143+
require.NoError(t, err)
144+
dp, err := fake.NewFakeDataProvider(in.MockerDataProvider)
145+
require.NoError(t, err)
100146
out, err := ns.NewSharedDBNodeSet(in.NodeSet, bc, dp.BaseURLDocker)
101147
require.NoError(t, err)
102148

103-
...
149+
t.Run("test something", func(t *testing.T) {
150+
for _, n := range out.CLNodes {
151+
require.NotEmpty(t, n.Node.HostURL)
152+
require.NotEmpty(t, n.Node.HostP2PURL)
153+
}
154+
})
104155
}
105156
```

book/src/framework/getting_started.md

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,31 @@
66

77
## Test setup
88

9-
To start writing tests create a directory for your project with `go.mod` and pull the framework
9+
To start writing tests create a directory for your project with `go.mod` and add a package
1010
```
1111
go get github.com/smartcontractkit/chainlink-testing-framework/framework
1212
```
1313

14-
Then download the CLI (runs from the directory where you have `go.mod`)
14+
Download our [CLI](https://github.com/smartcontractkit/chainlink-testing-framework/releases/tag/framework%2Fv0.1.8)
15+
16+
OS X `arm64` (M1/M2/M3 MacBooks)
17+
```
18+
curl -L https://github.com/smartcontractkit/chainlink-testing-framework/releases/download/framework%2F<!-- cmdrun git describe --tags --match "framework/v[0-9]*.[0-9]*.[0-9]*" --abbrev=0 | sed 's/^framework\///' -->/framework-<!-- cmdrun git describe --tags --match "framework/v[0-9]*.[0-9]*.[0-9]*" --abbrev=0 | sed 's/^framework\///' -->-darwin-arm64.tar.gz | tar -xz
19+
```
20+
21+
OS X `amd64` (old Intel chips)
22+
```
23+
curl -L https://github.com/smartcontractkit/chainlink-testing-framework/releases/download/framework%2F<!-- cmdrun git describe --tags --match "framework/v[0-9]*.[0-9]*.[0-9]*" --abbrev=0 | sed 's/^framework\///' -->/framework-<!-- cmdrun git describe --tags --match "framework/v[0-9]*.[0-9]*.[0-9]*" --abbrev=0 | sed 's/^framework\///' -->-darwin-amd64.tar.gz | tar -xz
24+
```
25+
Linux `arm64`
26+
```
27+
curl -L https://github.com/smartcontractkit/chainlink-testing-framework/releases/download/framework%2F<!-- cmdrun git describe --tags --match "framework/v[0-9]*.[0-9]*.[0-9]*" --abbrev=0 | sed 's/^framework\///' -->/framework-<!-- cmdrun git describe --tags --match "framework/v[0-9]*.[0-9]*.[0-9]*" --abbrev=0 | sed 's/^framework\///' -->-linux-arm64.tar.gz | tar -xz
28+
```
29+
30+
Linux `amd64`
1531
```
16-
go get github.com/smartcontractkit/chainlink-testing-framework/framework/cmd && \
17-
go install github.com/smartcontractkit/chainlink-testing-framework/framework/cmd && \
18-
mv ~/go/bin/cmd ~/go/bin/ctf
32+
curl -L https://github.com/smartcontractkit/chainlink-testing-framework/releases/download/framework%2F<!-- cmdrun git describe --tags --match "framework/v[0-9]*.[0-9]*.[0-9]*" --abbrev=0 | sed 's/^framework\///' -->/framework-<!-- cmdrun git describe --tags --match "framework/v[0-9]*.[0-9]*.[0-9]*" --abbrev=0 | sed 's/^framework\///' -->-linux-amd64.tar.gz | tar -xz
1933
```
20-
Or download a binary release [here](https://github.com/smartcontractkit/chainlink-testing-framework/releases/tag/framework%2Fv0.1.7) and rename it to `ctf`
2134

2235
More CLI [docs](./cli.md)
2336

framework/.changeset/v0.1.9.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- Simplify CLI download, generate URLs for every platform automatically
2+
- Finalize Node and NodeSet docs

0 commit comments

Comments
 (0)