From 0e1b932b7d6f15842584f53f5346913c679e6e52 Mon Sep 17 00:00:00 2001 From: Supun Setunga Date: Wed, 23 Oct 2024 11:44:12 -0700 Subject: [PATCH] Remove attachments enabling flag --- cmd/cmd.go | 1 - runtime/config.go | 2 - runtime/environment.go | 1 - sema/check_attach_expression.go | 6 -- sema/check_composite_declaration.go | 7 -- sema/check_expression.go | 6 -- sema/check_remove_statement.go | 6 -- sema/config.go | 2 - sema/errors.go | 16 ---- ..._to_v1_contract_upgrade_validation_test.go | 7 +- tests/attachments_test.go | 14 +-- tests/checker/access_test.go | 3 +- tests/checker/attachments_test.go | 92 ------------------- tests/checker/storable_test.go | 1 - tests/checker/utils.go | 7 +- tests/convertValues_test.go | 2 +- tests/entitlements_test.go | 8 +- tests/interpreter/attachments_test.go | 55 ++++------- tests/interpreter/entitlements_test.go | 24 ++--- tests/interpreter/interpreter_test.go | 7 +- tests/interpreter/resources_test.go | 6 -- tests/runtime_test.go | 10 +- tests/runtime_utils/testruntime.go | 7 -- tests/storage_test.go | 2 +- 24 files changed, 53 insertions(+), 239 deletions(-) diff --git a/cmd/cmd.go b/cmd/cmd.go index 0172a68db5..b7f11e59d3 100644 --- a/cmd/cmd.go +++ b/cmd/cmd.go @@ -119,7 +119,6 @@ func DefaultCheckerConfig( Elaboration: importedChecker.Elaboration, }, nil }, - AttachmentsEnabled: true, } } diff --git a/runtime/config.go b/runtime/config.go index 8f652fd894..c3be0083d5 100644 --- a/runtime/config.go +++ b/runtime/config.go @@ -35,8 +35,6 @@ type Config struct { ResourceOwnerChangeHandlerEnabled bool // CoverageReport enables and collects coverage reporting metrics CoverageReport *CoverageReport - // AttachmentsEnabled specifies if attachments are enabled - AttachmentsEnabled bool // LegacyContractUpgradeEnabled enabled specifies whether to use the old parser when parsing an old contract LegacyContractUpgradeEnabled bool // ContractUpdateTypeRemovalEnabled specifies if type removal is enabled in contract updates diff --git a/runtime/environment.go b/runtime/environment.go index 9aff5b329d..ef3d0130d6 100644 --- a/runtime/environment.go +++ b/runtime/environment.go @@ -211,7 +211,6 @@ func (e *interpreterEnvironment) newCheckerConfig() *sema.Config { LocationHandler: e.ResolveLocation, ImportHandler: e.resolveImport, CheckHandler: e.newCheckHandler(), - AttachmentsEnabled: e.config.AttachmentsEnabled, } } diff --git a/sema/check_attach_expression.go b/sema/check_attach_expression.go index 392f5caec5..3a468544fc 100644 --- a/sema/check_attach_expression.go +++ b/sema/check_attach_expression.go @@ -25,12 +25,6 @@ import ( func (checker *Checker) VisitAttachExpression(expression *ast.AttachExpression) Type { - if !checker.Config.AttachmentsEnabled { - checker.report(&AttachmentsNotEnabledError{ - Range: ast.NewRangeFromPositioned(checker.memoryGauge, expression), - }) - } - attachment := expression.Attachment baseExpression := expression.Base diff --git a/sema/check_composite_declaration.go b/sema/check_composite_declaration.go index fdcfc70531..9b201296cf 100644 --- a/sema/check_composite_declaration.go +++ b/sema/check_composite_declaration.go @@ -145,13 +145,6 @@ func (checker *Checker) VisitAttachmentDeclaration(declaration *ast.AttachmentDe } func (checker *Checker) visitAttachmentDeclaration(declaration *ast.AttachmentDeclaration) (_ struct{}) { - - if !checker.Config.AttachmentsEnabled { - checker.report(&AttachmentsNotEnabledError{ - Range: ast.NewRangeFromPositioned(checker.memoryGauge, declaration), - }) - } - checker.visitCompositeLikeDeclaration(declaration) attachmentType := checker.Elaboration.CompositeDeclarationType(declaration) checker.checkAttachmentMembersAccess(attachmentType) diff --git a/sema/check_expression.go b/sema/check_expression.go index 683c6bcfe6..caff4f0ee6 100644 --- a/sema/check_expression.go +++ b/sema/check_expression.go @@ -444,12 +444,6 @@ func (checker *Checker) checkTypeIndexingExpression( targetExpression := indexExpression.TargetExpression - if !checker.Config.AttachmentsEnabled { - checker.report(&AttachmentsNotEnabledError{ - Range: ast.NewRangeFromPositioned(checker.memoryGauge, indexExpression), - }) - } - expressionType := ast.ExpressionAsType(indexExpression.IndexingExpression) if expressionType == nil { return InvalidType diff --git a/sema/check_remove_statement.go b/sema/check_remove_statement.go index 6ac905ea74..bfb984ed22 100644 --- a/sema/check_remove_statement.go +++ b/sema/check_remove_statement.go @@ -25,12 +25,6 @@ import ( func (checker *Checker) VisitRemoveStatement(statement *ast.RemoveStatement) (_ struct{}) { - if !checker.Config.AttachmentsEnabled { - checker.report(&AttachmentsNotEnabledError{ - Range: ast.NewRangeFromPositioned(checker.memoryGauge, statement), - }) - } - nominalType := checker.convertNominalType(statement.Attachment) base := checker.VisitExpression(statement.Value, statement, nil) checker.checkUnusedExpressionResourceLoss(base, statement.Value) diff --git a/sema/config.go b/sema/config.go index 06f6e9ce95..1f22107539 100644 --- a/sema/config.go +++ b/sema/config.go @@ -53,6 +53,4 @@ type Config struct { AllowNativeDeclarations bool // AllowStaticDeclarations determines if declarations may be static AllowStaticDeclarations bool - // AttachmentsEnabled determines if attachments are enabled - AttachmentsEnabled bool } diff --git a/sema/errors.go b/sema/errors.go index 3686d9f185..96edbf076e 100644 --- a/sema/errors.go +++ b/sema/errors.go @@ -4639,22 +4639,6 @@ func (e *InvalidTypeIndexingError) Error() string { ) } -// AttachmentsNotEnabledError -type AttachmentsNotEnabledError struct { - ast.Range -} - -var _ SemanticError = &AttachmentsNotEnabledError{} -var _ errors.UserError = &AttachmentsNotEnabledError{} - -func (*AttachmentsNotEnabledError) isSemanticError() {} - -func (*AttachmentsNotEnabledError) IsUserError() {} - -func (e *AttachmentsNotEnabledError) Error() string { - return "attachments are not enabled and cannot be used in this environment" -} - // InvalidAttachmentEntitlementError type InvalidAttachmentEntitlementError struct { Attachment *CompositeType diff --git a/stdlib/cadence_v0.42_to_v1_contract_upgrade_validation_test.go b/stdlib/cadence_v0.42_to_v1_contract_upgrade_validation_test.go index 0fa29ad911..365f0eeaf8 100644 --- a/stdlib/cadence_v0.42_to_v1_contract_upgrade_validation_test.go +++ b/stdlib/cadence_v0.42_to_v1_contract_upgrade_validation_test.go @@ -49,8 +49,7 @@ func testContractUpdate(t *testing.T, oldCode string, newCode string) error { utils.TestLocation, nil, &sema.Config{ - AccessCheckMode: sema.AccessCheckModeStrict, - AttachmentsEnabled: true, + AccessCheckMode: sema.AccessCheckModeStrict, }) require.NoError(t, err) @@ -130,8 +129,7 @@ func parseAndCheckPrograms( location, nil, &sema.Config{ - AccessCheckMode: sema.AccessCheckModeStrict, - AttachmentsEnabled: true, + AccessCheckMode: sema.AccessCheckModeStrict, }, ) @@ -171,7 +169,6 @@ func parseAndCheckPrograms( return }, - AttachmentsEnabled: true, }) require.NoError(t, err) diff --git a/tests/attachments_test.go b/tests/attachments_test.go index 5cb1909ee8..cf3de8047c 100644 --- a/tests/attachments_test.go +++ b/tests/attachments_test.go @@ -36,7 +36,7 @@ func TestRuntimeAccountAttachmentSaveAndLoad(t *testing.T) { t.Parallel() storage := NewTestLedger(nil, nil) - rt := NewTestInterpreterRuntimeWithAttachments() + rt := NewTestInterpreterRuntime() var logs []string var events []string @@ -147,7 +147,7 @@ func TestRuntimeAccountAttachmentExportFailure(t *testing.T) { t.Parallel() storage := NewTestLedger(nil, nil) - rt := NewTestInterpreterRuntimeWithAttachments() + rt := NewTestInterpreterRuntime() logs := make([]string, 0) events := make([]string, 0) @@ -238,7 +238,7 @@ func TestRuntimeAccountAttachmentExport(t *testing.T) { t.Parallel() storage := NewTestLedger(nil, nil) - rt := NewTestInterpreterRuntimeWithAttachments() + rt := NewTestInterpreterRuntime() var logs []string var events []string @@ -323,7 +323,7 @@ func TestRuntimeAccountAttachedExport(t *testing.T) { t.Parallel() storage := NewTestLedger(nil, nil) - rt := NewTestInterpreterRuntimeWithAttachments() + rt := NewTestInterpreterRuntime() var logs []string var events []string @@ -411,7 +411,7 @@ func TestRuntimeAccountAttachmentSaveAndBorrow(t *testing.T) { t.Parallel() storage := NewTestLedger(nil, nil) - rt := NewTestInterpreterRuntimeWithAttachments() + rt := NewTestInterpreterRuntime() var logs []string var events []string @@ -525,7 +525,7 @@ func TestRuntimeAccountAttachmentCapability(t *testing.T) { t.Parallel() storage := NewTestLedger(nil, nil) - rt := NewTestInterpreterRuntimeWithAttachments() + rt := NewTestInterpreterRuntime() var logs []string var events []string @@ -666,7 +666,7 @@ func TestRuntimeAttachmentStorage(t *testing.T) { address := common.MustBytesToAddress([]byte{0x1}) newRuntime := func() (TestInterpreterRuntime, *TestRuntimeInterface) { - runtime := NewTestInterpreterRuntimeWithAttachments() + runtime := NewTestInterpreterRuntime() accountCodes := map[common.Location][]byte{} diff --git a/tests/checker/access_test.go b/tests/checker/access_test.go index 13e2eb3de6..041fad225e 100644 --- a/tests/checker/access_test.go +++ b/tests/checker/access_test.go @@ -603,8 +603,7 @@ func TestCheckAccessModifierGlobalCompositeDeclaration(t *testing.T) { ), ParseAndCheckOptions{ Config: &sema.Config{ - AccessCheckMode: checkMode, - AttachmentsEnabled: true, + AccessCheckMode: checkMode, }, }, ) diff --git a/tests/checker/attachments_test.go b/tests/checker/attachments_test.go index c35be0f06a..de3e3dd406 100644 --- a/tests/checker/attachments_test.go +++ b/tests/checker/attachments_test.go @@ -3816,7 +3816,6 @@ func TestCheckAttachmentsExternalMutation(t *testing.T) { `, ParseAndCheckOptions{Config: &sema.Config{ SuggestionsEnabled: true, - AttachmentsEnabled: true, }}, ) @@ -3896,7 +3895,6 @@ func TestCheckAttachmentsExternalMutation(t *testing.T) { `, ParseAndCheckOptions{Config: &sema.Config{ SuggestionsEnabled: true, - AttachmentsEnabled: true, }}, ) @@ -3970,7 +3968,6 @@ func TestCheckAttachmentsExternalMutation(t *testing.T) { `, ParseAndCheckOptions{Config: &sema.Config{ SuggestionsEnabled: true, - AttachmentsEnabled: true, }}, ) @@ -4389,95 +4386,6 @@ func TestCheckAttachmentsResourceReference(t *testing.T) { }) } -func TestCheckAttachmentsNotEnabled(t *testing.T) { - - t.Parallel() - - parseAndCheckWithoutAttachments := func(t *testing.T, code string) (*sema.Checker, error) { - return ParseAndCheckWithOptions(t, code, ParseAndCheckOptions{}) - } - - t.Run("declaration", func(t *testing.T) { - - t.Parallel() - - _, err := parseAndCheckWithoutAttachments(t, - ` - struct S {} - attachment Test for S {}`, - ) - - errs := RequireCheckerErrors(t, err, 1) - assert.IsType(t, &sema.AttachmentsNotEnabledError{}, errs[0]) - }) - - t.Run("attach", func(t *testing.T) { - - t.Parallel() - - _, err := parseAndCheckWithoutAttachments(t, - ` - struct S {} - let s = attach A() to S() - `, - ) - - errs := RequireCheckerErrors(t, err, 2) - assert.IsType(t, &sema.AttachmentsNotEnabledError{}, errs[0]) - assert.IsType(t, &sema.NotDeclaredError{}, errs[1]) - }) - - t.Run("remove", func(t *testing.T) { - - t.Parallel() - - _, err := parseAndCheckWithoutAttachments(t, - ` - struct S {} - fun foo() { - remove A from S() - } - `, - ) - - errs := RequireCheckerErrors(t, err, 2) - assert.IsType(t, &sema.AttachmentsNotEnabledError{}, errs[0]) - assert.IsType(t, &sema.NotDeclaredError{}, errs[1]) - }) - - t.Run("type indexing", func(t *testing.T) { - - t.Parallel() - - _, err := parseAndCheckWithoutAttachments(t, - ` - struct S {} - attachment A for S {} - let s = S() - let r = s[A] - `, - ) - - errs := RequireCheckerErrors(t, err, 2) - assert.IsType(t, &sema.AttachmentsNotEnabledError{}, errs[0]) - assert.IsType(t, &sema.AttachmentsNotEnabledError{}, errs[1]) - }) - - t.Run("regular indexing ok", func(t *testing.T) { - - t.Parallel() - - _, err := parseAndCheckWithoutAttachments(t, - ` - let x = [1, 2, 3] - let y = x[2] - `, - ) - - require.NoError(t, err) - }) -} - func TestCheckAttachmentForEachAttachment(t *testing.T) { t.Parallel() diff --git a/tests/checker/storable_test.go b/tests/checker/storable_test.go index 5aac22ecfe..5d1b97c2c5 100644 --- a/tests/checker/storable_test.go +++ b/tests/checker/storable_test.go @@ -47,7 +47,6 @@ func TestCheckStorable(t *testing.T) { BaseValueActivationHandler: func(_ common.Location) *sema.VariableActivation { return baseValueActivation }, - AttachmentsEnabled: true, }, }, ) diff --git a/tests/checker/utils.go b/tests/checker/utils.go index f0c1e91442..3afe516b80 100644 --- a/tests/checker/utils.go +++ b/tests/checker/utils.go @@ -37,12 +37,7 @@ import ( ) func ParseAndCheck(t testing.TB, code string) (*sema.Checker, error) { - return ParseAndCheckWithOptions(t, code, ParseAndCheckOptions{ - // allow attachments is on by default for testing purposes - Config: &sema.Config{ - AttachmentsEnabled: true, - }, - }) + return ParseAndCheckWithOptions(t, code, ParseAndCheckOptions{}) } type ParseAndCheckOptions struct { diff --git a/tests/convertValues_test.go b/tests/convertValues_test.go index 1ad217ad69..9637b6fb0e 100644 --- a/tests/convertValues_test.go +++ b/tests/convertValues_test.go @@ -5270,7 +5270,7 @@ func TestRuntimeNestedStructArgPassing(t *testing.T) { func TestRuntimeDestroyedResourceReferenceExport(t *testing.T) { t.Parallel() - rt := NewTestInterpreterRuntimeWithAttachments() + rt := NewTestInterpreterRuntime() script := []byte(` access(all) resource S {} diff --git a/tests/entitlements_test.go b/tests/entitlements_test.go index b09c67b726..f0f5f7ea5f 100644 --- a/tests/entitlements_test.go +++ b/tests/entitlements_test.go @@ -221,7 +221,7 @@ func TestRuntimeAccountEntitlementAttachment(t *testing.T) { t.Parallel() storage := NewTestLedger(nil, nil) - rt := NewTestInterpreterRuntimeWithAttachments() + rt := NewTestInterpreterRuntime() accountCodes := map[Location][]byte{} deployTx := DeploymentTransaction("Test", []byte(` @@ -507,7 +507,7 @@ func TestRuntimeAccountEntitlementCapabilityCasting(t *testing.T) { t.Parallel() storage := NewTestLedger(nil, nil) - rt := NewTestInterpreterRuntimeWithAttachments() + rt := NewTestInterpreterRuntime() accountCodes := map[Location][]byte{} deployTx := DeploymentTransaction("Test", []byte(` @@ -607,7 +607,7 @@ func TestRuntimeAccountEntitlementCapabilityDictionary(t *testing.T) { t.Parallel() storage := NewTestLedger(nil, nil) - rt := NewTestInterpreterRuntimeWithAttachments() + rt := NewTestInterpreterRuntime() accountCodes := map[Location][]byte{} deployTx := DeploymentTransaction("Test", []byte(` @@ -722,7 +722,7 @@ func TestRuntimeAccountEntitlementGenericCapabilityDictionary(t *testing.T) { t.Parallel() storage := NewTestLedger(nil, nil) - rt := NewTestInterpreterRuntimeWithAttachments() + rt := NewTestInterpreterRuntime() accountCodes := map[Location][]byte{} deployTx := DeploymentTransaction("Test", []byte(` diff --git a/tests/interpreter/attachments_test.go b/tests/interpreter/attachments_test.go index fb2fe3657f..3c61208033 100644 --- a/tests/interpreter/attachments_test.go +++ b/tests/interpreter/attachments_test.go @@ -1265,9 +1265,6 @@ func TestInterpretAttachmentDestructor(t *testing.T) { return nil }, }, - CheckerConfig: &sema.Config{ - AttachmentsEnabled: true, - }, }) require.NoError(t, err) @@ -1315,9 +1312,6 @@ func TestInterpretAttachmentDestructor(t *testing.T) { return nil }, }, - CheckerConfig: &sema.Config{ - AttachmentsEnabled: true, - }, }) require.NoError(t, err) @@ -1361,9 +1355,6 @@ func TestInterpretAttachmentDestructor(t *testing.T) { return nil }, }, - CheckerConfig: &sema.Config{ - AttachmentsEnabled: true, - }, }) require.NoError(t, err) @@ -1410,9 +1401,6 @@ func TestInterpretAttachmentDestructor(t *testing.T) { return nil }, }, - CheckerConfig: &sema.Config{ - AttachmentsEnabled: true, - }, }) require.NoError(t, err) @@ -1463,9 +1451,6 @@ func TestInterpretAttachmentDestructor(t *testing.T) { return nil }, }, - CheckerConfig: &sema.Config{ - AttachmentsEnabled: true, - }, }) require.NoError(t, err) @@ -1524,9 +1509,6 @@ func TestInterpretAttachmentDestructor(t *testing.T) { return nil }, }, - CheckerConfig: &sema.Config{ - AttachmentsEnabled: true, - }, }) require.NoError(t, err) @@ -1582,9 +1564,9 @@ func TestInterpretAttachmentResourceReferenceInvalidation(t *testing.T) { access(all) fun returnSameRef(_ ref: &A): &A { return ref - }`, sema.Config{ - AttachmentsEnabled: true, - }) + }`, + sema.Config{}, + ) _, err := inter.Invoke("test") require.ErrorAs(t, err, &interpreter.InvalidatedResourceReferenceError{}) @@ -1611,9 +1593,9 @@ func TestInterpretAttachmentResourceReferenceInvalidation(t *testing.T) { access(all) fun returnSameRef(_ ref: &A): &A { return ref - }`, sema.Config{ - AttachmentsEnabled: true, - }) + }`, + sema.Config{}, + ) _, err := inter.Invoke("test") require.ErrorAs(t, err, &interpreter.InvalidatedResourceReferenceError{}) @@ -1661,9 +1643,9 @@ func TestInterpretAttachmentResourceReferenceInvalidation(t *testing.T) { access(all) fun returnSameRef(_ ref: &A): &A { return ref - }`, sema.Config{ - AttachmentsEnabled: true, - }) + }`, + sema.Config{}, + ) _, err := inter.Invoke("test") require.ErrorAs(t, err, &interpreter.InvalidatedResourceReferenceError{}) @@ -1706,9 +1688,9 @@ func TestInterpretAttachmentResourceReferenceInvalidation(t *testing.T) { r2.setID(5) authAccount.storage.save(<-r2, to: /storage/foo) return ref!.id - }`, sema.Config{ - AttachmentsEnabled: true, - }) + }`, + sema.Config{}, + ) _, err := inter.Invoke("test") require.ErrorAs(t, err, &interpreter.InvalidatedResourceReferenceError{}) @@ -1740,9 +1722,9 @@ func TestInterpretAttachmentResourceReferenceInvalidation(t *testing.T) { access(all) fun returnSameRef(_ ref: &A): &A { return ref - }`, sema.Config{ - AttachmentsEnabled: true, - }) + }`, + sema.Config{}, + ) _, err := inter.Invoke("test") require.ErrorAs(t, err, &interpreter.InvalidatedResourceReferenceError{}) @@ -1784,9 +1766,9 @@ func TestInterpretAttachmentResourceReferenceInvalidation(t *testing.T) { a.setID(5) authAccount.storage.save(<-r2, to: /storage/foo) return ref!.id - }`, sema.Config{ - AttachmentsEnabled: true, - }) + }`, + sema.Config{}, + ) _, err := inter.Invoke("test") require.ErrorAs(t, err, &interpreter.InvalidatedResourceReferenceError{}) @@ -2524,7 +2506,6 @@ func TestInterpretBuiltinCompositeAttachment(t *testing.T) { BaseValueActivationHandler: func(_ common.Location) *sema.VariableActivation { return baseValueActivation }, - AttachmentsEnabled: true, }, Config: &interpreter.Config{ BaseActivationHandler: func(_ common.Location) *interpreter.VariableActivation { diff --git a/tests/interpreter/entitlements_test.go b/tests/interpreter/entitlements_test.go index 14106837ff..0475ec1191 100644 --- a/tests/interpreter/entitlements_test.go +++ b/tests/interpreter/entitlements_test.go @@ -1441,9 +1441,9 @@ func TestInterpretEntitlementMappingFields(t *testing.T) { let i = ref?.foo() return i! } - `, sema.Config{ - AttachmentsEnabled: false, - }) + `, + sema.Config{}, + ) value, err := inter.Invoke("test") require.NoError(t, err) @@ -2534,9 +2534,9 @@ func TestInterpretEntitledAttachments(t *testing.T) { let ref = account.storage.borrow(from: /storage/foo)! return ref[A]! } - `, sema.Config{ - AttachmentsEnabled: true, - }) + `, + sema.Config{}, + ) value, err := inter.Invoke("test") require.NoError(t, err) @@ -2576,9 +2576,9 @@ func TestInterpretEntitledAttachments(t *testing.T) { let ref = account.storage.borrow(from: /storage/foo)! return ref[A]!.entitled() } - `, sema.Config{ - AttachmentsEnabled: true, - }) + `, + sema.Config{}, + ) value, err := inter.Invoke("test") require.NoError(t, err) @@ -2618,9 +2618,9 @@ func TestInterpretEntitledAttachments(t *testing.T) { let ref = account.storage.borrow(from: /storage/foo)! return ref[A]!.entitled() } - `, sema.Config{ - AttachmentsEnabled: true, - }) + `, + sema.Config{}, + ) value, err := inter.Invoke("test") require.NoError(t, err) diff --git a/tests/interpreter/interpreter_test.go b/tests/interpreter/interpreter_test.go index 7c4c6d762f..6a697eff69 100644 --- a/tests/interpreter/interpreter_test.go +++ b/tests/interpreter/interpreter_test.go @@ -50,12 +50,7 @@ type ParseCheckAndInterpretOptions struct { } func parseCheckAndInterpret(t testing.TB, code string) *interpreter.Interpreter { - inter, err := parseCheckAndInterpretWithOptions(t, code, ParseCheckAndInterpretOptions{ - // attachments should be on by default in tests - CheckerConfig: &sema.Config{ - AttachmentsEnabled: true, - }, - }) + inter, err := parseCheckAndInterpretWithOptions(t, code, ParseCheckAndInterpretOptions{}) require.NoError(t, err) return inter } diff --git a/tests/interpreter/resources_test.go b/tests/interpreter/resources_test.go index 8afacd870b..f6d1b11283 100644 --- a/tests/interpreter/resources_test.go +++ b/tests/interpreter/resources_test.go @@ -2537,9 +2537,6 @@ func TestInterpreterDefaultDestroyEventBaseShadowing(t *testing.T) { destroy trollAttachment } `, ParseCheckAndInterpretOptions{ - CheckerConfig: &sema.Config{ - AttachmentsEnabled: true, - }, Config: &interpreter.Config{ OnEventEmitted: func(inter *interpreter.Interpreter, locationRange interpreter.LocationRange, event *interpreter.CompositeValue, eventType *sema.CompositeType) error { events = append(events, event) @@ -2588,9 +2585,6 @@ func TestInterpreterDefaultDestroyEventBaseShadowing(t *testing.T) { destroy trollAttachment } `, ParseCheckAndInterpretOptions{ - CheckerConfig: &sema.Config{ - AttachmentsEnabled: true, - }, Config: &interpreter.Config{ OnEventEmitted: func(inter *interpreter.Interpreter, locationRange interpreter.LocationRange, event *interpreter.CompositeValue, eventType *sema.CompositeType) error { events = append(events, event) diff --git a/tests/runtime_test.go b/tests/runtime_test.go index 3a80d0c83d..de7487cab3 100644 --- a/tests/runtime_test.go +++ b/tests/runtime_test.go @@ -3356,7 +3356,7 @@ func TestRuntimeStorageLoadedDestructionConcreteTypeWithAttachment(t *testing.T) t.Parallel() - runtime := NewTestInterpreterRuntimeWithAttachments() + runtime := NewTestInterpreterRuntime() addressValue := Address{ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, @@ -3486,7 +3486,7 @@ func TestRuntimeStorageLoadedDestructionConcreteTypeWithAttachmentUnloadedContra t.Parallel() - runtime := NewTestInterpreterRuntimeWithAttachments() + runtime := NewTestInterpreterRuntime() addressValue := Address{ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, @@ -3620,7 +3620,7 @@ func TestRuntimeStorageLoadedDestructionConcreteTypeSameNamedInterface(t *testin t.Parallel() - runtime := NewTestInterpreterRuntimeWithAttachments() + runtime := NewTestInterpreterRuntime() addressValue := Address{ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, @@ -10560,7 +10560,7 @@ func TestRuntimeNonPublicAccessModifierInInterface(t *testing.T) { t.Parallel() - runtime := NewTestInterpreterRuntimeWithAttachments() + runtime := NewTestInterpreterRuntime() address1 := common.MustBytesToAddress([]byte{0x1}) address2 := common.MustBytesToAddress([]byte{0x2}) @@ -10693,7 +10693,7 @@ func TestRuntimeContractWithInvalidCapability(t *testing.T) { t.Parallel() - runtime := NewTestInterpreterRuntimeWithAttachments() + runtime := NewTestInterpreterRuntime() address := common.MustBytesToAddress([]byte{0x1}) diff --git a/tests/runtime_utils/testruntime.go b/tests/runtime_utils/testruntime.go index 5ea11f137d..81f1f057b5 100644 --- a/tests/runtime_utils/testruntime.go +++ b/tests/runtime_utils/testruntime.go @@ -38,19 +38,12 @@ func NewTestInterpreterRuntimeWithConfig(config runtime.Config) TestInterpreterR var DefaultTestInterpreterConfig = runtime.Config{ AtreeValidationEnabled: true, - AttachmentsEnabled: true, } func NewTestInterpreterRuntime() TestInterpreterRuntime { return NewTestInterpreterRuntimeWithConfig(DefaultTestInterpreterConfig) } -func NewTestInterpreterRuntimeWithAttachments() TestInterpreterRuntime { - config := DefaultTestInterpreterConfig - config.AttachmentsEnabled = true - return NewTestInterpreterRuntimeWithConfig(config) -} - func (r TestInterpreterRuntime) ExecuteTransaction(script runtime.Script, context runtime.Context) error { i := context.Interface.(*TestRuntimeInterface) i.onTransactionExecutionStart() diff --git a/tests/storage_test.go b/tests/storage_test.go index 39aeccd5bc..3895ca2327 100644 --- a/tests/storage_test.go +++ b/tests/storage_test.go @@ -5941,7 +5941,7 @@ func TestRuntimeStorageReferenceBoundFunction(t *testing.T) { t.Run("struct", func(t *testing.T) { t.Parallel() - runtime := NewTestInterpreterRuntimeWithAttachments() + runtime := NewTestInterpreterRuntime() tx := []byte(` transaction {