Skip to content

Commit

Permalink
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions docs/architecture.md
Original file line number Diff line number Diff line change
@@ -197,3 +197,46 @@ The `INFO` level is enabled by default, use it for information useful for node
operators. The `DEBUG` level is enabled on the canary nodes, use it for
information useful in debugging testnet failures. The `TRACE` level is not
generally enabled, use it for arbitrary debug output.

### Testing

Rust has built-in support for writing unit tests by marking functions
with `#[test]` directive. Take full advantage of that! Testing not
only confirms that what was written works the way it was intended but
also help during refactoring since the caught unintended behaviour
changes.

Not all tests are created equal though and while some can need only
milliseconds to run, others may run for several seconds or even
minutes. Tests that take a long time should be marked as such with an
`expensive_tests` feature, for example:

```rust
#[test]
#[cfg_attr(not(feature = "expensive_tests"), ignore)]
fn test_catchup_random_single_part_sync() {
test_catchup_random_single_part_sync_common(false, false, 13)
}
```

Such tests will be ignored by default and can be executed by using
`--ignored` or `--include-ignored` flag as in `cargo test --
--ignored` or by compiling the tests with `expensive_tests` feature
enabled.

Because expensive tests are not run by default, they are also not run
in CI. Instead, they are run nightly and need to be explicitly
included in `nightly/expensive.txt` file; for example:

```text
expensive --timeout=1800 near-client near_client tests::catching_up::test_catchup_random_single_part_sync
expensive --timeout=1800 near-client near_client tests::catching_up::test_catchup_random_single_part_sync --features nightly_protocol,nightly_protocol_features
```

For more details regarding nightly tests see `nightly/README.md`.

Note that what counts as a slow test isn’t exactly defined as of now.
If it takes just a couple seconds than it’s probably fine. Anything
slower should probably be classified as expensive test. In
particular, if libtest complains the test takes more than 60 seconds
than it definitely is.

0 comments on commit dc2baea

Please sign in to comment.