diff options
Diffstat (limited to 'dhcpv6/option_serverid_test.go')
-rw-r--r-- | dhcpv6/option_serverid_test.go | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/dhcpv6/option_serverid_test.go b/dhcpv6/option_serverid_test.go index 3422287..b0250c2 100644 --- a/dhcpv6/option_serverid_test.go +++ b/dhcpv6/option_serverid_test.go @@ -2,12 +2,31 @@ package dhcpv6 import ( "net" + "reflect" "testing" "github.com/insomniacslk/dhcp/iana" "github.com/stretchr/testify/require" ) +func TestParseMessageOptionsWithServerID(t *testing.T) { + buf := []byte{ + 0, 2, // Server ID option + 0, 10, // length + 0, 3, // DUID_LL + 0, 1, // hwtype ethernet + 0, 1, 2, 3, 4, 5, // HW addr + } + + want := &DUIDLL{HWType: iana.HWTypeEthernet, LinkLayerAddr: net.HardwareAddr{0, 1, 2, 3, 4, 5}} + var mo MessageOptions + if err := mo.FromBytes(buf); err != nil { + t.Errorf("FromBytes = %v", err) + } else if got := mo.ServerID(); !reflect.DeepEqual(got, want) { + t.Errorf("ServerID = %v, want %v", got, want) + } +} + func TestParseOptServerID(t *testing.T) { data := []byte{ 0, 3, // DUID_LL |