From 2ebc639426f6346fdc39e30d6b1834915c3659b2 Mon Sep 17 00:00:00 2001 From: Krzysztof Tomecki <152964795+chris-4chain@users.noreply.github.com> Date: Thu, 11 Jan 2024 09:47:59 +0100 Subject: [PATCH] fix(BUX-461): default fee --- chainstate/definitions.go | 2 +- go.mod | 2 ++ utils/fees_test.go | 38 ++++++++++++++++++++++++++------------ 3 files changed, 29 insertions(+), 13 deletions(-) diff --git a/chainstate/definitions.go b/chainstate/definitions.go index 072016d0..970dff97 100644 --- a/chainstate/definitions.go +++ b/chainstate/definitions.go @@ -56,7 +56,7 @@ const ( func DefaultFee() *utils.FeeUnit { return &utils.FeeUnit{ Satoshis: 1, - Bytes: 20, + Bytes: 1000, } } diff --git a/go.mod b/go.mod index a23a30ad..cb6c78fa 100644 --- a/go.mod +++ b/go.mod @@ -153,3 +153,5 @@ replace github.com/centrifugal/protocol => github.com/centrifugal/protocol v0.9. // Issue: go.mongodb.org/mongo-driver/x/bsonx: cannot find module providing package go.mongodb.org/mongo-driver/x/bsonx // Need to convert bsonx to bsoncore replace go.mongodb.org/mongo-driver => go.mongodb.org/mongo-driver v1.11.7 + +replace github.com/bitcoin-sv/go-broadcast-client => E:\Data\Source\4chain\go-broadcast-client diff --git a/utils/fees_test.go b/utils/fees_test.go index 4bad5063..721a7ccd 100644 --- a/utils/fees_test.go +++ b/utils/fees_test.go @@ -33,16 +33,30 @@ func TestGetOutputSizeForType(t *testing.T) { } func TestIsLowerThan(t *testing.T) { - one := FeeUnit{ - Satoshis: 1, - Bytes: 20, - } - two := FeeUnit{ - Satoshis: 2, - Bytes: 20, - } - assert.True(t, one.IsLowerThan(&two)) - assert.False(t, two.IsLowerThan(&one)) + t.Run("same satoshis, different bytes", func(t *testing.T) { + one := FeeUnit{ + Satoshis: 1, + Bytes: 1000, + } + two := FeeUnit{ + Satoshis: 1, + Bytes: 20, + } + assert.True(t, one.IsLowerThan(&two)) + assert.False(t, two.IsLowerThan(&one)) + }) + t.Run("same bytes, different satoshis", func(t *testing.T) { + one := FeeUnit{ + Satoshis: 1, + Bytes: 20, + } + two := FeeUnit{ + Satoshis: 2, + Bytes: 20, + } + assert.True(t, one.IsLowerThan(&two)) + assert.False(t, two.IsLowerThan(&one)) + }) } func TestLowestFee(t *testing.T) { @@ -87,8 +101,8 @@ func TestLowestFee(t *testing.T) { }) t.Run("lowest fee as defaultValue", func(t *testing.T) { - feeList, defaultFee := initTest() - feeList = []FeeUnit{} + _, defaultFee := initTest() + feeList := []FeeUnit{} assert.Equal(t, defaultFee, *LowestFee(feeList, &defaultFee)) }) }