mirror of
https://github.com/lightningnetwork/lnd.git
synced 2024-11-19 01:43:16 +01:00
7dfe4018ce
This commit was previously split into the following parts to ease review: - 2d746f68: replace imports - 4008f0fd: use ecdsa.Signature - 849e33d1: remove btcec.S256() - b8f6ebbd: use v2 library correctly - fa80bca9: bump go modules
51 lines
846 B
Go
51 lines
846 B
Go
package autopilot_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/btcsuite/btcd/btcutil"
|
|
"github.com/lightningnetwork/lnd/autopilot"
|
|
)
|
|
|
|
// TestMedian tests the Median method.
|
|
func TestMedian(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
testCases := []struct {
|
|
values []btcutil.Amount
|
|
median btcutil.Amount
|
|
}{
|
|
{
|
|
values: []btcutil.Amount{},
|
|
median: 0,
|
|
},
|
|
{
|
|
values: []btcutil.Amount{10},
|
|
median: 10,
|
|
},
|
|
{
|
|
values: []btcutil.Amount{10, 20},
|
|
median: 15,
|
|
},
|
|
{
|
|
values: []btcutil.Amount{10, 20, 30},
|
|
median: 20,
|
|
},
|
|
{
|
|
values: []btcutil.Amount{30, 10, 20},
|
|
median: 20,
|
|
},
|
|
{
|
|
values: []btcutil.Amount{10, 10, 10, 10, 5000000},
|
|
median: 10,
|
|
},
|
|
}
|
|
|
|
for _, test := range testCases {
|
|
res := autopilot.Median(test.values)
|
|
if res != test.median {
|
|
t.Fatalf("expected median %v, got %v", test.median, res)
|
|
}
|
|
}
|
|
}
|