tailscale/net/packet/geneve_test.go
Jordan Whited 8b1e7f646e
net/packet: implement Geneve header serialization (#15301)
Updates tailscale/corp#27100

Signed-off-by: Jordan Whited <jordan@tailscale.com>
2025-03-13 13:33:26 -07:00

33 lines
585 B
Go

// Copyright (c) Tailscale Inc & AUTHORS
// SPDX-License-Identifier: BSD-3-Clause
package packet
import (
"testing"
"github.com/google/go-cmp/cmp"
)
func TestGeneveHeader(t *testing.T) {
in := GeneveHeader{
Version: 3,
Protocol: GeneveProtocolDisco,
VNI: 1<<24 - 1,
Control: true,
}
b := make([]byte, GeneveFixedHeaderLength)
err := in.Encode(b)
if err != nil {
t.Fatal(err)
}
out := GeneveHeader{}
err = out.Decode(b)
if err != nil {
t.Fatal(err)
}
if diff := cmp.Diff(out, in); diff != "" {
t.Fatalf("wrong results (-got +want)\n%s", diff)
}
}