diff options
Diffstat (limited to 'dhcpv6/option_iaprefix_test.go')
-rw-r--r-- | dhcpv6/option_iaprefix_test.go | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/dhcpv6/option_iaprefix_test.go b/dhcpv6/option_iaprefix_test.go index 6a98b8b..7a24d2b 100644 --- a/dhcpv6/option_iaprefix_test.go +++ b/dhcpv6/option_iaprefix_test.go @@ -4,6 +4,7 @@ import ( "bytes" "net" "testing" + "time" "github.com/stretchr/testify/require" ) @@ -20,10 +21,10 @@ func TestOptIAPrefix(t *testing.T) { if err != nil { t.Fatal(err) } - if pl := opt.PreferredLifetime; pl != 0xaabbccdd { + if pl := opt.PreferredLifetime; pl != 0xaabbccdd*time.Second { t.Fatalf("Invalid Preferred Lifetime. Expected 0xaabbccdd, got %v", pl) } - if vl := opt.ValidLifetime; vl != 0xeeff0011 { + if vl := opt.ValidLifetime; vl != 0xeeff0011*time.Second { t.Fatalf("Invalid Valid Lifetime. Expected 0xeeff0011, got %v", vl) } if pr := opt.PrefixLength(); pr != 36 { @@ -43,8 +44,8 @@ func TestOptIAPrefixToBytes(t *testing.T) { 0, 8, 0, 2, 0xaa, 0xbb, // options } opt := OptIAPrefix{ - PreferredLifetime: 0xaabbccdd, - ValidLifetime: 0xeeff0011, + PreferredLifetime: 0xaabbccdd * time.Second, + ValidLifetime: 0xeeff0011 * time.Second, prefixLength: 36, ipv6Prefix: net.IPv6zero, } @@ -69,8 +70,8 @@ func TestOptIAPrefixParseInvalidTooShort(t *testing.T) { func TestOptIAPrefixString(t *testing.T) { buf := []byte{ - 0xaa, 0xbb, 0xcc, 0xdd, // preferredLifetime - 0xee, 0xff, 0x00, 0x11, // validLifetime + 0x00, 0x00, 0x00, 60, // preferredLifetime + 0x00, 0x00, 0x00, 50, // validLifetime 36, // prefixLength 0x20, 0x01, 0x0d, 0xb8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // ipv6Prefix } @@ -85,12 +86,12 @@ func TestOptIAPrefixString(t *testing.T) { ) require.Contains( t, str, - "preferredlifetime=2864434397", + "preferredlifetime=1m", "String() should return the preferredlifetime", ) require.Contains( t, str, - "validlifetime=4009689105", + "validlifetime=50s", "String() should return the validlifetime", ) } |