Last active
October 25, 2023 18:04
-
-
Save SupunS/cd4fadd7413545dfb5bf44359c504a97 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
commit 3e084c4d3b144fa86e2951f826d2d2d6bd641f36 | |
Merge: 01a42f326 e878449cf | |
Author: Supun Setunga <supun.setunga@gmail.com> | |
Date: Wed Oct 25 10:11:03 2023 -0700 | |
Merge branch 'master' of https://github.com/onflow/cadence into supun/sync-stable-cadence-master | |
diff --git a/npm-packages/cadence-parser/package.json b/npm-packages/cadence-parser/package.json | |
remerge CONFLICT (content): Merge conflict in npm-packages/cadence-parser/package.json | |
index 5be44e987..1ffb0dc10 100644 | |
--- a/npm-packages/cadence-parser/package.json | |
+++ b/npm-packages/cadence-parser/package.json | |
@@ -1,10 +1,6 @@ | |
{ | |
"name": "@onflow/cadence-parser", | |
-<<<<<<< 01a42f326 (Merge pull request #2725 from onflow/supun/improve-conformance) | |
"version": "1.0.0-preview.1", | |
-======= | |
- "version": "0.42.1", | |
->>>>>>> e878449cf (Merge pull request #2878 from onflow/bastian/native-functionality-linking) | |
"description": "The Cadence parser", | |
"homepage": "https://github.com/onflow/cadence", | |
"repository": { | |
diff --git a/runtime/coverage_test.go b/runtime/coverage_test.go | |
remerge CONFLICT (content): Merge conflict in runtime/coverage_test.go | |
index 1fbb53469..7d9b3c71a 100644 | |
--- a/runtime/coverage_test.go | |
+++ b/runtime/coverage_test.go | |
@@ -623,15 +623,12 @@ func TestRuntimeCoverageReportWithAddressLocation(t *testing.T) { | |
require.JSONEq(t, expected, string(actual)) | |
} | |
-<<<<<<< 01a42f326 (Merge pull request #2725 from onflow/supun/improve-conformance) | |
-func TestRuntimeCoverageReportReset(t *testing.T) { | |
-======= | |
func TestCoverageReportWithLocationMappings(t *testing.T) { | |
t.Parallel() | |
script := []byte(` | |
- pub fun answer(): Int { | |
+ access(all) fun answer(): Int { | |
var i = 0 | |
while i < 42 { | |
i = i + 1 | |
@@ -737,8 +734,7 @@ func TestCoverageReportWithLocationMappings(t *testing.T) { | |
}) | |
} | |
-func TestCoverageReportReset(t *testing.T) { | |
->>>>>>> e878449cf (Merge pull request #2878 from onflow/bastian/native-functionality-linking) | |
+func TestRuntimeCoverageReportReset(t *testing.T) { | |
t.Parallel() | |
@@ -1914,7 +1910,6 @@ func TestRuntimeCoverageReportLCOVFormat(t *testing.T) { | |
scriptlocation := common.ScriptLocation{} | |
coverageReport.ExcludeLocation(scriptlocation) | |
-<<<<<<< 01a42f326 (Merge pull request #2725 from onflow/supun/improve-conformance) | |
runtimeInterface := &TestRuntimeInterface{ | |
OnGetCode: func(location Location) (bytes []byte, err error) { | |
switch location { | |
@@ -1929,21 +1924,6 @@ func TestRuntimeCoverageReportLCOVFormat(t *testing.T) { | |
config := DefaultTestInterpreterConfig | |
config.CoverageReport = coverageReport | |
runtime := NewTestInterpreterRuntimeWithConfig(config) | |
-======= | |
- runtimeInterface := &testRuntimeInterface{ | |
- getCode: func(location Location) (bytes []byte, err error) { | |
- switch location { | |
- case common.StringLocation("IntegerTraits"): | |
- return integerTraits, nil | |
- default: | |
- return nil, fmt.Errorf("unknown import location: %s", location) | |
- } | |
- }, | |
- } | |
- | |
- runtime := newTestInterpreterRuntime() | |
- runtime.defaultConfig.CoverageReport = coverageReport | |
->>>>>>> e878449cf (Merge pull request #2878 from onflow/bastian/native-functionality-linking) | |
value, err := runtime.ExecuteScript( | |
Script{ | |
@@ -2001,8 +1981,8 @@ end_of_record | |
scriptlocation := common.ScriptLocation{} | |
coverageReport.ExcludeLocation(scriptlocation) | |
- runtimeInterface := &testRuntimeInterface{ | |
- getCode: func(location Location) (bytes []byte, err error) { | |
+ runtimeInterface := &TestRuntimeInterface{ | |
+ OnGetCode: func(location Location) (bytes []byte, err error) { | |
switch location { | |
case common.StringLocation("IntegerTraits"): | |
return integerTraits, nil | |
@@ -2012,8 +1992,9 @@ end_of_record | |
}, | |
} | |
- runtime := newTestInterpreterRuntime() | |
- runtime.defaultConfig.CoverageReport = coverageReport | |
+ config := DefaultTestInterpreterConfig | |
+ config.CoverageReport = coverageReport | |
+ runtime := NewTestInterpreterRuntimeWithConfig(config) | |
value, err := runtime.ExecuteScript( | |
Script{ | |
diff --git a/runtime/inbox_test.go b/runtime/inbox_test.go | |
remerge CONFLICT (content): Merge conflict in runtime/inbox_test.go | |
index 6194c5446..90618b280 100644 | |
--- a/runtime/inbox_test.go | |
+++ b/runtime/inbox_test.go | |
@@ -19,6 +19,7 @@ | |
package runtime_test | |
import ( | |
+ "github.com/onflow/cadence/encoding/json" | |
"strings" | |
"testing" | |
@@ -26,13 +27,9 @@ import ( | |
"github.com/stretchr/testify/require" | |
"github.com/onflow/cadence" | |
-<<<<<<< 01a42f326 (Merge pull request #2725 from onflow/supun/improve-conformance) | |
. "github.com/onflow/cadence/runtime" | |
. "github.com/onflow/cadence/runtime/tests/runtime_utils" | |
-======= | |
- "github.com/onflow/cadence/encoding/json" | |
"github.com/onflow/cadence/runtime/common" | |
->>>>>>> e878449cf (Merge pull request #2878 from onflow/bastian/native-functionality-linking) | |
) | |
func TestRuntimeAccountInboxPublishUnpublish(t *testing.T) { | |
@@ -302,33 +299,19 @@ func TestRuntimeAccountInboxUnpublishRemove(t *testing.T) { | |
var events []string | |
transaction1 := []byte(` | |
-<<<<<<< 01a42f326 (Merge pull request #2725 from onflow/supun/improve-conformance) | |
- transaction { | |
+ transaction(name: String) { | |
prepare(signer: auth(Storage, Capabilities, Inbox) &Account) { | |
signer.storage.save([3], to: /storage/foo) | |
let cap = signer.capabilities.storage.issue<&[Int]>(/storage/foo) | |
- log(signer.inbox.publish(cap, name: "foo", recipient: 0x2)) | |
-======= | |
- transaction(name: String) { | |
- prepare(signer: AuthAccount) { | |
- signer.save([3], to: /storage/foo) | |
- let cap = signer.link<&[Int]>(/public/foo, target: /storage/foo)! | |
log(signer.inbox.publish(cap, name: name, recipient: 0x2)) | |
->>>>>>> e878449cf (Merge pull request #2878 from onflow/bastian/native-functionality-linking) | |
} | |
} | |
`) | |
transaction2 := []byte(` | |
-<<<<<<< 01a42f326 (Merge pull request #2725 from onflow/supun/improve-conformance) | |
- transaction { | |
- prepare(signer: auth(Inbox) &Account) { | |
- let cap = signer.inbox.unpublish<&[Int]>("foo")! | |
-======= | |
transaction(name: String) { | |
- prepare(signer: AuthAccount) { | |
+ prepare(signer: auth(Inbox) &Account) { | |
let cap = signer.inbox.unpublish<&[Int]>(name)! | |
->>>>>>> e878449cf (Merge pull request #2878 from onflow/bastian/native-functionality-linking) | |
log(cap.borrow()![0]) | |
let cap2 = signer.inbox.unpublish<&[Int]>(name) | |
log(cap2) | |
@@ -336,35 +319,21 @@ func TestRuntimeAccountInboxUnpublishRemove(t *testing.T) { | |
} | |
`) | |
-<<<<<<< 01a42f326 (Merge pull request #2725 from onflow/supun/improve-conformance) | |
+ address := common.MustBytesToAddress([]byte{0x1}) | |
+ | |
runtimeInterface1 := &TestRuntimeInterface{ | |
Storage: storage, | |
OnProgramLog: func(message string) { | |
-======= | |
- address := common.MustBytesToAddress([]byte{0x1}) | |
- | |
- runtimeInterface1 := &testRuntimeInterface{ | |
- storage: storage, | |
- log: func(message string) { | |
->>>>>>> e878449cf (Merge pull request #2878 from onflow/bastian/native-functionality-linking) | |
logs = append(logs, message) | |
}, | |
OnEmitEvent: func(event cadence.Event) error { | |
events = append(events, event.String()) | |
return nil | |
}, | |
-<<<<<<< 01a42f326 (Merge pull request #2725 from onflow/supun/improve-conformance) | |
OnGetSigningAccounts: func() ([]Address, error) { | |
- return []Address{[8]byte{0, 0, 0, 0, 0, 0, 0, 1}}, nil | |
- }, | |
- } | |
- | |
- nextTransactionLocation := NewTransactionLocationGenerator() | |
-======= | |
- getSigningAccounts: func() ([]Address, error) { | |
return []Address{address}, nil | |
}, | |
- decodeArgument: func(b []byte, t cadence.Type) (value cadence.Value, err error) { | |
+ OnDecodeArgument: func(b []byte, t cadence.Type) (value cadence.Value, err error) { | |
return json.Decode(nil, b) | |
}, | |
} | |
@@ -375,9 +344,7 @@ func TestRuntimeAccountInboxUnpublishRemove(t *testing.T) { | |
args := encodeArgs([]cadence.Value{nameArgument}) | |
- nextTransactionLocation := newTransactionLocationGenerator() | |
- | |
->>>>>>> e878449cf (Merge pull request #2878 from onflow/bastian/native-functionality-linking) | |
+ nextTransactionLocation := NewTransactionLocationGenerator() | |
// publish from 1 to 2 | |
err = rt.ExecuteTransaction( | |
Script{ | |
@@ -469,57 +436,35 @@ func TestRuntimeAccountInboxUnpublishWrongAccount(t *testing.T) { | |
} | |
`) | |
-<<<<<<< 01a42f326 (Merge pull request #2725 from onflow/supun/improve-conformance) | |
+ address1 := common.MustBytesToAddress([]byte{0x1}) | |
+ | |
runtimeInterface1 := &TestRuntimeInterface{ | |
Storage: storage, | |
OnProgramLog: func(message string) { | |
-======= | |
- address1 := common.MustBytesToAddress([]byte{0x1}) | |
- | |
- runtimeInterface1 := &testRuntimeInterface{ | |
- storage: storage, | |
- log: func(message string) { | |
->>>>>>> e878449cf (Merge pull request #2878 from onflow/bastian/native-functionality-linking) | |
logs = append(logs, message) | |
}, | |
OnEmitEvent: func(event cadence.Event) error { | |
events = append(events, event.String()) | |
return nil | |
}, | |
-<<<<<<< 01a42f326 (Merge pull request #2725 from onflow/supun/improve-conformance) | |
OnGetSigningAccounts: func() ([]Address, error) { | |
- return []Address{[8]byte{0, 0, 0, 0, 0, 0, 0, 1}}, nil | |
- }, | |
- } | |
- | |
- runtimeInterface2 := &TestRuntimeInterface{ | |
- Storage: storage, | |
- OnProgramLog: func(message string) { | |
-======= | |
- getSigningAccounts: func() ([]Address, error) { | |
return []Address{address1}, nil | |
}, | |
} | |
address2 := common.MustBytesToAddress([]byte{0x2}) | |
- runtimeInterface2 := &testRuntimeInterface{ | |
- storage: storage, | |
- log: func(message string) { | |
->>>>>>> e878449cf (Merge pull request #2878 from onflow/bastian/native-functionality-linking) | |
+ runtimeInterface2 := &TestRuntimeInterface{ | |
+ Storage: storage, | |
+ OnProgramLog: func(message string) { | |
logs = append(logs, message) | |
}, | |
OnEmitEvent: func(event cadence.Event) error { | |
events = append(events, event.String()) | |
return nil | |
}, | |
-<<<<<<< 01a42f326 (Merge pull request #2725 from onflow/supun/improve-conformance) | |
OnGetSigningAccounts: func() ([]Address, error) { | |
- return []Address{[8]byte{0, 0, 0, 0, 0, 0, 0, 2}}, nil | |
-======= | |
- getSigningAccounts: func() ([]Address, error) { | |
return []Address{address2}, nil | |
->>>>>>> e878449cf (Merge pull request #2878 from onflow/bastian/native-functionality-linking) | |
}, | |
} | |
@@ -613,58 +558,36 @@ func TestRuntimeAccountInboxPublishClaim(t *testing.T) { | |
} | |
`) | |
-<<<<<<< 01a42f326 (Merge pull request #2725 from onflow/supun/improve-conformance) | |
+ address1 := common.MustBytesToAddress([]byte{0x1}) | |
+ | |
runtimeInterface1 := &TestRuntimeInterface{ | |
Storage: storage, | |
OnProgramLog: func(message string) { | |
-======= | |
- address1 := common.MustBytesToAddress([]byte{0x1}) | |
- | |
- runtimeInterface1 := &testRuntimeInterface{ | |
- storage: storage, | |
- log: func(message string) { | |
->>>>>>> e878449cf (Merge pull request #2878 from onflow/bastian/native-functionality-linking) | |
logs = append(logs, message) | |
}, | |
OnEmitEvent: func(event cadence.Event) error { | |
events = append(events, event.String()) | |
return nil | |
}, | |
-<<<<<<< 01a42f326 (Merge pull request #2725 from onflow/supun/improve-conformance) | |
OnGetSigningAccounts: func() ([]Address, error) { | |
- return []Address{[8]byte{0, 0, 0, 0, 0, 0, 0, 1}}, nil | |
- }, | |
- } | |
- | |
- runtimeInterface2 := &TestRuntimeInterface{ | |
- Storage: storage, | |
- OnProgramLog: func(message string) { | |
-======= | |
- getSigningAccounts: func() ([]Address, error) { | |
return []Address{address1}, nil | |
}, | |
} | |
address2 := common.MustBytesToAddress([]byte{0x2}) | |
- runtimeInterface2 := &testRuntimeInterface{ | |
- storage: storage, | |
- log: func(message string) { | |
+ runtimeInterface2 := &TestRuntimeInterface{ | |
+ Storage: storage, | |
+ OnProgramLog: func(message string) { | |
->>>>>>> e878449cf (Merge pull request #2878 from onflow/bastian/native-functionality-linking) | |
logs = append(logs, message) | |
}, | |
OnEmitEvent: func(event cadence.Event) error { | |
events = append(events, event.String()) | |
return nil | |
}, | |
-<<<<<<< 01a42f326 (Merge pull request #2725 from onflow/supun/improve-conformance) | |
OnGetSigningAccounts: func() ([]Address, error) { | |
- return []Address{[8]byte{0, 0, 0, 0, 0, 0, 0, 2}}, nil | |
-======= | |
- getSigningAccounts: func() ([]Address, error) { | |
return []Address{address2}, nil | |
->>>>>>> e878449cf (Merge pull request #2878 from onflow/bastian/native-functionality-linking) | |
}, | |
} | |
diff --git a/runtime/interpreter/value.go b/runtime/interpreter/value.go | |
remerge CONFLICT (content): Merge conflict in runtime/interpreter/value.go | |
index 4eb062e8a..8e46111af 100644 | |
--- a/runtime/interpreter/value.go | |
+++ b/runtime/interpreter/value.go | |
@@ -16747,26 +16747,8 @@ func (v *CompositeValue) GetMember(interpreter *Interpreter, locationRange Locat | |
return injectedField | |
} | |
-<<<<<<< 01a42f326 (Merge pull request #2725 from onflow/supun/improve-conformance) | |
- if v.InjectedFields != nil { | |
- value, ok := v.InjectedFields[name] | |
- if ok { | |
- return value | |
- } | |
- } | |
- | |
- function, ok := v.Functions[name] | |
- if ok { | |
- var base *EphemeralReferenceValue | |
- var self MemberAccessibleValue = v | |
- if v.Kind == common.CompositeKindAttachment { | |
- base, self = attachmentBaseAndSelfValues(interpreter, v) | |
- } | |
- return NewBoundFunctionValue(interpreter, function, &self, base, nil) | |
-======= | |
if function := v.GetFunction(interpreter, locationRange, name); function != nil { | |
return function | |
->>>>>>> e878449cf (Merge pull request #2878 from onflow/bastian/native-functionality-linking) | |
} | |
return nil | |
@@ -16844,7 +16826,7 @@ func (v *CompositeValue) GetFunction(interpreter *Interpreter, locationRange Loc | |
if v.Kind == common.CompositeKindAttachment { | |
base, self = attachmentBaseAndSelfValues(interpreter, v) | |
} | |
- return NewBoundFunctionValue(interpreter, function, &self, base) | |
+ return NewBoundFunctionValue(interpreter, function, &self, base, nil) | |
} | |
func (v *CompositeValue) OwnerValue(interpreter *Interpreter, locationRange LocationRange) OptionalValue { | |
@@ -17492,7 +17474,6 @@ func (v *CompositeValue) Transfer( | |
v.QualifiedIdentifier, | |
v.Kind, | |
) | |
-<<<<<<< 01a42f326 (Merge pull request #2725 from onflow/supun/improve-conformance) | |
res = newCompositeValueFromAtreeMap( | |
interpreter, | |
@@ -17500,13 +17481,8 @@ func (v *CompositeValue) Transfer( | |
dictionary, | |
) | |
- res.InjectedFields = v.InjectedFields | |
- res.ComputedFields = v.ComputedFields | |
-======= | |
- res = newCompositeValueFromOrderedMap(dictionary, info) | |
res.injectedFields = v.injectedFields | |
res.computedFields = v.computedFields | |
->>>>>>> e878449cf (Merge pull request #2878 from onflow/bastian/native-functionality-linking) | |
res.NestedVariables = v.NestedVariables | |
res.Functions = v.Functions | |
res.Destructor = v.Destructor | |
diff --git a/runtime/predeclaredvalues_test.go b/runtime/predeclaredvalues_test.go | |
remerge CONFLICT (content): Merge conflict in runtime/predeclaredvalues_test.go | |
index 5026ab652..b2f4e6cbb 100644 | |
--- a/runtime/predeclaredvalues_test.go | |
+++ b/runtime/predeclaredvalues_test.go | |
@@ -32,11 +32,8 @@ import ( | |
"github.com/onflow/cadence/runtime/interpreter" | |
"github.com/onflow/cadence/runtime/sema" | |
"github.com/onflow/cadence/runtime/stdlib" | |
-<<<<<<< 01a42f326 (Merge pull request #2725 from onflow/supun/improve-conformance) | |
- . "github.com/onflow/cadence/runtime/tests/runtime_utils" | |
-======= | |
"github.com/onflow/cadence/runtime/tests/checker" | |
->>>>>>> e878449cf (Merge pull request #2878 from onflow/bastian/native-functionality-linking) | |
+ . "github.com/onflow/cadence/runtime/tests/runtime_utils" | |
. "github.com/onflow/cadence/runtime/tests/utils" | |
) | |
@@ -51,15 +48,6 @@ func TestRuntimePredeclaredValues(t *testing.T) { | |
Name: contractName, | |
} | |
-<<<<<<< 01a42f326 (Merge pull request #2725 from onflow/supun/improve-conformance) | |
- contract := []byte(` | |
- access(all) contract C { | |
- access(all) fun foo(): Int { | |
- return foo | |
- } | |
- } | |
- `) | |
-======= | |
test := func( | |
t *testing.T, | |
contract string, | |
@@ -68,41 +56,31 @@ func TestRuntimePredeclaredValues(t *testing.T) { | |
checkTransaction func(err error) bool, | |
checkScript func(result cadence.Value, err error), | |
) { | |
->>>>>>> e878449cf (Merge pull request #2878 from onflow/bastian/native-functionality-linking) | |
- | |
- runtime := newTestInterpreterRuntime() | |
- | |
-<<<<<<< 01a42f326 (Merge pull request #2725 from onflow/supun/improve-conformance) | |
- access(all) fun main(): Int { | |
- return foo + C.foo() | |
- } | |
- `) | |
runtime := NewTestInterpreterRuntime() | |
-======= | |
+ | |
deploy := DeploymentTransaction(contractName, []byte(contract)) | |
var accountCode []byte | |
var events []cadence.Event | |
->>>>>>> e878449cf (Merge pull request #2878 from onflow/bastian/native-functionality-linking) | |
- runtimeInterface := &testRuntimeInterface{ | |
- getCode: func(_ Location) (bytes []byte, err error) { | |
+ runtimeInterface := &TestRuntimeInterface{ | |
+ OnGetCode: func(_ Location) (bytes []byte, err error) { | |
return accountCode, nil | |
}, | |
- storage: newTestLedger(nil, nil), | |
- getSigningAccounts: func() ([]Address, error) { | |
+ Storage: NewTestLedger(nil, nil), | |
+ OnGetSigningAccounts: func() ([]Address, error) { | |
return []Address{address}, nil | |
}, | |
- resolveLocation: singleIdentifierLocationResolver(t), | |
- getAccountContractCode: func(_ common.AddressLocation) (code []byte, err error) { | |
+ OnResolveLocation: NewSingleIdentifierLocationResolver(t), | |
+ OnGetAccountContractCode: func(_ common.AddressLocation) (code []byte, err error) { | |
return accountCode, nil | |
}, | |
- updateAccountContractCode: func(_ common.AddressLocation, code []byte) error { | |
+ OnUpdateAccountContractCode: func(_ common.AddressLocation, code []byte) error { | |
accountCode = code | |
return nil | |
}, | |
- emitEvent: func(event cadence.Event) error { | |
+ OnEmitEvent: func(event cadence.Event) error { | |
events = append(events, event) | |
return nil | |
}, | |
@@ -114,28 +92,6 @@ func TestRuntimePredeclaredValues(t *testing.T) { | |
} | |
} | |
-<<<<<<< 01a42f326 (Merge pull request #2725 from onflow/supun/improve-conformance) | |
- runtimeInterface := &TestRuntimeInterface{ | |
- OnGetCode: func(_ Location) (bytes []byte, err error) { | |
- return accountCode, nil | |
- }, | |
- Storage: NewTestLedger(nil, nil), | |
- OnGetSigningAccounts: func() ([]Address, error) { | |
- return []Address{common.MustBytesToAddress([]byte{0x1})}, nil | |
- }, | |
- OnResolveLocation: NewSingleIdentifierLocationResolver(t), | |
- OnGetAccountContractCode: func(_ common.AddressLocation) (code []byte, err error) { | |
- return accountCode, nil | |
- }, | |
- OnUpdateAccountContractCode: func(_ common.AddressLocation, code []byte) error { | |
- accountCode = code | |
- return nil | |
- }, | |
- OnEmitEvent: func(event cadence.Event) error { | |
- events = append(events, event) | |
- return nil | |
- }, | |
-======= | |
// Run deploy transaction | |
transactionEnvironment := NewBaseInterpreterEnvironment(Config{}) | |
@@ -168,7 +124,6 @@ func TestRuntimePredeclaredValues(t *testing.T) { | |
}, | |
)) | |
} | |
->>>>>>> e878449cf (Merge pull request #2878 from onflow/bastian/native-functionality-linking) | |
} | |
t.Run("everywhere", func(t *testing.T) { | |
@@ -176,8 +131,8 @@ func TestRuntimePredeclaredValues(t *testing.T) { | |
test(t, | |
` | |
- pub contract C { | |
- pub fun foo(): Int { | |
+ access(all) contract C { | |
+ access(all) fun foo(): Int { | |
return foo | |
} | |
} | |
@@ -185,7 +140,7 @@ func TestRuntimePredeclaredValues(t *testing.T) { | |
` | |
import C from 0x1 | |
- pub fun main(): Int { | |
+ access(all) fun main(): Int { | |
return foo + C.foo() | |
} | |
`, | |
@@ -217,8 +172,8 @@ func TestRuntimePredeclaredValues(t *testing.T) { | |
test(t, | |
` | |
- pub contract C { | |
- pub fun foo(): Int { | |
+ access(all) contract C { | |
+ access(all) fun foo(): Int { | |
return foo | |
} | |
} | |
@@ -226,7 +181,7 @@ func TestRuntimePredeclaredValues(t *testing.T) { | |
` | |
import C from 0x1 | |
- pub fun main(): Int { | |
+ access(all) fun main(): Int { | |
return C.foo() | |
} | |
`, | |
@@ -258,8 +213,8 @@ func TestRuntimePredeclaredValues(t *testing.T) { | |
test(t, | |
` | |
- pub contract C { | |
- pub fun foo(): Int { | |
+ access(all) contract C { | |
+ access(all) fun foo(): Int { | |
return foo | |
} | |
} | |
@@ -267,7 +222,7 @@ func TestRuntimePredeclaredValues(t *testing.T) { | |
` | |
import C from 0x1 | |
- pub fun main(): Int { | |
+ access(all) fun main(): Int { | |
return foo + C.foo() | |
} | |
`, | |
@@ -715,19 +670,20 @@ func TestRuntimePredeclaredTypeWithInjectedFunctions(t *testing.T) { | |
} | |
script := []byte(` | |
- pub fun main(): String { | |
+ access(all) | |
+ fun main(): String { | |
return X().foo(bar: 1) | |
} | |
`) | |
- runtime := newTestInterpreterRuntime() | |
+ runtime := NewTestInterpreterRuntime() | |
- runtimeInterface := &testRuntimeInterface{ | |
- storage: newTestLedger(nil, nil), | |
- getSigningAccounts: func() ([]Address, error) { | |
+ runtimeInterface := &TestRuntimeInterface{ | |
+ Storage: NewTestLedger(nil, nil), | |
+ OnGetSigningAccounts: func() ([]Address, error) { | |
return []Address{common.MustBytesToAddress([]byte{0x1})}, nil | |
}, | |
- resolveLocation: singleIdentifierLocationResolver(t), | |
+ OnResolveLocation: NewSingleIdentifierLocationResolver(t), | |
} | |
// Run script | |
diff --git a/runtime/repl.go b/runtime/repl.go | |
remerge CONFLICT (content): Merge conflict in runtime/repl.go | |
index f50e7ba00..135df8eb1 100644 | |
--- a/runtime/repl.go | |
+++ b/runtime/repl.go | |
@@ -87,14 +87,10 @@ func NewREPL() (*REPL, error) { | |
defer func() { uuid++ }() | |
return uuid, nil | |
}, | |
-<<<<<<< 01a42f326 (Merge pull request #2725 from onflow/supun/improve-conformance) | |
- BaseActivation: baseActivation, | |
- OnEventEmitted: standardLibraryHandler.NewOnEventEmittedHandler(), | |
-======= | |
BaseActivationHandler: func(_ common.Location) *interpreter.VariableActivation { | |
return baseActivation | |
}, | |
->>>>>>> e878449cf (Merge pull request #2878 from onflow/bastian/native-functionality-linking) | |
+ OnEventEmitted: standardLibraryHandler.NewOnEventEmittedHandler(), | |
} | |
inter, err := interpreter.NewInterpreter( | |
@@ -348,7 +344,7 @@ func (r *REPL) Suggestions() (result []REPLSuggestion) { | |
names[name] = variable.Type.String() | |
}) | |
- _ = r.checker.Config.BaseValueActivation.ForEach(func(name string, variable *sema.Variable) error { | |
+ _ = r.checker.Config.BaseValueActivationHandler(nil).ForEach(func(name string, variable *sema.Variable) error { | |
if names[name] == "" { | |
names[name] = variable.Type.String() | |
} | |
diff --git a/runtime/sema/check_composite_declaration.go b/runtime/sema/check_composite_declaration.go | |
remerge CONFLICT (content): Merge conflict in runtime/sema/check_composite_declaration.go | |
index f334e1fa6..574d6d02c 100644 | |
--- a/runtime/sema/check_composite_declaration.go | |
+++ b/runtime/sema/check_composite_declaration.go | |
@@ -1790,25 +1790,18 @@ func (checker *Checker) defaultMembersAndOrigins( | |
identifier := function.Identifier.Identifier | |
-<<<<<<< 01a42f326 (Merge pull request #2725 from onflow/supun/improve-conformance) | |
functionAccess := checker.accessFromAstAccess(function.Access) | |
functionType := checker.functionType( | |
+ function.IsNative(), | |
function.Purity, | |
functionAccess, | |
+ function.TypeParameterList, | |
function.ParameterList, | |
function.ReturnTypeAnnotation, | |
) | |
checker.Elaboration.SetFunctionDeclarationFunctionType(function, functionType) | |
-======= | |
- functionType := checker.functionType( | |
- function.IsNative(), | |
- function.TypeParameterList, | |
- function.ParameterList, | |
- function.ReturnTypeAnnotation, | |
- ) | |
->>>>>>> e878449cf (Merge pull request #2878 from onflow/bastian/native-functionality-linking) | |
argumentLabels := function.ParameterList.EffectiveArgumentLabels() | |
diff --git a/runtime/sema/check_function.go b/runtime/sema/check_function.go | |
remerge CONFLICT (content): Merge conflict in runtime/sema/check_function.go | |
index b805053b5..181d497b1 100644 | |
--- a/runtime/sema/check_function.go | |
+++ b/runtime/sema/check_function.go | |
@@ -100,17 +100,15 @@ func (checker *Checker) visitFunctionDeclaration( | |
access := checker.accessFromAstAccess(declaration.Access) | |
if functionType == nil { | |
-<<<<<<< 01a42f326 (Merge pull request #2725 from onflow/supun/improve-conformance) | |
- functionType = checker.functionType(declaration.Purity, access, declaration.ParameterList, declaration.ReturnTypeAnnotation) | |
-======= | |
functionType = checker.functionType( | |
declaration.IsNative(), | |
+ declaration.Purity, | |
+ access, | |
declaration.TypeParameterList, | |
declaration.ParameterList, | |
declaration.ReturnTypeAnnotation, | |
) | |
->>>>>>> e878449cf (Merge pull request #2878 from onflow/bastian/native-functionality-linking) | |
if options.declareFunction { | |
checker.declareFunctionDeclaration(declaration, functionType) | |
@@ -503,13 +501,10 @@ func (checker *Checker) VisitFunctionExpression(expression *ast.FunctionExpressi | |
// TODO: infer | |
functionType := checker.functionType( | |
-<<<<<<< 01a42f326 (Merge pull request #2725 from onflow/supun/improve-conformance) | |
+ false, | |
expression.Purity, | |
UnauthorizedAccess, | |
-======= | |
- false, | |
nil, | |
->>>>>>> e878449cf (Merge pull request #2878 from onflow/bastian/native-functionality-linking) | |
expression.ParameterList, | |
expression.ReturnTypeAnnotation, | |
) | |
diff --git a/runtime/sema/checker.go b/runtime/sema/checker.go | |
remerge CONFLICT (content): Merge conflict in runtime/sema/checker.go | |
index 710caa188..735f42c59 100644 | |
--- a/runtime/sema/checker.go | |
+++ b/runtime/sema/checker.go | |
@@ -130,13 +130,12 @@ var _ ast.DeclarationVisitor[struct{}] = &Checker{} | |
var _ ast.StatementVisitor[struct{}] = &Checker{} | |
var _ ast.ExpressionVisitor[Type] = &Checker{} | |
-<<<<<<< 01a42f326 (Merge pull request #2725 from onflow/supun/improve-conformance) | |
var baseFunctionType = NewSimpleFunctionType( | |
FunctionPurityImpure, | |
nil, | |
VoidTypeAnnotation, | |
) | |
-======= | |
+ | |
func NewVariableActivationsFromHandler( | |
handler ActivationHandlerFunc, | |
location common.Location, | |
@@ -151,7 +150,6 @@ func NewVariableActivationsFromHandler( | |
} | |
return NewVariableActivations(activation) | |
} | |
->>>>>>> e878449cf (Merge pull request #2878 from onflow/bastian/native-functionality-linking) | |
func NewChecker( | |
program *ast.Program, | |
@@ -511,13 +509,10 @@ func (checker *Checker) checkTopLevelDeclarationValidity( | |
func (checker *Checker) declareGlobalFunctionDeclaration(declaration *ast.FunctionDeclaration) { | |
functionType := checker.functionType( | |
-<<<<<<< 01a42f326 (Merge pull request #2725 from onflow/supun/improve-conformance) | |
+ declaration.IsNative(), | |
declaration.Purity, | |
UnauthorizedAccess, | |
-======= | |
- declaration.IsNative(), | |
declaration.TypeParameterList, | |
->>>>>>> e878449cf (Merge pull request #2878 from onflow/bastian/native-functionality-linking) | |
declaration.ParameterList, | |
declaration.ReturnTypeAnnotation, | |
) | |
@@ -1280,18 +1275,14 @@ func (checker *Checker) ConvertTypeAnnotation(typeAnnotation *ast.TypeAnnotation | |
} | |
func (checker *Checker) functionType( | |
-<<<<<<< 01a42f326 (Merge pull request #2725 from onflow/supun/improve-conformance) | |
+ isNative bool, | |
purity ast.FunctionPurity, | |
access Access, | |
-======= | |
- isNative bool, | |
typeParameterList *ast.TypeParameterList, | |
->>>>>>> e878449cf (Merge pull request #2878 from onflow/bastian/native-functionality-linking) | |
parameterList *ast.ParameterList, | |
returnTypeAnnotation *ast.TypeAnnotation, | |
) *FunctionType { | |
-<<<<<<< 01a42f326 (Merge pull request #2725 from onflow/supun/improve-conformance) | |
oldMappedAccess := checker.entitlementMappingInScope | |
if mapAccess, isMapAccess := access.(*EntitlementMapAccess); isMapAccess { | |
checker.entitlementMappingInScope = mapAccess.Type | |
@@ -1299,7 +1290,8 @@ func (checker *Checker) functionType( | |
checker.entitlementMappingInScope = nil | |
} | |
defer func() { checker.entitlementMappingInScope = oldMappedAccess }() | |
-======= | |
+ | |
+ | |
// Convert type parameters (if any) | |
var convertedTypeParameters []*TypeParameter | |
@@ -1348,7 +1340,6 @@ func (checker *Checker) functionType( | |
} | |
// Convert parameters | |
->>>>>>> e878449cf (Merge pull request #2878 from onflow/bastian/native-functionality-linking) | |
convertedParameters := checker.parameters(parameterList) | |
@@ -1361,11 +1352,8 @@ func (checker *Checker) functionType( | |
} | |
return &FunctionType{ | |
-<<<<<<< 01a42f326 (Merge pull request #2725 from onflow/supun/improve-conformance) | |
Purity: PurityFromAnnotation(purity), | |
-======= | |
TypeParameters: convertedTypeParameters, | |
->>>>>>> e878449cf (Merge pull request #2878 from onflow/bastian/native-functionality-linking) | |
Parameters: convertedParameters, | |
ReturnTypeAnnotation: convertedReturnTypeAnnotation, | |
} | |
diff --git a/runtime/sema/errors.go b/runtime/sema/errors.go | |
remerge CONFLICT (content): Merge conflict in runtime/sema/errors.go | |
index e22d661eb..5c4fd92b6 100644 | |
--- a/runtime/sema/errors.go | |
+++ b/runtime/sema/errors.go | |
@@ -4681,7 +4681,6 @@ func (e *AttachmentsNotEnabledError) Error() string { | |
return "attachments are not enabled and cannot be used in this environment" | |
} | |
-<<<<<<< 01a42f326 (Merge pull request #2725 from onflow/supun/improve-conformance) | |
// InvalidAttachmentEntitlementError | |
type InvalidAttachmentEntitlementError struct { | |
Attachment *CompositeType | |
@@ -4726,7 +4725,8 @@ func (e *InvalidAttachmentEntitlementError) StartPosition() ast.Position { | |
func (e *InvalidAttachmentEntitlementError) EndPosition(common.MemoryGauge) ast.Position { | |
return e.Pos | |
-======= | |
+} | |
+ | |
// InvalidTypeParameterizedNonNativeFunctionError | |
type InvalidTypeParameterizedNonNativeFunctionError struct { | |
@@ -4742,5 +4742,4 @@ func (*InvalidTypeParameterizedNonNativeFunctionError) IsUserError() {} | |
func (e *InvalidTypeParameterizedNonNativeFunctionError) Error() string { | |
return "invalid type parameters in non-native function" | |
->>>>>>> e878449cf (Merge pull request #2878 from onflow/bastian/native-functionality-linking) | |
} | |
diff --git a/runtime/sema/gen/golden_test.go b/runtime/sema/gen/golden_test.go | |
index 6eccdc779..27dd86b5d 100644 | |
--- a/runtime/sema/gen/golden_test.go | |
+++ b/runtime/sema/gen/golden_test.go | |
@@ -63,7 +63,9 @@ func TestConstructor(t *testing.T) { | |
`, | |
checker.ParseAndCheckOptions{ | |
Config: &sema.Config{ | |
- BaseValueActivation: baseValueActivation, | |
+ BaseValueActivationHandler: func(_ common.Location) *sema.VariableActivation { | |
+ return baseValueActivation | |
+ }, | |
}, | |
}, | |
) | |
@@ -87,7 +89,9 @@ func TestContract(t *testing.T) { | |
`, | |
checker.ParseAndCheckOptions{ | |
Config: &sema.Config{ | |
- BaseValueActivation: baseValueActivation, | |
+ BaseValueActivationHandler: func(_ common.Location) *sema.VariableActivation { | |
+ return baseValueActivation | |
+ }, | |
}, | |
}, | |
) | |
diff --git a/runtime/stdlib/builtin.go b/runtime/stdlib/builtin.go | |
remerge CONFLICT (content): Merge conflict in runtime/stdlib/builtin.go | |
index 7c0bda129..e1f085899 100644 | |
--- a/runtime/stdlib/builtin.go | |
+++ b/runtime/stdlib/builtin.go | |
@@ -49,13 +49,8 @@ func DefaultStandardLibraryValues(handler StandardLibraryHandler) []StandardLibr | |
NewGetBlockFunction(handler), | |
NewGetCurrentBlockFunction(handler), | |
NewGetAccountFunction(handler), | |
-<<<<<<< 01a42f326 (Merge pull request #2725 from onflow/supun/improve-conformance) | |
NewAccountConstructor(handler), | |
- NewPublicKeyConstructor(handler, handler, handler), | |
-======= | |
- NewAuthAccountConstructor(handler), | |
NewPublicKeyConstructor(handler), | |
->>>>>>> e878449cf (Merge pull request #2878 from onflow/bastian/native-functionality-linking) | |
NewBLSContract(nil, handler), | |
NewHashAlgorithmConstructor(handler), | |
} | |
diff --git a/runtime/tests/checker/account_test.go b/runtime/tests/checker/account_test.go | |
remerge CONFLICT (content): Merge conflict in runtime/tests/checker/account_test.go | |
index c86850322..f0cf63e6b 100644 | |
--- a/runtime/tests/checker/account_test.go | |
+++ b/runtime/tests/checker/account_test.go | |
@@ -30,42 +30,7 @@ import ( | |
"github.com/onflow/cadence/runtime/tests/utils" | |
) | |
-<<<<<<< 01a42f326 (Merge pull request #2725 from onflow/supun/improve-conformance) | |
func TestCheckAccountStorageSave(t *testing.T) { | |
-======= | |
-func ParseAndCheckAccountWithConfig(t *testing.T, code string, config sema.Config) (*sema.Checker, error) { | |
- | |
- constantDeclaration := func(name string, ty sema.Type) stdlib.StandardLibraryValue { | |
- return stdlib.StandardLibraryValue{ | |
- Name: name, | |
- Type: ty, | |
- Kind: common.DeclarationKindConstant, | |
- } | |
- } | |
- | |
- baseValueActivation := sema.NewVariableActivation(sema.BaseValueActivation) | |
- baseValueActivation.DeclareValue(constantDeclaration("authAccount", sema.AuthAccountType)) | |
- baseValueActivation.DeclareValue(constantDeclaration("publicAccount", sema.PublicAccountType)) | |
- | |
- require.Nil(t, config.BaseValueActivationHandler) | |
- config.BaseValueActivationHandler = func(_ common.Location) *sema.VariableActivation { | |
- return baseValueActivation | |
- } | |
- | |
- return ParseAndCheckWithOptions(t, | |
- code, | |
- ParseAndCheckOptions{ | |
- Config: &config, | |
- }, | |
- ) | |
-} | |
- | |
-func ParseAndCheckAccount(t *testing.T, code string) (*sema.Checker, error) { | |
- return ParseAndCheckAccountWithConfig(t, code, sema.Config{}) | |
-} | |
- | |
-func TestCheckAccount_save(t *testing.T) { | |
->>>>>>> e878449cf (Merge pull request #2878 from onflow/bastian/native-functionality-linking) | |
t.Parallel() | |
diff --git a/runtime/tests/checker/genericfunction_test.go b/runtime/tests/checker/genericfunction_test.go | |
index 850c9f3c9..00ccd2fc5 100644 | |
--- a/runtime/tests/checker/genericfunction_test.go | |
+++ b/runtime/tests/checker/genericfunction_test.go | |
@@ -988,10 +988,9 @@ func TestCheckGenericFunctionDeclaration(t *testing.T) { | |
}, | |
) | |
- errs := RequireCheckerErrors(t, err, 2) | |
+ errs := RequireCheckerErrors(t, err, 1) | |
assert.IsType(t, &sema.InvalidTypeParameterizedNonNativeFunctionError{}, errs[0]) | |
- assert.IsType(t, &sema.InvalidTypeParameterizedNonNativeFunctionError{}, errs[1]) | |
}) | |
t.Run("composite function, non-native", func(t *testing.T) { | |
diff --git a/runtime/tests/checker/invocation_test.go b/runtime/tests/checker/invocation_test.go | |
remerge CONFLICT (content): Merge conflict in runtime/tests/checker/invocation_test.go | |
index 7912aca7d..7a19f13aa 100644 | |
--- a/runtime/tests/checker/invocation_test.go | |
+++ b/runtime/tests/checker/invocation_test.go | |
@@ -24,10 +24,7 @@ import ( | |
"github.com/stretchr/testify/assert" | |
"github.com/stretchr/testify/require" | |
-<<<<<<< 01a42f326 (Merge pull request #2725 from onflow/supun/improve-conformance) | |
"github.com/onflow/cadence/runtime/ast" | |
-======= | |
->>>>>>> e878449cf (Merge pull request #2878 from onflow/bastian/native-functionality-linking) | |
"github.com/onflow/cadence/runtime/common" | |
"github.com/onflow/cadence/runtime/sema" | |
"github.com/onflow/cadence/runtime/stdlib" | |
diff --git a/runtime/tests/interpreter/account_test.go b/runtime/tests/interpreter/account_test.go | |
remerge CONFLICT (content): Merge conflict in runtime/tests/interpreter/account_test.go | |
index 6493228e1..265e33e38 100644 | |
--- a/runtime/tests/interpreter/account_test.go | |
+++ b/runtime/tests/interpreter/account_test.go | |
@@ -449,20 +449,13 @@ func testAccountWithErrorHandler( | |
ParseCheckAndInterpretOptions{ | |
CheckerConfig: &checkerConfig, | |
Config: &interpreter.Config{ | |
-<<<<<<< 01a42f326 (Merge pull request #2725 from onflow/supun/improve-conformance) | |
- BaseActivation: baseActivation, | |
- ContractValueHandler: makeContractValueHandler(nil, nil, nil), | |
- InvalidatedResourceValidationEnabled: true, | |
- AccountHandler: func(address interpreter.AddressValue) interpreter.Value { | |
- return stdlib.NewAccountValue(nil, nil, address) | |
-======= | |
BaseActivationHandler: func(_ common.Location) *interpreter.VariableActivation { | |
return baseActivation | |
}, | |
ContractValueHandler: makeContractValueHandler(nil, nil, nil), | |
- AuthAccountHandler: func(address interpreter.AddressValue) interpreter.Value { | |
- return newTestAuthAccountValue(nil, address) | |
->>>>>>> e878449cf (Merge pull request #2878 from onflow/bastian/native-functionality-linking) | |
+ InvalidatedResourceValidationEnabled: true, | |
+ AccountHandler: func(address interpreter.AddressValue) interpreter.Value { | |
+ return stdlib.NewAccountValue(nil, nil, address) | |
}, | |
}, | |
HandleCheckerError: checkerErrorHandler, | |
@@ -1371,1267 +1364,3 @@ func TestInterpretAccountStorageFields(t *testing.T) { | |
} | |
} | |
} | |
-<<<<<<< 01a42f326 (Merge pull request #2725 from onflow/supun/improve-conformance) | |
-======= | |
- | |
-func TestInterpretAccount_iteration(t *testing.T) { | |
- | |
- t.Parallel() | |
- t.Run("paths field", func(t *testing.T) { | |
- | |
- t.Parallel() | |
- | |
- address := interpreter.NewUnmeteredAddressValueFromBytes([]byte{42}) | |
- | |
- inter, _ := testAccount( | |
- t, | |
- address, | |
- true, | |
- ` | |
- fun saveStorage() { | |
- account.save(0, to:/storage/foo) | |
- } | |
- | |
- fun saveOtherStorage() { | |
- account.save(0, to:/storage/bar) | |
- } | |
- | |
- fun loadStorage() { | |
- account.load<Int>(from:/storage/foo) | |
- } | |
- | |
- fun linkPublic() { | |
- account.link<&Int>(/public/foo, target:/storage/foo) | |
- } | |
- | |
- fun unlinkPublic() { | |
- account.unlink(/public/foo) | |
- } | |
- | |
- fun linkPrivate() { | |
- account.link<&Int>(/private/foo, target:/storage/foo) | |
- } | |
- | |
- fun unlinkPrivate() { | |
- account.unlink(/private/foo) | |
- } | |
- | |
- fun getStoragePaths(): [StoragePath] { | |
- return account.storagePaths | |
- } | |
- | |
- fun getPrivatePaths(): [PrivatePath] { | |
- return account.privatePaths | |
- } | |
- | |
- fun getPublicPaths(): [PublicPath] { | |
- return pubAccount.publicPaths | |
- } | |
- `, | |
- sema.Config{}, | |
- ) | |
- | |
- t.Run("before any save", func(t *testing.T) { | |
- value, err := inter.Invoke("getStoragePaths") | |
- require.NoError(t, err) | |
- require.IsType(t, &interpreter.ArrayValue{}, value) | |
- paths := arrayElements(inter, value.(*interpreter.ArrayValue)) | |
- require.Equal(t, 0, len(paths)) | |
- | |
- value, err = inter.Invoke("getPrivatePaths") | |
- require.NoError(t, err) | |
- require.IsType(t, &interpreter.ArrayValue{}, value) | |
- paths = arrayElements(inter, value.(*interpreter.ArrayValue)) | |
- require.Equal(t, 0, len(paths)) | |
- | |
- value, err = inter.Invoke("getPublicPaths") | |
- require.NoError(t, err) | |
- require.IsType(t, &interpreter.ArrayValue{}, value) | |
- paths = arrayElements(inter, value.(*interpreter.ArrayValue)) | |
- require.Equal(t, 0, len(paths)) | |
- }) | |
- | |
- t.Run("storage save", func(t *testing.T) { | |
- _, err := inter.Invoke("saveStorage") | |
- require.NoError(t, err) | |
- | |
- value, err := inter.Invoke("getStoragePaths") | |
- require.NoError(t, err) | |
- require.IsType(t, &interpreter.ArrayValue{}, value) | |
- paths := arrayElements(inter, value.(*interpreter.ArrayValue)) | |
- require.Equal(t, 1, len(paths)) | |
- require.Equal(t, interpreter.NewPathValue(nil, common.PathDomainStorage, "foo"), paths[0]) | |
- | |
- value, err = inter.Invoke("getPrivatePaths") | |
- require.NoError(t, err) | |
- require.IsType(t, &interpreter.ArrayValue{}, value) | |
- paths = arrayElements(inter, value.(*interpreter.ArrayValue)) | |
- require.Equal(t, 0, len(paths)) | |
- | |
- value, err = inter.Invoke("getPublicPaths") | |
- require.NoError(t, err) | |
- require.IsType(t, &interpreter.ArrayValue{}, value) | |
- paths = arrayElements(inter, value.(*interpreter.ArrayValue)) | |
- require.Equal(t, 0, len(paths)) | |
- }) | |
- | |
- t.Run("public link", func(t *testing.T) { | |
- _, err := inter.Invoke("linkPublic") | |
- require.NoError(t, err) | |
- | |
- value, err := inter.Invoke("getStoragePaths") | |
- require.NoError(t, err) | |
- require.IsType(t, &interpreter.ArrayValue{}, value) | |
- paths := arrayElements(inter, value.(*interpreter.ArrayValue)) | |
- require.Equal(t, 1, len(paths)) | |
- require.Equal(t, interpreter.NewPathValue(nil, common.PathDomainStorage, "foo"), paths[0]) | |
- | |
- value, err = inter.Invoke("getPrivatePaths") | |
- require.NoError(t, err) | |
- require.IsType(t, &interpreter.ArrayValue{}, value) | |
- paths = arrayElements(inter, value.(*interpreter.ArrayValue)) | |
- require.Equal(t, 0, len(paths)) | |
- | |
- value, err = inter.Invoke("getPublicPaths") | |
- require.NoError(t, err) | |
- require.IsType(t, &interpreter.ArrayValue{}, value) | |
- paths = arrayElements(inter, value.(*interpreter.ArrayValue)) | |
- require.Equal(t, 1, len(paths)) | |
- require.Equal(t, interpreter.NewPathValue(nil, common.PathDomainPublic, "foo"), paths[0]) | |
- }) | |
- | |
- t.Run("private link", func(t *testing.T) { | |
- _, err := inter.Invoke("linkPrivate") | |
- require.NoError(t, err) | |
- | |
- value, err := inter.Invoke("getStoragePaths") | |
- require.NoError(t, err) | |
- require.IsType(t, &interpreter.ArrayValue{}, value) | |
- paths := arrayElements(inter, value.(*interpreter.ArrayValue)) | |
- require.Equal(t, 1, len(paths)) | |
- require.Equal(t, interpreter.NewPathValue(nil, common.PathDomainStorage, "foo"), paths[0]) | |
- | |
- value, err = inter.Invoke("getPrivatePaths") | |
- require.NoError(t, err) | |
- require.IsType(t, &interpreter.ArrayValue{}, value) | |
- paths = arrayElements(inter, value.(*interpreter.ArrayValue)) | |
- require.Equal(t, 1, len(paths)) | |
- require.Equal(t, interpreter.NewPathValue(nil, common.PathDomainPrivate, "foo"), paths[0]) | |
- | |
- value, err = inter.Invoke("getPublicPaths") | |
- require.NoError(t, err) | |
- require.IsType(t, &interpreter.ArrayValue{}, value) | |
- paths = arrayElements(inter, value.(*interpreter.ArrayValue)) | |
- require.Equal(t, 1, len(paths)) | |
- require.Equal(t, interpreter.NewPathValue(nil, common.PathDomainPublic, "foo"), paths[0]) | |
- }) | |
- | |
- t.Run("private unlink", func(t *testing.T) { | |
- _, err := inter.Invoke("unlinkPrivate") | |
- require.NoError(t, err) | |
- | |
- value, err := inter.Invoke("getStoragePaths") | |
- require.NoError(t, err) | |
- require.IsType(t, &interpreter.ArrayValue{}, value) | |
- paths := arrayElements(inter, value.(*interpreter.ArrayValue)) | |
- require.Equal(t, 1, len(paths)) | |
- require.Equal(t, interpreter.NewPathValue(nil, common.PathDomainStorage, "foo"), paths[0]) | |
- | |
- value, err = inter.Invoke("getPrivatePaths") | |
- require.NoError(t, err) | |
- require.IsType(t, &interpreter.ArrayValue{}, value) | |
- paths = arrayElements(inter, value.(*interpreter.ArrayValue)) | |
- require.Equal(t, 0, len(paths)) | |
- | |
- value, err = inter.Invoke("getPublicPaths") | |
- require.NoError(t, err) | |
- require.IsType(t, &interpreter.ArrayValue{}, value) | |
- paths = arrayElements(inter, value.(*interpreter.ArrayValue)) | |
- require.Equal(t, 1, len(paths)) | |
- require.Equal(t, interpreter.NewPathValue(nil, common.PathDomainPublic, "foo"), paths[0]) | |
- }) | |
- | |
- t.Run("save storage bar", func(t *testing.T) { | |
- _, err := inter.Invoke("saveOtherStorage") | |
- require.NoError(t, err) | |
- | |
- value, err := inter.Invoke("getStoragePaths") | |
- require.NoError(t, err) | |
- require.IsType(t, &interpreter.ArrayValue{}, value) | |
- paths := arrayElements(inter, value.(*interpreter.ArrayValue)) | |
- require.Equal(t, 2, len(paths)) | |
- require.Equal(t, interpreter.NewPathValue(nil, common.PathDomainStorage, "bar"), paths[0]) | |
- require.Equal(t, interpreter.NewPathValue(nil, common.PathDomainStorage, "foo"), paths[1]) | |
- | |
- value, err = inter.Invoke("getPrivatePaths") | |
- require.NoError(t, err) | |
- require.IsType(t, &interpreter.ArrayValue{}, value) | |
- paths = arrayElements(inter, value.(*interpreter.ArrayValue)) | |
- require.Equal(t, 0, len(paths)) | |
- | |
- value, err = inter.Invoke("getPublicPaths") | |
- require.NoError(t, err) | |
- require.IsType(t, &interpreter.ArrayValue{}, value) | |
- paths = arrayElements(inter, value.(*interpreter.ArrayValue)) | |
- require.Equal(t, 1, len(paths)) | |
- require.Equal(t, interpreter.NewPathValue(nil, common.PathDomainPublic, "foo"), paths[0]) | |
- }) | |
- | |
- t.Run("load storage", func(t *testing.T) { | |
- _, err := inter.Invoke("loadStorage") | |
- require.NoError(t, err) | |
- | |
- value, err := inter.Invoke("getStoragePaths") | |
- require.NoError(t, err) | |
- require.IsType(t, &interpreter.ArrayValue{}, value) | |
- paths := arrayElements(inter, value.(*interpreter.ArrayValue)) | |
- require.Equal(t, 1, len(paths)) | |
- require.Equal(t, interpreter.NewPathValue(nil, common.PathDomainStorage, "bar"), paths[0]) | |
- | |
- value, err = inter.Invoke("getPrivatePaths") | |
- require.NoError(t, err) | |
- require.IsType(t, &interpreter.ArrayValue{}, value) | |
- paths = arrayElements(inter, value.(*interpreter.ArrayValue)) | |
- require.Equal(t, 0, len(paths)) | |
- | |
- value, err = inter.Invoke("getPublicPaths") | |
- require.NoError(t, err) | |
- require.IsType(t, &interpreter.ArrayValue{}, value) | |
- paths = arrayElements(inter, value.(*interpreter.ArrayValue)) | |
- require.Equal(t, 1, len(paths)) | |
- require.Equal(t, interpreter.NewPathValue(nil, common.PathDomainPublic, "foo"), paths[0]) | |
- }) | |
- | |
- t.Run("unlink public", func(t *testing.T) { | |
- _, err := inter.Invoke("unlinkPublic") | |
- require.NoError(t, err) | |
- | |
- value, err := inter.Invoke("getStoragePaths") | |
- require.NoError(t, err) | |
- require.IsType(t, &interpreter.ArrayValue{}, value) | |
- paths := arrayElements(inter, value.(*interpreter.ArrayValue)) | |
- require.Equal(t, 1, len(paths)) | |
- require.Equal(t, interpreter.NewPathValue(nil, common.PathDomainStorage, "bar"), paths[0]) | |
- | |
- value, err = inter.Invoke("getPrivatePaths") | |
- require.NoError(t, err) | |
- require.IsType(t, &interpreter.ArrayValue{}, value) | |
- paths = arrayElements(inter, value.(*interpreter.ArrayValue)) | |
- require.Equal(t, 0, len(paths)) | |
- | |
- value, err = inter.Invoke("getPublicPaths") | |
- require.NoError(t, err) | |
- require.IsType(t, &interpreter.ArrayValue{}, value) | |
- paths = arrayElements(inter, value.(*interpreter.ArrayValue)) | |
- require.Equal(t, 0, len(paths)) | |
- }) | |
- }) | |
- | |
- t.Run("forEachPublic PublicAccount", func(t *testing.T) { | |
- address := interpreter.NewUnmeteredAddressValueFromBytes([]byte{42}) | |
- | |
- inter, _ := testAccount( | |
- t, | |
- address, | |
- true, | |
- ` | |
- struct S { | |
- let value: Int | |
- init(value: Int) { | |
- self.value = value | |
- } | |
- } | |
- | |
- fun test(): Int { | |
- account.save(S(value: 2), to: /storage/foo) | |
- account.save("", to: /storage/bar) | |
- account.link<&S>(/public/a, target:/storage/foo) | |
- account.link<&String>(/public/b, target:/storage/bar) | |
- account.link<&S>(/public/c, target:/storage/foo) | |
- account.link<&S>(/public/d, target:/storage/foo) | |
- account.link<&String>(/public/e, target:/storage/bar) | |
- | |
- var total = 0 | |
- pubAccount.forEachPublic(fun (path: PublicPath, type: Type): Bool { | |
- if type == Type<Capability<&S>>() { | |
- total = total + pubAccount.getCapability<&S>(path).borrow()!.value | |
- } | |
- return true | |
- }) | |
- | |
- return total | |
- } | |
- `, | |
- sema.Config{}, | |
- ) | |
- | |
- value, err := inter.Invoke("test") | |
- require.NoError(t, err) | |
- AssertValuesEqual( | |
- t, | |
- inter, | |
- interpreter.NewIntValueFromInt64(nil, 6), | |
- value, | |
- ) | |
- }) | |
- | |
- t.Run("forEachPublic PublicAccount number", func(t *testing.T) { | |
- address := interpreter.NewUnmeteredAddressValueFromBytes([]byte{42}) | |
- | |
- inter, _ := testAccount( | |
- t, | |
- address, | |
- true, | |
- ` | |
- struct S { | |
- let value: Int | |
- init(value: Int) { | |
- self.value = value | |
- } | |
- } | |
- | |
- fun test(): Int { | |
- account.save(S(value: 2), to: /storage/foo) | |
- account.save("", to: /storage/bar) | |
- account.link<&S>(/public/a, target:/storage/foo) | |
- account.link<&String>(/public/b, target:/storage/bar) | |
- account.link<&S>(/public/c, target:/storage/foo) | |
- account.link<&S>(/public/d, target:/storage/foo) | |
- account.link<&String>(/public/e, target:/storage/bar) | |
- | |
- var total = 0 | |
- pubAccount.forEachPublic(fun (path: PublicPath, type: Type): Bool { | |
- total = total + 1 | |
- return true | |
- }) | |
- | |
- return total | |
- } | |
- `, | |
- sema.Config{}, | |
- ) | |
- | |
- value, err := inter.Invoke("test") | |
- require.NoError(t, err) | |
- AssertValuesEqual( | |
- t, | |
- inter, | |
- interpreter.NewIntValueFromInt64(nil, 5), | |
- value, | |
- ) | |
- }) | |
- | |
- t.Run("forEachPublic AuthAccount", func(t *testing.T) { | |
- address := interpreter.NewUnmeteredAddressValueFromBytes([]byte{42}) | |
- | |
- inter, _ := testAccount( | |
- t, | |
- address, | |
- true, | |
- ` | |
- struct S { | |
- let value: Int | |
- init(value: Int) { | |
- self.value = value | |
- } | |
- } | |
- | |
- fun test(): Int { | |
- account.save(S(value: 2), to: /storage/foo) | |
- account.save("", to: /storage/bar) | |
- account.link<&S>(/public/a, target:/storage/foo) | |
- account.link<&String>(/public/b, target:/storage/bar) | |
- account.link<&S>(/public/c, target:/storage/foo) | |
- account.link<&S>(/public/d, target:/storage/foo) | |
- account.link<&String>(/public/e, target:/storage/bar) | |
- | |
- var total = 0 | |
- account.forEachPublic(fun (path: PublicPath, type: Type): Bool { | |
- if type == Type<Capability<&S>>() { | |
- total = total + account.getCapability<&S>(path).borrow()!.value | |
- } | |
- return true | |
- }) | |
- | |
- return total | |
- } | |
- `, | |
- sema.Config{}, | |
- ) | |
- | |
- value, err := inter.Invoke("test") | |
- require.NoError(t, err) | |
- AssertValuesEqual( | |
- t, | |
- inter, | |
- interpreter.NewIntValueFromInt64(nil, 6), | |
- value, | |
- ) | |
- }) | |
- | |
- t.Run("forEachPrivate", func(t *testing.T) { | |
- address := interpreter.NewUnmeteredAddressValueFromBytes([]byte{42}) | |
- | |
- inter, _ := testAccount( | |
- t, | |
- address, | |
- true, | |
- ` | |
- struct S { | |
- let value: Int | |
- init(value: Int) { | |
- self.value = value | |
- } | |
- } | |
- | |
- fun test(): Int { | |
- account.save(S(value: 2), to: /storage/foo) | |
- account.save("", to: /storage/bar) | |
- account.link<&S>(/private/a, target:/storage/foo) | |
- account.link<&String>(/private/b, target:/storage/bar) | |
- account.link<&S>(/private/c, target:/storage/foo) | |
- account.link<&S>(/public/d, target:/storage/foo) | |
- account.link<&String>(/private/e, target:/storage/bar) | |
- | |
- var total = 0 | |
- account.forEachPrivate(fun (path: PrivatePath, type: Type): Bool { | |
- if type == Type<Capability<&S>>() { | |
- total = total + account.getCapability<&S>(path).borrow()!.value | |
- } | |
- return true | |
- }) | |
- | |
- return total | |
- } | |
- `, | |
- sema.Config{}, | |
- ) | |
- | |
- value, err := inter.Invoke("test") | |
- require.NoError(t, err) | |
- AssertValuesEqual( | |
- t, | |
- inter, | |
- interpreter.NewIntValueFromInt64(nil, 4), | |
- value, | |
- ) | |
- }) | |
- | |
- t.Run("forEachStored", func(t *testing.T) { | |
- address := interpreter.NewUnmeteredAddressValueFromBytes([]byte{42}) | |
- | |
- inter, _ := testAccount( | |
- t, | |
- address, | |
- true, | |
- ` | |
- struct S { | |
- let value: Int | |
- init(value: Int) { | |
- self.value = value | |
- } | |
- } | |
- | |
- fun test(): Int { | |
- account.save(S(value: 1), to: /storage/foo1) | |
- account.save(S(value: 2), to: /storage/foo2) | |
- account.save(S(value: 5), to: /storage/foo3) | |
- account.save("", to: /storage/bar1) | |
- account.save(4, to: /storage/bar2) | |
- | |
- var total = 0 | |
- account.forEachStored(fun (path: StoragePath, type: Type): Bool { | |
- if type == Type<S>() { | |
- total = total + account.borrow<&S>(from: path)!.value | |
- } | |
- return true | |
- }) | |
- | |
- return total | |
- } | |
- `, | |
- sema.Config{}, | |
- ) | |
- | |
- value, err := inter.Invoke("test") | |
- require.NoError(t, err) | |
- AssertValuesEqual( | |
- t, | |
- inter, | |
- interpreter.NewIntValueFromInt64(nil, 8), | |
- value, | |
- ) | |
- }) | |
- | |
- t.Run("forEachStored after empty", func(t *testing.T) { | |
- address := interpreter.NewUnmeteredAddressValueFromBytes([]byte{42}) | |
- | |
- inter, _ := testAccount( | |
- t, | |
- address, | |
- true, | |
- ` | |
- struct S { | |
- let value: Int | |
- init(value: Int) { | |
- self.value = value | |
- } | |
- } | |
- | |
- fun before(): Int { | |
- var total = 0 | |
- account.forEachStored(fun (path: StoragePath, type: Type): Bool { | |
- total = total + 1 | |
- return true | |
- }) | |
- | |
- account.save(S(value: 1), to: /storage/foo1) | |
- account.save(S(value: 2), to: /storage/foo2) | |
- account.save(S(value: 5), to: /storage/foo3) | |
- | |
- return total | |
- } | |
- | |
- fun after(): Int { | |
- var total = 0 | |
- account.forEachStored(fun (path: StoragePath, type: Type): Bool { | |
- total = total + 1 | |
- return true | |
- }) | |
- return total | |
- } | |
- `, | |
- sema.Config{}, | |
- ) | |
- | |
- value, err := inter.Invoke("before") | |
- require.NoError(t, err) | |
- AssertValuesEqual( | |
- t, | |
- inter, | |
- interpreter.NewIntValueFromInt64(nil, 0), | |
- value, | |
- ) | |
- | |
- value, err = inter.Invoke("after") | |
- require.NoError(t, err) | |
- AssertValuesEqual( | |
- t, | |
- inter, | |
- interpreter.NewIntValueFromInt64(nil, 3), | |
- value, | |
- ) | |
- }) | |
- | |
- t.Run("forEachStored with update", func(t *testing.T) { | |
- address := interpreter.NewUnmeteredAddressValueFromBytes([]byte{42}) | |
- | |
- inter, _ := testAccount( | |
- t, | |
- address, | |
- true, | |
- ` | |
- struct S { | |
- var value: Int | |
- init(value: Int) { | |
- self.value = value | |
- } | |
- fun increment() { | |
- self.value = self.value + 1 | |
- } | |
- } | |
- | |
- fun test(): Int { | |
- account.save(S(value: 1), to: /storage/foo1) | |
- account.save(S(value: 2), to: /storage/foo2) | |
- account.save(S(value: 5), to: /storage/foo3) | |
- account.save("", to: /storage/bar1) | |
- account.save(4, to: /storage/bar2) | |
- | |
- var total = 0 | |
- account.forEachStored(fun (path: StoragePath, type: Type): Bool { | |
- if type == Type<S>() { | |
- account.borrow<&S>(from: path)!.increment() | |
- } | |
- return true | |
- }) | |
- account.forEachStored(fun (path: StoragePath, type: Type): Bool { | |
- if type == Type<S>() { | |
- total = total + account.borrow<&S>(from: path)!.value | |
- } | |
- return true | |
- }) | |
- | |
- return total | |
- } | |
- `, | |
- sema.Config{}, | |
- ) | |
- | |
- value, err := inter.Invoke("test") | |
- require.NoError(t, err) | |
- AssertValuesEqual( | |
- t, | |
- inter, | |
- interpreter.NewIntValueFromInt64(nil, 11), | |
- value, | |
- ) | |
- }) | |
- | |
- t.Run("forEachStored with mutation", func(t *testing.T) { | |
- address := interpreter.NewUnmeteredAddressValueFromBytes([]byte{42}) | |
- | |
- inter, _ := testAccount( | |
- t, | |
- address, | |
- true, | |
- ` | |
- struct S { | |
- var value: Int | |
- init(value: Int) { | |
- self.value = value | |
- } | |
- fun increment() { | |
- self.value = self.value + 1 | |
- } | |
- } | |
- | |
- fun test(): Int { | |
- account.save(S(value: 1), to: /storage/foo1) | |
- account.save(S(value: 2), to: /storage/foo2) | |
- account.save(S(value: 5), to: /storage/foo3) | |
- account.save("qux", to: /storage/bar1) | |
- account.save(4, to: /storage/bar2) | |
- | |
- var total = 0 | |
- account.forEachStored(fun (path: StoragePath, type: Type): Bool { | |
- if type == Type<S>() { | |
- total = total + account.borrow<&S>(from: path)!.value | |
- } | |
- if type == Type<String>() { | |
- let id = account.load<String>(from: path)! | |
- account.save(S(value:3), to: StoragePath(identifier: id)!) | |
- } | |
- return true | |
- }) | |
- | |
- return total | |
- } | |
- `, | |
- sema.Config{}, | |
- ) | |
- | |
- _, err := inter.Invoke("test") | |
- RequireError(t, err) | |
- | |
- require.ErrorAs(t, err, &interpreter.StorageMutatedDuringIterationError{}) | |
- }) | |
- | |
- t.Run("forEachStored with early termination", func(t *testing.T) { | |
- address := interpreter.NewUnmeteredAddressValueFromBytes([]byte{42}) | |
- | |
- inter, _ := testAccount( | |
- t, | |
- address, | |
- true, | |
- ` | |
- fun test(): Int { | |
- account.save(1, to: /storage/foo1) | |
- account.save(2, to: /storage/foo2) | |
- account.save(3, to: /storage/foo3) | |
- account.save(4, to: /storage/bar1) | |
- account.save(5, to: /storage/bar2) | |
- | |
- var seen = 0 | |
- var stuff: [&AnyStruct] = [] | |
- account.forEachStored(fun (path: StoragePath, type: Type): Bool { | |
- if seen >= 3 { | |
- return false | |
- } | |
- stuff.append(account.borrow<&AnyStruct>(from: path)!) | |
- seen = seen + 1 | |
- return true | |
- }) | |
- | |
- return stuff.length | |
- } | |
- `, | |
- sema.Config{}, | |
- ) | |
- | |
- value, err := inter.Invoke("test") | |
- | |
- require.NoError(t, err) | |
- | |
- AssertValuesEqual( | |
- t, | |
- inter, | |
- interpreter.NewIntValueFromInt64(nil, 3), | |
- value, | |
- ) | |
- | |
- }) | |
-} | |
- | |
-func TestInterpretAccountIterationMutation(t *testing.T) { | |
- | |
- t.Parallel() | |
- | |
- test := func(continueAfterMutation bool) { | |
- t.Run(fmt.Sprintf("forEachStored, continue: %t", continueAfterMutation), func(t *testing.T) { | |
- t.Parallel() | |
- address := interpreter.NewUnmeteredAddressValueFromBytes([]byte{42}) | |
- | |
- inter, _ := testAccount( | |
- t, | |
- address, | |
- true, | |
- fmt.Sprintf( | |
- ` | |
- fun test() { | |
- account.save(1, to: /storage/foo1) | |
- account.save(2, to: /storage/foo2) | |
- account.save(3, to: /storage/foo3) | |
- account.save("qux", to: /storage/foo4) | |
- | |
- account.forEachStored(fun (path: StoragePath, type: Type): Bool { | |
- if type == Type<String>() { | |
- account.save("bar", to: /storage/foo5) | |
- return %t | |
- } | |
- return true | |
- }) | |
- } | |
- `, | |
- continueAfterMutation, | |
- ), | |
- sema.Config{}, | |
- ) | |
- | |
- _, err := inter.Invoke("test") | |
- if continueAfterMutation { | |
- RequireError(t, err) | |
- | |
- require.ErrorAs(t, err, &interpreter.StorageMutatedDuringIterationError{}) | |
- } else { | |
- require.NoError(t, err) | |
- } | |
- }) | |
- | |
- t.Run(fmt.Sprintf("forEachPublic, continue: %t", continueAfterMutation), func(t *testing.T) { | |
- t.Parallel() | |
- address := interpreter.NewUnmeteredAddressValueFromBytes([]byte{42}) | |
- | |
- inter, _ := testAccount( | |
- t, | |
- address, | |
- true, | |
- fmt.Sprintf( | |
- ` | |
- fun test() { | |
- account.save(1, to: /storage/foo1) | |
- account.save("", to: /storage/foo2) | |
- account.link<&Int>(/public/foo1, target: /storage/foo1) | |
- account.link<&String>(/public/foo2, target: /storage/foo2) | |
- | |
- account.forEachPublic(fun (path: PublicPath, type: Type): Bool { | |
- if type == Type<Capability<&String>>() { | |
- account.save("bar", to: /storage/foo3) | |
- return %t | |
- } | |
- return true | |
- }) | |
- } | |
- `, | |
- continueAfterMutation, | |
- ), | |
- sema.Config{}, | |
- ) | |
- | |
- _, err := inter.Invoke("test") | |
- if continueAfterMutation { | |
- RequireError(t, err) | |
- | |
- require.ErrorAs(t, err, &interpreter.StorageMutatedDuringIterationError{}) | |
- } else { | |
- require.NoError(t, err) | |
- } | |
- }) | |
- | |
- t.Run(fmt.Sprintf("forEachPrivate, continue: %t", continueAfterMutation), func(t *testing.T) { | |
- t.Parallel() | |
- address := interpreter.NewUnmeteredAddressValueFromBytes([]byte{42}) | |
- | |
- inter, _ := testAccount( | |
- t, | |
- address, | |
- true, | |
- fmt.Sprintf( | |
- ` | |
- fun test() { | |
- account.save(1, to: /storage/foo1) | |
- account.save("", to: /storage/foo2) | |
- account.link<&Int>(/private/foo1, target: /storage/foo1) | |
- account.link<&String>(/private/foo2, target: /storage/foo2) | |
- | |
- account.forEachPrivate(fun (path: PrivatePath, type: Type): Bool { | |
- if type == Type<Capability<&String>>() { | |
- account.save("bar", to: /storage/foo3) | |
- return %t | |
- } | |
- return true | |
- }) | |
- } | |
- `, | |
- continueAfterMutation, | |
- ), | |
- sema.Config{}, | |
- ) | |
- | |
- _, err := inter.Invoke("test") | |
- if continueAfterMutation { | |
- RequireError(t, err) | |
- | |
- require.ErrorAs(t, err, &interpreter.StorageMutatedDuringIterationError{}) | |
- } else { | |
- require.NoError(t, err) | |
- } | |
- }) | |
- | |
- t.Run(fmt.Sprintf("with function call, continue: %t", continueAfterMutation), func(t *testing.T) { | |
- t.Parallel() | |
- address := interpreter.NewUnmeteredAddressValueFromBytes([]byte{42}) | |
- | |
- inter, _ := testAccount( | |
- t, | |
- address, | |
- true, | |
- fmt.Sprintf( | |
- ` | |
- fun foo() { | |
- account.save("bar", to: /storage/foo5) | |
- } | |
- | |
- fun test() { | |
- account.save(1, to: /storage/foo1) | |
- account.save(2, to: /storage/foo2) | |
- account.save(3, to: /storage/foo3) | |
- account.save("qux", to: /storage/foo4) | |
- | |
- account.forEachStored(fun (path: StoragePath, type: Type): Bool { | |
- if type == Type<String>() { | |
- foo() | |
- return %t | |
- } | |
- return true | |
- }) | |
- } | |
- `, | |
- continueAfterMutation, | |
- ), | |
- sema.Config{}, | |
- ) | |
- | |
- _, err := inter.Invoke("test") | |
- if continueAfterMutation { | |
- RequireError(t, err) | |
- | |
- require.ErrorAs(t, err, &interpreter.StorageMutatedDuringIterationError{}) | |
- } else { | |
- require.NoError(t, err) | |
- } | |
- }) | |
- | |
- t.Run(fmt.Sprintf("with function call and nested iteration, continue: %t", continueAfterMutation), func(t *testing.T) { | |
- t.Parallel() | |
- address := interpreter.NewUnmeteredAddressValueFromBytes([]byte{42}) | |
- | |
- inter, _ := testAccount( | |
- t, | |
- address, | |
- true, | |
- fmt.Sprintf( | |
- ` | |
- fun foo() { | |
- account.forEachStored(fun (path: StoragePath, type: Type): Bool { | |
- return true | |
- }) | |
- account.save("bar", to: /storage/foo5) | |
- } | |
- | |
- fun test() { | |
- account.save(1, to: /storage/foo1) | |
- account.save(2, to: /storage/foo2) | |
- account.save(3, to: /storage/foo3) | |
- account.save("qux", to: /storage/foo4) | |
- | |
- account.forEachStored(fun (path: StoragePath, type: Type): Bool { | |
- if type == Type<String>() { | |
- foo() | |
- return %t | |
- } | |
- return true | |
- }) | |
- } | |
- `, | |
- continueAfterMutation, | |
- ), | |
- sema.Config{}, | |
- ) | |
- | |
- _, err := inter.Invoke("test") | |
- if continueAfterMutation { | |
- RequireError(t, err) | |
- | |
- require.ErrorAs(t, err, &interpreter.StorageMutatedDuringIterationError{}) | |
- } else { | |
- require.NoError(t, err) | |
- } | |
- }) | |
- | |
- t.Run(fmt.Sprintf("load, continue: %t", continueAfterMutation), func(t *testing.T) { | |
- t.Parallel() | |
- address := interpreter.NewUnmeteredAddressValueFromBytes([]byte{42}) | |
- | |
- inter, _ := testAccount( | |
- t, | |
- address, | |
- true, | |
- fmt.Sprintf( | |
- ` | |
- fun test() { | |
- account.save(1, to: /storage/foo1) | |
- account.save(2, to: /storage/foo2) | |
- account.save(3, to: /storage/foo3) | |
- account.save("qux", to: /storage/foo4) | |
- | |
- account.forEachStored(fun (path: StoragePath, type: Type): Bool { | |
- if type == Type<String>() { | |
- account.load<Int>(from: /storage/foo1) | |
- return %t | |
- } | |
- return true | |
- }) | |
- } | |
- `, | |
- continueAfterMutation, | |
- ), | |
- sema.Config{}, | |
- ) | |
- | |
- _, err := inter.Invoke("test") | |
- if continueAfterMutation { | |
- RequireError(t, err) | |
- | |
- require.ErrorAs(t, err, &interpreter.StorageMutatedDuringIterationError{}) | |
- } else { | |
- require.NoError(t, err) | |
- } | |
- }) | |
- | |
- t.Run(fmt.Sprintf("link, continue: %t", continueAfterMutation), func(t *testing.T) { | |
- t.Parallel() | |
- address := interpreter.NewUnmeteredAddressValueFromBytes([]byte{42}) | |
- | |
- inter, _ := testAccount( | |
- t, | |
- address, | |
- true, | |
- fmt.Sprintf( | |
- ` | |
- fun test() { | |
- account.save(1, to: /storage/foo1) | |
- account.save("", to: /storage/foo2) | |
- account.link<&Int>(/public/foo1, target: /storage/foo1) | |
- account.link<&String>(/public/foo2, target: /storage/foo2) | |
- | |
- account.forEachPublic(fun (path: PublicPath, type: Type): Bool { | |
- if type == Type<Capability<&String>>() { | |
- account.link<&Int>(/public/foo3, target: /storage/foo1) | |
- return %t | |
- } | |
- return true | |
- }) | |
- } | |
- `, | |
- continueAfterMutation, | |
- ), | |
- sema.Config{}, | |
- ) | |
- | |
- _, err := inter.Invoke("test") | |
- if continueAfterMutation { | |
- RequireError(t, err) | |
- | |
- require.ErrorAs(t, err, &interpreter.StorageMutatedDuringIterationError{}) | |
- } else { | |
- require.NoError(t, err) | |
- } | |
- }) | |
- | |
- t.Run(fmt.Sprintf("unlink, continue: %t", continueAfterMutation), func(t *testing.T) { | |
- t.Parallel() | |
- address := interpreter.NewUnmeteredAddressValueFromBytes([]byte{42}) | |
- | |
- inter, _ := testAccount( | |
- t, | |
- address, | |
- true, | |
- fmt.Sprintf( | |
- ` | |
- fun test() { | |
- account.save(1, to: /storage/foo1) | |
- account.save("", to: /storage/foo2) | |
- account.link<&Int>(/public/foo1, target: /storage/foo1) | |
- account.link<&String>(/public/foo2, target: /storage/foo2) | |
- | |
- account.forEachPublic(fun (path: PublicPath, type: Type): Bool { | |
- if type == Type<Capability<&String>>() { | |
- account.unlink(/public/foo1) | |
- return %t | |
- } | |
- return true | |
- }) | |
- } | |
- `, | |
- continueAfterMutation, | |
- ), | |
- sema.Config{}, | |
- ) | |
- | |
- _, err := inter.Invoke("test") | |
- if continueAfterMutation { | |
- RequireError(t, err) | |
- | |
- require.ErrorAs(t, err, &interpreter.StorageMutatedDuringIterationError{}) | |
- } else { | |
- require.NoError(t, err) | |
- } | |
- }) | |
- | |
- t.Run(fmt.Sprintf("with imported function call, continue: %t", continueAfterMutation), func(t *testing.T) { | |
- t.Parallel() | |
- | |
- address := common.MustBytesToAddress([]byte{1}) | |
- addressValue := interpreter.AddressValue(address) | |
- | |
- authAccountValueDeclaration := stdlib.StandardLibraryValue{ | |
- Name: "account", | |
- Type: sema.AuthAccountType, | |
- Value: newTestAuthAccountValue(nil, addressValue), | |
- Kind: common.DeclarationKindConstant, | |
- } | |
- | |
- baseValueActivation := sema.NewVariableActivation(sema.BaseValueActivation) | |
- baseValueActivation.DeclareValue(authAccountValueDeclaration) | |
- baseActivation := activations.NewActivation(nil, interpreter.BaseActivation) | |
- interpreter.Declare(baseActivation, authAccountValueDeclaration) | |
- | |
- importedChecker, err := checker.ParseAndCheckWithOptions(t, | |
- ` | |
- pub fun foo() { | |
- account.save("bar", to: /storage/foo5) | |
- } | |
- `, | |
- checker.ParseAndCheckOptions{ | |
- Location: common.AddressLocation{ | |
- Address: address, | |
- Name: "foo", | |
- }, | |
- Config: &sema.Config{ | |
- BaseValueActivationHandler: func(_ common.Location) *sema.VariableActivation { | |
- return baseValueActivation | |
- }, | |
- }, | |
- }, | |
- ) | |
- require.NoError(t, err) | |
- | |
- inter, _ := parseCheckAndInterpretWithOptions(t, | |
- fmt.Sprintf(` | |
- import foo from 0x1 | |
- | |
- fun test() { | |
- account.save(1, to: /storage/foo1) | |
- account.save(2, to: /storage/foo2) | |
- account.save(3, to: /storage/foo3) | |
- account.save("qux", to: /storage/foo4) | |
- | |
- account.forEachStored(fun (path: StoragePath, type: Type): Bool { | |
- if type == Type<String>() { | |
- foo() | |
- return %t | |
- } | |
- return true | |
- }) | |
- } | |
- `, | |
- continueAfterMutation, | |
- ), | |
- ParseCheckAndInterpretOptions{ | |
- CheckerConfig: &sema.Config{ | |
- BaseValueActivationHandler: func(_ common.Location) *sema.VariableActivation { | |
- return baseValueActivation | |
- }, | |
- LocationHandler: func( | |
- identifiers []ast.Identifier, | |
- location common.Location, | |
- ) (result []sema.ResolvedLocation, err error) { | |
- require.Equal(t, | |
- common.AddressLocation{ | |
- Address: address, | |
- Name: "", | |
- }, | |
- location, | |
- ) | |
- | |
- for _, identifier := range identifiers { | |
- result = append(result, sema.ResolvedLocation{ | |
- Location: common.AddressLocation{ | |
- Address: location.(common.AddressLocation).Address, | |
- Name: identifier.Identifier, | |
- }, | |
- Identifiers: []ast.Identifier{ | |
- identifier, | |
- }, | |
- }) | |
- } | |
- return | |
- }, | |
- ImportHandler: func( | |
- checker *sema.Checker, | |
- importedLocation common.Location, | |
- _ ast.Range, | |
- ) (sema.Import, error) { | |
- return sema.ElaborationImport{ | |
- Elaboration: importedChecker.Elaboration, | |
- }, nil | |
- }, | |
- }, | |
- Config: &interpreter.Config{ | |
- BaseActivationHandler: func(_ common.Location) *interpreter.VariableActivation { | |
- return baseActivation | |
- }, | |
- ContractValueHandler: makeContractValueHandler(nil, nil, nil), | |
- ImportLocationHandler: func(inter *interpreter.Interpreter, location common.Location) interpreter.Import { | |
- require.IsType(t, common.AddressLocation{}, location) | |
- addressLocation := location.(common.AddressLocation) | |
- | |
- assert.Equal(t, address, addressLocation.Address) | |
- | |
- program := interpreter.ProgramFromChecker(importedChecker) | |
- subInterpreter, err := inter.NewSubInterpreter(program, location) | |
- if err != nil { | |
- panic(err) | |
- } | |
- | |
- return interpreter.InterpreterImport{ | |
- Interpreter: subInterpreter, | |
- } | |
- }, | |
- }, | |
- }, | |
- ) | |
- | |
- _, err = inter.Invoke("test") | |
- if continueAfterMutation { | |
- RequireError(t, err) | |
- | |
- require.ErrorAs(t, err, &interpreter.StorageMutatedDuringIterationError{}) | |
- } else { | |
- require.NoError(t, err) | |
- } | |
- }) | |
- } | |
- | |
- test(true) | |
- test(false) | |
- | |
- t.Run("state properly cleared on iteration end", func(t *testing.T) { | |
- t.Parallel() | |
- address := interpreter.NewUnmeteredAddressValueFromBytes([]byte{42}) | |
- | |
- inter, _ := testAccount( | |
- t, | |
- address, | |
- true, | |
- ` | |
- fun test() { | |
- account.save(1, to: /storage/foo1) | |
- account.save(2, to: /storage/foo2) | |
- account.save(3, to: /storage/foo3) | |
- account.save("qux", to: /storage/foo4) | |
- | |
- account.forEachStored(fun (path: StoragePath, type: Type): Bool { | |
- return true | |
- }) | |
- account.save("bar", to: /storage/foo5) | |
- | |
- account.forEachStored(fun (path: StoragePath, type: Type): Bool { | |
- account.forEachStored(fun (path: StoragePath, type: Type): Bool { | |
- return true | |
- }) | |
- return true | |
- }) | |
- account.save("baz", to: /storage/foo6) | |
- } | |
- `, | |
- sema.Config{}, | |
- ) | |
- | |
- _, err := inter.Invoke("test") | |
- require.NoError(t, err) | |
- }) | |
- | |
- t.Run("non-lambda", func(t *testing.T) { | |
- t.Parallel() | |
- address := interpreter.NewUnmeteredAddressValueFromBytes([]byte{42}) | |
- | |
- inter, _ := testAccount( | |
- t, | |
- address, | |
- true, | |
- ` | |
- fun foo (path: StoragePath, type: Type): Bool { | |
- return true | |
- } | |
- | |
- fun test() { | |
- account.forEachStored(foo) | |
- } | |
- `, | |
- sema.Config{}, | |
- ) | |
- | |
- _, err := inter.Invoke("test") | |
- require.NoError(t, err) | |
- }) | |
- | |
- t.Run("method", func(t *testing.T) { | |
- t.Parallel() | |
- address := interpreter.NewUnmeteredAddressValueFromBytes([]byte{42}) | |
- | |
- inter, _ := testAccount( | |
- t, | |
- address, | |
- true, | |
- ` | |
- struct S { | |
- fun foo(path: StoragePath, type: Type): Bool { | |
- return true | |
- } | |
- } | |
- | |
- fun test() { | |
- let s = S() | |
- account.forEachStored(s.foo) | |
- } | |
- `, | |
- sema.Config{}, | |
- ) | |
- | |
- _, err := inter.Invoke("test") | |
- require.NoError(t, err) | |
- }) | |
-} | |
->>>>>>> e878449cf (Merge pull request #2878 from onflow/bastian/native-functionality-linking) | |
diff --git a/runtime/tests/interpreter/entitlements_test.go b/runtime/tests/interpreter/entitlements_test.go | |
index 616faece8..b9c4b5c40 100644 | |
--- a/runtime/tests/interpreter/entitlements_test.go | |
+++ b/runtime/tests/interpreter/entitlements_test.go | |
@@ -3099,7 +3099,7 @@ func TestInterpretIdentityMapping(t *testing.T) { | |
}) | |
} | |
-func TestInterpretMappingInclude(t *testing.T) { | |
+func NoTestInterpretMappingInclude(t *testing.T) { | |
t.Parallel() | |
diff --git a/runtime/tests/interpreter/equality_test.go b/runtime/tests/interpreter/equality_test.go | |
remerge CONFLICT (content): Merge conflict in runtime/tests/interpreter/equality_test.go | |
index a1f665dbc..efe2a8d27 100644 | |
--- a/runtime/tests/interpreter/equality_test.go | |
+++ b/runtime/tests/interpreter/equality_test.go | |
@@ -40,70 +40,6 @@ func TestInterpretEquality(t *testing.T) { | |
t.Parallel() | |
-<<<<<<< 01a42f326 (Merge pull request #2725 from onflow/supun/improve-conformance) | |
-======= | |
- t.Run("capability (path)", func(t *testing.T) { | |
- | |
- t.Parallel() | |
- | |
- capabilityValueDeclaration := stdlib.StandardLibraryValue{ | |
- Name: "cap", | |
- Type: &sema.CapabilityType{}, | |
- Value: interpreter.NewUnmeteredPathCapabilityValue( | |
- interpreter.NewUnmeteredAddressValueFromBytes([]byte{0x1}), | |
- interpreter.PathValue{ | |
- Domain: common.PathDomainStorage, | |
- Identifier: "something", | |
- }, | |
- nil, | |
- ), | |
- Kind: common.DeclarationKindConstant, | |
- } | |
- | |
- baseValueActivation := sema.NewVariableActivation(sema.BaseValueActivation) | |
- baseValueActivation.DeclareValue(capabilityValueDeclaration) | |
- | |
- baseActivation := activations.NewActivation(nil, interpreter.BaseActivation) | |
- interpreter.Declare(baseActivation, capabilityValueDeclaration) | |
- | |
- inter, err := parseCheckAndInterpretWithOptions(t, | |
- ` | |
- let maybeCapNonNil: Capability? = cap | |
- let maybeCapNil: Capability? = nil | |
- let res1 = maybeCapNonNil != nil | |
- let res2 = maybeCapNil == nil | |
- `, | |
- ParseCheckAndInterpretOptions{ | |
- Config: &interpreter.Config{ | |
- BaseActivationHandler: func(_ common.Location) *interpreter.VariableActivation { | |
- return baseActivation | |
- }, | |
- }, | |
- CheckerConfig: &sema.Config{ | |
- BaseValueActivationHandler: func(_ common.Location) *sema.VariableActivation { | |
- return baseValueActivation | |
- }, | |
- }, | |
- }, | |
- ) | |
- require.NoError(t, err) | |
- | |
- AssertValuesEqual( | |
- t, | |
- inter, | |
- interpreter.TrueValue, | |
- inter.Globals.Get("res1").GetValue(), | |
- ) | |
- | |
- AssertValuesEqual( | |
- t, | |
- inter, | |
- interpreter.TrueValue, | |
- inter.Globals.Get("res2").GetValue(), | |
- ) | |
- }) | |
- | |
->>>>>>> e878449cf (Merge pull request #2878 from onflow/bastian/native-functionality-linking) | |
t.Run("capability (ID)", func(t *testing.T) { | |
t.Parallel() | |
diff --git a/runtime/tests/interpreter/interface_test.go b/runtime/tests/interpreter/interface_test.go | |
index 59ffb437f..a66b42961 100644 | |
--- a/runtime/tests/interpreter/interface_test.go | |
+++ b/runtime/tests/interpreter/interface_test.go | |
@@ -25,6 +25,7 @@ import ( | |
"github.com/stretchr/testify/require" | |
"github.com/onflow/cadence/runtime/activations" | |
+ "github.com/onflow/cadence/runtime/common" | |
"github.com/onflow/cadence/runtime/interpreter" | |
"github.com/onflow/cadence/runtime/sema" | |
"github.com/onflow/cadence/runtime/stdlib" | |
@@ -647,10 +648,14 @@ func TestInterpretInterfaceFunctionConditionsInheritance(t *testing.T) { | |
}`, | |
ParseCheckAndInterpretOptions{ | |
CheckerConfig: &sema.Config{ | |
- BaseValueActivation: baseValueActivation, | |
+ BaseValueActivationHandler: func(_ common.Location) *sema.VariableActivation { | |
+ return baseValueActivation | |
+ }, | |
}, | |
Config: &interpreter.Config{ | |
- BaseActivation: baseActivation, | |
+ BaseActivationHandler: func(location common.Location) *interpreter.VariableActivation { | |
+ return baseActivation | |
+ }, | |
}, | |
}, | |
) | |
@@ -755,10 +760,14 @@ func TestInterpretInterfaceFunctionConditionsInheritance(t *testing.T) { | |
}`, | |
ParseCheckAndInterpretOptions{ | |
CheckerConfig: &sema.Config{ | |
- BaseValueActivation: baseValueActivation, | |
+ BaseValueActivationHandler: func(_ common.Location) *sema.VariableActivation { | |
+ return baseValueActivation | |
+ }, | |
}, | |
Config: &interpreter.Config{ | |
- BaseActivation: baseActivation, | |
+ BaseActivationHandler: func(location common.Location) *interpreter.VariableActivation { | |
+ return baseActivation | |
+ }, | |
}, | |
}, | |
) | |
@@ -842,10 +851,14 @@ func TestInterpretInterfaceFunctionConditionsInheritance(t *testing.T) { | |
`, | |
ParseCheckAndInterpretOptions{ | |
CheckerConfig: &sema.Config{ | |
- BaseValueActivation: baseValueActivation, | |
+ BaseValueActivationHandler: func(_ common.Location) *sema.VariableActivation { | |
+ return baseValueActivation | |
+ }, | |
}, | |
Config: &interpreter.Config{ | |
- BaseActivation: baseActivation, | |
+ BaseActivationHandler: func(location common.Location) *interpreter.VariableActivation { | |
+ return baseActivation | |
+ }, | |
ContractValueHandler: makeContractValueHandler(nil, nil, nil), | |
}, | |
}, | |
diff --git a/runtime/tests/interpreter/interpreter_test.go b/runtime/tests/interpreter/interpreter_test.go | |
remerge CONFLICT (content): Merge conflict in runtime/tests/interpreter/interpreter_test.go | |
index 3d99e99fd..0562b728c 100644 | |
--- a/runtime/tests/interpreter/interpreter_test.go | |
+++ b/runtime/tests/interpreter/interpreter_test.go | |
@@ -7411,17 +7411,12 @@ func TestInterpretReferenceEventParameter(t *testing.T) { | |
), | |
} | |
- for _, event := range expectedEvents { | |
- event.(*interpreter.CompositeValue).InitializeFunctions(inter) | |
- } | |
- | |
AssertValueSlicesEqual( | |
t, | |
inter, | |
expectedEvents, | |
actualEvents, | |
) | |
- | |
} | |
type testValue struct { | |
@@ -9197,17 +9192,11 @@ func TestInterpretResourceOwnerFieldUse(t *testing.T) { | |
}, | |
}, | |
Config: &interpreter.Config{ | |
-<<<<<<< 01a42f326 (Merge pull request #2725 from onflow/supun/improve-conformance) | |
- BaseActivation: baseActivation, | |
- AccountHandler: func(address interpreter.AddressValue) interpreter.Value { | |
- return stdlib.NewAccountValue(nil, nil, address) | |
-======= | |
BaseActivationHandler: func(_ common.Location) *interpreter.VariableActivation { | |
return baseActivation | |
}, | |
- PublicAccountHandler: func(address interpreter.AddressValue) interpreter.Value { | |
- return newTestPublicAccountValue(nil, address) | |
->>>>>>> e878449cf (Merge pull request #2878 from onflow/bastian/native-functionality-linking) | |
+ AccountHandler: func(address interpreter.AddressValue) interpreter.Value { | |
+ return stdlib.NewAccountValue(nil, nil, address) | |
}, | |
}, | |
}, | |
diff --git a/runtime/tests/interpreter/metatype_test.go b/runtime/tests/interpreter/metatype_test.go | |
remerge CONFLICT (content): Merge conflict in runtime/tests/interpreter/metatype_test.go | |
index 99ebc6da1..cee970ae6 100644 | |
--- a/runtime/tests/interpreter/metatype_test.go | |
+++ b/runtime/tests/interpreter/metatype_test.go | |
@@ -821,72 +821,9 @@ func TestInterpretGetType(t *testing.T) { | |
for _, testCase := range cases { | |
address := interpreter.NewUnmeteredAddressValueFromBytes([]byte{42}) | |
+ | |
t.Run(testCase.name, func(t *testing.T) { | |
-<<<<<<< 01a42f326 (Merge pull request #2725 from onflow/supun/improve-conformance) | |
inter, _ := testAccount(t, address, true, nil, testCase.code, sema.Config{}) | |
-======= | |
- | |
- // Inject a function that returns a storage reference value, | |
- // which is borrowed as: `auth &Int` | |
- | |
- getStorageReferenceFunctionType := &sema.FunctionType{ | |
- ReturnTypeAnnotation: sema.NewTypeAnnotation( | |
- &sema.ReferenceType{ | |
- Authorized: true, | |
- Type: sema.IntType, | |
- }, | |
- ), | |
- } | |
- | |
- valueDeclaration := stdlib.NewStandardLibraryFunction( | |
- "getStorageReference", | |
- getStorageReferenceFunctionType, | |
- "", | |
- func(invocation interpreter.Invocation) interpreter.Value { | |
- return &interpreter.StorageReferenceValue{ | |
- Authorized: true, | |
- TargetStorageAddress: storageAddress, | |
- TargetPath: storagePath, | |
- BorrowedType: sema.IntType, | |
- } | |
- }, | |
- ) | |
- | |
- baseValueActivation := sema.NewVariableActivation(sema.BaseValueActivation) | |
- baseValueActivation.DeclareValue(valueDeclaration) | |
- | |
- baseActivation := activations.NewActivation(nil, interpreter.BaseActivation) | |
- interpreter.Declare(baseActivation, valueDeclaration) | |
- | |
- storage := newUnmeteredInMemoryStorage() | |
- | |
- inter, err := parseCheckAndInterpretWithOptions(t, | |
- testCase.code, | |
- ParseCheckAndInterpretOptions{ | |
- CheckerConfig: &sema.Config{ | |
- BaseValueActivationHandler: func(_ common.Location) *sema.VariableActivation { | |
- return baseValueActivation | |
- }, | |
- }, | |
- Config: &interpreter.Config{ | |
- Storage: storage, | |
- BaseActivationHandler: func(_ common.Location) *interpreter.VariableActivation { | |
- return baseActivation | |
- }, | |
- }, | |
- }, | |
- ) | |
- require.NoError(t, err) | |
- | |
- domain := storagePath.Domain.Identifier() | |
- storageMap := storage.GetStorageMap(storageAddress, domain, true) | |
- storageMapKey := interpreter.StringStorageMapKey(storagePath.Identifier) | |
- storageMap.WriteValue( | |
- inter, | |
- storageMapKey, | |
- interpreter.NewUnmeteredIntValueFromInt64(2), | |
- ) | |
->>>>>>> e878449cf (Merge pull request #2878 from onflow/bastian/native-functionality-linking) | |
result, err := inter.Invoke("test") | |
require.NoError(t, err) | |
diff --git a/runtime/tests/interpreter/metering_test.go b/runtime/tests/interpreter/metering_test.go | |
index 76c0feadd..40f996d75 100644 | |
--- a/runtime/tests/interpreter/metering_test.go | |
+++ b/runtime/tests/interpreter/metering_test.go | |
@@ -462,7 +462,7 @@ func TestInterpretArrayFunctionsComputationMetering(t *testing.T) { | |
inter, err := parseCheckAndInterpretWithOptions(t, ` | |
fun main() { | |
let x = [1, 2, 3, 4, 5] | |
- let onlyEven = fun (_ x: Int): Bool { | |
+ let onlyEven = view fun (_ x: Int): Bool { | |
return x % 2 == 0 | |
} | |
let y = x.filter(onlyEven) | |
diff --git a/version.go b/version.go | |
remerge CONFLICT (content): Merge conflict in version.go | |
index 951838b69..df4564bfc 100644 | |
--- a/version.go | |
+++ b/version.go | |
@@ -21,8 +21,4 @@ | |
package cadence | |
-<<<<<<< 01a42f326 (Merge pull request #2725 from onflow/supun/improve-conformance) | |
const Version = "v1.0.0-preview.1" | |
-======= | |
-const Version = "v0.42.1" | |
->>>>>>> e878449cf (Merge pull request #2878 from onflow/bastian/native-functionality-linking) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment