diff options
author | Andrea Barberio <insomniac@slackware.it> | 2017-12-23 12:27:23 +0000 |
---|---|---|
committer | Andrea Barberio <insomniac@slackware.it> | 2017-12-23 12:27:23 +0000 |
commit | 522537fb5eebceb57ed5f2b39101a854e97b4da9 (patch) | |
tree | a5b1d77f9111cad1228faf8d92d2701c044aa880 /dhcpv6/dhcpv6relay_test.go | |
parent | 82b6d0f716f1be6b1ce48c8e3039c90c688e4f4e (diff) |
Added setters and getters for DHCPv6Relay and basic testing
Diffstat (limited to 'dhcpv6/dhcpv6relay_test.go')
-rw-r--r-- | dhcpv6/dhcpv6relay_test.go | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/dhcpv6/dhcpv6relay_test.go b/dhcpv6/dhcpv6relay_test.go new file mode 100644 index 0000000..a128993 --- /dev/null +++ b/dhcpv6/dhcpv6relay_test.go @@ -0,0 +1,35 @@ +package dhcpv6 + +import ( + "bytes" + "net" + "testing" +) + +func TestDHCPv6Relay(t *testing.T) { + ll := net.IP{0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xaa, 0xbb, 0xcc, 0xff, 0xfe, 0xdd, 0xee, 0xff} + ma := net.IP{0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01} + d := DHCPv6Relay{ + messageType: RELAY_FORW, + hopCount: 10, + linkAddr: ll, + peerAddr: ma, + // options is left empty here for testing purposes, even if it's + // mandatory to have at least a relay message option + } + if mt := d.MessageType(); mt != RELAY_FORW { + t.Fatalf("Invalid message type. Expected %v, got %v", RELAY_FORW, mt) + } + if hc := d.HopCount(); hc != 10 { + t.Fatalf("Invalid hop count. Expected 10, got %v", hc) + } + if la := d.LinkAddr(); !bytes.Equal(la, ll) { + t.Fatalf("Invalid link address. Expected %v, got %v", ll, la) + } + if pa := d.PeerAddr(); !bytes.Equal(pa, ma) { + t.Fatalf("Invalid peer address. Expected %v, got %v", ma, pa) + } + if opts := d.Options(); len(opts) != 0 { + t.Fatalf("Invalid options. Expected none, got %v", opts) + } +} |