-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #876 from sputn1ck/asset_loop_out_fixes
Minor asset loop out fixes
- Loading branch information
Showing
10 changed files
with
825 additions
and
413 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package assets | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/btcsuite/btcd/btcutil" | ||
"github.com/lightningnetwork/lnd/lnwire" | ||
) | ||
|
||
func TestGetPaymentMaxAmount(t *testing.T) { | ||
tests := []struct { | ||
satAmount btcutil.Amount | ||
feeLimitMultiplier float64 | ||
expectedAmount lnwire.MilliSatoshi | ||
expectError bool | ||
}{ | ||
{ | ||
satAmount: btcutil.Amount(250000), | ||
feeLimitMultiplier: 1.2, | ||
expectedAmount: lnwire.MilliSatoshi(300000000), | ||
expectError: false, | ||
}, | ||
{ | ||
satAmount: btcutil.Amount(100000), | ||
feeLimitMultiplier: 1.5, | ||
expectedAmount: lnwire.MilliSatoshi(150000000), | ||
expectError: false, | ||
}, | ||
{ | ||
satAmount: btcutil.Amount(50000), | ||
feeLimitMultiplier: 2.0, | ||
expectedAmount: lnwire.MilliSatoshi(100000000), | ||
expectError: false, | ||
}, | ||
{ | ||
satAmount: btcutil.Amount(0), | ||
feeLimitMultiplier: 1.2, | ||
expectedAmount: lnwire.MilliSatoshi(0), | ||
expectError: true, | ||
}, | ||
{ | ||
satAmount: btcutil.Amount(250000), | ||
feeLimitMultiplier: 0.8, | ||
expectedAmount: lnwire.MilliSatoshi(0), | ||
expectError: true, | ||
}, | ||
} | ||
|
||
for _, test := range tests { | ||
result, err := getPaymentMaxAmount( | ||
test.satAmount, test.feeLimitMultiplier, | ||
) | ||
if test.expectError { | ||
if err == nil { | ||
t.Fatalf("expected error but got none") | ||
} | ||
} else { | ||
if err != nil { | ||
t.Fatalf("unexpected error: %v", err) | ||
} | ||
if result != test.expectedAmount { | ||
t.Fatalf("expected %v, got %v", | ||
test.expectedAmount, result) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.