From a073d76979d1950a52462823c10b495f4f8c3728 Mon Sep 17 00:00:00 2001 From: Ghanan Gowripalan Date: Mon, 22 Mar 2021 12:30:03 -0700 Subject: Return tcpip.Error from (*Stack).GetMainNICAddress PiperOrigin-RevId: 364381970 --- pkg/tcpip/network/ipv6/ipv6_test.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'pkg/tcpip/network/ipv6') diff --git a/pkg/tcpip/network/ipv6/ipv6_test.go b/pkg/tcpip/network/ipv6/ipv6_test.go index 266a53e3b..81f5f23c3 100644 --- a/pkg/tcpip/network/ipv6/ipv6_test.go +++ b/pkg/tcpip/network/ipv6/ipv6_test.go @@ -343,6 +343,8 @@ func TestReceiveOnSolicitedNodeAddr(t *testing.T) { // TestAddIpv6Address tests adding IPv6 addresses. func TestAddIpv6Address(t *testing.T) { + const nicID = 1 + tests := []struct { name string addr tcpip.Address @@ -367,18 +369,18 @@ func TestAddIpv6Address(t *testing.T) { s := stack.New(stack.Options{ NetworkProtocols: []stack.NetworkProtocolFactory{NewProtocol}, }) - if err := s.CreateNIC(1, &stubLinkEndpoint{}); err != nil { - t.Fatalf("CreateNIC(_) = %s", err) + if err := s.CreateNIC(nicID, &stubLinkEndpoint{}); err != nil { + t.Fatalf("CreateNIC(%d, _) = %s", nicID, err) } - if err := s.AddAddress(1, ProtocolNumber, test.addr); err != nil { - t.Fatalf("AddAddress(_, %d, nil) = %s", ProtocolNumber, err) + if err := s.AddAddress(nicID, ProtocolNumber, test.addr); err != nil { + t.Fatalf("AddAddress(%d, %d, nil) = %s", nicID, ProtocolNumber, err) } - if addr, ok := s.GetMainNICAddress(1, header.IPv6ProtocolNumber); !ok { - t.Fatalf("got stack.GetMainNICAddress(1, %d) = (_, false), want = (_, true)", header.IPv6ProtocolNumber) + if addr, err := s.GetMainNICAddress(nicID, ProtocolNumber); err != nil { + t.Fatalf("stack.GetMainNICAddress(%d, %d): %s", nicID, ProtocolNumber, err) } else if addr.Address != test.addr { - t.Fatalf("got stack.GetMainNICAddress(1_, %d) = (%s, true), want = (%s, true)", header.IPv6ProtocolNumber, addr.Address, test.addr) + t.Fatalf("got stack.GetMainNICAddress(%d, %d) = %s, want = %s", nicID, ProtocolNumber, addr.Address, test.addr) } }) } -- cgit v1.2.3