summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDennis Marttinen <twelho@welho.tech>2022-10-01 14:56:15 +0300
committerDennis Marttinen <twelho@welho.tech>2022-10-01 15:16:13 +0300
commitfd26ffdbe087ea69ccce6b043c1aedfc72a1c4dc (patch)
treed231bb056b8226178de13d6b9a75b98873e462b8
parent043f1726f02e2908b959423a0b95a9affdc08b73 (diff)
dhcpv4: add test for NewInform() with modifiers
`NewInform()` exposes a consumer-facing interface that accepts modifiers, but this functionality is never tested unlike with for example `NewRequest()` and `NewRenew()`. To ensure that modifiers are correctly respected and any future modifications won't break this support, add a modifier test for `NewInform()`. Signed-off-by: Dennis Marttinen <twelho@welho.tech>
-rw-r--r--dhcpv4/dhcpv4_test.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/dhcpv4/dhcpv4_test.go b/dhcpv4/dhcpv4_test.go
index eff7a71..d2d6edd 100644
--- a/dhcpv4/dhcpv4_test.go
+++ b/dhcpv4/dhcpv4_test.go
@@ -355,6 +355,16 @@ func TestNewInform(t *testing.T) {
require.True(t, m.ClientIPAddr.Equal(localIP))
}
+func TestDHCPv4NewInformWithModifier(t *testing.T) {
+ hwAddr := net.HardwareAddr{1, 2, 3, 4, 5, 6}
+ localIP := net.IPv4(10, 10, 11, 11)
+ serverID := net.IPv4(192, 168, 0, 1)
+ m, err := NewInform(hwAddr, localIP, WithOption(OptServerIdentifier(serverID)))
+
+ require.NoError(t, err)
+ require.True(t, serverID.Equal(m.ServerIdentifier()))
+}
+
func TestIsOptionRequested(t *testing.T) {
pkt, err := New()
require.NoError(t, err)