Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

utils/bag: print generic type for bag elements #1507

Merged
merged 9 commits into from
May 18, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix unique bag unit tests
Signed-off-by: Gyuho Lee <gyuho.lee@avalabs.org>
  • Loading branch information
gyuho committed May 15, 2023
commit 65000e1454a83873125ab3566dead42046338810
4 changes: 2 additions & 2 deletions snow/consensus/snowman/poll/early_term_no_traversal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ func TestEarlyTermNoTraversalString(t *testing.T) {

poll.Vote(vdr1, vtxID)

expected := `waiting on Bag: (Size = 1)
expected := `waiting on Bag[ids.ID]: (Size = 1)
NodeID-BaMPFdqMUQ46BV8iRcwbVfsam55kMqcp: 1
received Bag: (Size = 1)
received Bag[ids.ID]: (Size = 1)
SYXsAycDPUu4z2ZksJD5fh5nTDcH3vCFHnpcVye5XuJ2jArg: 1`
if result := poll.String(); expected != result {
t.Fatalf("Poll should have returned %s but returned %s", expected, result)
Expand Down
4 changes: 2 additions & 2 deletions snow/consensus/snowman/poll/no_early_term_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ func TestNoEarlyTermString(t *testing.T) {

poll.Vote(vdr1, vtxID)

expected := `waiting on Bag: (Size = 1)
expected := `waiting on Bag[ids.ID]: (Size = 1)
NodeID-BaMPFdqMUQ46BV8iRcwbVfsam55kMqcp: 1
received Bag: (Size = 1)
received Bag[ids.ID]: (Size = 1)
SYXsAycDPUu4z2ZksJD5fh5nTDcH3vCFHnpcVye5XuJ2jArg: 1`
if result := poll.String(); expected != result {
t.Fatalf("Poll should have returned %s but returned %s", expected, result)
Expand Down
4 changes: 2 additions & 2 deletions snow/consensus/snowman/poll/set_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,9 +316,9 @@ func TestSetString(t *testing.T) {

expected := `current polls: (Size = 1)
RequestID 0:
waiting on Bag: (Size = 1)
waiting on Bag[ids.NodeID]: (Size = 1)
NodeID-6HgC8KRBEhXYbF4riJyJFLSHt37UNuRt: 1
received Bag: (Size = 0)`
received Bag[ids.ID]: (Size = 0)`
if !s.Add(0, vdrs) {
t.Fatalf("Should have been able to add a new poll")
} else if str := s.String(); expected != str {
Expand Down
4 changes: 2 additions & 2 deletions utils/bag/unique_bag.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,10 @@ func (b *UniqueBag[T]) Bag(threshold int) Bag[T] {
return bag
}

func (b *UniqueBag[_]) PrefixedString(prefix string) string {
func (b *UniqueBag[T]) PrefixedString(prefix string) string {
sb := strings.Builder{}

sb.WriteString(fmt.Sprintf("UniqueBag: (Size = %d)", len(*b)))
sb.WriteString(fmt.Sprintf("UniqueBag[%T]: (Size = %d)", *new(T), len(*b)))
for key, set := range *b {
sb.WriteString(fmt.Sprintf("\n%s %v: %s", prefix, key, set))
}
Expand Down