mirror of
https://github.com/miekg/dns.git
synced 2025-08-07 18:16:59 +02:00
This reduces the time it takes to run the test. Shorter timeouts on clients to avoid awaiting for the detault timeouts. It's also reduces the iterations in some test functions, this doesn't seem to impact the tests indicating those numbers where random to begin with. Use shorter crypto keys, as we don't need to strength in tests. Stop using Google Public DNS and other remotes in tests as well: it's faster, keeps things local and avoids spilling info to Google. This brings the test duration down from ~8s to ~2s on my machine, a 4x reduction. ~~~ PASS ok github.com/miekg/dns 2.046s Switched to branch 'master' Your branch is up-to-date with 'origin/master'. PASS ok github.com/miekg/dns 7.915s ~~~ Signed-off-by: Miek Gieben <miek@miek.nl>
45 lines
1.2 KiB
Go
45 lines
1.2 KiB
Go
package dns
|
|
|
|
// Tests that solve that an specific issue.
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestNSEC3MissingSalt(t *testing.T) {
|
|
rr := testRR("ji6neoaepv8b5o6k4ev33abha8ht9fgc.example. NSEC3 1 1 12 aabbccdd K8UDEMVP1J2F7EG6JEBPS17VP3N8I58H")
|
|
m := new(Msg)
|
|
m.Answer = []RR{rr}
|
|
mb, err := m.Pack()
|
|
if err != nil {
|
|
t.Fatalf("expected to pack message. err: %s", err)
|
|
}
|
|
if err := m.Unpack(mb); err != nil {
|
|
t.Fatalf("expected to unpack message. missing salt? err: %s", err)
|
|
}
|
|
in := rr.(*NSEC3).Salt
|
|
out := m.Answer[0].(*NSEC3).Salt
|
|
if in != out {
|
|
t.Fatalf("expected salts to match. packed: `%s`. returned: `%s`", in, out)
|
|
}
|
|
}
|
|
|
|
func TestNSEC3MixedNextDomain(t *testing.T) {
|
|
rr := testRR("ji6neoaepv8b5o6k4ev33abha8ht9fgc.example. NSEC3 1 1 12 - k8udemvp1j2f7eg6jebps17vp3n8i58h")
|
|
m := new(Msg)
|
|
m.Answer = []RR{rr}
|
|
mb, err := m.Pack()
|
|
if err != nil {
|
|
t.Fatalf("expected to pack message. err: %s", err)
|
|
}
|
|
if err := m.Unpack(mb); err != nil {
|
|
t.Fatalf("expected to unpack message. err: %s", err)
|
|
}
|
|
in := strings.ToUpper(rr.(*NSEC3).NextDomain)
|
|
out := m.Answer[0].(*NSEC3).NextDomain
|
|
if in != out {
|
|
t.Fatalf("expected round trip to produce NextDomain `%s`, instead `%s`", in, out)
|
|
}
|
|
}
|