clock.go 656 B

12345678910111213141516171819202122232425262728293031
  1. // NOTE: forcetypeassert is skipped for the mock because the test would fail if
  2. // the returned value doesn't match the type.
  3. package lnmock
  4. import (
  5. "time"
  6. "github.com/lightningnetwork/lnd/clock"
  7. "github.com/stretchr/testify/mock"
  8. )
  9. // MockClock implements the `clock.Clock` interface.
  10. type MockClock struct {
  11. mock.Mock
  12. }
  13. // Compile time assertion that MockClock implements clock.Clock.
  14. var _ clock.Clock = (*MockClock)(nil)
  15. func (m *MockClock) Now() time.Time {
  16. args := m.Called()
  17. return args.Get(0).(time.Time)
  18. }
  19. func (m *MockClock) TickAfter(d time.Duration) <-chan time.Time {
  20. args := m.Called(d)
  21. return args.Get(0).(chan time.Time)
  22. }