You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 10 Notes/Running Unit Tests for status-go.md
+15-13Lines changed: 15 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -121,9 +121,9 @@ The obvious
121
121
make test
122
122
```
123
123
124
-
is a mistery to me as looking at the source code, it looks it has no chance to succeed without some extra steps.
124
+
a number of tests will most certainly. To understand the root cause, let's investigate a bit.
125
125
126
-
`make test` uses `_assets/scripts/run_unit_tests.sh`, where we find the following fragment:
126
+
`make test` uses `_assets/scripts/run_unit_tests.sh` under the hood, where we find the following fragment:
127
127
128
128
```bash
129
129
if [[ $HAS_PROTOCOL_PACKAGE == 'false' ]]; then
@@ -144,14 +144,14 @@ else
144
144
fi
145
145
```
146
146
147
-
From the comments, we see that the `else` branch will be used. It is split into two parts:
147
+
From the comments, we see that the `else` branch is currently used when running the tests. It splits running tests into two parts:
148
148
149
149
1. All the tests except for the tests for `status-go/protocol` module, those are faster, which is reflected in the the shorter timeout: `DEFAULT_TIMEOUT_MINUTES=5`.
150
-
2. The `protocol tests` - slower (`PROTOCOL_TIMEOUT_MINUTES=45`). By default `UNIT_TEST_COUNT=1`.
150
+
2. The `protocol tests` - there are many of them (over 900) and can take longer to run (`PROTOCOL_TIMEOUT_MINUTES=45`). By default `UNIT_TEST_COUNT=1`, which means it tries to run the protocol tests only once.
151
151
152
-
For our regular development, we may not like to run all tests. In particular, the `protocol` tests seem to be less relevant to our use case of message history archives. Thus, in what follows I am skipping the longer protocol tests.
152
+
> The timeout variables `DEFAULT_TIMEOUT_MINUTES` and `PROTOCOL_TIMEOUT_MINUTES` are used as the value of the `-timeout` option passed down to `go test`. It limits the time all the tests are allowing to take.
153
153
154
-
Now, if you run`make test`the tests will fail:
154
+
We may observe more or less failures, depending on the run, but one test will consistently fail, even if we modify the script to only run non-protocol tests: `TestBasicWakuV2`:
155
155
156
156
```bash
157
157
=== RUN TestBasicWakuV2
@@ -163,7 +163,7 @@ Now, if you run `make test` the tests will fail:
163
163
--- FAIL: TestBasicWakuV2 (0.00s)
164
164
```
165
165
166
-
Indeed, we can confirm it by running just the `TestBasicWakuV2`:
166
+
Let's try to run this test without using the `run_unit_tests.sh` script to confirm the problem:
If we look into source code of `messaging/waku/waku_test.go`, and scroll down a bit (!!), we will find the following comment:
177
+
If we look into source code of `messaging/waku/waku_test.go` where `TestBasicWakuV2` is defined, and scroll down a bit (!!), we will find the following comment:
178
178
179
179
```go
180
180
// In order to run these tests, you must run an nwaku node
@@ -257,7 +257,7 @@ PASS messaging/waku
257
257
DONE 14 tests, 1 skipped in 33.720s
258
258
```
259
259
260
-
Now, we should also be able to successfully run all the tests using `make test`:
260
+
Now, we should also be able to successfully run all the non-protocol tests using `make test`:
261
261
262
262
```bash
263
263
make test
@@ -341,25 +341,25 @@ DONE 2 tests in 0.307s
341
341
342
342
### Running "protocol" tests
343
343
344
-
I only run all the tests (including `protocol` tests) using `make test` once. Got most of the test pass, but not all. To get a better feedback and to track progress, I prefer to run them using `gotestsum` command:
344
+
When runing all the tests (including `protocol` tests) using `make test`, most of the tests pass, but not all. As already indicated above, in order to get a better feedback and to track progress, I prefer to run them using `gotestsum` command:
So, the reason I recorded it, is that the output can be pretty misleading if you are seeing this output for the first time. The `6 failures` is actually $1$ (one) failing test:
362
+
So, the reason I recorded it here, is that the output can be pretty misleading if you are seeing this output for the first time. The `6 failures` is actually $1$ (one) failing test:
0 commit comments