mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-02-22 14:22:37 +01:00
chainntnfs: fix testHistoricalConfDetailsTxIndex
Fix the following uint test flake, ``` --- FAIL: TestHistoricalConfDetailsTxIndex (0.00s) --- FAIL: TestHistoricalConfDetailsTxIndex/rpc_polling_enabled (1.16s) bitcoind_test.go:174: should have found the transaction within the mempool, but did not: TxNotFoundIndex FAIL ```
This commit is contained in:
parent
d8924d26ce
commit
1968034075
1 changed files with 16 additions and 11 deletions
|
@ -5,6 +5,7 @@ package bitcoindnotify
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"fmt"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -14,6 +15,7 @@ import (
|
||||||
"github.com/lightningnetwork/lnd/blockcache"
|
"github.com/lightningnetwork/lnd/blockcache"
|
||||||
"github.com/lightningnetwork/lnd/chainntnfs"
|
"github.com/lightningnetwork/lnd/chainntnfs"
|
||||||
"github.com/lightningnetwork/lnd/channeldb"
|
"github.com/lightningnetwork/lnd/channeldb"
|
||||||
|
"github.com/lightningnetwork/lnd/lntest/wait"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -162,18 +164,21 @@ func testHistoricalConfDetailsTxIndex(t *testing.T, rpcPolling bool) {
|
||||||
confReq, err := chainntnfs.NewConfRequest(txid, pkScript)
|
confReq, err := chainntnfs.NewConfRequest(txid, pkScript)
|
||||||
require.NoError(t, err, "unable to create conf request")
|
require.NoError(t, err, "unable to create conf request")
|
||||||
|
|
||||||
// The transaction should be found in the mempool at this point.
|
// The transaction should be found in the mempool at this point. We use
|
||||||
_, txStatus, err = notifier.historicalConfDetails(confReq, 0, 0)
|
// wait here to give miner some time to propagate the tx to our node.
|
||||||
require.NoError(t, err, "unable to retrieve historical conf details")
|
err = wait.NoError(func() error {
|
||||||
|
// The call should return no error.
|
||||||
|
_, txStatus, err = notifier.historicalConfDetails(confReq, 0, 0)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
// Since it has yet to be included in a block, it should have been found
|
if txStatus != chainntnfs.TxFoundMempool {
|
||||||
// within the mempool.
|
return fmt.Errorf("cannot the tx in mempool, status "+
|
||||||
switch txStatus {
|
"is: %v", txStatus)
|
||||||
case chainntnfs.TxFoundMempool:
|
}
|
||||||
default:
|
|
||||||
t.Fatalf("should have found the transaction within the "+
|
return nil
|
||||||
"mempool, but did not: %v", txStatus)
|
}, wait.DefaultTimeout)
|
||||||
}
|
require.NoError(t, err, "timeout waitinfg for historicalConfDetails")
|
||||||
|
|
||||||
if _, err := miner.Client.Generate(1); err != nil {
|
if _, err := miner.Client.Generate(1); err != nil {
|
||||||
t.Fatalf("unable to generate block: %v", err)
|
t.Fatalf("unable to generate block: %v", err)
|
||||||
|
|
Loading…
Add table
Reference in a new issue