Skip to content

Commit fc083ed

Browse files
authored
Merge pull request #775 from rsksmart/fix-GBI-2658
feat: Improved FeeRate Logging | GBI-2658
2 parents 7dac57d + 54a64aa commit fc083ed

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

internal/entities/utils/encoding.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func (bf *BigFloat) UnmarshalBSONValue(bsonType bsontype.Type, bytes []byte) err
6666
}
6767

6868
func (bf *BigFloat) String() string {
69-
return bf.Native().String()
69+
return bf.Native().Text('f', -1)
7070
}
7171

7272
func DecodeKey(key string, expectedBytes int) ([]byte, error) {

internal/entities/utils/encoding_test.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package utils_test
22

33
import (
4+
"fmt"
45
"math"
56
"math/big"
67
"reflect"
@@ -163,6 +164,20 @@ func TestNewBigFloat64(t *testing.T) {
163164
}
164165
}
165166

167+
func TestBigFloat_StringFormatsFixedPoint(t *testing.T) {
168+
bf := utils.NewBigFloat64(0.000012)
169+
expected := "0.000012"
170+
require.Equal(t, expected, bf.String())
171+
}
172+
173+
func TestStructFormatting_UsesFixedPoint(t *testing.T) {
174+
type sample struct {
175+
FeeRate *utils.BigFloat
176+
}
177+
payload := sample{FeeRate: utils.NewBigFloat64(0.000012)}
178+
formatted := fmt.Sprintf("%+v", payload)
179+
require.Contains(t, formatted, "FeeRate:0.000012")
180+
}
166181
func TestBigFloat_Native(t *testing.T) {
167182
tests := []struct {
168183
name string

0 commit comments

Comments
 (0)