test(bitswap/message) no duplicates
Brian Tiger Chow committed
Oct 27, 2014 at 06:31 UTC
91a31a3e7dc7a5b6ca2d85df7bf7d114bc94d7bc
1 file changed
+17
exchange/bitswap/message/message_test.go
+17
@@ -169,3 +169,20 @@ func contains(s []string, x string) bool {
169
}
170
return false
171
}
172
+
173
+func TestDuplicates(t *testing.T) {
174
+ b := blocks.NewBlock([]byte("foo"))
175
+ msg := New()
176
+
177
+ msg.AddWanted(b.Key())
178
+ msg.AddWanted(b.Key())
179
+ if len(msg.Wantlist()) != 1 {
180
+ t.Fatal("Duplicate in BitSwapMessage")
181
+ }
182
+
183
+ msg.AddBlock(*b)
184
+ msg.AddBlock(*b)
185
+ if len(msg.Blocks()) != 1 {
186
+ t.Fatal("Duplicate in BitSwapMessage")
187
+ }
188
+}