peerdb_test.go 782 B

1234567891011121314151617181920212223242526272829303132
  1. //go:build linux
  2. package overlay
  3. import (
  4. "net"
  5. "testing"
  6. )
  7. func TestPeerMarshal(t *testing.T) {
  8. _, ipNet, _ := net.ParseCIDR("192.168.0.1/24")
  9. p := &peerEntry{
  10. eid: "eid",
  11. isLocal: true,
  12. peerIPMask: ipNet.Mask,
  13. vtep: ipNet.IP,
  14. }
  15. entryDB := p.MarshalDB()
  16. x := entryDB.UnMarshalDB()
  17. if x.eid != p.eid {
  18. t.Fatalf("Incorrect Unmarshalling for eid: %v != %v", x.eid, p.eid)
  19. }
  20. if x.isLocal != p.isLocal {
  21. t.Fatalf("Incorrect Unmarshalling for isLocal: %v != %v", x.isLocal, p.isLocal)
  22. }
  23. if x.peerIPMask.String() != p.peerIPMask.String() {
  24. t.Fatalf("Incorrect Unmarshalling for eid: %v != %v", x.peerIPMask, p.peerIPMask)
  25. }
  26. if x.vtep.String() != p.vtep.String() {
  27. t.Fatalf("Incorrect Unmarshalling for eid: %v != %v", x.vtep, p.vtep)
  28. }
  29. }