mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-02-22 22:25:24 +01:00
This commit adds two methods to handle dispatching beats. These are exported methods so other systems can send beats to their managed subinstances.
50 lines
1.2 KiB
Go
50 lines
1.2 KiB
Go
package chainio
|
|
|
|
import (
|
|
"github.com/btcsuite/btclog/v2"
|
|
"github.com/stretchr/testify/mock"
|
|
)
|
|
|
|
// MockConsumer is a mock implementation of the Consumer interface.
|
|
type MockConsumer struct {
|
|
mock.Mock
|
|
}
|
|
|
|
// Compile-time constraint to ensure MockConsumer implements Consumer.
|
|
var _ Consumer = (*MockConsumer)(nil)
|
|
|
|
// Name returns a human-readable string for this subsystem.
|
|
func (m *MockConsumer) Name() string {
|
|
args := m.Called()
|
|
return args.String(0)
|
|
}
|
|
|
|
// ProcessBlock takes a blockbeat and processes it. A receive-only error chan
|
|
// must be returned.
|
|
func (m *MockConsumer) ProcessBlock(b Blockbeat) error {
|
|
args := m.Called(b)
|
|
|
|
return args.Error(0)
|
|
}
|
|
|
|
// MockBlockbeat is a mock implementation of the Blockbeat interface.
|
|
type MockBlockbeat struct {
|
|
mock.Mock
|
|
}
|
|
|
|
// Compile-time constraint to ensure MockBlockbeat implements Blockbeat.
|
|
var _ Blockbeat = (*MockBlockbeat)(nil)
|
|
|
|
// Height returns the current block height.
|
|
func (m *MockBlockbeat) Height() int32 {
|
|
args := m.Called()
|
|
|
|
return args.Get(0).(int32)
|
|
}
|
|
|
|
// logger returns the logger for the blockbeat.
|
|
func (m *MockBlockbeat) logger() btclog.Logger {
|
|
args := m.Called()
|
|
|
|
return args.Get(0).(btclog.Logger)
|
|
}
|