Skip to content

Commit

Permalink
test(bitswap/message) no duplicates
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Tiger Chow committed Oct 27, 2014
1 parent 28db08d commit cc7ec0f
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions exchange/bitswap/message/message_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}

0 comments on commit cc7ec0f

Please sign in to comment.