diff --git a/vms/platformvm/block/builder/builder_test.go b/vms/platformvm/block/builder/builder_test.go index da36c61cc1a1..19d00acf110d 100644 --- a/vms/platformvm/block/builder/builder_test.go +++ b/vms/platformvm/block/builder/builder_test.go @@ -32,8 +32,10 @@ func TestBuildBlockBasic(t *testing.T) { require := require.New(t) env := newEnvironment(t) + env.ctx.Lock.Lock() defer func() { require.NoError(shutdownEnvironment(env)) + env.ctx.Lock.Unlock() }() // Create a valid transaction @@ -50,13 +52,12 @@ func TestBuildBlockBasic(t *testing.T) { txID := tx.ID() // Issue the transaction + env.ctx.Lock.Unlock() require.NoError(env.network.IssueTx(context.Background(), tx)) + env.ctx.Lock.Lock() _, ok := env.mempool.Get(txID) require.True(ok) - env.ctx.Lock.Lock() - defer env.ctx.Lock.Unlock() - // [BuildBlock] should build a block with the transaction blkIntf, err := env.Builder.BuildBlock(context.Background()) require.NoError(err) @@ -96,8 +97,10 @@ func TestBuildBlockShouldReward(t *testing.T) { require := require.New(t) env := newEnvironment(t) + env.ctx.Lock.Lock() defer func() { require.NoError(shutdownEnvironment(env)) + env.ctx.Lock.Unlock() }() var ( @@ -124,13 +127,12 @@ func TestBuildBlockShouldReward(t *testing.T) { txID := tx.ID() // Issue the transaction + env.ctx.Lock.Unlock() require.NoError(env.network.IssueTx(context.Background(), tx)) + env.ctx.Lock.Lock() _, ok := env.mempool.Get(txID) require.True(ok) - env.ctx.Lock.Lock() - defer env.ctx.Lock.Unlock() - // Build and accept a block with the tx blk, err := env.Builder.BuildBlock(context.Background()) require.NoError(err) @@ -231,8 +233,10 @@ func TestBuildBlockForceAdvanceTime(t *testing.T) { require := require.New(t) env := newEnvironment(t) + env.ctx.Lock.Lock() defer func() { require.NoError(shutdownEnvironment(env)) + env.ctx.Lock.Unlock() }() // Create a valid transaction @@ -249,13 +253,12 @@ func TestBuildBlockForceAdvanceTime(t *testing.T) { txID := tx.ID() // Issue the transaction + env.ctx.Lock.Unlock() require.NoError(env.network.IssueTx(context.Background(), tx)) + env.ctx.Lock.Lock() _, ok := env.mempool.Get(txID) require.True(ok) - env.ctx.Lock.Lock() - defer env.ctx.Lock.Unlock() - var ( now = env.backend.Clk.Time() nextTime = now.Add(2 * txexecutor.SyncBound) @@ -492,7 +495,9 @@ func TestPreviouslyDroppedTxsCanBeReAddedToMempool(t *testing.T) { txID := tx.ID() // Issue the transaction + env.ctx.Lock.Unlock() require.NoError(env.network.IssueTx(context.Background(), tx)) + env.ctx.Lock.Lock() _, ok := env.mempool.Get(txID) require.True(ok) @@ -514,7 +519,9 @@ func TestPreviouslyDroppedTxsCanBeReAddedToMempool(t *testing.T) { env.mempool.Remove(tx) // Issue the transaction again + env.ctx.Lock.Unlock() require.NoError(env.network.IssueTx(context.Background(), tx)) + env.ctx.Lock.Lock() _, ok = env.mempool.Get(txID) require.True(ok) diff --git a/vms/platformvm/service_test.go b/vms/platformvm/service_test.go index d6d96e66df41..f8394003f044 100644 --- a/vms/platformvm/service_test.go +++ b/vms/platformvm/service_test.go @@ -235,15 +235,16 @@ func TestGetTxStatus(t *testing.T) { require.Equal(status.Unknown, resp.Status) require.Zero(resp.Reason) - service.vm.ctx.Lock.Lock() - // put the chain in existing chain list err = service.vm.Network.IssueTx(context.Background(), tx) require.ErrorIs(err, database.ErrNotFound) // Missing shared memory UTXO + service.vm.ctx.Lock.Lock() mutableSharedMemory.SharedMemory = sm + service.vm.ctx.Lock.Unlock() require.NoError(service.vm.Network.IssueTx(context.Background(), tx)) + service.vm.ctx.Lock.Lock() block, err := service.vm.BuildBlock(context.Background()) require.NoError(err) @@ -337,10 +338,9 @@ func TestGetTx(t *testing.T) { err = service.GetTx(nil, arg, &response) require.ErrorIs(err, database.ErrNotFound) // We haven't issued the tx yet - service.vm.ctx.Lock.Lock() - require.NoError(service.vm.Network.IssueTx(context.Background(), tx)) + service.vm.ctx.Lock.Lock() blk, err := service.vm.BuildBlock(context.Background()) require.NoError(err) diff --git a/vms/platformvm/validator_set_property_test.go b/vms/platformvm/validator_set_property_test.go index 5eff65b68729..c2bf7d4a2755 100644 --- a/vms/platformvm/validator_set_property_test.go +++ b/vms/platformvm/validator_set_property_test.go @@ -291,7 +291,14 @@ func addSubnetValidator(vm *VM, data *validatorInputData, subnetID ids.ID) (*sta if err != nil { return nil, fmt.Errorf("could not create AddSubnetValidatorTx: %w", err) } - return internalAddValidator(vm, signedTx) + + vm.ctx.Lock.Unlock() + if err := vm.Network.IssueTx(context.Background(), signedTx); err != nil { + return nil, fmt.Errorf("could not add tx to mempool: %w", err) + } + vm.ctx.Lock.Lock() + + return acceptBlockWithTx(vm, signedTx) } func addPrimaryValidatorWithBLSKey(vm *VM, data *validatorInputData) (*state.Staker, error) { @@ -351,7 +358,14 @@ func addPrimaryValidatorWithBLSKey(vm *VM, data *validatorInputData) (*state.Sta if err := signedTx.SyntacticVerify(vm.ctx); err != nil { return nil, fmt.Errorf("failed syntax verification of AddPermissionlessValidatorTx: %w", err) } - return internalAddValidator(vm, signedTx) + + vm.ctx.Lock.Unlock() + if err := vm.Network.IssueTx(context.Background(), signedTx); err != nil { + return nil, fmt.Errorf("could not add tx to mempool: %w", err) + } + vm.ctx.Lock.Lock() + + return acceptBlockWithTx(vm, signedTx) } func addPrimaryValidatorWithoutBLSKey(vm *VM, data *validatorInputData) (*state.Staker, error) { @@ -369,14 +383,17 @@ func addPrimaryValidatorWithoutBLSKey(vm *VM, data *validatorInputData) (*state. if err != nil { return nil, fmt.Errorf("could not create AddValidatorTx: %w", err) } - return internalAddValidator(vm, signedTx) -} -func internalAddValidator(vm *VM, signedTx *txs.Tx) (*state.Staker, error) { + vm.ctx.Lock.Unlock() if err := vm.Network.IssueTx(context.Background(), signedTx); err != nil { return nil, fmt.Errorf("could not add tx to mempool: %w", err) } + vm.ctx.Lock.Lock() + + return acceptBlockWithTx(vm, signedTx) +} +func acceptBlockWithTx(vm *VM, signedTx *txs.Tx) (*state.Staker, error) { blk, err := vm.Builder.BuildBlock(context.Background()) if err != nil { return nil, fmt.Errorf("failed building block: %w", err) @@ -783,9 +800,11 @@ func buildVM(t *testing.T) (*VM, ids.ID, error) { if err != nil { return nil, ids.Empty, err } + vm.ctx.Lock.Unlock() if err := vm.Network.IssueTx(context.Background(), testSubnet1); err != nil { return nil, ids.Empty, err } + vm.ctx.Lock.Lock() blk, err := vm.Builder.BuildBlock(context.Background()) if err != nil { diff --git a/vms/platformvm/vm_regression_test.go b/vms/platformvm/vm_regression_test.go index cfc0b20329ca..40c0a6b5cb29 100644 --- a/vms/platformvm/vm_regression_test.go +++ b/vms/platformvm/vm_regression_test.go @@ -73,7 +73,9 @@ func TestAddDelegatorTxOverDelegatedRegression(t *testing.T) { require.NoError(err) // trigger block creation + vm.ctx.Lock.Unlock() require.NoError(vm.Network.IssueTx(context.Background(), addValidatorTx)) + vm.ctx.Lock.Lock() addValidatorBlock, err := vm.Builder.BuildBlock(context.Background()) require.NoError(err) @@ -105,7 +107,9 @@ func TestAddDelegatorTxOverDelegatedRegression(t *testing.T) { require.NoError(err) // trigger block creation + vm.ctx.Lock.Unlock() require.NoError(vm.Network.IssueTx(context.Background(), addFirstDelegatorTx)) + vm.ctx.Lock.Lock() addFirstDelegatorBlock, err := vm.Builder.BuildBlock(context.Background()) require.NoError(err) @@ -139,7 +143,9 @@ func TestAddDelegatorTxOverDelegatedRegression(t *testing.T) { require.NoError(err) // trigger block creation + vm.ctx.Lock.Unlock() require.NoError(vm.Network.IssueTx(context.Background(), addSecondDelegatorTx)) + vm.ctx.Lock.Lock() addSecondDelegatorBlock, err := vm.Builder.BuildBlock(context.Background()) require.NoError(err) @@ -163,8 +169,10 @@ func TestAddDelegatorTxOverDelegatedRegression(t *testing.T) { require.NoError(err) // trigger block creation + vm.ctx.Lock.Unlock() err = vm.Network.IssueTx(context.Background(), addThirdDelegatorTx) require.ErrorIs(err, executor.ErrOverDelegated) + vm.ctx.Lock.Lock() } func TestAddDelegatorTxHeapCorruption(t *testing.T) { @@ -236,7 +244,9 @@ func TestAddDelegatorTxHeapCorruption(t *testing.T) { require.NoError(err) // issue the add validator tx + vm.ctx.Lock.Unlock() require.NoError(vm.Network.IssueTx(context.Background(), addValidatorTx)) + vm.ctx.Lock.Lock() // trigger block creation for the validator tx addValidatorBlock, err := vm.Builder.BuildBlock(context.Background()) @@ -258,7 +268,9 @@ func TestAddDelegatorTxHeapCorruption(t *testing.T) { require.NoError(err) // issue the first add delegator tx + vm.ctx.Lock.Unlock() require.NoError(vm.Network.IssueTx(context.Background(), addFirstDelegatorTx)) + vm.ctx.Lock.Lock() // trigger block creation for the first add delegator tx addFirstDelegatorBlock, err := vm.Builder.BuildBlock(context.Background()) @@ -280,7 +292,9 @@ func TestAddDelegatorTxHeapCorruption(t *testing.T) { require.NoError(err) // issue the second add delegator tx + vm.ctx.Lock.Unlock() require.NoError(vm.Network.IssueTx(context.Background(), addSecondDelegatorTx)) + vm.ctx.Lock.Lock() // trigger block creation for the second add delegator tx addSecondDelegatorBlock, err := vm.Builder.BuildBlock(context.Background()) @@ -302,7 +316,9 @@ func TestAddDelegatorTxHeapCorruption(t *testing.T) { require.NoError(err) // issue the third add delegator tx + vm.ctx.Lock.Unlock() require.NoError(vm.Network.IssueTx(context.Background(), addThirdDelegatorTx)) + vm.ctx.Lock.Lock() // trigger block creation for the third add delegator tx addThirdDelegatorBlock, err := vm.Builder.BuildBlock(context.Background()) @@ -324,7 +340,9 @@ func TestAddDelegatorTxHeapCorruption(t *testing.T) { require.NoError(err) // issue the fourth add delegator tx + vm.ctx.Lock.Unlock() require.NoError(vm.Network.IssueTx(context.Background(), addFourthDelegatorTx)) + vm.ctx.Lock.Lock() // trigger block creation for the fourth add delegator tx addFourthDelegatorBlock, err := vm.Builder.BuildBlock(context.Background()) @@ -1157,7 +1175,9 @@ func TestAddDelegatorTxAddBeforeRemove(t *testing.T) { require.NoError(err) // issue the add validator tx + vm.ctx.Lock.Unlock() require.NoError(vm.Network.IssueTx(context.Background(), addValidatorTx)) + vm.ctx.Lock.Lock() // trigger block creation for the validator tx addValidatorBlock, err := vm.Builder.BuildBlock(context.Background()) @@ -1179,7 +1199,9 @@ func TestAddDelegatorTxAddBeforeRemove(t *testing.T) { require.NoError(err) // issue the first add delegator tx + vm.ctx.Lock.Unlock() require.NoError(vm.Network.IssueTx(context.Background(), addFirstDelegatorTx)) + vm.ctx.Lock.Lock() // trigger block creation for the first add delegator tx addFirstDelegatorBlock, err := vm.Builder.BuildBlock(context.Background()) @@ -1202,8 +1224,10 @@ func TestAddDelegatorTxAddBeforeRemove(t *testing.T) { // attempting to issue the second add delegator tx should fail because the // total stake weight would go over the limit. + vm.ctx.Lock.Unlock() err = vm.Network.IssueTx(context.Background(), addSecondDelegatorTx) require.ErrorIs(err, executor.ErrOverDelegated) + vm.ctx.Lock.Lock() } func TestRemovePermissionedValidatorDuringPendingToCurrentTransitionNotTracked(t *testing.T) { @@ -1239,7 +1263,9 @@ func TestRemovePermissionedValidatorDuringPendingToCurrentTransitionNotTracked(t ) require.NoError(err) + vm.ctx.Lock.Unlock() require.NoError(vm.Network.IssueTx(context.Background(), addValidatorTx)) + vm.ctx.Lock.Lock() // trigger block creation for the validator tx addValidatorBlock, err := vm.Builder.BuildBlock(context.Background()) @@ -1256,7 +1282,9 @@ func TestRemovePermissionedValidatorDuringPendingToCurrentTransitionNotTracked(t ) require.NoError(err) + vm.ctx.Lock.Unlock() require.NoError(vm.Network.IssueTx(context.Background(), createSubnetTx)) + vm.ctx.Lock.Lock() // trigger block creation for the subnet tx createSubnetBlock, err := vm.Builder.BuildBlock(context.Background()) @@ -1276,7 +1304,9 @@ func TestRemovePermissionedValidatorDuringPendingToCurrentTransitionNotTracked(t ) require.NoError(err) + vm.ctx.Lock.Unlock() require.NoError(vm.Network.IssueTx(context.Background(), addSubnetValidatorTx)) + vm.ctx.Lock.Lock() // trigger block creation for the validator tx addSubnetValidatorBlock, err := vm.Builder.BuildBlock(context.Background()) @@ -1305,7 +1335,9 @@ func TestRemovePermissionedValidatorDuringPendingToCurrentTransitionNotTracked(t // validator set into the current validator set. vm.clock.Set(validatorStartTime) + vm.ctx.Lock.Unlock() require.NoError(vm.Network.IssueTx(context.Background(), removeSubnetValidatorTx)) + vm.ctx.Lock.Lock() // trigger block creation for the validator tx removeSubnetValidatorBlock, err := vm.Builder.BuildBlock(context.Background()) @@ -1357,7 +1389,9 @@ func TestRemovePermissionedValidatorDuringPendingToCurrentTransitionTracked(t *t ) require.NoError(err) + vm.ctx.Lock.Unlock() require.NoError(vm.Network.IssueTx(context.Background(), addValidatorTx)) + vm.ctx.Lock.Lock() // trigger block creation for the validator tx addValidatorBlock, err := vm.Builder.BuildBlock(context.Background()) @@ -1374,7 +1408,9 @@ func TestRemovePermissionedValidatorDuringPendingToCurrentTransitionTracked(t *t ) require.NoError(err) + vm.ctx.Lock.Unlock() require.NoError(vm.Network.IssueTx(context.Background(), createSubnetTx)) + vm.ctx.Lock.Lock() // trigger block creation for the subnet tx createSubnetBlock, err := vm.Builder.BuildBlock(context.Background()) @@ -1394,7 +1430,9 @@ func TestRemovePermissionedValidatorDuringPendingToCurrentTransitionTracked(t *t ) require.NoError(err) + vm.ctx.Lock.Unlock() require.NoError(vm.Network.IssueTx(context.Background(), addSubnetValidatorTx)) + vm.ctx.Lock.Lock() // trigger block creation for the validator tx addSubnetValidatorBlock, err := vm.Builder.BuildBlock(context.Background()) @@ -1415,7 +1453,9 @@ func TestRemovePermissionedValidatorDuringPendingToCurrentTransitionTracked(t *t // validator set into the current validator set. vm.clock.Set(validatorStartTime) + vm.ctx.Lock.Unlock() require.NoError(vm.Network.IssueTx(context.Background(), removeSubnetValidatorTx)) + vm.ctx.Lock.Lock() // trigger block creation for the validator tx removeSubnetValidatorBlock, err := vm.Builder.BuildBlock(context.Background()) @@ -1509,7 +1549,9 @@ func TestSubnetValidatorBLSKeyDiffAfterExpiry(t *testing.T) { require.NoError(err) require.NoError(primaryTx.SyntacticVerify(vm.ctx)) + vm.ctx.Lock.Unlock() require.NoError(vm.Network.IssueTx(context.Background(), primaryTx)) + vm.ctx.Lock.Lock() require.NoError(buildAndAcceptStandardBlock(vm)) // move time ahead, promoting primary validator to current @@ -1536,7 +1578,9 @@ func TestSubnetValidatorBLSKeyDiffAfterExpiry(t *testing.T) { ) require.NoError(err) + vm.ctx.Lock.Unlock() require.NoError(vm.Network.IssueTx(context.Background(), subnetTx)) + vm.ctx.Lock.Lock() require.NoError(buildAndAcceptStandardBlock(vm)) // move time ahead, promoting the subnet validator to current @@ -1640,7 +1684,9 @@ func TestSubnetValidatorBLSKeyDiffAfterExpiry(t *testing.T) { require.NoError(err) require.NoError(uPrimaryRestartTx.SyntacticVerify(vm.ctx)) + vm.ctx.Lock.Unlock() require.NoError(vm.Network.IssueTx(context.Background(), primaryRestartTx)) + vm.ctx.Lock.Lock() require.NoError(buildAndAcceptStandardBlock(vm)) // move time ahead, promoting restarted primary validator to current @@ -1747,7 +1793,9 @@ func TestPrimaryNetworkValidatorPopulatedToEmptyBLSKeyDiff(t *testing.T) { ) require.NoError(err) + vm.ctx.Lock.Unlock() require.NoError(vm.Network.IssueTx(context.Background(), primaryTx1)) + vm.ctx.Lock.Lock() require.NoError(buildAndAcceptStandardBlock(vm)) // move time ahead, promoting primary validator to current @@ -1839,7 +1887,9 @@ func TestPrimaryNetworkValidatorPopulatedToEmptyBLSKeyDiff(t *testing.T) { require.NoError(err) require.NoError(uPrimaryRestartTx.SyntacticVerify(vm.ctx)) + vm.ctx.Lock.Unlock() require.NoError(vm.Network.IssueTx(context.Background(), primaryRestartTx)) + vm.ctx.Lock.Lock() require.NoError(buildAndAcceptStandardBlock(vm)) // move time ahead, promoting restarted primary validator to current @@ -1910,7 +1960,9 @@ func TestSubnetValidatorPopulatedToEmptyBLSKeyDiff(t *testing.T) { ) require.NoError(err) + vm.ctx.Lock.Unlock() require.NoError(vm.Network.IssueTx(context.Background(), primaryTx1)) + vm.ctx.Lock.Lock() require.NoError(buildAndAcceptStandardBlock(vm)) // move time ahead, promoting primary validator to current @@ -1937,7 +1989,9 @@ func TestSubnetValidatorPopulatedToEmptyBLSKeyDiff(t *testing.T) { ) require.NoError(err) + vm.ctx.Lock.Unlock() require.NoError(vm.Network.IssueTx(context.Background(), subnetTx)) + vm.ctx.Lock.Lock() require.NoError(buildAndAcceptStandardBlock(vm)) // move time ahead, promoting the subnet validator to current @@ -2041,7 +2095,9 @@ func TestSubnetValidatorPopulatedToEmptyBLSKeyDiff(t *testing.T) { require.NoError(err) require.NoError(uPrimaryRestartTx.SyntacticVerify(vm.ctx)) + vm.ctx.Lock.Unlock() require.NoError(vm.Network.IssueTx(context.Background(), primaryRestartTx)) + vm.ctx.Lock.Lock() require.NoError(buildAndAcceptStandardBlock(vm)) // move time ahead, promoting restarted primary validator to current @@ -2119,7 +2175,9 @@ func TestSubnetValidatorSetAfterPrimaryNetworkValidatorRemoval(t *testing.T) { ) require.NoError(err) + vm.ctx.Lock.Unlock() require.NoError(vm.Network.IssueTx(context.Background(), primaryTx1)) + vm.ctx.Lock.Lock() require.NoError(buildAndAcceptStandardBlock(vm)) // move time ahead, promoting primary validator to current @@ -2143,7 +2201,9 @@ func TestSubnetValidatorSetAfterPrimaryNetworkValidatorRemoval(t *testing.T) { ) require.NoError(err) + vm.ctx.Lock.Unlock() require.NoError(vm.Network.IssueTx(context.Background(), subnetTx)) + vm.ctx.Lock.Lock() require.NoError(buildAndAcceptStandardBlock(vm)) // move time ahead, promoting the subnet validator to current diff --git a/vms/platformvm/vm_test.go b/vms/platformvm/vm_test.go index 3c3a017ec396..b871ee9d3e44 100644 --- a/vms/platformvm/vm_test.go +++ b/vms/platformvm/vm_test.go @@ -350,7 +350,11 @@ func defaultVM(t *testing.T, fork activeFork) (*VM, database.Database, *mutableS keys[0].PublicKey().Address(), // change addr ) require.NoError(err) + + ctx.Lock.Unlock() require.NoError(vm.Network.IssueTx(context.Background(), testSubnet1)) + ctx.Lock.Lock() + blk, err := vm.Builder.BuildBlock(context.Background()) require.NoError(err) require.NoError(blk.Verify(context.Background())) @@ -447,7 +451,9 @@ func TestAddValidatorCommit(t *testing.T) { require.NoError(err) // trigger block creation + vm.ctx.Lock.Unlock() require.NoError(vm.Network.IssueTx(context.Background(), tx)) + vm.ctx.Lock.Lock() blk, err := vm.Builder.BuildBlock(context.Background()) require.NoError(err) @@ -548,7 +554,9 @@ func TestAddValidatorReject(t *testing.T) { require.NoError(err) // trigger block creation + vm.ctx.Lock.Unlock() require.NoError(vm.Network.IssueTx(context.Background(), tx)) + vm.ctx.Lock.Lock() blk, err := vm.Builder.BuildBlock(context.Background()) require.NoError(err) @@ -593,7 +601,9 @@ func TestAddValidatorInvalidNotReissued(t *testing.T) { require.NoError(err) // trigger block creation + vm.ctx.Lock.Unlock() err = vm.Network.IssueTx(context.Background(), tx) + vm.ctx.Lock.Lock() require.ErrorIs(err, txexecutor.ErrAlreadyValidator) } @@ -628,7 +638,9 @@ func TestAddSubnetValidatorAccept(t *testing.T) { require.NoError(err) // trigger block creation + vm.ctx.Lock.Unlock() require.NoError(vm.Network.IssueTx(context.Background(), tx)) + vm.ctx.Lock.Lock() blk, err := vm.Builder.BuildBlock(context.Background()) require.NoError(err) @@ -676,7 +688,9 @@ func TestAddSubnetValidatorReject(t *testing.T) { require.NoError(err) // trigger block creation + vm.ctx.Lock.Unlock() require.NoError(vm.Network.IssueTx(context.Background(), tx)) + vm.ctx.Lock.Lock() blk, err := vm.Builder.BuildBlock(context.Background()) require.NoError(err) @@ -870,7 +884,9 @@ func TestCreateChain(t *testing.T) { ) require.NoError(err) + vm.ctx.Lock.Unlock() require.NoError(vm.Network.IssueTx(context.Background(), tx)) + vm.ctx.Lock.Lock() blk, err := vm.Builder.BuildBlock(context.Background()) require.NoError(err) // should contain proposal to create chain @@ -921,7 +937,9 @@ func TestCreateSubnet(t *testing.T) { ) require.NoError(err) + vm.ctx.Lock.Unlock() require.NoError(vm.Network.IssueTx(context.Background(), createSubnetTx)) + vm.ctx.Lock.Lock() // should contain the CreateSubnetTx blk, err := vm.Builder.BuildBlock(context.Background()) @@ -962,7 +980,9 @@ func TestCreateSubnet(t *testing.T) { ) require.NoError(err) + vm.ctx.Lock.Unlock() require.NoError(vm.Network.IssueTx(context.Background(), addValidatorTx)) + vm.ctx.Lock.Lock() blk, err = vm.Builder.BuildBlock(context.Background()) // should add validator to the new subnet require.NoError(err) @@ -1065,7 +1085,9 @@ func TestAtomicImport(t *testing.T) { ) require.NoError(err) + vm.ctx.Lock.Unlock() require.NoError(vm.Network.IssueTx(context.Background(), tx)) + vm.ctx.Lock.Lock() blk, err := vm.Builder.BuildBlock(context.Background()) require.NoError(err) @@ -2065,7 +2087,9 @@ func TestRemovePermissionedValidatorDuringAddPending(t *testing.T) { ) require.NoError(err) + vm.ctx.Lock.Unlock() require.NoError(vm.Network.IssueTx(context.Background(), addValidatorTx)) + vm.ctx.Lock.Lock() // trigger block creation for the validator tx addValidatorBlock, err := vm.Builder.BuildBlock(context.Background()) @@ -2082,7 +2106,9 @@ func TestRemovePermissionedValidatorDuringAddPending(t *testing.T) { ) require.NoError(err) + vm.ctx.Lock.Unlock() require.NoError(vm.Network.IssueTx(context.Background(), createSubnetTx)) + vm.ctx.Lock.Lock() // trigger block creation for the subnet tx createSubnetBlock, err := vm.Builder.BuildBlock(context.Background()) @@ -2151,7 +2177,10 @@ func TestTransferSubnetOwnershipTx(t *testing.T) { require.NoError(err) subnetID := createSubnetTx.ID() + vm.ctx.Lock.Unlock() require.NoError(vm.Network.IssueTx(context.Background(), createSubnetTx)) + vm.ctx.Lock.Lock() + createSubnetBlock, err := vm.Builder.BuildBlock(context.Background()) require.NoError(err) @@ -2183,7 +2212,10 @@ func TestTransferSubnetOwnershipTx(t *testing.T) { ) require.NoError(err) + vm.ctx.Lock.Unlock() require.NoError(vm.Network.IssueTx(context.Background(), transferSubnetOwnershipTx)) + vm.ctx.Lock.Lock() + transferSubnetOwnershipBlock, err := vm.Builder.BuildBlock(context.Background()) require.NoError(err) @@ -2269,7 +2301,10 @@ func TestBaseTx(t *testing.T) { require.Equal(vm.TxFee, totalInputAmt-totalOutputAmt) require.Equal(sendAmt, key1OutputAmt) + vm.ctx.Lock.Unlock() require.NoError(vm.Network.IssueTx(context.Background(), baseTx)) + vm.ctx.Lock.Lock() + baseTxBlock, err := vm.Builder.BuildBlock(context.Background()) require.NoError(err)