diff options
author | Riobard Zhan <me@riobard.com> | 2020-09-10 01:55:24 +0800 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2020-10-14 10:46:00 +0200 |
commit | 22af3890f60d11472977f2fbdf50e6d5b406e356 (patch) | |
tree | ed90d020d5876239d15181284353ce322f5dcbee /replay/replay_test.go | |
parent | c8fe925020de61b30eec2bc016fb7f45df78dc6c (diff) |
replay: clean up internals and better documentation
Signed-off-by: Riobard Zhan <me@riobard.com>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'replay/replay_test.go')
-rw-r--r-- | replay/replay_test.go | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/replay/replay_test.go b/replay/replay_test.go index ceae2f3..5af66ff 100644 --- a/replay/replay_test.go +++ b/replay/replay_test.go @@ -19,13 +19,13 @@ const RejectAfterMessages = (1 << 64) - (1 << 4) - 1 func TestReplay(t *testing.T) { var filter ReplayFilter - T_LIM := CounterWindowSize + 1 + const T_LIM = windowSize + 1 testNumber := 0 - T := func(n uint64, v bool) { + T := func(n uint64, expected bool) { testNumber++ - if filter.ValidateCounter(n, RejectAfterMessages) != v { - t.Fatal("Test", testNumber, "failed", n, v) + if filter.ValidateCounter(n, RejectAfterMessages) != expected { + t.Fatal("Test", testNumber, "failed", n, expected) } } @@ -69,7 +69,7 @@ func TestReplay(t *testing.T) { t.Log("Bulk test 1") filter.Init() testNumber = 0 - for i := uint64(1); i <= CounterWindowSize; i++ { + for i := uint64(1); i <= windowSize; i++ { T(i, true) } T(0, true) @@ -78,7 +78,7 @@ func TestReplay(t *testing.T) { t.Log("Bulk test 2") filter.Init() testNumber = 0 - for i := uint64(2); i <= CounterWindowSize+1; i++ { + for i := uint64(2); i <= windowSize+1; i++ { T(i, true) } T(1, true) @@ -87,14 +87,14 @@ func TestReplay(t *testing.T) { t.Log("Bulk test 3") filter.Init() testNumber = 0 - for i := CounterWindowSize + 1; i > 0; i-- { + for i := uint64(windowSize + 1); i > 0; i-- { T(i, true) } t.Log("Bulk test 4") filter.Init() testNumber = 0 - for i := CounterWindowSize + 2; i > 1; i-- { + for i := uint64(windowSize + 2); i > 1; i-- { T(i, true) } T(0, false) @@ -102,18 +102,18 @@ func TestReplay(t *testing.T) { t.Log("Bulk test 5") filter.Init() testNumber = 0 - for i := CounterWindowSize; i > 0; i-- { + for i := uint64(windowSize); i > 0; i-- { T(i, true) } - T(CounterWindowSize+1, true) + T(windowSize+1, true) T(0, false) t.Log("Bulk test 6") filter.Init() testNumber = 0 - for i := CounterWindowSize; i > 0; i-- { + for i := uint64(windowSize); i > 0; i-- { T(i, true) } T(0, true) - T(CounterWindowSize+1, true) + T(windowSize+1, true) } |