Randomness apparently not good enough for windows. Tests were failing. This fix improves it

This commit is contained in:
Winni Neessen 2022-10-26 13:43:51 +02:00
parent 021e003e78
commit 5bf0c10525
Signed by: wneessen
GPG key ID: 5F3AF39B820C119D
2 changed files with 3 additions and 3 deletions

4
msg.go
View file

@ -360,9 +360,9 @@ func (m *Msg) SetMessageID() {
ct := time.Now().UnixNano()
r := rand.New(rand.NewSource(ct))
rn := r.Int63()
pid := os.Getpid()
pid := os.Getpid() * (r.Intn(10000) + 1)
cts := fmt.Sprintf("%d", ct)
mid := fmt.Sprintf("%d.%d.%s@%s", pid, rn, cts[:15], hn)
mid := fmt.Sprintf("%d.%d.%s@%s", pid, rn, cts[:16], hn)
m.SetMessageIDWithValue(mid)
}

View file

@ -710,7 +710,7 @@ func TestMsg_SetMessageIDRandomness(t *testing.T) {
}
for k, v := range c {
if v > 1 {
t.Errorf("MessageID randomness not give. MessageID %q was generated %d times", k, v)
t.Errorf("MessageID randomness not given. MessageID %q was generated %d times", k, v)
}
}
}