Skip to content
This repository has been archived by the owner on Apr 2, 2024. It is now read-only.

Commit

Permalink
refactor(BUX-461): small changes after self-review
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-4chain authored and dorzepowski committed Jan 12, 2024
1 parent 5d8820b commit b166a27
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
3 changes: 1 addition & 2 deletions chainstate/broadcast_client_init.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ func (c *Client) broadcastClientInit(ctx context.Context) error {
Bytes: int(fee.MiningFee.Bytes),
}
}
lowest := utils.LowestFee(fees, c.options.config.feeUnit)
c.options.config.feeUnit = lowest
c.options.config.feeUnit = utils.LowestFee(fees, c.options.config.feeUnit)
}

return nil
Expand Down
2 changes: 1 addition & 1 deletion chainstate/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func NewClient(ctx context.Context, opts ...ClientOps) (ClientInterface, error)
case finalFeeUnit == nil:
return nil, errors.New("no fee unit found")
case finalFeeUnit.IsZero():
return nil, errors.New("fee unit suggests no fees (free)")
client.options.logger.Info().Msg("fee unit suggests no fees (free)")
default:
client.options.logger.Info().Msgf("using fee unit: %s", finalFeeUnit)
}
Expand Down
13 changes: 13 additions & 0 deletions utils/fees_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,19 @@ func TestIsLowerThan(t *testing.T) {
assert.True(t, one.IsLowerThan(&two))
assert.False(t, two.IsLowerThan(&one))
})

t.Run("zero as bytes in denominator", func(t *testing.T) {
one := FeeUnit{
Satoshis: 1,
Bytes: 0,
}
two := FeeUnit{
Satoshis: 2,
Bytes: 0,
}
assert.False(t, one.IsLowerThan(&two))
assert.False(t, two.IsLowerThan(&one))
})
}

func TestLowestFee(t *testing.T) {
Expand Down

0 comments on commit b166a27

Please sign in to comment.