mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-27 06:01:48 +02:00
itest: add test for walletrpc.EstimateFee
Make sure conf_target=1 is accepted, but conf_target=0 is not.
This commit is contained in:
@@ -731,6 +731,10 @@ var allTestCases = []*lntest.TestCase{
|
||||
Name: "delete canceled invoice",
|
||||
TestFunc: testDeleteCanceledInvoice,
|
||||
},
|
||||
{
|
||||
Name: "estimate fee",
|
||||
TestFunc: testEstimateFee,
|
||||
},
|
||||
}
|
||||
|
||||
// appendPrefixed is used to add a prefix to each test name in the subtests
|
||||
|
@@ -5,6 +5,7 @@ import (
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/btcsuite/btcd/btcutil"
|
||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||
@@ -1593,3 +1594,49 @@ func testReorgNotifications(ht *lntest.HarnessTest) {
|
||||
require.NotNil(ht, spendDetails)
|
||||
require.Equal(ht, txid2a[:], spendDetails.SpendingTxHash)
|
||||
}
|
||||
|
||||
// testEstimateFee tests walletrpc.EstimateFee API.
|
||||
func testEstimateFee(ht *lntest.HarnessTest) {
|
||||
alice := ht.NewNode("Alice", nil)
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
confTarget int32
|
||||
errContains string
|
||||
}{
|
||||
{
|
||||
name: "conf target 1",
|
||||
confTarget: 1,
|
||||
},
|
||||
{
|
||||
name: "conf target 0",
|
||||
confTarget: 0,
|
||||
errContains: "must be greater than 0",
|
||||
},
|
||||
{
|
||||
name: "conf target -1",
|
||||
confTarget: -1,
|
||||
errContains: "must be greater than 0",
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
ht.Run(tc.name, func(t *testing.T) {
|
||||
req := &walletrpc.EstimateFeeRequest{
|
||||
ConfTarget: tc.confTarget,
|
||||
}
|
||||
resp, err := alice.RPC.WalletKit.EstimateFee(ctx, req)
|
||||
|
||||
if tc.errContains != "" {
|
||||
require.ErrorContains(t, err, tc.errContains)
|
||||
return
|
||||
}
|
||||
|
||||
require.NoError(t, err)
|
||||
require.NotZero(t, resp.SatPerKw)
|
||||
require.NotZero(t, resp.MinRelayFeeSatPerKw)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user