diff --git a/snow/consensus/snowman/poll/early_term_no_traversal_test.go b/snow/consensus/snowman/poll/early_term_no_traversal_test.go index 63cca569543..875ad66cc92 100644 --- a/snow/consensus/snowman/poll/early_term_no_traversal_test.go +++ b/snow/consensus/snowman/poll/early_term_no_traversal_test.go @@ -57,9 +57,9 @@ func TestEarlyTermNoTraversalString(t *testing.T) { poll.Vote(vdr1, vtxID) - expected := `waiting on Bag: (Size = 1) + expected := `waiting on Bag[ids.NodeID]: (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) diff --git a/snow/consensus/snowman/poll/no_early_term_test.go b/snow/consensus/snowman/poll/no_early_term_test.go index fdc42a57bbc..a517af0bf46 100644 --- a/snow/consensus/snowman/poll/no_early_term_test.go +++ b/snow/consensus/snowman/poll/no_early_term_test.go @@ -53,9 +53,9 @@ func TestNoEarlyTermString(t *testing.T) { poll.Vote(vdr1, vtxID) - expected := `waiting on Bag: (Size = 1) + expected := `waiting on Bag[ids.NodeID]: (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) diff --git a/snow/consensus/snowman/poll/set_test.go b/snow/consensus/snowman/poll/set_test.go index 75d82355eec..cb9f4fa756c 100644 --- a/snow/consensus/snowman/poll/set_test.go +++ b/snow/consensus/snowman/poll/set_test.go @@ -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 { diff --git a/utils/bag/bag.go b/utils/bag/bag.go index cf889fa5a62..170f7e7ba08 100644 --- a/utils/bag/bag.go +++ b/utils/bag/bag.go @@ -9,6 +9,7 @@ import ( "golang.org/x/exp/maps" + "github.com/ava-labs/avalanchego/utils" "github.com/ava-labs/avalanchego/utils/set" ) @@ -154,10 +155,10 @@ func (b *Bag[T]) Remove(elt T) { b.size -= count } -func (b *Bag[_]) PrefixedString(prefix string) string { +func (b *Bag[T]) PrefixedString(prefix string) string { sb := strings.Builder{} - sb.WriteString(fmt.Sprintf("Bag: (Size = %d)", b.Len())) + sb.WriteString(fmt.Sprintf("Bag[%T]: (Size = %d)", utils.Zero[T](), b.Len())) for elt, count := range b.counts { sb.WriteString(fmt.Sprintf("\n%s %v: %d", prefix, elt, count)) } diff --git a/utils/bag/bag_test.go b/utils/bag/bag_test.go index 2f28f0f049d..ab37c5fd43b 100644 --- a/utils/bag/bag_test.go +++ b/utils/bag/bag_test.go @@ -152,7 +152,7 @@ func TestBagString(t *testing.T) { bag.AddCount(elt0, 1337) - expected := "Bag: (Size = 1337)\n" + + expected := "Bag[int]: (Size = 1337)\n" + " 123: 1337" require.Equal(t, expected, bag.String()) diff --git a/utils/bag/unique_bag.go b/utils/bag/unique_bag.go index debad45b3a7..751159f16d9 100644 --- a/utils/bag/unique_bag.go +++ b/utils/bag/unique_bag.go @@ -9,6 +9,7 @@ import ( "golang.org/x/exp/maps" + "github.com/ava-labs/avalanchego/utils" "github.com/ava-labs/avalanchego/utils/set" ) @@ -93,10 +94,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)", utils.Zero[T](), len(*b))) for key, set := range *b { sb.WriteString(fmt.Sprintf("\n%s %v: %s", prefix, key, set)) }