summaryrefslogtreecommitdiffhomepage
path: root/dhcpv6/option_iaprefix_test.go
diff options
context:
space:
mode:
authorChris Koch <chrisko@google.com>2019-12-28 06:30:10 -0800
committerChris K <c@chrisko.ch>2020-01-02 06:40:00 -0700
commit9a95b101e205d121810f3922999e1af1d39e4c43 (patch)
treea8e7787a32f68ba96ecea1eb1b9402bd8cfe86f6 /dhcpv6/option_iaprefix_test.go
parentb3fbc9f9fdd5ac725d73f2a9109e59d4947f067d (diff)
v6: use time.Duration for duration fields
Signed-off-by: Chris Koch <chrisko@google.com>
Diffstat (limited to 'dhcpv6/option_iaprefix_test.go')
-rw-r--r--dhcpv6/option_iaprefix_test.go17
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",
)
}