1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-06-29 17:36:38 +08:00

test(bitswap/message) no duplicates

This commit is contained in:
Brian Tiger Chow
2014-10-27 06:31:49 -07:00
parent cebeff43b9
commit 91a31a3e7d

View File

@ -169,3 +169,20 @@ func contains(s []string, x string) bool {
}
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")
}
}