reinstate tagging (now protection) tests
This commit is contained in:
parent
44d9cb8639
commit
9a5528b3ec
|
@ -14,64 +14,55 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestTagTracerMeshTags(t *testing.T) {
|
func TestTagTracerMeshTags(t *testing.T) {
|
||||||
t.Skip("test disabled until we figure out an interface for getting protected peers from the connman")
|
|
||||||
|
|
||||||
// test that tags are applied when the tagTracer sees graft and prune events
|
// test that tags are applied when the tagTracer sees graft and prune events
|
||||||
|
|
||||||
// cmgr := connmgr.NewConnManager(5, 10, time.Minute)
|
cmgr := connmgr.NewConnManager(5, 10, time.Minute)
|
||||||
// tt := newTagTracer(cmgr)
|
tt := newTagTracer(cmgr)
|
||||||
|
|
||||||
// p := peer.ID("a-peer")
|
p := peer.ID("a-peer")
|
||||||
// topic := "a-topic"
|
topic := "a-topic"
|
||||||
|
|
||||||
// tt.Join(topic)
|
tt.Join(topic)
|
||||||
// tt.Graft(p, topic)
|
tt.Graft(p, topic)
|
||||||
|
|
||||||
// tag := "pubsub:" + topic
|
tag := "pubsub:" + topic
|
||||||
// val := getTagValue(cmgr, p, tag)
|
if !cmgr.IsProtected(p, tag) {
|
||||||
// if val != GossipSubConnTagValueMeshPeer {
|
t.Fatal("expected the mesh peer to be protected")
|
||||||
// t.Errorf("expected mesh peer to have tag %s with value %d, got %d",
|
}
|
||||||
// tag, GossipSubConnTagValueMeshPeer, val)
|
|
||||||
// }
|
|
||||||
|
|
||||||
// tt.Prune(p, topic)
|
tt.Prune(p, topic)
|
||||||
// val = getTagValue(cmgr, p, tag)
|
if cmgr.IsProtected(p, tag) {
|
||||||
// if val != 0 {
|
t.Fatal("expected the former mesh peer to be unprotected")
|
||||||
// t.Errorf("expected peer to be untagged when pruned from mesh, but tag %s was %d", tag, val)
|
}
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestTagTracerDirectPeerTags(t *testing.T) {
|
func TestTagTracerDirectPeerTags(t *testing.T) {
|
||||||
t.Skip("test disabled until we figure out an interface for getting protected peers from the connman")
|
// test that we add a tag to direct peers
|
||||||
|
cmgr := connmgr.NewConnManager(5, 10, time.Minute)
|
||||||
|
tt := newTagTracer(cmgr)
|
||||||
|
|
||||||
// // test that we add a tag to direct peers
|
p1 := peer.ID("1")
|
||||||
// cmgr := connmgr.NewConnManager(5, 10, time.Minute)
|
p2 := peer.ID("2")
|
||||||
// tt := newTagTracer(cmgr)
|
p3 := peer.ID("3")
|
||||||
|
|
||||||
// p1 := peer.ID("1")
|
// in the real world, tagTracer.direct is set in the WithDirectPeers option function
|
||||||
// p2 := peer.ID("2")
|
tt.direct = make(map[peer.ID]struct{})
|
||||||
// p3 := peer.ID("3")
|
tt.direct[p1] = struct{}{}
|
||||||
|
|
||||||
// // in the real world, tagTracer.direct is set in the WithDirectPeers option function
|
tt.AddPeer(p1, GossipSubID_v10)
|
||||||
// tt.direct = make(map[peer.ID]struct{})
|
tt.AddPeer(p2, GossipSubID_v10)
|
||||||
// tt.direct[p1] = struct{}{}
|
tt.AddPeer(p3, GossipSubID_v10)
|
||||||
|
|
||||||
// tt.AddPeer(p1, GossipSubID_v10)
|
tag := "pubsub:<direct>"
|
||||||
// tt.AddPeer(p2, GossipSubID_v10)
|
if !cmgr.IsProtected(p1, tag) {
|
||||||
// tt.AddPeer(p3, GossipSubID_v10)
|
t.Fatal("expected direct peer to be protected")
|
||||||
|
}
|
||||||
|
|
||||||
// tag := "pubsub:direct"
|
for _, p := range []peer.ID{p2, p3} {
|
||||||
// val := getTagValue(cmgr, p1, tag)
|
if cmgr.IsProtected(p, tag) {
|
||||||
// if val != GossipSubConnTagValueDirectPeer {
|
t.Fatal("expected non-direct peer to be unprotected")
|
||||||
// t.Errorf("expected direct peer to have tag %s value %d, was %d", tag, GossipSubConnTagValueDirectPeer, val)
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
// for _, p := range []peer.ID{p2, p3} {
|
|
||||||
// val := getTagValue(cmgr, p, tag)
|
|
||||||
// if val != 0 {
|
|
||||||
// t.Errorf("expected non-direct peer to have tag %s value %d, was %d", tag, 0, val)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestTagTracerDeliveryTags(t *testing.T) {
|
func TestTagTracerDeliveryTags(t *testing.T) {
|
||||||
|
|
Loading…
Reference in New Issue