snow: Add tests for Transitive.Shutdown()

This commit is contained in:
Alex Willmer 2020-04-09 00:27:35 +01:00
parent 540c826ec7
commit ce5bc64afa
2 changed files with 27 additions and 0 deletions

View File

@ -24,6 +24,22 @@ var (
errMissing = errors.New("missing")
)
func TestEngineShutdown(t *testing.T) {
config := DefaultConfig()
vmShutdownCalled := false
vm := &VMTest{}
vm.ShutdownF = func() { vmShutdownCalled = true }
config.VM = vm
transitive := &Transitive{}
transitive.Initialize(config)
transitive.finishBootstrapping()
transitive.Shutdown()
if !vmShutdownCalled {
t.Fatal("Shutting down the Transitive did not shutdown the VM")
}
}
func TestEngineAdd(t *testing.T) {
config := DefaultConfig()

View File

@ -64,6 +64,17 @@ func setup(t *testing.T) (validators.Validator, validators.Set, *common.SenderTe
return vdr, vals, sender, vm, te, gBlk
}
func TestEngineShutdown(t *testing.T) {
_, _, _, vm, transitive, _ := setup(t)
vmShutdownCalled := false
vm.ShutdownF = func() { vmShutdownCalled = true }
vm.CantShutdown = false
transitive.Shutdown()
if !vmShutdownCalled {
t.Fatal("Shutting down the Transitive did not shutdown the VM")
}
}
func TestEngineAdd(t *testing.T) {
vdr, _, sender, vm, te, _ := setup(t)