mirror of
https://github.com/tailscale/tailscale.git
synced 2025-04-04 15:26:00 +00:00
33 lines
585 B
Go
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)
|
||
|
}
|
||
|
}
|