Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions engine/execution/block_result_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ func makeBlockExecutionResultFixture(serviceEventsPerChunk []int) *BlockExecutio

// Tests that ServiceEventCountForChunk method works as expected under various circumstances:
func TestBlockExecutionResult_ServiceEventCountForChunk(t *testing.T) {
t.Parallel()

t.Run("no service events", func(t *testing.T) {
nChunks := rand.Intn(10) + 1 // always contains at least system chunk
blockResult := makeBlockExecutionResultFixture(make([]int, nChunks))
Expand Down
4 changes: 4 additions & 0 deletions engine/execution/computation/execution_verification_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ var chain = flow.Emulator.Chain()
// This is not relevant to the test, as only the non-system transactions are tested.

func Test_ExecutionMatchesVerification(t *testing.T) {

t.Parallel()

t.Run("empty block", func(t *testing.T) {
executeBlockAndVerify(t,
[][]*flow.TransactionBody{},
Expand Down Expand Up @@ -339,6 +342,7 @@ func Test_ExecutionMatchesVerification(t *testing.T) {
}

func TestTransactionFeeDeduction(t *testing.T) {
t.Parallel()

type testCase struct {
name string
Expand Down
12 changes: 12 additions & 0 deletions engine/execution/computation/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ import (
var scriptLogThreshold = 1 * time.Second

func TestComputeBlockWithStorage(t *testing.T) {
t.Parallel()

chain := flow.Mainnet.Chain()

vm := fvm.NewVirtualMachine()
Expand Down Expand Up @@ -180,6 +182,7 @@ func TestComputeBlockWithStorage(t *testing.T) {
}

func TestComputeBlock_Uploader(t *testing.T) {
t.Parallel()

noopCollector := &metrics.NoopCollector{}

Expand Down Expand Up @@ -230,6 +233,7 @@ func TestComputeBlock_Uploader(t *testing.T) {
}

func TestExecuteScript(t *testing.T) {
t.Parallel()

logger := zerolog.Nop()

Expand Down Expand Up @@ -296,6 +300,7 @@ func TestExecuteScript(t *testing.T) {
// Balance script used to swallow errors, which meant that even if the view was empty, a script that did nothing but get
// the balance of an account would succeed and return 0.
func TestExecuteScript_BalanceScriptFailsIfViewIsEmpty(t *testing.T) {
t.Parallel()

logger := zerolog.Nop()

Expand Down Expand Up @@ -361,6 +366,7 @@ func TestExecuteScript_BalanceScriptFailsIfViewIsEmpty(t *testing.T) {
}

func TestExecuteScripPanicsAreHandled(t *testing.T) {
t.Parallel()

ctx := fvm.NewContext()

Expand Down Expand Up @@ -411,6 +417,7 @@ func TestExecuteScripPanicsAreHandled(t *testing.T) {
}

func TestExecuteScript_LongScriptsAreLogged(t *testing.T) {
t.Parallel()

ctx := fvm.NewContext()

Expand Down Expand Up @@ -464,6 +471,7 @@ func TestExecuteScript_LongScriptsAreLogged(t *testing.T) {
}

func TestExecuteScript_ShortScriptsAreNotLogged(t *testing.T) {
t.Parallel()

ctx := fvm.NewContext()

Expand Down Expand Up @@ -647,6 +655,7 @@ func (f *FakeBlockComputer) ExecuteBlock(
}

func TestExecuteScriptTimeout(t *testing.T) {
t.Parallel()

timeout := 1 * time.Millisecond
manager, err := New(
Expand Down Expand Up @@ -694,6 +703,7 @@ func TestExecuteScriptTimeout(t *testing.T) {
}

func TestExecuteScriptCancelled(t *testing.T) {
t.Parallel()

timeout := 30 * time.Second
manager, err := New(
Expand Down Expand Up @@ -750,6 +760,7 @@ func TestExecuteScriptCancelled(t *testing.T) {
}

func Test_EventEncodingFailsOnlyTxAndCarriesOn(t *testing.T) {
t.Parallel()

chain := flow.Mainnet.Chain()
vm := fvm.NewVirtualMachine()
Expand Down Expand Up @@ -908,6 +919,7 @@ func (e *testingEventEncoder) Encode(event cadence.Event) ([]byte, error) {
}

func TestScriptStorageMutationsDiscarded(t *testing.T) {
t.Parallel()

timeout := 10 * time.Second
chain := flow.Mainnet.Chain()
Expand Down
4 changes: 4 additions & 0 deletions engine/execution/computation/programs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ const (
)

func TestPrograms_TestContractUpdates(t *testing.T) {
t.Parallel()

chain := flow.Mainnet.Chain()
vm := fvm.NewVirtualMachine()
execCtx := fvm.NewContext(fvm.WithChain(chain))
Expand Down Expand Up @@ -215,6 +217,8 @@ func (b blockProvider) ByHeightFrom(height uint64, _ *flow.Header) (*flow.Header
// -> Block121 (emit event - version should be 2)
// -> Block1211 (emit event - version should be 2)
func TestPrograms_TestBlockForks(t *testing.T) {
t.Parallel()

block := unittest.BlockFixture()
chain := flow.Emulator.Chain()
vm := fvm.NewVirtualMachine()
Expand Down
6 changes: 6 additions & 0 deletions engine/execution/execution_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ func sendBlock(exeNode *testmock.ExecutionNode, from flow.Identifier, proposal *
// create another child block which will trigger the parent
// block to be incorporated and be passed to the ingestion engine
func TestExecutionFlow(t *testing.T) {
t.Parallel()

hub := stub.NewNetworkHub()

chainID := flow.Testnet
Expand Down Expand Up @@ -383,6 +385,8 @@ func makeSuccessBlock(t *testing.T, conID *flow.Identity, colID *flow.Identity,
// Test a successful tx should change the statecommitment,
// but a failed Tx should not change the statecommitment.
func TestFailedTxWillNotChangeStateCommitment(t *testing.T) {
t.Parallel()

hub := stub.NewNetworkHub()

chainID := flow.Emulator
Expand Down Expand Up @@ -547,6 +551,8 @@ func mockCollectionEngineToReturnCollections(t *testing.T, collectionNode *testm

// Test the receipt will be sent to multiple verification nodes
func TestBroadcastToMultipleVerificationNodes(t *testing.T) {
t.Parallel()

hub := stub.NewNetworkHub()

chainID := flow.Emulator
Expand Down
16 changes: 16 additions & 0 deletions fvm/accounts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,8 @@ func newAccountKey(

func TestCreateAccount(t *testing.T) {

t.Parallel()

options := []fvm.Option{
fvm.WithAuthorizationChecksEnabled(false),
fvm.WithSequenceNumberCheckAndIncrementEnabled(false),
Expand Down Expand Up @@ -469,6 +471,8 @@ func TestCreateAccount(t *testing.T) {

func TestCreateAccount_WithRestrictedAccountCreation(t *testing.T) {

t.Parallel()

options := []fvm.Option{
fvm.WithAuthorizationChecksEnabled(false),
fvm.WithSequenceNumberCheckAndIncrementEnabled(false),
Expand Down Expand Up @@ -614,6 +618,8 @@ func TestCreateAccount_WithRestrictedAccountCreation(t *testing.T) {

func TestAddAccountKey(t *testing.T) {

t.Parallel()

options := []fvm.Option{
fvm.WithAuthorizationChecksEnabled(false),
fvm.WithSequenceNumberCheckAndIncrementEnabled(false),
Expand Down Expand Up @@ -932,6 +938,8 @@ func TestAddAccountKey(t *testing.T) {

func TestRemoveAccountKey(t *testing.T) {

t.Parallel()

options := []fvm.Option{
fvm.WithAuthorizationChecksEnabled(false),
fvm.WithSequenceNumberCheckAndIncrementEnabled(false),
Expand Down Expand Up @@ -1211,6 +1219,8 @@ func TestRemoveAccountKey(t *testing.T) {

func TestGetAccountKey(t *testing.T) {

t.Parallel()

options := []fvm.Option{
fvm.WithAuthorizationChecksEnabled(false),
fvm.WithSequenceNumberCheckAndIncrementEnabled(false),
Expand Down Expand Up @@ -1483,6 +1493,9 @@ func byteSliceToCadenceArrayLiteral(bytes []byte) string {
}

func TestAccountBalanceFields(t *testing.T) {

t.Parallel()

t.Run("Get balance works",
newVMTest().withContextOptions(
fvm.WithAuthorizationChecksEnabled(false),
Expand Down Expand Up @@ -1725,6 +1738,9 @@ func TestAccountBalanceFields(t *testing.T) {
}

func TestGetStorageCapacity(t *testing.T) {

t.Parallel()

t.Run("Get storage capacity",
newVMTest().withContextOptions(
fvm.WithAuthorizationChecksEnabled(false),
Expand Down
2 changes: 2 additions & 0 deletions fvm/environment/programs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ func getTestContract(
}

func Test_Programs(t *testing.T) {
t.Parallel()

vm := fvm.NewVirtualMachine()
derivedBlockData := derived.NewEmptyDerivedBlockData(0)

Expand Down
4 changes: 4 additions & 0 deletions fvm/fvm_blockcontext_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1751,6 +1751,8 @@ func TestBlockContext_GetAccount(t *testing.T) {
}

func TestBlockContext_Random(t *testing.T) {
t.Parallel()

chain, vm := createChainAndVm(flow.Mainnet)
header := &flow.Header{HeaderBody: flow.HeaderBody{Height: 42}}
source := testutil.EntropyProviderFixture(nil)
Expand Down Expand Up @@ -1906,6 +1908,8 @@ func TestBlockContext_ExecuteTransaction_CreateAccount_WithMonotonicAddresses(t
}

func TestBlockContext_ExecuteTransaction_FailingTransactions(t *testing.T) {
t.Parallel()

getBalance := func(
vm fvm.VM,
chain flow.Chain,
Expand Down
28 changes: 28 additions & 0 deletions fvm/fvm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,8 @@ func TestWithServiceAccount(t *testing.T) {
}

func TestEventLimits(t *testing.T) {
t.Parallel()

chain, vm := createChainAndVm(flow.Mainnet)

ctx := fvm.NewContext(
Expand Down Expand Up @@ -579,6 +581,7 @@ func TestEventLimits(t *testing.T) {
// TestHappyPathSigning checks that a signing a transaction with `Sign` doesn't produce an error.
// Transaction verification tests are in `TestVerifySignatureFromTransaction`.
func TestHappyPathTransactionSigning(t *testing.T) {
t.Parallel()

newVMTest().run(
func(t *testing.T, vm fvm.VM, chain flow.Chain, ctx fvm.Context, snapshotTree snapshot.SnapshotTree) {
Expand Down Expand Up @@ -620,6 +623,8 @@ func TestHappyPathTransactionSigning(t *testing.T) {
}

func TestTransactionFeeDeduction(t *testing.T) {
t.Parallel()

getBalance := func(vm fvm.VM, chain flow.Chain, ctx fvm.Context, snapshotTree snapshot.SnapshotTree, address flow.Address) uint64 {
sc := systemcontracts.SystemContractsForChain(chain.ChainID())
code := []byte(fmt.Sprintf(
Expand Down Expand Up @@ -1098,6 +1103,7 @@ func TestTransactionFeeDeduction(t *testing.T) {
}

func TestSettingExecutionWeights(t *testing.T) {
t.Parallel()

// change the chain so that the metering settings are read from the service account
chain := flow.Emulator.Chain()
Expand Down Expand Up @@ -1837,6 +1843,8 @@ func TestEnforcingComputationLimit(t *testing.T) {
}

func TestStorageCapacity(t *testing.T) {
t.Parallel()

t.Run("Storage capacity updates on FLOW transfer", newVMTest().
withContextOptions(
fvm.WithAuthorizationChecksEnabled(false),
Expand Down Expand Up @@ -2328,6 +2336,9 @@ func TestScriptExecutionLimit(t *testing.T) {
}

func TestInteractionLimit(t *testing.T) {

t.Parallel()

type testCase struct {
name string
interactionLimit uint64
Expand Down Expand Up @@ -2497,6 +2508,7 @@ func TestInteractionLimit(t *testing.T) {
}

func TestAttachments(t *testing.T) {
t.Parallel()

newVMTest().
withBootstrapProcedureOptions().
Expand Down Expand Up @@ -2531,6 +2543,8 @@ func TestAttachments(t *testing.T) {
}

func TestCapabilityControllers(t *testing.T) {
t.Parallel()

test := func(t *testing.T) {
newVMTest().
withBootstrapProcedureOptions().
Expand Down Expand Up @@ -2800,6 +2814,8 @@ func TestStorageIterationWithBrokenValues(t *testing.T) {
}

func TestEntropyCallOnlyOkIfAllowed(t *testing.T) {
t.Parallel()

source := testutil.EntropyProviderFixture(nil)

test := func(t *testing.T, allowed bool) {
Expand Down Expand Up @@ -2859,6 +2875,8 @@ func TestEntropyCallOnlyOkIfAllowed(t *testing.T) {
}

func TestEntropyCallExpectsNoParameters(t *testing.T) {
t.Parallel()

source := testutil.EntropyProviderFixture(nil)
newVMTest().
withBootstrapProcedureOptions().
Expand Down Expand Up @@ -2902,6 +2920,7 @@ func TestEntropyCallExpectsNoParameters(t *testing.T) {
}

func TestTransientNetworkCoreContractAddresses(t *testing.T) {
t.Parallel()

// This test ensures that the transient networks have the correct core contract addresses.
newVMTest().
Expand All @@ -2927,6 +2946,8 @@ func TestTransientNetworkCoreContractAddresses(t *testing.T) {
}

func TestFlowCallbackScheduler(t *testing.T) {
t.Parallel()

ctxOpts := []fvm.Option{
fvm.WithScheduleCallbacksEnabled(true),
}
Expand Down Expand Up @@ -2975,6 +2996,8 @@ func TestFlowCallbackScheduler(t *testing.T) {
}

func TestEVM(t *testing.T) {
t.Parallel()

blocks := new(envMock.Blocks)
block1 := unittest.BlockFixture()
blocks.On("ByHeightFrom",
Expand Down Expand Up @@ -3244,6 +3267,8 @@ func TestEVM(t *testing.T) {
}

func TestVMBridge(t *testing.T) {
t.Parallel()

blocks := new(envMock.Blocks)
block1 := unittest.BlockFixture()
blocks.On("ByHeightFrom",
Expand Down Expand Up @@ -3812,6 +3837,7 @@ func TestVMBridge(t *testing.T) {
}

func TestAccountCapabilitiesGetEntitledRejection(t *testing.T) {
t.Parallel()

// Note: This cannot be tested anymore using a transaction,
// because publish method also aborts when trying to publish an entitled capability.
Expand Down Expand Up @@ -3874,6 +3900,7 @@ func TestAccountCapabilitiesGetEntitledRejection(t *testing.T) {
}

func TestAccountCapabilitiesPublishEntitledRejection(t *testing.T) {
t.Parallel()

t.Run("entitled capability", newVMTest().
run(func(
Expand Down Expand Up @@ -4131,6 +4158,7 @@ func TestCrypto(t *testing.T) {
}

func Test_BlockHashListShouldWriteOnPush(t *testing.T) {
t.Parallel()

chain := flow.Emulator.Chain()
sc := systemcontracts.SystemContractsForChain(chain.ChainID())
Expand Down
Loading
Loading