@@ -15,15 +15,15 @@ func TestReplayProtection_Reset(t *testing.T) {
15
15
16
16
func TestReplayProtection (t * testing.T ) {
17
17
r := NewReplayProtection ()
18
- for i := 0 ; i < 2 ; i += 1 {
18
+ for i := 0 ; i < 2 ; i += 1 {
19
19
r .Reset ()
20
20
if r .MostRecentSequence != 0 {
21
21
t .Fatalf ("sequence was not 0" )
22
22
}
23
23
24
24
// sequence numbers with high bit set should be ignored
25
25
sequence := uint64 (1 << 63 )
26
- if r .AlreadyReceived (sequence ) != 0 {
26
+ if r .AlreadyReceived (sequence ) {
27
27
t .Fatalf ("sequence numbers with high bit set should be ignored" )
28
28
}
29
29
@@ -33,34 +33,34 @@ func TestReplayProtection(t *testing.T) {
33
33
34
34
// the first time we receive packets, they should not be already received
35
35
maxSequence := uint64 (REPLAY_PROTECTION_BUFFER_SIZE * 4 )
36
- for sequence = 0 ; sequence < maxSequence ; sequence += 1 {
37
- if r .AlreadyReceived (sequence ) != 0 {
36
+ for sequence = 0 ; sequence < maxSequence ; sequence += 1 {
37
+ if r .AlreadyReceived (sequence ) {
38
38
t .Fatalf ("the first time we receive packets, they should not be already received" )
39
39
}
40
40
}
41
41
42
42
// old packets outside buffer should be considered already received
43
- if r .AlreadyReceived (0 ) != 1 {
43
+ if ! r .AlreadyReceived (0 ) {
44
44
t .Fatalf ("old packets outside buffer should be considered already received" )
45
45
}
46
46
47
47
// packets received a second time should be flagged already received
48
- for sequence = maxSequence - 10 ; sequence < maxSequence ; sequence += 1 {
49
- if r .AlreadyReceived (sequence ) != 1 {
48
+ for sequence = maxSequence - 10 ; sequence < maxSequence ; sequence += 1 {
49
+ if ! r .AlreadyReceived (sequence ) {
50
50
t .Fatalf ("packets received a second time should be flagged already received" )
51
51
}
52
52
}
53
53
54
54
// jumping ahead to a much higher sequence should be considered not already received
55
- if r .AlreadyReceived (maxSequence + REPLAY_PROTECTION_BUFFER_SIZE ) != 0 {
55
+ if r .AlreadyReceived (maxSequence + REPLAY_PROTECTION_BUFFER_SIZE ) {
56
56
t .Fatalf ("jumping ahead to a much higher sequence should be considered not already received" )
57
57
}
58
58
59
59
// old packets should be considered already received
60
- for sequence = 0 ; sequence < maxSequence ; sequence += 1 {
61
- if r .AlreadyReceived (sequence ) != 1 {
60
+ for sequence = 0 ; sequence < maxSequence ; sequence += 1 {
61
+ if ! r .AlreadyReceived (sequence ) {
62
62
t .Fatalf ("old packets should be considered already received" )
63
63
}
64
64
}
65
65
}
66
- }
66
+ }
0 commit comments