mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-07-04 12:31:39 +02:00
chainntnfs: extend interface test to ensure initial conf height is correct
This commit is contained in:
@ -2,7 +2,7 @@ package btcdnotify
|
|||||||
|
|
||||||
import "github.com/lightningnetwork/lnd/chainntnfs"
|
import "github.com/lightningnetwork/lnd/chainntnfs"
|
||||||
|
|
||||||
// confEntry represents an entry in the min-confirmation heap. .
|
// confEntry represents an entry in the min-confirmation heap.
|
||||||
type confEntry struct {
|
type confEntry struct {
|
||||||
*confirmationsNotification
|
*confirmationsNotification
|
||||||
|
|
||||||
@ -13,7 +13,7 @@ type confEntry struct {
|
|||||||
|
|
||||||
// confirmationHeap is a list of confEntries sorted according to nearest
|
// confirmationHeap is a list of confEntries sorted according to nearest
|
||||||
// "confirmation" height.Each entry within the min-confirmation heap is sorted
|
// "confirmation" height.Each entry within the min-confirmation heap is sorted
|
||||||
// according to the smallest dleta from the current blockheight to the
|
// according to the smallest delta from the current blockheight to the
|
||||||
// triggerHeight of the next entry confirmationHeap
|
// triggerHeight of the next entry confirmationHeap
|
||||||
type confirmationHeap struct {
|
type confirmationHeap struct {
|
||||||
items []*confEntry
|
items []*confEntry
|
||||||
|
@ -207,6 +207,8 @@ func testBatchConfirmationNotification(miner *rpctest.Harness,
|
|||||||
confIntents[i] = confIntent
|
confIntents[i] = confIntent
|
||||||
}
|
}
|
||||||
|
|
||||||
|
initialConfHeight := uint32(currentHeight + 1)
|
||||||
|
|
||||||
// Now, for each confirmation intent, generate the delta number of blocks
|
// Now, for each confirmation intent, generate the delta number of blocks
|
||||||
// needed to trigger the confirmation notification. A goroutine is
|
// needed to trigger the confirmation notification. A goroutine is
|
||||||
// spawned in order to verify the proper notification is triggered.
|
// spawned in order to verify the proper notification is triggered.
|
||||||
@ -233,7 +235,17 @@ func testBatchConfirmationNotification(miner *rpctest.Harness,
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case <-confSent:
|
case conf := <-confSent:
|
||||||
|
// All of the notifications above were originally
|
||||||
|
// confirmed in the same block. The returned
|
||||||
|
// notification should list the initial confirmation
|
||||||
|
// height rather than the height they were _fully_
|
||||||
|
// confirmed.
|
||||||
|
if conf.BlockHeight != initialConfHeight {
|
||||||
|
t.Fatalf("notification has incorrect initial "+
|
||||||
|
"conf height: expected %v, got %v",
|
||||||
|
initialConfHeight, conf.BlockHeight)
|
||||||
|
}
|
||||||
continue
|
continue
|
||||||
case <-time.After(20 * time.Second):
|
case <-time.After(20 * time.Second):
|
||||||
t.Fatalf("confirmation notification never received: %v", numConfs)
|
t.Fatalf("confirmation notification never received: %v", numConfs)
|
||||||
|
Reference in New Issue
Block a user