chainntnfs: add ChainNotifier test interface for test methods

TestChainNotifier wraps the ChainNotifier interface to allow adding additional testing methods with access to private fields in the notifiers. These testing methods are only compiled when the build tag "debug" is set. UnsafeStart allows starting a notifier with a specified best block.

UnsafeStart is useful for the purpose of testing cases where a notifier's best block is out of date when it receives a new block.
This commit is contained in:
Valentine Wallace committed 2018-08-11 22:45:03 -07:00
1 parent 79cbea1c9c
commit b3a5b3b576
4 files changed
+266

No files matched your search

+13
View File
@@ -0,0 +1,13 @@
package chainntnfs
import "github.com/btcsuite/btcd/chaincfg/chainhash"
// TestChainNotifier enables the use of methods that are only present during
// testing for ChainNotifiers.
type TestChainNotifier interface {
ChainNotifier
// UnsafeStart enables notifiers to start up with a specific best block.
// Used for testing.
UnsafeStart(int32, *chainhash.Hash, int32, func() error) error
}