itest: add test for walletrpc.EstimateFee

Make sure conf_target=1 is accepted, but conf_target=0 is not.
This commit is contained in:
Boris Nagaev
2025-07-17 11:19:41 -03:00
parent b0e9a4b79f
commit cd6e648a7f
2 changed files with 51 additions and 0 deletions

View File

@@ -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

View File

@@ -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)
})
}
}