File: peerdb_test.go

package info (click to toggle)
docker.io 26.1.5%2Bdfsg1-9
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 68,576 kB
  • sloc: sh: 5,748; makefile: 912; ansic: 664; asm: 228; python: 162
file content (32 lines) | stat: -rw-r--r-- 782 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
//go:build linux

package overlay

import (
	"net"
	"testing"
)

func TestPeerMarshal(t *testing.T) {
	_, ipNet, _ := net.ParseCIDR("192.168.0.1/24")
	p := &peerEntry{
		eid:        "eid",
		isLocal:    true,
		peerIPMask: ipNet.Mask,
		vtep:       ipNet.IP,
	}
	entryDB := p.MarshalDB()
	x := entryDB.UnMarshalDB()
	if x.eid != p.eid {
		t.Fatalf("Incorrect Unmarshalling for eid: %v != %v", x.eid, p.eid)
	}
	if x.isLocal != p.isLocal {
		t.Fatalf("Incorrect Unmarshalling for isLocal: %v != %v", x.isLocal, p.isLocal)
	}
	if x.peerIPMask.String() != p.peerIPMask.String() {
		t.Fatalf("Incorrect Unmarshalling for eid: %v != %v", x.peerIPMask, p.peerIPMask)
	}
	if x.vtep.String() != p.vtep.String() {
		t.Fatalf("Incorrect Unmarshalling for eid: %v != %v", x.vtep, p.vtep)
	}
}