Merge pull request #7242 from morehouse/itest_mining_patch
lntemp: after mining, sync to latest block
This commit is contained in:
3 files changed
+36
-2
No files matched your search
@@ -294,6 +294,7 @@ details. Along the way, several
|
|||||||
PRs([6776](https://github.com/lightningnetwork/lnd/pull/6776),
|
PRs([6776](https://github.com/lightningnetwork/lnd/pull/6776),
|
||||||
[6822](https://github.com/lightningnetwork/lnd/pull/6822),
|
[6822](https://github.com/lightningnetwork/lnd/pull/6822),
|
||||||
[7172](https://github.com/lightningnetwork/lnd/pull/7172),
|
[7172](https://github.com/lightningnetwork/lnd/pull/7172),
|
||||||
|
[7242](https://github.com/lightningnetwork/lnd/pull/7242),
|
||||||
[7245](https://github.com/lightningnetwork/lnd/pull/7245)) have been made to
|
[7245](https://github.com/lightningnetwork/lnd/pull/7245)) have been made to
|
||||||
refactor the itest for code health and maintenance.
|
refactor the itest for code health and maintenance.
|
||||||
|
|
||||||
|
|||||||
+4
-2
@@ -1291,7 +1291,8 @@ func (h *HarnessTest) MineBlocks(num uint32) []*wire.MsgBlock {
|
|||||||
blocks := h.Miner.MineBlocksSlow(num)
|
blocks := h.Miner.MineBlocksSlow(num)
|
||||||
|
|
||||||
// Make sure all the active nodes are synced.
|
// Make sure all the active nodes are synced.
|
||||||
h.AssertActiveNodesSynced()
|
bestBlock := blocks[len(blocks)-1]
|
||||||
|
h.AssertActiveNodesSyncedTo(bestBlock)
|
||||||
|
|
||||||
return blocks
|
return blocks
|
||||||
}
|
}
|
||||||
@@ -1318,7 +1319,8 @@ func (h *HarnessTest) MineBlocksAndAssertNumTxes(num uint32,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Finally, make sure all the active nodes are synced.
|
// Finally, make sure all the active nodes are synced.
|
||||||
h.AssertActiveNodesSynced()
|
bestBlock := blocks[len(blocks)-1]
|
||||||
|
h.AssertActiveNodesSyncedTo(bestBlock)
|
||||||
|
|
||||||
return blocks
|
return blocks
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,6 +39,29 @@ func (h *HarnessTest) WaitForBlockchainSync(hn *node.HarnessNode) {
|
|||||||
require.NoError(h, err, "timeout waiting for blockchain sync")
|
require.NoError(h, err, "timeout waiting for blockchain sync")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WaitForBlockchainSyncTo waits until the node is synced to bestBlock.
|
||||||
|
func (h *HarnessTest) WaitForBlockchainSyncTo(hn *node.HarnessNode,
|
||||||
|
bestBlock *wire.MsgBlock) {
|
||||||
|
|
||||||
|
bestBlockHash := bestBlock.BlockHash().String()
|
||||||
|
err := wait.NoError(func() error {
|
||||||
|
resp := hn.RPC.GetInfo()
|
||||||
|
if resp.SyncedToChain {
|
||||||
|
if resp.BlockHash == bestBlockHash {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return fmt.Errorf("%s's backend is synced to the "+
|
||||||
|
"wrong block (expected=%s, actual=%s)",
|
||||||
|
hn.Name(), bestBlockHash, resp.BlockHash)
|
||||||
|
}
|
||||||
|
|
||||||
|
return fmt.Errorf("%s is not synced to chain", hn.Name())
|
||||||
|
}, DefaultTimeout)
|
||||||
|
|
||||||
|
require.NoError(h, err, "timeout waiting for blockchain sync")
|
||||||
|
}
|
||||||
|
|
||||||
// AssertPeerConnected asserts that the given node b is connected to a.
|
// AssertPeerConnected asserts that the given node b is connected to a.
|
||||||
func (h *HarnessTest) AssertPeerConnected(a, b *node.HarnessNode) {
|
func (h *HarnessTest) AssertPeerConnected(a, b *node.HarnessNode) {
|
||||||
err := wait.NoError(func() error {
|
err := wait.NoError(func() error {
|
||||||
@@ -1324,6 +1347,14 @@ func (h *HarnessTest) AssertActiveNodesSynced() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AssertActiveNodesSyncedTo asserts all active nodes have synced to the
|
||||||
|
// provided bestBlock.
|
||||||
|
func (h *HarnessTest) AssertActiveNodesSyncedTo(bestBlock *wire.MsgBlock) {
|
||||||
|
for _, node := range h.manager.activeNodes {
|
||||||
|
h.WaitForBlockchainSyncTo(node, bestBlock)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// AssertPeerNotConnected asserts that the given node b is not connected to a.
|
// AssertPeerNotConnected asserts that the given node b is not connected to a.
|
||||||
func (h *HarnessTest) AssertPeerNotConnected(a, b *node.HarnessNode) {
|
func (h *HarnessTest) AssertPeerNotConnected(a, b *node.HarnessNode) {
|
||||||
err := wait.NoError(func() error {
|
err := wait.NoError(func() error {
|
||||||
|
|||||||
Reference in new issue
Block a user