Skip to content

Commit

Permalink
Add minssing Prefix Information test
Browse files Browse the repository at this point in the history
Signed-off-by: Yutaro Hayakawa <[email protected]>
  • Loading branch information
YutaroHayakawa committed May 20, 2024
1 parent 8c8382c commit d4c4062
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions daemon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,15 @@ func TestDaemonHappyPath(t *testing.T) {
ReachableTimeMilliseconds: 10000,
RetransmitTimeMilliseconds: 10000,
MTU: 1500,
Prefixes: []*PrefixConfig{
{
Prefix: "fd00::/64",
OnLink: true,
Autonomous: true,
PreferredLifetimeSeconds: ptr.To(100),
ValidLifetimeSeconds: ptr.To(200),
},
},
Routes: []*RouteConfig{
{
Prefix: "2001:db8::/64",
Expand Down Expand Up @@ -143,6 +152,22 @@ func TestDaemonHappyPath(t *testing.T) {
require.NotNil(t, mtuOption, "MTU option is not advertised")
require.Equal(t, uint32(1500), mtuOption.MTU, "Invalid MTU")

// Find and check Prefix Information options
prefixOptions := map[netip.Addr]*ndp.PrefixInformation{}
for _, option := range ra.msg.Options {
if opt, ok := option.(*ndp.PrefixInformation); ok {
prefixOptions[opt.Prefix] = opt
}
}
prefix := netip.MustParseAddr("fd00::")
require.Contains(t, prefixOptions, prefix)
prefixInfo := prefixOptions[prefix]
require.Equal(t, uint8(64), prefixInfo.PrefixLength)
require.True(t, prefixInfo.OnLink)
require.True(t, prefixInfo.AutonomousAddressConfiguration)
require.Equal(t, time.Second*100, prefixInfo.PreferredLifetime)
require.Equal(t, time.Second*200, prefixInfo.ValidLifetime)

// Find and check Route Information options
routeOptions := map[netip.Addr]*ndp.RouteInformation{}
for _, option := range ra.msg.Options {
Expand Down

0 comments on commit d4c4062

Please sign in to comment.