chainfee: make sure web API has been started before estimating

Previously we may get a floor feerate when calling `EstimateFeePerKW`
due to the fee estimator not finishing its startup process, which gives
us an empty fee map.

This is now fixed to return an error if the estimator is not started.
This commit is contained in:
yyforyongyu committed 2024-07-24 20:05:00 +08:00
1 parent 0a0d51ce22
commit 7e60d41898
2 files changed
+44 -26

No files matched your search

+4 -4
View File
@@ -252,12 +252,12 @@ func TestWebAPIFeeEstimator(t *testing.T) {
feeSource, false, minFeeUpdateTimeout, maxFeeUpdateTimeout,
)
// Test that requesting a fee when no fees have been cached won't fail.
// Test that when the estimator is not started, an error is returned.
feeRate, err := estimator.EstimateFeePerKW(5)
require.NoErrorf(t, err, "expected no error")
require.Equalf(t, FeePerKwFloor, feeRate, "expected fee rate floor "+
"returned when no cached fee rate found")
require.Error(t, err, "expected an error")
require.Zero(t, feeRate, "expected zero fee rate")
// Start the estimator.
require.NoError(t, estimator.Start(), "unable to start fee estimator")
for _, tc := range testCases {