tests: props, statuses, the resize rules and migration step 6 (#22)
tests/tprops.nim is new: the caps (per bucket, keys, values), the key rules, the registry (empty fallback, a registered key's kind and bucket), set/unset and the clone that keeps an edit away from the original bucket. ttokens covers radius, the three buckets, the status set (round trip, sorted, replaced rather than appended, removed by the FK cascade). tmoverules covers per-token radius, shrink/grow/squeeze, the no-crossing rule, the corner relaxation and the independence of the two sources; the old `blocked` tests became `stuckWalls`. tviews covers the bucket and source filtering, one `token` frame per change and the effective radius. tdb/tdb's fixtures move to step 6, and tprobing follows the rename.
This commit is contained in:
+8
-7
@@ -3,14 +3,14 @@
|
||||
## Attacker model: owns one token and may send any destination, any number of times (rate limit is a transport
|
||||
## concern, M3). It sees only the reply (ack/nack + position), exactly what the wire carries.
|
||||
##
|
||||
## CONCRETE BOUND B = stepCap + tokenRadius (token vision radius, or the scene default, plus r):
|
||||
## CONCRETE BOUND B = stepCap + r (token vision radius, or the scene default, plus the token radius):
|
||||
## P1 a probe longer than the cap always gets the same nack, whatever the walls and doors are;
|
||||
## P2 the reply to any probe from position s depends on walls only within distance B of s; so by induction two
|
||||
## scenes that differ only in walls/doors farther than B from every position the token ever occupied produce
|
||||
## IDENTICAL reply sequences (no wall or door state beyond B is recoverable, however many probes);
|
||||
## P3 inside B, one probe yields one bit (ack/nack): it can reveal walls behind a wall within the disc, which is
|
||||
## what the cap allows (cap = LOS radius); the negative control shows the harness does detect that;
|
||||
## P4 nacks mutate nothing (position, blocked flag), so probing cannot be used to move or unflag a token.
|
||||
## P4 nacks mutate nothing (position, lock status), so probing cannot be used to move or unlock a token.
|
||||
import std/[unittest, math]
|
||||
import geometry, moverules, testutil
|
||||
|
||||
@@ -22,8 +22,9 @@ const
|
||||
let me = Actor(role: rolePlayer, player: 1)
|
||||
|
||||
proc mkScene(walls: seq[Wall]): Scene =
|
||||
Scene(w: WorldW, h: WorldW, tokenRadius: R, visionDefault: Cap, walls: walls,
|
||||
tokens: @[Token(pos: (300.0, 2000.0), owner: 1, hasVision: true, visionRadius: Cap)])
|
||||
Scene(w: WorldW, h: WorldW, visionDefault: Cap, walls: walls,
|
||||
tokens: @[Token(pos: (300.0, 2000.0), owner: 1, radius: R, hasVision: true,
|
||||
visionRadius: Cap)])
|
||||
|
||||
type Trace = object
|
||||
replies: seq[MoveResult]
|
||||
@@ -106,14 +107,14 @@ suite "probing (T8)":
|
||||
check ca.moveToken(me, 0, (500.0, 2000.0)).kind == mkAck
|
||||
check cb.moveToken(me, 0, (500.0, 2000.0)).kind == mkNack
|
||||
|
||||
test "P4: probing cannot unflag or move a blocked token":
|
||||
test "P4: probing cannot unlock or move a locked token":
|
||||
var s = mkScene(@[W(310, 1900, 310, 2100)]) # overlaps the token at (300,2000)
|
||||
s.tokens[0].blocked = true
|
||||
s.tokens[0].locked = true
|
||||
var r = Rng(s: 11)
|
||||
for i in 0 ..< 500:
|
||||
let res = s.moveToken(me, 0, (r.uni(0, 600), r.uni(1700, 2300)))
|
||||
check res == MoveResult(kind: mkNack, pos: (300.0, 2000.0))
|
||||
check s.tokens[0].blocked and s.tokens[0].pos == (300.0, 2000.0)
|
||||
check s.tokens[0].locked and s.tokens[0].pos == (300.0, 2000.0)
|
||||
|
||||
test "doors beyond the bound: opening or closing them changes no reply":
|
||||
var r = Rng(s: 31)
|
||||
|
||||
Reference in New Issue
Block a user