dns/resolver_test.go
Miek Gieben fd9afcb44d Add signature helper function
Do this in dnssec.go so that all DNSSEC stuff in contained
in that file.
Add testing too
2010-12-24 11:50:42 +01:00

46 lines
816 B
Go

package dns
import (
"testing"
"time"
)
func TestResolver(t *testing.T) {
res := new(Resolver)
ch := NewQuerier(res)
res.Servers = []string{"127.0.0.1"}
res.Timeout = 2
res.Attempts = 1
m := new(Msg)
m.MsgHdr.Recursion_desired = true //only set this bit
m.Question = make([]Question, 1)
// ask something
m.Question[0] = Question{"miek.nl", TypeSOA, ClassINET}
ch <- DnsMsg{m, nil}
in := <-ch
if in.Dns.Rcode != RcodeSuccess {
t.Log("Failed to get an valid answer")
t.Fail()
t.Logf("%v\n", in)
}
// ask something
m.Question[0] = Question{"www.nlnetlabs.nl", TypeRRSIG, ClassINET}
ch <- DnsMsg{m, nil}
in = <-ch
if in.Dns.Rcode != RcodeSuccess {
t.Log("Failed to get an valid answer")
t.Fail()
t.Logf("%v\n", in)
}
ch <- DnsMsg{nil, nil}
time.Sleep(0.5e9)
}