Fixed platformvm locking

This commit is contained in:
StephenButtolph 2020-05-10 15:26:41 -04:00
parent 394441cbb4
commit ac27d66c02
1 changed files with 14 additions and 3 deletions

View File

@ -1271,6 +1271,8 @@ func TestRestartPartiallyAccepted(t *testing.T) {
firstVM.clock.Set(defaultGenesisTime)
firstCtx := defaultContext()
firstCtx.Lock.Lock()
firstMsgChan := make(chan common.Message, 1)
if err := firstVM.Initialize(firstCtx, db, genesisBytes, firstMsgChan, nil); err != nil {
t.Fatal(err)
@ -1318,6 +1320,7 @@ func TestRestartPartiallyAccepted(t *testing.T) {
}
firstVM.Shutdown()
firstCtx.Lock.Unlock()
secondVM := &VM{
SnowmanVM: &core.SnowmanVM{},
@ -1330,6 +1333,9 @@ func TestRestartPartiallyAccepted(t *testing.T) {
secondVM.clock.Set(defaultGenesisTime)
secondCtx := defaultContext()
secondCtx.Lock.Lock()
defer secondCtx.Lock.Unlock()
secondMsgChan := make(chan common.Message, 1)
if err := secondVM.Initialize(secondCtx, db, genesisBytes, secondMsgChan, nil); err != nil {
t.Fatal(err)
@ -1371,6 +1377,8 @@ func TestRestartFullyAccepted(t *testing.T) {
firstVM.clock.Set(defaultGenesisTime)
firstCtx := defaultContext()
firstCtx.Lock.Lock()
firstMsgChan := make(chan common.Message, 1)
if err := firstVM.Initialize(firstCtx, db, genesisBytes, firstMsgChan, nil); err != nil {
t.Fatal(err)
@ -1418,6 +1426,7 @@ func TestRestartFullyAccepted(t *testing.T) {
}
firstVM.Shutdown()
firstCtx.Lock.Unlock()
secondVM := &VM{
SnowmanVM: &core.SnowmanVM{},
@ -1430,6 +1439,9 @@ func TestRestartFullyAccepted(t *testing.T) {
secondVM.clock.Set(defaultGenesisTime)
secondCtx := defaultContext()
secondCtx.Lock.Lock()
defer secondCtx.Lock.Unlock()
secondMsgChan := make(chan common.Message, 1)
if err := secondVM.Initialize(secondCtx, db, genesisBytes, secondMsgChan, nil); err != nil {
t.Fatal(err)
@ -1471,7 +1483,6 @@ func TestBootstrapPartiallyAccepted(t *testing.T) {
SnowmanVM: &core.SnowmanVM{},
chainManager: chains.MockManager{},
}
defer vm.Shutdown()
defaultSubnet := validators.NewSet()
vm.validators = validators.NewManager()
@ -1479,9 +1490,9 @@ func TestBootstrapPartiallyAccepted(t *testing.T) {
vm.clock.Set(defaultGenesisTime)
ctx := defaultContext()
msgChan := make(chan common.Message, 1)
ctx.Lock.Lock()
msgChan := make(chan common.Message, 1)
if err := vm.Initialize(ctx, vmDB, genesisBytes, msgChan, nil); err != nil {
t.Fatal(err)
}