diff --git a/itest/list_on_test.go b/itest/list_on_test.go index b0ab57774..851662f13 100644 --- a/itest/list_on_test.go +++ b/itest/list_on_test.go @@ -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 diff --git a/itest/lnd_misc_test.go b/itest/lnd_misc_test.go index 23112137d..30b6b77f7 100644 --- a/itest/lnd_misc_test.go +++ b/itest/lnd_misc_test.go @@ -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) + }) + } +}