MCPcopy Create free account
hub / github.com/dadgar/onecache / TestContainsRemote

Function TestContainsRemote

onecache/onecache_rpc_test.go:73–96  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

71}
72
73func TestContainsRemote(t *testing.T) {
74 nodes, err := connectedTestNodes(2, 1)
75 defer tearDownNodes(nodes)
76 if err != nil {
77 t.Fatalf("connectedTestNodes(2, 1) failed: %v", err)
78 }
79
80 n1 := nodes[0]
81 n2 := nodes[1]
82
83 // Store a value on the second node
84 k := "foo"
85 if err := n2.data.Set(k, []byte("bar"), 0, 0); err != nil {
86 t.Fatalf("Set(%v) failed: %v", k, err)
87 }
88
89 var resp bool
90 args := StorageArgs{Key: k, ExplicitPeer: n2.name}
91 if err := n1.server.Contains(args, &resp); err != nil {
92 t.Errorf("Contains(%+v) returned an error %v", args, err)
93 } else if !resp {
94 t.Errorf("Contains(%+v) returned false; want true (%v)", args, resp)
95 }
96}
97
98func TestContainsRemoteInvalid(t *testing.T) {
99 nodes, err := connectedTestNodes(2, 1)

Callers

nothing calls this directly

Calls 4

connectedTestNodesFunction · 0.85
tearDownNodesFunction · 0.85
SetMethod · 0.45
ContainsMethod · 0.45

Tested by

no test coverage detected