Skip to content

Commit a84b1cb

Browse files
committed
sync with main
2 parents 77ed694 + 0dd918b commit a84b1cb

File tree

21 files changed

+144
-55
lines changed

21 files changed

+144
-55
lines changed

book/src/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
- [Components Cleanup](framework/components/cleanup.md)
1919
- [Components Caching](framework/components/caching.md)
2020
- [Mocking Services](framework/components/mocking.md)
21+
- [Copying Files](framework/copying_files.md)
2122
- [External Environment](framework/components/external.md)
2223
- [Secrets]()
2324
- [Observability Stack](framework/observability/observability_stack.md)

book/src/framework/components/state.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ When deploying a component, you can explicitly configure port ranges if the defa
99
Defaults are:
1010
- [NodeSet](../components/chainlink/nodeset.md) (Node HTTP API): `10000..100XX`
1111
- [NodeSet](../components/chainlink/nodeset.md) (Node P2P API): `12000..120XX`
12+
- Shared `PostgreSQL` volume is called `postgresql_data`
1213
```
1314
[nodeset]
1415
# HTTP API port range start, each new node get port incremented (host machine)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Copying Files
2+
3+
You can copy files to containers by using the `ContainerName` from the output and specifying the source `src` and destination `dst` paths.
4+
5+
However, using this API is discouraged and will be **deprecated** in the future, as it violates the principles of "black-box" testing. If your service relies on this functionality, consider designing a configuration or API to address the requirement instead.
6+
7+
```go
8+
bc, err := blockchain.NewBlockchainNetwork(&blockchain.Input{
9+
...
10+
})
11+
require.NoError(t, err)
12+
13+
err = dockerClient.CopyFile(bc.ContainerName, "local_file.txt", "/home")
14+
require.NoError(t, err)
15+
```

framework/.changeset/v0.2.6.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Reflect DB changes in interactive mode

framework/.changeset/v0.2.7.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
- Do not expose P2P URL to prevent confusion
2+
- Add container names into outputs
3+
- Add `CopyFile` command for Docker

framework/cmd/interactive.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,6 @@ func createComponentsFromForm(form *nodeSetForm) error {
5252
nspecs := make([]*clnode.Input, 0)
5353
for i := 0; i < form.Nodes; i++ {
5454
nspecs = append(nspecs, &clnode.Input{
55-
DbInput: &postgres.Input{
56-
Image: "postgres:15.6",
57-
},
5855
Node: &clnode.NodeInput{
5956
Image: form.CLVersion,
6057
},
@@ -64,7 +61,10 @@ func createComponentsFromForm(form *nodeSetForm) error {
6461
_, err = simple_node_set.NewSharedDBNodeSet(&simple_node_set.Input{
6562
Nodes: 5,
6663
OverrideMode: "all",
67-
NodeSpecs: nspecs,
64+
DbInput: &postgres.Input{
65+
Image: "postgres:15.6",
66+
},
67+
NodeSpecs: nspecs,
6868
}, bc)
6969
}
7070
err = spinner.New().

framework/components/blockchain/anvil.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,9 @@ func deployAnvil(in *Input) (*Output, error) {
5555
return nil, err
5656
}
5757
return &Output{
58-
UseCache: true,
59-
ChainID: in.ChainID,
58+
UseCache: true,
59+
ChainID: in.ChainID,
60+
ContainerName: containerName,
6061
Nodes: []*Node{
6162
{
6263
HostWSUrl: fmt.Sprintf("ws://%s:%s", host, mp.Port()),

framework/components/blockchain/blockchain.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@ type Input struct {
1717

1818
// Output is a blockchain network output, ChainID and one or more nodes that forms the network
1919
type Output struct {
20-
UseCache bool `toml:"use_cache"`
21-
ChainID string `toml:"chain_id"`
22-
Nodes []*Node `toml:"nodes"`
20+
UseCache bool `toml:"use_cache"`
21+
ContainerName string `toml:"container_name"`
22+
ChainID string `toml:"chain_id"`
23+
Nodes []*Node `toml:"nodes"`
2324
}
2425

2526
// Node represents blockchain node output, URLs required for connection locally and inside docker network

framework/components/clnode/clnode.go

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ type Output struct {
6767
type NodeOut struct {
6868
APIAuthUser string `toml:"api_auth_user"`
6969
APIAuthPassword string `toml:"api_auth_password"`
70+
ContainerName string `toml:"container_name"`
7071
HostURL string `toml:"url"`
71-
HostP2PURL string `toml:"p2p_url"`
7272
DockerURL string `toml:"docker_internal_url"`
7373
DockerP2PUrl string `toml:"p2p_docker_internal_url"`
7474
}
@@ -124,7 +124,7 @@ func newNode(in *Input, pgOut *postgres.Output) (*NodeOut, error) {
124124
if err != nil {
125125
return nil, err
126126
}
127-
cfgPath, err := writeDefaultConfig(in)
127+
cfgPath, err := writeDefaultConfig()
128128
if err != nil {
129129
return nil, err
130130
}
@@ -150,7 +150,6 @@ func newNode(in *Input, pgOut *postgres.Output) (*NodeOut, error) {
150150
}
151151

152152
httpPort := fmt.Sprintf("%s/tcp", DefaultHTTPPort)
153-
p2pPort := fmt.Sprintf("%s/udp", DefaultP2PPort)
154153
var containerName string
155154
if in.Node.Name != "" {
156155
containerName = in.Node.Name
@@ -161,7 +160,7 @@ func newNode(in *Input, pgOut *postgres.Output) (*NodeOut, error) {
161160
for _, p := range in.Node.CustomPorts {
162161
customPorts = append(customPorts, fmt.Sprintf("%d/tcp", p))
163162
}
164-
exposedPorts := []string{httpPort, p2pPort}
163+
exposedPorts := []string{httpPort}
165164
exposedPorts = append(exposedPorts, customPorts...)
166165

167166
portBindings := nat.PortMap{
@@ -171,12 +170,6 @@ func newNode(in *Input, pgOut *postgres.Output) (*NodeOut, error) {
171170
HostPort: fmt.Sprintf("%d/tcp", in.Node.HTTPPort),
172171
},
173172
},
174-
nat.Port(p2pPort): []nat.PortBinding{
175-
{
176-
HostIP: "0.0.0.0",
177-
HostPort: fmt.Sprintf("%d/udp", in.Node.P2PPort),
178-
},
179-
},
180173
}
181174
for _, p := range customPorts {
182175
portBindings[nat.Port(p)] = []nat.PortBinding{
@@ -286,13 +279,12 @@ func newNode(in *Input, pgOut *postgres.Output) (*NodeOut, error) {
286279
}
287280

288281
mp := nat.Port(fmt.Sprintf("%d/tcp", in.Node.HTTPPort))
289-
mpP2P := nat.Port(fmt.Sprintf("%d/udp", in.Node.P2PPort))
290282

291283
return &NodeOut{
292284
APIAuthUser: DefaultAPIUser,
293285
APIAuthPassword: DefaultAPIPassword,
286+
ContainerName: containerName,
294287
HostURL: fmt.Sprintf("http://%s:%s", host, mp.Port()),
295-
HostP2PURL: fmt.Sprintf("http://%s:%s", host, mpP2P.Port()),
296288
DockerURL: fmt.Sprintf("http://%s:%s", containerName, DefaultHTTPPort),
297289
DockerP2PUrl: fmt.Sprintf("http://%s:%s", containerName, DefaultP2PPort),
298290
}, nil
@@ -303,7 +295,7 @@ type DefaultCLNodeConfig struct {
303295
SecureCookies bool
304296
}
305297

306-
func generateDefaultConfig(in *Input) (string, error) {
298+
func generateDefaultConfig() (string, error) {
307299
config := DefaultCLNodeConfig{
308300
HTTPPort: DefaultHTTPPort,
309301
SecureCookies: false,
@@ -351,8 +343,8 @@ func writeDefaultSecrets(pgOut *postgres.Output) (*os.File, error) {
351343
return WriteTmpFile(secretsOverrides, "secrets.toml")
352344
}
353345

354-
func writeDefaultConfig(in *Input) (*os.File, error) {
355-
cfg, err := generateDefaultConfig(in)
346+
func writeDefaultConfig() (*os.File, error) {
347+
cfg, err := generateDefaultConfig()
356348
if err != nil {
357349
return nil, err
358350
}

framework/components/clnode/clnode_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func checkBasicOutputs(t *testing.T, output *clnode.Output) {
2323
require.Contains(t, output.Node.DockerP2PUrl, "cl-node")
2424
require.NotNil(t, output.PostgreSQL)
2525
require.Contains(t, output.PostgreSQL.Url, "postgresql://chainlink:[email protected]")
26-
require.Contains(t, output.PostgreSQL.DockerInternalURL, "postgresql://chainlink:thispasswordislongenough@postgresql-")
26+
require.Contains(t, output.PostgreSQL.DockerInternalURL, "postgresql://chainlink:thispasswordislongenough@ns-postgresql")
2727
}
2828

2929
func TestComponentDockerNodeWithSharedDB(t *testing.T) {

0 commit comments

Comments
 (0)