Commit f758e76d authored by Brian Tiger Chow's avatar Brian Tiger Chow

test(bitswap/message) no duplicates

parent 8cd17e8d
...@@ -169,3 +169,20 @@ func contains(s []string, x string) bool { ...@@ -169,3 +169,20 @@ func contains(s []string, x string) bool {
} }
return false return false
} }
func TestDuplicates(t *testing.T) {
b := blocks.NewBlock([]byte("foo"))
msg := New()
msg.AddWanted(b.Key())
msg.AddWanted(b.Key())
if len(msg.Wantlist()) != 1 {
t.Fatal("Duplicate in BitSwapMessage")
}
msg.AddBlock(*b)
msg.AddBlock(*b)
if len(msg.Blocks()) != 1 {
t.Fatal("Duplicate in BitSwapMessage")
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment