summaryrefslogtreecommitdiffstats
path: root/docs/TESTING.md
blob: acdcdd4662d0b041854761bb18f2a584f3f05384 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# Testing

## Automated suite

```sh
cargo test
```

The suite is deterministic and headless: no network, no PTY, no sleeps, no
shared global database. Each test owns its state.

| File | Covers |
| --- | --- |
| `tests/client_core.rs` | Client command/game flows via a headless screen applying logical effects. |
| `tests/client_ui.rs` | Help, history, completion, bet parsing, display width, cursor math. |
| `tests/protocol.rs` | Newline buffering and timeout/error classification. |
| `tests/server_core.rs` | Handler, bcrypt migration, SQL injection, transaction rollback, `plays` audit, sessions. |
| `tests/server_setup.rs` | `--init` identity generation, PKCS#12 loadability, overwrite refusal. |
| `tests/slots.rs` | Server slots payout rules and overflow handling. |
| `tests/storage.rs` | Client/server SQLite storage helpers. |
| `tests/tofu.rs` | SPKI fingerprint and TOFU decisions. |

`tests/tofu.rs` and `tests/server_setup.rs` shell out to `openssl`, so run them
on a machine where the `openssl` CLI is available.

## Manual TUI checklist

There is no CI. Run this on Linux and on a Windows VM before a release.
Use an 80-column terminal because several output lines are width-sensitive.

1. Run `cargo run --bin server -- --init` once, then start the server with a
   valid `identity.p12` and start the client.
2. First contact prints three lines and the 64-character fingerprint does not
   wrap at 80 columns. `Connected to ...` shows a one-decimal ping.
3. `register` / `login`: backspace removes one `*` per key, Esc cancels the
   prompt, Ctrl+C exits and restores the terminal.
4. `help` fits 80 columns. Tab completion wraps within 76 columns and the
   cursor stays visible.
5. `play slots 50` shows a 5x3 grid, the `Pays bet x symbol x shape` lines, and
   the fetched balance.
6. Space shows `Spinning...`, then the 3 rows, win text, winning-line list, and
   new balance inside the same 10-line board. Winning symbols appear as
   yellow/bold `{ X }` cells; the `Winning lines:` list names the payline
   (e.g. `4 (V)`). The controls line is never overwritten. Slots rules and RTP:
   `docs/SLOTS.md`.
7. `+` / `-` after a spin changes only the bet; no stale grid or result lines
   appear.
8. `q` clears the board. Ctrl+C in a game clears the board and exits.
9. `info`, `ping`, `send hello`, and `hosts` print readable output; the host
   fingerprint fits 80 columns.
10. Windows: repeat 2-9 and confirm keys are not duplicated or printed twice.

## Manual server checks

- Register, log out, log in again (bcrypt path).
- Log in with a pre-0.3 user row (legacy SHA-256) and confirm it still works;
  the row is upgraded to bcrypt.
- Spin several times and confirm `plays` grows by one row per spin while
  `users.balance` changes by `winnings - bet`.