mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-08 14:57:38 +02:00
Merge pull request #9885 from ffranr/sm-isrunning-unit-test
protofsm: exercise `StateMachine.IsRunning()` in unit test
This commit is contained in:
@@ -357,13 +357,26 @@ func TestStateMachineDaemonEvents(t *testing.T) {
|
|||||||
}
|
}
|
||||||
stateMachine := NewStateMachine(cfg)
|
stateMachine := NewStateMachine(cfg)
|
||||||
|
|
||||||
|
// Before we start up the state machine, we'll assert that the machine
|
||||||
|
// is not running.
|
||||||
|
require.False(t, stateMachine.IsRunning())
|
||||||
|
|
||||||
// As we're triggering internal events, we'll also subscribe to the set
|
// As we're triggering internal events, we'll also subscribe to the set
|
||||||
// of new states so we can assert as we go.
|
// of new states so we can assert as we go.
|
||||||
stateSub := stateMachine.RegisterStateEvents()
|
stateSub := stateMachine.RegisterStateEvents()
|
||||||
defer stateMachine.RemoveStateSub(stateSub)
|
defer stateMachine.RemoveStateSub(stateSub)
|
||||||
|
|
||||||
stateMachine.Start(ctx)
|
stateMachine.Start(ctx)
|
||||||
defer stateMachine.Stop()
|
defer func() {
|
||||||
|
stateMachine.Stop()
|
||||||
|
|
||||||
|
// After we stop the state machine, we expect it to no longer be
|
||||||
|
// running.
|
||||||
|
require.False(t, stateMachine.IsRunning())
|
||||||
|
}()
|
||||||
|
|
||||||
|
// The state machine should now be running.
|
||||||
|
require.True(t, stateMachine.IsRunning())
|
||||||
|
|
||||||
// As soon as we send in the daemon event, we expect the
|
// As soon as we send in the daemon event, we expect the
|
||||||
// disable+broadcast events to be processed, as they are unconditional.
|
// disable+broadcast events to be processed, as they are unconditional.
|
||||||
|
Reference in New Issue
Block a user