@@ -10,43 +10,30 @@ A lightweight Go client utility for interacting with Codex client.
1010
1111We will be running codex client, and then use a small testing utility to check if the low level abstraction - CodexClient - correctly uploads and downloads the content.
1212
13- ### Running CodexClient
13+ ### Integration Codex library
1414
15- I often remove some logging noise, by slightly changing the build
16- params in ` build.nims ` (nim-codex):
15+ You need to download the library file by using:
1716
18- ``` nim
19- task codex, "build codex binary":
20- buildBinary "codex",
21- # params = "-d:chronicles_runtime_filtering -d:chronicles_log_level=TRACE"
22- params =
23- "-d:chronicles_runtime_filtering -d:chronicles_log_level=TRACE -d:chronicles_enabled_topics:restapi:TRACE,node:TRACE"
24- ```
25-
26- You see a slightly more selective ` params ` in the ` codex ` task.
27-
28- To run the client I use the following command:
29-
30- ``` bash
31- ./build/codex --data-dir=./data-1 --listen-addrs=/ip4/127.0.0.1/tcp/8081 --api-port=8001 --nat=none --disc-port=8091 --log-level=TRACE
17+ ``` sh
18+ make fetch
3219```
3320
3421### Building codex-upload and codex-download utilities
3522
3623Use the following command to build the ` codex-upload ` and ` codex-download ` utilities:
3724
3825``` bash
39- go build -o bin/codex-upload ./cmd/ upload
40- go build -o bin/codex-download ./cmd/ download
26+ make build- upload
27+ make build- download
4128```
4229### Uploading content to Codex
4330
4431Now, using the ` codex-upload ` utility, we can upload the content to Codex as follows:
4532
4633``` bash
4734~ /code/local/go-codex-client
48- ❯ ./bin/codex-upload -file test-data.bin -host localhost -port 8001
49- Uploading test-data.bin (43 bytes) to Codex at localhost:8001...
35+ ❯ ./bin/codex-upload -file test-data.bin
36+ Uploading test-data.bin (43 bytes) to Codex
5037✅ Upload successful!
5138CID: zDvZRwzm8K7bcyPeBXcZzWD7AWc4VqNuseduDr3VsuYA1yXej49V
5239```
@@ -57,8 +44,8 @@ Now, having the content uploaded to Codex - let's get it back using the `codex-d
5744
5845``` bash
5946~ /code/local/go-codex-client
60- ❯ ./bin/codex-download -cid zDvZRwzm8K7bcyPeBXcZzWD7AWc4VqNuseduDr3VsuYA1yXej49V -file output.bin -host localhost -port 8001
61- Downloading CID zDvZRwzm8K7bcyPeBXcZzWD7AWc4VqNuseduDr3VsuYA1yXej49V from Codex at localhost:8001 ...
47+ ❯ ./bin/codex-download -cid zDvZRwzm8K7bcyPeBXcZzWD7AWc4VqNuseduDr3VsuYA1yXej49V -file output.bin
48+ Downloading CID zDvZRwzm8K7bcyPeBXcZzWD7AWc4VqNuseduDr3VsuYA1yXej49V from Codex...
6249✅ Download successful!
6350Saved to: output.bin
6451```
@@ -85,115 +72,23 @@ next section.
8572To run all unit tests:
8673
8774``` bash
88- ❯ go test -v ./communities -count 1
89- ```
90-
91- To be more selective, e.g. in order to run all the tests from
92- ` CodexArchiveDownloaderSuite ` , run:
93-
94- ``` bash
95- go test -v ./communities -run CodexArchiveDownloader -count 1
96- ```
97-
98- or for an individual test from that suite:
99-
100- ``` bash
101- go test -v ./communities -run TestCodexArchiveDownloaderSuite/TestCancellationDuringPolling -count 1
102- ```
103-
104- You can also use
` gotestsum ` to run the tests (you may need to install it first, e.g.
` go install gotest.tools/[email protected] ` ):
105-
106- ``` bash
107- gotestsum --packages=" ./communities" -f testname --rerun-fails -- -count 1
108- ```
109-
110- For a more verbose output including logs use ` -f standard-verbose ` , e.g.:
111-
112- ``` bash
113- gotestsum --packages=" ./communities" -f standard-verbose --rerun-fails -- -v -count 1
114- ```
115-
116- To be more selective, e.g. in order to run all the tests from
117- ` CodexArchiveDownloaderSuite ` , run:
118-
119- ``` bash
120- gotestsum --packages=" ./communities" -f testname --rerun-fails -- -run CodexArchiveDownloader -count 1
121- ```
122-
123- or for an individual test from that suite:
124-
125- ``` bash
126- gotestsum --packages=" ./communities" -f testname --rerun-fails -- -run TestCodexArchiveDownloaderSuite/TestCancellationDuringPolling -count 1
127- ```
128-
129- Notice, that the ` -run ` flag accepts a regular expression that matches against the full test path, so you can be more concise in naming if necessary, e.g.:
130-
131- ``` bash
132- gotestsum --packages=" ./communities" -f testname --rerun-fails -- -run CodexArchiveDownloader/Cancellation -count 1
133- ```
134-
135- This also applies to native ` go test ` command.
136-
137- ### Running integration tests
138-
139- When building Codex client for testing like here, I often remove some logging noise, by slightly changing the build params in ` build.nims ` :
140-
141- ``` nim
142- task codex, "build codex binary":
143- buildBinary "codex",
144- # params = "-d:chronicles_runtime_filtering -d:chronicles_log_level=TRACE"
145- params =
146- "-d:chronicles_runtime_filtering -d:chronicles_log_level=TRACE -d:chronicles_enabled_topics:restapi:TRACE,node:TRACE"
147- ```
148-
149- You see a slightly more selective ` params ` in the ` codex ` task.
150-
151- To start Codex client, use e.g.:
152-
153- ``` bash
154- ./build/codex --data-dir=./data-1 --listen-addrs=/ip4/127.0.0.1/tcp/8081 --api-port=8001 --nat=none --disc-port=8091 --log-level=TRACE
155- ```
156-
157- To run the integration test, use ` codex_integration ` tag and narrow the scope using ` -run Integration ` :
158-
159- ``` bash
160- CODEX_API_PORT=8001 go test -v -tags=codex_integration ./communities -run Integration -timeout 15s
161- ```
162-
163- This will run all integration tests, including CodexClient integration tests.
164-
165- To make sure that the test is actually run and not cached, use ` count ` option:
166-
167- ``` bash
168- CODEX_API_PORT=8001 go test -v -tags=codex_integration ./communities -run Integration -timeout 15s -count 1
169- ```
170-
171- To be more specific and only run the tests related to, e.g. index downloader or archive
172- downloader you can use:
173-
174- ``` bash
175- CODEX_API_PORT=8001 go test -v -tags=codex_integration ./communities -run CodexIndexDownloaderIntegration -timeout 15s -count 1
176-
177- CODEX_API_PORT=8001 go test -v -tags=codex_integration ./communities -run CodexArchiveDownloaderIntegration -timeout 15s -count 1
178- ```
179-
180- and then, if you prefer to use ` gotestsum ` :
181-
182- ``` bash
183- CODEX_API_PORT=8001 gotestsum --packages=" ./communities" -f standard-verbose --rerun-fails -- -tags=codex_integration -run CodexIndexDownloaderIntegration -v -count 1
184-
185- CODEX_API_PORT=8001 gotestsum --packages=" ./communities" -f standard-verbose --rerun-fails -- -tags=codex_integration -run CodexArchiveDownloaderIntegration -v -count 1
75+ ❯ make test
76+ === RUN TestUpload_Success
77+ --- PASS: TestUpload_Success (0.00s)
78+ === RUN TestDownload_Success
79+ --- PASS: TestDownload_Success (0.00s)
80+ === RUN TestDownloadWithContext_Cancel
81+ --- PASS: TestDownloadWithContext_Cancel (0.04s)
82+ PASS
83+ ok go-codex-client/communities 0.044s
18684```
18785
188- or to run all integration tests (including CodexClient integration tests) :
86+ To run the integration test, use ` test- integration` :
18987
19088``` bash
191- CODEX_API_PORT=8001 gotestsum --packages= " ./communities " -f standard-verbose --rerun-fails -- -tags=codex_integration -v -count 1 -run Integration
89+ make test-integration
19290```
19391
194- I prefer to be more selective when running integration tests.
195-
196-
19792### Regenerating artifacts
19893
19994Everything you need comes included in the repo. But if you decide to change things,
0 commit comments