github.com/pwn-term/docker@v0.0.0-20210616085119-6e977cce2565/libnetwork/drivers/overlay/peerdb_test.go (about)

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