p2p/discover: fix test

This commit is contained in:
Felix Lange 2025-04-02 13:18:40 +02:00
parent 220a8cf423
commit df865cb868

View file

@ -181,18 +181,16 @@ func TestUDPv5_handshakeRepeatChallenge(t *testing.T) {
nonce1 := v5wire.Nonce{1} nonce1 := v5wire.Nonce{1}
nonce2 := v5wire.Nonce{2} nonce2 := v5wire.Nonce{2}
nonce3 := v5wire.Nonce{3} nonce3 := v5wire.Nonce{3}
var authTag1 v5wire.Nonce var firstAuthTag *v5wire.Nonce
check := func(p *v5wire.Whoareyou, actualAuthTag, wantNonce v5wire.Nonce) { check := func(p *v5wire.Whoareyou, authTag, wantNonce v5wire.Nonce) {
t.Helper() t.Helper()
if p.Nonce != wantNonce { if p.Nonce != wantNonce {
t.Error("wrong nonce in WHOAREYOU:", p.Nonce, wantNonce) t.Error("wrong nonce in WHOAREYOU:", p.Nonce, "want:", wantNonce)
} }
if authTag1 == (v5wire.Nonce{}) { if firstAuthTag == nil {
authTag1 = actualAuthTag firstAuthTag = &authTag
} else { } else if authTag != *firstAuthTag {
if authTag1 != authTag1 { t.Error("wrong auth tag in WHOAREYOU header:", authTag, "want:", *firstAuthTag)
t.Error("wrong auth tag in WHOAREYOU header:", authTag1, wantNonce)
}
} }
} }