From 522537fb5eebceb57ed5f2b39101a854e97b4da9 Mon Sep 17 00:00:00 2001 From: Andrea Barberio Date: Sat, 23 Dec 2017 12:27:23 +0000 Subject: Added setters and getters for DHCPv6Relay and basic testing --- dhcpv6/dhcpv6relay_test.go | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 dhcpv6/dhcpv6relay_test.go (limited to 'dhcpv6/dhcpv6relay_test.go') 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) + } +} -- cgit v1.2.3