mirror of
https://github.com/getAlby/lndhub.go.git
synced 2025-12-20 14:14:47 +01:00
40 lines
797 B
Go
40 lines
797 B
Go
package service
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/getAlby/lndhub.go/db/models"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestCalcFeeWithInvoiceLessThan1000(t *testing.T) {
|
|
invoice := &models.Invoice{
|
|
Amount: 500,
|
|
}
|
|
|
|
feeLimit := calcFeeLimit(invoice)
|
|
expectedFee := int64(10)
|
|
assert.Equal(t, expectedFee, feeLimit.GetFixed())
|
|
}
|
|
|
|
func TestCalcFeeWithInvoiceEqualTo1000(t *testing.T) {
|
|
invoice := &models.Invoice{
|
|
Amount: 500,
|
|
}
|
|
|
|
feeLimit := calcFeeLimit(invoice)
|
|
expectedFee := int64(10)
|
|
assert.Equal(t, expectedFee, feeLimit.GetFixed())
|
|
}
|
|
|
|
func TestCalcFeeWithInvoiceMoreThan1000(t *testing.T) {
|
|
invoice := &models.Invoice{
|
|
Amount: 1500,
|
|
}
|
|
|
|
feeLimit := calcFeeLimit(invoice)
|
|
// 1500 * 0.01 + 1
|
|
expectedFee := int64(16)
|
|
assert.Equal(t, expectedFee, feeLimit.GetFixed())
|
|
}
|