Merge pull request #7531 from yyforyongyu/fix-web-fee-estimator

Fix web fee estimator test flake and increase retry timeout for channel close
This commit is contained in:
Oliver Gugger authored and GitHub committed 2023-03-22 20:56:49 +01:00
commit 78351e1730
2 files changed
+19 -19

No files matched your search

+1 -1
View File
@@ -1132,7 +1132,7 @@ func (h *HarnessTest) CloseChannelAssertPending(hn *node.HarnessNode,
// active htlcs` or `link failed to shutdown` if we close the // active htlcs` or `link failed to shutdown` if we close the
// channel. We need to investigate the order of settling the // channel. We need to investigate the order of settling the
// payments and updating commitments to properly fix it. // payments and updating commitments to properly fix it.
time.Sleep(2 * time.Second) time.Sleep(5 * time.Second)
// Give it another chance. // Give it another chance.
stream = hn.RPC.CloseChannel(closeReq) stream = hn.RPC.CloseChannel(closeReq)
+18 -18
View File
@@ -5,7 +5,6 @@ import (
"encoding/json" "encoding/json"
"io" "io"
"reflect" "reflect"
"strings"
"testing" "testing"
"github.com/btcsuite/btcd/btcutil" "github.com/btcsuite/btcd/btcutil"
@@ -204,6 +203,10 @@ func TestWebAPIFeeEstimator(t *testing.T) {
} }
// Construct mock fee source for the Estimator to pull fees from. // Construct mock fee source for the Estimator to pull fees from.
//
// This will create a `feeByBlockTarget` map with the following values,
// - 20: testFeeRate
// - 100: 42, which will be floored to feeFloor.
testFees := make(map[uint32]uint32) testFees := make(map[uint32]uint32)
for _, tc := range testCases { for _, tc := range testCases {
if tc.apiEst != 0 { if tc.apiEst != 0 {
@@ -233,25 +236,22 @@ func TestWebAPIFeeEstimator(t *testing.T) {
tc := tc tc := tc
t.Run(tc.name, func(t *testing.T) { t.Run(tc.name, func(t *testing.T) {
est, err := estimator.EstimateFeePerKW(tc.target) est, err := estimator.EstimateFeePerKW(tc.target)
if tc.err != "" {
if err == nil ||
!strings.Contains(err.Error(), tc.err) {
t.Fatalf("expected fee estimation to "+ // Test an error case.
"fail, instead got: %v", err) if tc.err != "" {
} require.Error(t, err, "expected error")
} else { require.ErrorContains(t, err, tc.err)
exp := SatPerKVByte(tc.est).FeePerKWeight()
if err != nil { return
t.Fatalf("unable to estimate fee for "+
"%v block target, got: %v",
tc.target, err)
}
if est != exp {
t.Fatalf("expected fee estimate of "+
"%v, got %v", exp, est)
}
} }
// Test an non-error case.
require.NoErrorf(t, err, "error from target %v",
tc.target)
exp := SatPerKVByte(tc.est).FeePerKWeight()
require.Equalf(t, exp, est, "target %v failed, fee "+
"map is %v", tc.target, feeSource.fees)
}) })
} }
} }