From 298fa4df0592ee3685ddfcd93d48b76e64c7d081 Mon Sep 17 00:00:00 2001 From: Raymond Zhang Date: Wed, 16 Oct 2024 16:49:07 -0400 Subject: [PATCH 01/46] Remove checking and parsing from suite, fix windows issues. --- compat/main.py | 68 ++++++++------------------------------------------ 1 file changed, 10 insertions(+), 58 deletions(-) diff --git a/compat/main.py b/compat/main.py index 1da0c95d21..fe6b697a32 100644 --- a/compat/main.py +++ b/compat/main.py @@ -4,7 +4,7 @@ import html import json import logging -import os +import os, stat import re import shlex import shutil @@ -76,17 +76,6 @@ def replace(pattern, replacement): with path.open(mode="w") as f: f.write(source) - @classmethod - def parse(cls, path: Path, use_json: bool, bench: bool) -> (bool, Optional): - return cls._run(PARSER_PATH, "Parsing", path, use_json, bench) - - def check(self, path: Path, use_json: bool, bench: bool) -> (bool, Optional): - extra_args = [ - f"-memberAccountAccess=S.{path}:S.{(path.parent / Path(other_path)).resolve()}" - for other_path in self.member_account_access - ] - return self._run(CHECKER_PATH, "Checking", path, use_json, bench, extra_args) - @staticmethod def _run( tool_path: Path, @@ -126,10 +115,11 @@ def run(self, working_dir: Path, prepare: bool, go_test_ref: Optional[str]) -> b if go_test_ref: replacement = f'github.com/onflow/cadence@{go_test_ref}' else: - replacement = shlex.quote(str(Path.cwd().parent.absolute())) + replacement = f'{Path.cwd().parent.absolute().resolve().as_posix()}' with cwd(working_dir / self.path): if prepare: + logger.info("Loading dependencies") subprocess.run([ "go", "mod", "edit", "-replace", f'github.com/onflow/cadence={replacement}', ]) @@ -200,6 +190,11 @@ def from_dict(cls, data: Dict): def _clone(self, working_dir: Path): if working_dir.exists(): + for root, dirs, files in os.walk(working_dir): + for dir in dirs: + os.chmod(os.path.join(root, dir), stat.S_IRWXU) + for file in files: + os.chmod(os.path.join(root, file), stat.S_IRWXU) shutil.rmtree(working_dir) logger.info(f"Cloning {self.url} ({self.branch})") @@ -223,57 +218,16 @@ def run( self._clone(working_dir) results: List[Result] = [] - check_succeeded = True - if check: - check_succeeded, results = self.check(working_dir, prepare=prepare, use_json=use_json, bench=bench) - go_tests_succeeded = True if go_test: for test in self.go_tests: if not test.run(working_dir, prepare=prepare, go_test_ref=go_test_ref): go_tests_succeeded = False - succeeded = check_succeeded and go_tests_succeeded + succeeded = go_tests_succeeded return succeeded, results - def check(self, working_dir: Path, prepare: bool, use_json: bool, bench: bool) -> (bool, List[Result]): - - run_succeeded = True - - results: List[Result] = [] - - for file in self.files: - path = working_dir.joinpath(file.path) - - if prepare: - file.rewrite(path) - - parse_succeeded, parse_results = \ - File.parse(path, use_json=use_json, bench=bench) - result = Result( - path=str(path), - parse_result=ParseResult.from_dict(parse_results[0]) if parse_results else None - ) - if not parse_succeeded: - run_succeeded = False - if use_json: - results.append(result) - continue - - check_succeeded, check_results = \ - file.check(path, use_json=use_json, bench=bench) - if check_results: - result.check_result = CheckResult.from_dict(check_results[0]) - if use_json: - results.append(result) - if not check_succeeded: - run_succeeded = False - continue - - return run_succeeded, results - - class Git: @staticmethod @@ -693,7 +647,7 @@ def build_all(): @click.option( "--go-test/--no-go-test", is_flag=True, - default=False, + default=True, help="Run the suite Go tests" ) @click.option( @@ -808,8 +762,6 @@ def run( names: Collection[str] ) -> (bool, List[Result]): - build_all() - all_succeeded = True if not names: From 8ce898631ecbf69d0d886f56cd3b65759d65c4f8 Mon Sep 17 00:00:00 2001 From: Raymond Zhang Date: Thu, 17 Oct 2024 10:43:18 -0400 Subject: [PATCH 02/46] Update flow-go version to pass tests. --- compat/main.py | 50 ++++++++++++++++++++++++++++---------------------- 1 file changed, 28 insertions(+), 22 deletions(-) diff --git a/compat/main.py b/compat/main.py index fe6b697a32..75eebd3e7f 100644 --- a/compat/main.py +++ b/compat/main.py @@ -111,18 +111,17 @@ class GoTest: path: str command: str - def run(self, working_dir: Path, prepare: bool, go_test_ref: Optional[str]) -> bool: - if go_test_ref: - replacement = f'github.com/onflow/cadence@{go_test_ref}' - else: - replacement = f'{Path.cwd().parent.absolute().resolve().as_posix()}' + def run(self, working_dir: Path, prepare: bool, cadence_version: str, flowgo_version: str) -> bool: + cadence_replacement = f'github.com/onflow/cadence@{cadence_version}' + flowgo_replacement = f'github.com/onflow/flow-go@{flowgo_version}' with cwd(working_dir / self.path): if prepare: - logger.info("Loading dependencies") + logger.info("Editing dependencies") subprocess.run([ - "go", "mod", "edit", "-replace", f'github.com/onflow/cadence={replacement}', + "go", "mod", "edit", "-replace", f'github.com/onflow/flow-go={flowgo_replacement}', ]) + logger.info("Downloading dependencies") subprocess.run([ "go", "get", "-t", ".", ]) @@ -209,7 +208,8 @@ def run( bench: bool, check: bool, go_test: bool, - go_test_ref: Optional[str], + cadence_version: str, + flowgo_version: str, ) -> (bool, List[Result]): working_dir = SUITE_PATH / name @@ -221,7 +221,7 @@ def run( go_tests_succeeded = True if go_test: for test in self.go_tests: - if not test.run(working_dir, prepare=prepare, go_test_ref=go_test_ref): + if not test.run(working_dir, prepare=prepare, cadence_version=cadence_version, flowgo_version=flowgo_version): go_tests_succeeded = False succeeded = go_tests_succeeded @@ -613,12 +613,6 @@ def _category(self) -> BenchCategory: def json_serialize(data) -> str: return json.dumps(data, indent=4, cls=EnhancedJSONEncoder) - -def build_all(): - for name in ("parse", "check"): - build(name) - - @click.command() @click.option( "--rerun", @@ -651,9 +645,14 @@ def build_all(): help="Run the suite Go tests" ) @click.option( - "--go-test-ref", - default=None, - help="Git ref of Cadence for Go tests" + "--cadence-version", + default="v1.0.0", + help="version of Cadence for Go tests" +) +@click.option( + "--flowgo-version", + default="v0.37.16", + help="version of flow-go for Go tests" ) @click.option( "--output", @@ -682,7 +681,8 @@ def main( bench: bool, check: bool, go_test: bool, - go_test_ref: Optional[str], + cadence_version: str, + flowgo_version: str, output: Optional[LazyFile], other_ref: Optional[str], delta_threshold: float, @@ -707,7 +707,8 @@ def main( bench=bench, check=check, go_test=go_test, - go_test_ref=go_test_ref, + cadence_version=cadence_version, + flowgo_version=flowgo_version, names=names ) @@ -758,12 +759,16 @@ def run( bench: bool, check: bool, go_test: bool, - go_test_ref: Optional[str], + cadence_version: str, + flowgo_version: str, names: Collection[str] ) -> (bool, List[Result]): all_succeeded = True + # only flow-go version has an impact + logger.info(f'Chosen versions: cadence@{cadence_version}, flow-go@{flowgo_version}') + if not names: names = load_index(SUITE_PATH / "index.yaml") @@ -780,7 +785,8 @@ def run( bench=bench, check=check, go_test=go_test, - go_test_ref=go_test_ref, + cadence_version=cadence_version, + flowgo_version=flowgo_version, ) if not run_succeeded: From 314bca6cd478c05ce57f6526fcaaf5696afe192a Mon Sep 17 00:00:00 2001 From: Raymond Zhang Date: Thu, 17 Oct 2024 10:54:56 -0400 Subject: [PATCH 03/46] Update to latest cadence version. --- compat/main.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/compat/main.py b/compat/main.py index 75eebd3e7f..1a8dea80e9 100644 --- a/compat/main.py +++ b/compat/main.py @@ -646,12 +646,12 @@ def json_serialize(data) -> str: ) @click.option( "--cadence-version", - default="v1.0.0", + default="v1.0.1", help="version of Cadence for Go tests" ) @click.option( "--flowgo-version", - default="v0.37.16", + default="v0.37.17", help="version of flow-go for Go tests" ) @click.option( @@ -766,7 +766,7 @@ def run( all_succeeded = True - # only flow-go version has an impact + # only flow-go version has an impact, cadence version will be upgraded to match flow-go version logger.info(f'Chosen versions: cadence@{cadence_version}, flow-go@{flowgo_version}') if not names: From 8800bfe7216c643ca58d15033b8c8d3a22e990cf Mon Sep 17 00:00:00 2001 From: Raymond Zhang Date: Thu, 17 Oct 2024 14:13:09 -0400 Subject: [PATCH 04/46] Fix formatting, add versioning back. --- compat/main.py | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/compat/main.py b/compat/main.py index 1a8dea80e9..a428a0af89 100644 --- a/compat/main.py +++ b/compat/main.py @@ -4,10 +4,11 @@ import html import json import logging -import os, stat +import os import re import shlex import shutil +import stat import subprocess import sys import textwrap @@ -111,9 +112,17 @@ class GoTest: path: str command: str - def run(self, working_dir: Path, prepare: bool, cadence_version: str, flowgo_version: str) -> bool: - cadence_replacement = f'github.com/onflow/cadence@{cadence_version}' - flowgo_replacement = f'github.com/onflow/flow-go@{flowgo_version}' + def run(self, working_dir: Path, prepare: bool, cadence_version: Optional[str], flowgo_version: Optional[str]) -> bool: + if cadence_version: + cadence_replacement = f'github.com/onflow/cadence@{cadence_version}' + else: + cadence_replacement = Path.cwd().parent.absolute().resolve().as_posix() + + if flowgo_version: + flowgo_replacement = f'github.com/onflow/flow-go@{flowgo_version}' + else: + # default flow-go version is 0.37.16 the one corresponding to cadence v1.0.0 + flowgo_replacement = f'github.com/onflow/flow-go@v0.37.16' with cwd(working_dir / self.path): if prepare: @@ -121,6 +130,9 @@ def run(self, working_dir: Path, prepare: bool, cadence_version: str, flowgo_ver subprocess.run([ "go", "mod", "edit", "-replace", f'github.com/onflow/flow-go={flowgo_replacement}', ]) + subprocess.run([ + "go", "mod", "edit", "-replace", f'github.com/onflow/cadence={cadence_replacement}', + ]) logger.info("Downloading dependencies") subprocess.run([ "go", "get", "-t", ".", @@ -191,9 +203,9 @@ def _clone(self, working_dir: Path): if working_dir.exists(): for root, dirs, files in os.walk(working_dir): for dir in dirs: - os.chmod(os.path.join(root, dir), stat.S_IRWXU) + os.chmod(os.path.join(root, dir), stat.S_IRUSR | stat.S_IWUSR) for file in files: - os.chmod(os.path.join(root, file), stat.S_IRWXU) + os.chmod(os.path.join(root, file), stat.S_IRUSR | stat.S_IWUSR) shutil.rmtree(working_dir) logger.info(f"Cloning {self.url} ({self.branch})") @@ -208,8 +220,8 @@ def run( bench: bool, check: bool, go_test: bool, - cadence_version: str, - flowgo_version: str, + cadence_version: Optional[str], + flowgo_version: Optional[str], ) -> (bool, List[Result]): working_dir = SUITE_PATH / name @@ -646,12 +658,12 @@ def json_serialize(data) -> str: ) @click.option( "--cadence-version", - default="v1.0.1", + default=None, help="version of Cadence for Go tests" ) @click.option( "--flowgo-version", - default="v0.37.17", + default=None, help="version of flow-go for Go tests" ) @click.option( @@ -766,8 +778,7 @@ def run( all_succeeded = True - # only flow-go version has an impact, cadence version will be upgraded to match flow-go version - logger.info(f'Chosen versions: cadence@{cadence_version}, flow-go@{flowgo_version}') + logger.info(f'Chosen versions: cadence@{ cadence_version if cadence_version else "local version" }, flow-go@{flowgo_version if flowgo_version else "v0.37.16"}') if not names: names = load_index(SUITE_PATH / "index.yaml") From 2874423ff59983b2a5cb13539f64643877bacf99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20M=C3=BCller?= Date: Thu, 17 Oct 2024 11:57:23 -0700 Subject: [PATCH 05/46] remove Crypto contract --- runtime/cmd/cmd.go | 7 - runtime/crypto_test.go | 82 ------ runtime/environment.go | 190 +++++-------- runtime/runtime_test.go | 2 - runtime/stdlib/contracts/crypto.cdc | 177 ------------ runtime/stdlib/contracts/crypto.go | 26 -- runtime/stdlib/contracts/crypto_test.cdc | 341 ----------------------- runtime/stdlib/crypto.go | 118 +------- runtime/stdlib/crypto_test.go | 31 --- runtime/stdlib/test.go | 11 - tools/analysis/analysis.go | 7 +- tools/analysis/analysis_test.go | 31 ++- tools/analysis/config.go | 2 + tools/analysis/programs.go | 34 ++- 14 files changed, 127 insertions(+), 932 deletions(-) delete mode 100644 runtime/stdlib/contracts/crypto.cdc delete mode 100644 runtime/stdlib/contracts/crypto.go delete mode 100644 runtime/stdlib/contracts/crypto_test.cdc delete mode 100644 runtime/stdlib/crypto_test.go diff --git a/runtime/cmd/cmd.go b/runtime/cmd/cmd.go index bbd43b2397..9cf8c372b4 100644 --- a/runtime/cmd/cmd.go +++ b/runtime/cmd/cmd.go @@ -97,13 +97,6 @@ func DefaultCheckerConfig( importedLocation common.Location, _ ast.Range, ) (sema.Import, error) { - if importedLocation == stdlib.CryptoCheckerLocation { - cryptoChecker := stdlib.CryptoChecker() - return sema.ElaborationImport{ - Elaboration: cryptoChecker.Elaboration, - }, nil - } - stringLocation, ok := importedLocation.(common.StringLocation) if !ok { return nil, &sema.CheckerError{ diff --git a/runtime/crypto_test.go b/runtime/crypto_test.go index 6cf6e1cec7..17a738511d 100644 --- a/runtime/crypto_test.go +++ b/runtime/crypto_test.go @@ -36,88 +36,6 @@ import ( . "github.com/onflow/cadence/runtime/tests/runtime_utils" ) -func TestRuntimeCrypto_verify(t *testing.T) { - - t.Parallel() - - runtime := NewTestInterpreterRuntime() - - script := []byte(` - import Crypto - - access(all) fun main(): Bool { - let publicKey = PublicKey( - publicKey: "0102".decodeHex(), - signatureAlgorithm: SignatureAlgorithm.ECDSA_P256 - ) - - let keyList = Crypto.KeyList() - keyList.add( - publicKey, - hashAlgorithm: HashAlgorithm.SHA3_256, - weight: 1.0 - ) - - let signatureSet = [ - Crypto.KeyListSignature( - keyIndex: 0, - signature: "0304".decodeHex() - ) - ] - - return keyList.verify( - signatureSet: signatureSet, - signedData: "0506".decodeHex(), - domainSeparationTag: "foo" - ) - } - `) - - var called bool - - storage := NewTestLedger(nil, nil) - - runtimeInterface := &TestRuntimeInterface{ - Storage: storage, - OnVerifySignature: func( - signature []byte, - tag string, - signedData []byte, - publicKey []byte, - signatureAlgorithm SignatureAlgorithm, - hashAlgorithm HashAlgorithm, - ) (bool, error) { - called = true - assert.Equal(t, []byte{3, 4}, signature) - assert.Equal(t, "foo", tag) - assert.Equal(t, []byte{5, 6}, signedData) - assert.Equal(t, []byte{1, 2}, publicKey) - assert.Equal(t, SignatureAlgorithmECDSA_P256, signatureAlgorithm) - assert.Equal(t, HashAlgorithmSHA3_256, hashAlgorithm) - return true, nil - }, - } - addPublicKeyValidation(runtimeInterface, nil) - - result, err := runtime.ExecuteScript( - Script{ - Source: script, - }, - Context{ - Interface: runtimeInterface, - Location: common.ScriptLocation{}, - }, - ) - require.NoError(t, err) - - assert.Equal(t, - cadence.NewBool(true), - result, - ) - - assert.True(t, called) -} - func TestRuntimeHashAlgorithm_hash(t *testing.T) { t.Parallel() diff --git a/runtime/environment.go b/runtime/environment.go index 825e09a8a0..2cf7a87c2e 100644 --- a/runtime/environment.go +++ b/runtime/environment.go @@ -674,40 +674,29 @@ func (e *interpreterEnvironment) resolveImport( importRange ast.Range, ) (sema.Import, error) { - var elaboration *sema.Elaboration - switch importedLocation { - case stdlib.CryptoCheckerLocation: - cryptoChecker := stdlib.CryptoChecker() - elaboration = cryptoChecker.Elaboration - - default: - - // Check for cyclic imports - if e.checkedImports[importedLocation] { - return nil, &sema.CyclicImportsError{ - Location: importedLocation, - Range: importRange, - } - } else { - e.checkedImports[importedLocation] = true - defer delete(e.checkedImports, importedLocation) - } - - const getAndSetProgram = true - program, err := e.GetProgram( - importedLocation, - getAndSetProgram, - e.checkedImports, - ) - if err != nil { - return nil, err + // Check for cyclic imports + if e.checkedImports[importedLocation] { + return nil, &sema.CyclicImportsError{ + Location: importedLocation, + Range: importRange, } + } else { + e.checkedImports[importedLocation] = true + defer delete(e.checkedImports, importedLocation) + } - elaboration = program.Elaboration + const getAndSetProgram = true + program, err := e.GetProgram( + importedLocation, + getAndSetProgram, + e.checkedImports, + ) + if err != nil { + return nil, err } return sema.ElaborationImport{ - Elaboration: elaboration, + Elaboration: program.Elaboration, }, nil } @@ -1006,36 +995,30 @@ func (e *interpreterEnvironment) newInjectedCompositeFieldsHandler() interpreter compositeKind common.CompositeKind, ) map[string]interpreter.Value { - switch location { - case stdlib.CryptoCheckerLocation: - return nil + switch compositeKind { + case common.CompositeKindContract: + var address Address - default: - switch compositeKind { - case common.CompositeKindContract: - var address Address - - switch location := location.(type) { - case common.AddressLocation: - address = location.Address - default: - return nil - } + switch location := location.(type) { + case common.AddressLocation: + address = location.Address + default: + return nil + } - addressValue := interpreter.NewAddressValue( - inter, - address, - ) + addressValue := interpreter.NewAddressValue( + inter, + address, + ) - return map[string]interpreter.Value{ - sema.ContractAccountFieldName: stdlib.NewAccountReferenceValue( - inter, - e, - addressValue, - interpreter.FullyEntitledAccountAccess, - interpreter.EmptyLocationRange, - ), - } + return map[string]interpreter.Value{ + sema.ContractAccountFieldName: stdlib.NewAccountReferenceValue( + inter, + e, + addressValue, + interpreter.FullyEntitledAccountAccess, + interpreter.EmptyLocationRange, + ), } } @@ -1046,36 +1029,22 @@ func (e *interpreterEnvironment) newInjectedCompositeFieldsHandler() interpreter func (e *interpreterEnvironment) newImportLocationHandler() interpreter.ImportLocationHandlerFunc { return func(inter *interpreter.Interpreter, location common.Location) interpreter.Import { - switch location { - case stdlib.CryptoCheckerLocation: - cryptoChecker := stdlib.CryptoChecker() - program := interpreter.ProgramFromChecker(cryptoChecker) - subInterpreter, err := inter.NewSubInterpreter(program, location) - if err != nil { - panic(err) - } - return interpreter.InterpreterImport{ - Interpreter: subInterpreter, - } - - default: - const getAndSetProgram = true - program, err := e.GetProgram( - location, - getAndSetProgram, - importResolutionResults{}, - ) - if err != nil { - panic(err) - } + const getAndSetProgram = true + program, err := e.GetProgram( + location, + getAndSetProgram, + importResolutionResults{}, + ) + if err != nil { + panic(err) + } - subInterpreter, err := inter.NewSubInterpreter(program, location) - if err != nil { - panic(err) - } - return interpreter.InterpreterImport{ - Interpreter: subInterpreter, - } + subInterpreter, err := inter.NewSubInterpreter(program, location) + if err != nil { + panic(err) + } + return interpreter.InterpreterImport{ + Interpreter: subInterpreter, } } } @@ -1123,45 +1092,30 @@ func (e *interpreterEnvironment) newCompositeValueFunctionsHandler() interpreter func (e *interpreterEnvironment) loadContract( inter *interpreter.Interpreter, compositeType *sema.CompositeType, - constructorGenerator func(common.Address) *interpreter.HostFunctionValue, - invocationRange ast.Range, + _ func(common.Address) *interpreter.HostFunctionValue, + _ ast.Range, ) *interpreter.CompositeValue { - switch compositeType.Location { - case stdlib.CryptoCheckerLocation: - contract, err := stdlib.NewCryptoContract( - inter, - constructorGenerator(common.ZeroAddress), - invocationRange, - ) - if err != nil { - panic(err) - } - return contract - - default: - - var storedValue interpreter.Value + var storedValue interpreter.Value - switch location := compositeType.Location.(type) { - - case common.AddressLocation: - storageMap := e.storage.GetStorageMap( - location.Address, - StorageDomainContract, - false, - ) - if storageMap != nil { - storedValue = storageMap.ReadValue(inter, interpreter.StringStorageMapKey(location.Name)) - } - } - - if storedValue == nil { - panic(errors.NewDefaultUserError("failed to load contract: %s", compositeType.Location)) + switch location := compositeType.Location.(type) { + // TODO: support e.g. CryptoContractLocation + case common.AddressLocation: + storageMap := e.storage.GetStorageMap( + location.Address, + StorageDomainContract, + false, + ) + if storageMap != nil { + storedValue = storageMap.ReadValue(inter, interpreter.StringStorageMapKey(location.Name)) } + } - return storedValue.(*interpreter.CompositeValue) + if storedValue == nil { + panic(errors.NewDefaultUserError("failed to load contract: %s", compositeType.Location)) } + + return storedValue.(*interpreter.CompositeValue) } func (e *interpreterEnvironment) newOnFunctionInvocationHandler() func(_ *interpreter.Interpreter) { diff --git a/runtime/runtime_test.go b/runtime/runtime_test.go index d3f13fa003..cfd7fd69e8 100644 --- a/runtime/runtime_test.go +++ b/runtime/runtime_test.go @@ -7730,8 +7730,6 @@ func BenchmarkRuntimeScriptNoop(b *testing.B) { Environment: environment, } - require.NotNil(b, stdlib.CryptoChecker()) - runtime := NewTestInterpreterRuntime() b.ReportAllocs() diff --git a/runtime/stdlib/contracts/crypto.cdc b/runtime/stdlib/contracts/crypto.cdc deleted file mode 100644 index a8c50dcdfe..0000000000 --- a/runtime/stdlib/contracts/crypto.cdc +++ /dev/null @@ -1,177 +0,0 @@ - -access(all) contract Crypto { - - access(all) - fun hash(_ data: [UInt8], algorithm: HashAlgorithm): [UInt8] { - return algorithm.hash(data) - } - - access(all) - fun hashWithTag(_ data: [UInt8], tag: String, algorithm: HashAlgorithm): [UInt8] { - return algorithm.hashWithTag(data, tag: tag) - } - - access(all) - struct KeyListEntry { - - access(all) - let keyIndex: Int - - access(all) - let publicKey: PublicKey - - access(all) - let hashAlgorithm: HashAlgorithm - - access(all) - let weight: UFix64 - - access(all) - let isRevoked: Bool - - init( - keyIndex: Int, - publicKey: PublicKey, - hashAlgorithm: HashAlgorithm, - weight: UFix64, - isRevoked: Bool - ) { - self.keyIndex = keyIndex - self.publicKey = publicKey - self.hashAlgorithm = hashAlgorithm - self.weight = weight - self.isRevoked = isRevoked - } - } - - access(all) - struct KeyList { - - access(self) - let entries: [KeyListEntry] - - init() { - self.entries = [] - } - - /// Adds a new key with the given weight - access(all) - fun add( - _ publicKey: PublicKey, - hashAlgorithm: HashAlgorithm, - weight: UFix64 - ): KeyListEntry { - - let keyIndex = self.entries.length - let entry = KeyListEntry( - keyIndex: keyIndex, - publicKey: publicKey, - hashAlgorithm: hashAlgorithm, - weight: weight, - isRevoked: false - ) - self.entries.append(entry) - return entry - } - - /// Returns the key at the given index, if it exists. - /// Revoked keys are always returned, but they have the `isRevoked` field set to true - access(all) - fun get(keyIndex: Int): KeyListEntry? { - if keyIndex >= self.entries.length { - return nil - } - - return self.entries[keyIndex] - } - - /// Marks the key at the given index revoked, but does not delete it - access(all) - fun revoke(keyIndex: Int) { - if keyIndex >= self.entries.length { - return - } - - let currentEntry = self.entries[keyIndex] - self.entries[keyIndex] = KeyListEntry( - keyIndex: currentEntry.keyIndex, - publicKey: currentEntry.publicKey, - hashAlgorithm: currentEntry.hashAlgorithm, - weight: currentEntry.weight, - isRevoked: true - ) - } - - /// Returns true if the given signatures are valid for the given signed data - access(all) - fun verify( - signatureSet: [KeyListSignature], - signedData: [UInt8], - domainSeparationTag: String - ): Bool { - - var validWeights: UFix64 = 0.0 - - let seenKeyIndices: {Int: Bool} = {} - - for signature in signatureSet { - - // Ensure the key index is valid - - if signature.keyIndex >= self.entries.length { - return false - } - - // Ensure this key index has not already been seen - - if seenKeyIndices[signature.keyIndex] ?? false { - return false - } - - // Record the key index was seen - - seenKeyIndices[signature.keyIndex] = true - - // Get the actual key - - let key = self.entries[signature.keyIndex] - - // Ensure the key is not revoked - - if key.isRevoked { - return false - } - - // Ensure the signature is valid - - if !key.publicKey.verify( - signature: signature.signature, - signedData: signedData, - domainSeparationTag: domainSeparationTag, - hashAlgorithm:key.hashAlgorithm - ) { - return false - } - - validWeights = validWeights + key.weight - } - - return validWeights >= 1.0 - } - } - - access(all) - struct KeyListSignature { - - access(all) - let keyIndex: Int - - access(all) - let signature: [UInt8] - - init(keyIndex: Int, signature: [UInt8]) { - self.keyIndex = keyIndex - self.signature = signature - } - } -} diff --git a/runtime/stdlib/contracts/crypto.go b/runtime/stdlib/contracts/crypto.go deleted file mode 100644 index a64180f160..0000000000 --- a/runtime/stdlib/contracts/crypto.go +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Cadence - The resource-oriented smart contract programming language - * - * Copyright Flow Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package contracts - -import ( - _ "embed" -) - -//go:embed crypto.cdc -var Crypto []byte diff --git a/runtime/stdlib/contracts/crypto_test.cdc b/runtime/stdlib/contracts/crypto_test.cdc deleted file mode 100644 index d4e654287b..0000000000 --- a/runtime/stdlib/contracts/crypto_test.cdc +++ /dev/null @@ -1,341 +0,0 @@ -import Test -import Crypto from "crypto.cdc" - -access(all) -fun setup() { - let err = Test.deployContract( - name: "Crypto", - path: "crypto.cdc", - arguments: [] - ) - - Test.expect(err, Test.beNil()) -} - -access(all) -fun testCryptoHash() { - let hash = Crypto.hash([1, 2, 3], algorithm: HashAlgorithm.SHA3_256) - Test.assertEqual(32, hash.length) -} - -access(all) -fun testCryptoHashWithTag() { - let hash = Crypto.hashWithTag( - [1, 2, 3], - tag: "v0.1.tag", - algorithm: HashAlgorithm.SHA3_256 - ) - Test.assertEqual(32, hash.length) -} - -access(all) -fun testAddKeyToKeyList() { - let keyList = Crypto.KeyList() - - let publicKey = PublicKey( - publicKey: - "db04940e18ec414664ccfd31d5d2d4ece3985acb8cb17a2025b2f1673427267968e52e2bbf3599059649d4b2cce98fdb8a3048e68abf5abe3e710129e90696ca".decodeHex(), - signatureAlgorithm: SignatureAlgorithm.ECDSA_P256 - ) - keyList.add( - publicKey, - hashAlgorithm: HashAlgorithm.SHA3_256, - weight: 1.0 - ) - - Test.assert(keyList.get(keyIndex: 0) != nil) -} - -access(all) -fun testGetKeyFromList() { - let keyList = Crypto.KeyList() - - let publicKey = PublicKey( - publicKey: - "db04940e18ec414664ccfd31d5d2d4ece3985acb8cb17a2025b2f1673427267968e52e2bbf3599059649d4b2cce98fdb8a3048e68abf5abe3e710129e90696ca".decodeHex(), - signatureAlgorithm: SignatureAlgorithm.ECDSA_P256 - ) - keyList.add( - publicKey, - hashAlgorithm: HashAlgorithm.SHA3_256, - weight: 1.0 - ) - - Test.assert(keyList.get(keyIndex: 0) != nil) - Test.assert(keyList.get(keyIndex: 2) == nil) -} - -access(all) -fun testRevokeKeyFromList() { - let keyList = Crypto.KeyList() - - let publicKey = PublicKey( - publicKey: - "db04940e18ec414664ccfd31d5d2d4ece3985acb8cb17a2025b2f1673427267968e52e2bbf3599059649d4b2cce98fdb8a3048e68abf5abe3e710129e90696ca".decodeHex(), - signatureAlgorithm: SignatureAlgorithm.ECDSA_P256 - ) - keyList.add( - publicKey, - hashAlgorithm: HashAlgorithm.SHA3_256, - weight: 0.5 - ) - - keyList.revoke(keyIndex: 0) - keyList.revoke(keyIndex: 2) - - Test.assert(keyList.get(keyIndex: 0)!.isRevoked) - Test.assert(keyList.get(keyIndex: 2) == nil) -} - -access(all) -fun testKeyListVerify() { - let keyList = Crypto.KeyList() - - let publicKeyA = PublicKey( - publicKey: - "db04940e18ec414664ccfd31d5d2d4ece3985acb8cb17a2025b2f1673427267968e52e2bbf3599059649d4b2cce98fdb8a3048e68abf5abe3e710129e90696ca".decodeHex(), - signatureAlgorithm: SignatureAlgorithm.ECDSA_P256 - ) - - keyList.add( - publicKeyA, - hashAlgorithm: HashAlgorithm.SHA3_256, - weight: 0.5 - ) - - let publicKeyB = PublicKey( - publicKey: - "df9609ee588dd4a6f7789df8d56f03f545d4516f0c99b200d73b9a3afafc14de5d21a4fc7a2a2015719dc95c9e756cfa44f2a445151aaf42479e7120d83df956".decodeHex(), - signatureAlgorithm: SignatureAlgorithm.ECDSA_P256 - ) - - keyList.add( - publicKeyB, - hashAlgorithm: HashAlgorithm.SHA3_256, - weight: 0.5 - ) - - let signatureSet = [ - Crypto.KeyListSignature( - keyIndex: 0, - signature: - "8870a8cbe6f44932ba59e0d15a706214cc4ad2538deb12c0cf718d86f32c47765462a92ce2da15d4a29eb4e2b6fa05d08c7db5d5b2a2cd8c2cb98ded73da31f6".decodeHex() - ), - Crypto.KeyListSignature( - keyIndex: 1, - signature: - "bbdc5591c3f937a730d4f6c0a6fde61a0a6ceaa531ccb367c3559335ab9734f4f2b9da8adbe371f1f7da913b5a3fdd96a871e04f078928ca89a83d841c72fadf".decodeHex() - ) - ] - - // "foo", encoded as UTF-8, in hex representation - let signedData = "666f6f".decodeHex() - - let isValid = keyList.verify( - signatureSet: signatureSet, - signedData: signedData, - domainSeparationTag: "FLOW-V0.0-user" - ) - - Test.assert(isValid) -} - -access(all) -fun testKeyListVerifyInsufficientWeights() { - let keyList = Crypto.KeyList() - - let publicKeyA = PublicKey( - publicKey: - "db04940e18ec414664ccfd31d5d2d4ece3985acb8cb17a2025b2f1673427267968e52e2bbf3599059649d4b2cce98fdb8a3048e68abf5abe3e710129e90696ca".decodeHex(), - signatureAlgorithm: SignatureAlgorithm.ECDSA_P256 - ) - - keyList.add( - publicKeyA, - hashAlgorithm: HashAlgorithm.SHA3_256, - weight: 0.4 - ) - - let publicKeyB = PublicKey( - publicKey: - "df9609ee588dd4a6f7789df8d56f03f545d4516f0c99b200d73b9a3afafc14de5d21a4fc7a2a2015719dc95c9e756cfa44f2a445151aaf42479e7120d83df956".decodeHex(), - signatureAlgorithm: SignatureAlgorithm.ECDSA_P256 - ) - - keyList.add( - publicKeyB, - hashAlgorithm: HashAlgorithm.SHA3_256, - weight: 0.5 - ) - - let signatureSet = [ - Crypto.KeyListSignature( - keyIndex: 0, - signature: - "8870a8cbe6f44932ba59e0d15a706214cc4ad2538deb12c0cf718d86f32c47765462a92ce2da15d4a29eb4e2b6fa05d08c7db5d5b2a2cd8c2cb98ded73da31f6".decodeHex() - ), - Crypto.KeyListSignature( - keyIndex: 1, - signature: - "bbdc5591c3f937a730d4f6c0a6fde61a0a6ceaa531ccb367c3559335ab9734f4f2b9da8adbe371f1f7da913b5a3fdd96a871e04f078928ca89a83d841c72fadf".decodeHex() - ) - ] - - // "foo", encoded as UTF-8, in hex representation - let signedData = "666f6f".decodeHex() - - let isValid = keyList.verify( - signatureSet: signatureSet, - signedData: signedData, - domainSeparationTag: "FLOW-V0.0-user" - ) - - Test.assert(!isValid) -} - -access(all) -fun testKeyListVerifyWithRevokedKey() { - let keyList = Crypto.KeyList() - - let publicKey = PublicKey( - publicKey: - "db04940e18ec414664ccfd31d5d2d4ece3985acb8cb17a2025b2f1673427267968e52e2bbf3599059649d4b2cce98fdb8a3048e68abf5abe3e710129e90696ca".decodeHex(), - signatureAlgorithm: SignatureAlgorithm.ECDSA_P256 - ) - keyList.add( - publicKey, - hashAlgorithm: HashAlgorithm.SHA3_256, - weight: 0.5 - ) - - let signatureSet = [ - Crypto.KeyListSignature( - keyIndex: 0, - signature: - "8870a8cbe6f44932ba59e0d15a706214cc4ad2538deb12c0cf718d86f32c47765462a92ce2da15d4a29eb4e2b6fa05d08c7db5d5b2a2cd8c2cb98ded73da31f6".decodeHex() - ) - ] - - // "foo", encoded as UTF-8, in hex representation - let signedData = "666f6f".decodeHex() - - keyList.revoke(keyIndex: 0) - - let isValid = keyList.verify( - signatureSet: signatureSet, - signedData: signedData, - domainSeparationTag: "FLOW-V0.0-user" - ) - - Test.assert(!isValid) -} - -access(all) -fun testKeyListVerifyWithMissingSignature() { - let keyList = Crypto.KeyList() - - let publicKey = PublicKey( - publicKey: - "db04940e18ec414664ccfd31d5d2d4ece3985acb8cb17a2025b2f1673427267968e52e2bbf3599059649d4b2cce98fdb8a3048e68abf5abe3e710129e90696ca".decodeHex(), - signatureAlgorithm: SignatureAlgorithm.ECDSA_P256 - ) - keyList.add( - publicKey, - hashAlgorithm: HashAlgorithm.SHA3_256, - weight: 0.5 - ) - - let signatureSet = [ - Crypto.KeyListSignature( - keyIndex: 1, - signature: - "8870a8cbe6f44932ba59e0d15a706214cc4ad2538deb12c0cf718d86f32c47765462a92ce2da15d4a29eb4e2b6fa05d08c7db5d5b2a2cd8c2cb98ded73da31f6".decodeHex() - ) - ] - - // "foo", encoded as UTF-8, in hex representation - let signedData = "666f6f".decodeHex() - - let isValid = keyList.verify( - signatureSet: signatureSet, - signedData: signedData, - domainSeparationTag: "FLOW-V0.0-user" - ) - - Test.assert(!isValid) -} - -access(all) -fun testKeyListVerifyDuplicateSignature() { - let keyList = Crypto.KeyList() - - let publicKey = PublicKey( - publicKey: - "db04940e18ec414664ccfd31d5d2d4ece3985acb8cb17a2025b2f1673427267968e52e2bbf3599059649d4b2cce98fdb8a3048e68abf5abe3e710129e90696ca".decodeHex(), - signatureAlgorithm: SignatureAlgorithm.ECDSA_P256 - ) - keyList.add( - publicKey, - hashAlgorithm: HashAlgorithm.SHA3_256, - weight: 0.5 - ) - - let signatureSet = [ - Crypto.KeyListSignature( - keyIndex: 0, - signature: - "8870a8cbe6f44932ba59e0d15a706214cc4ad2538deb12c0cf718d86f32c47765462a92ce2da15d4a29eb4e2b6fa05d08c7db5d5b2a2cd8c2cb98ded73da31f6".decodeHex() - ), - Crypto.KeyListSignature( - keyIndex: 0, - signature: - "8870a8cbe6f44932ba59e0d15a706214cc4ad2538deb12c0cf718d86f32c47765462a92ce2da15d4a29eb4e2b6fa05d08c7db5d5b2a2cd8c2cb98ded73da31f6".decodeHex() - ) - ] - - // "foo", encoded as UTF-8, in hex representation - let signedData = "666f6f".decodeHex() - - let isValid = keyList.verify( - signatureSet: signatureSet, - signedData: signedData, - domainSeparationTag: "FLOW-V0.0-user" - ) - - Test.assert(!isValid) -} - -access(all) -fun testKeyListVerifyInvalidSignature() { - let keyList = Crypto.KeyList() - - let publicKey = PublicKey( - publicKey: - "db04940e18ec414664ccfd31d5d2d4ece3985acb8cb17a2025b2f1673427267968e52e2bbf3599059649d4b2cce98fdb8a3048e68abf5abe3e710129e90696ca".decodeHex(), - signatureAlgorithm: SignatureAlgorithm.ECDSA_P256 - ) - keyList.add( - publicKey, - hashAlgorithm: HashAlgorithm.SHA3_256, - weight: 0.5 - ) - - let signatureSet = [ - Crypto.KeyListSignature( - keyIndex: 0, - signature: - "db70a8cbe6f44932ba59e0d15a706214cc4ad2538deb12c0cf718d86f32c47765462a92ce2da15d4a29eb4e2b6fa05d08c7db5d5b2a2cd8c2cb98ded73da31f6".decodeHex() - ) - ] - - // "foo", encoded as UTF-8, in hex representation - let signedData = "666f6f".decodeHex() - - let isValid = keyList.verify( - signatureSet: signatureSet, - signedData: signedData, - domainSeparationTag: "FLOW-V0.0-user" - ) - - Test.assert(!isValid) -} diff --git a/runtime/stdlib/crypto.go b/runtime/stdlib/crypto.go index 585018540d..689de2e216 100644 --- a/runtime/stdlib/crypto.go +++ b/runtime/stdlib/crypto.go @@ -1,128 +1,12 @@ -/* - * Cadence - The resource-oriented smart contract programming language - * - * Copyright Flow Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - package stdlib import ( - "sync" - - "github.com/onflow/cadence/runtime/ast" "github.com/onflow/cadence/runtime/common" - "github.com/onflow/cadence/runtime/errors" - "github.com/onflow/cadence/runtime/parser" - "github.com/onflow/cadence/runtime/stdlib/contracts" - "github.com/onflow/cadence/runtime/interpreter" "github.com/onflow/cadence/runtime/sema" ) -const CryptoCheckerLocation = common.IdentifierLocation("Crypto") - -var cryptoOnce sync.Once - -// Deprecated: Use CryptoChecker instead -var cryptoChecker *sema.Checker - -// Deprecated: Use CryptoContractType instead -var cryptoContractType *sema.CompositeType - -// Deprecated: Use CryptoContractInitializerTypes -var cryptoContractInitializerTypes []sema.Type - -func CryptoChecker() *sema.Checker { - cryptoOnce.Do(initCrypto) - return cryptoChecker -} - -func CryptoContractType() *sema.CompositeType { - cryptoOnce.Do(initCrypto) - return cryptoContractType -} - -func CryptoContractInitializerTypes() []sema.Type { - cryptoOnce.Do(initCrypto) - return cryptoContractInitializerTypes -} - -func initCrypto() { - program, err := parser.ParseProgram( - nil, - contracts.Crypto, - parser.Config{}, - ) - if err != nil { - panic(err) - } - - cryptoChecker, err = sema.NewChecker( - program, - CryptoCheckerLocation, - nil, - &sema.Config{ - AccessCheckMode: sema.AccessCheckModeStrict, - }, - ) - if err != nil { - panic(err) - } - - err = cryptoChecker.Check() - if err != nil { - panic(err) - } - - variable, ok := cryptoChecker.Elaboration.GetGlobalType("Crypto") - if !ok { - panic(errors.NewUnreachableError()) - } - cryptoContractType = variable.Type.(*sema.CompositeType) - - cryptoContractInitializerTypes = make([]sema.Type, len(cryptoContractType.ConstructorParameters)) - for i, parameter := range cryptoContractType.ConstructorParameters { - cryptoContractInitializerTypes[i] = parameter.TypeAnnotation.Type - } -} - -func NewCryptoContract( - inter *interpreter.Interpreter, - constructor interpreter.FunctionValue, - invocationRange ast.Range, -) ( - *interpreter.CompositeValue, - error, -) { - initializerTypes := CryptoContractInitializerTypes() - value, err := inter.InvokeFunctionValue( - constructor, - nil, - initializerTypes, - initializerTypes, - CryptoContractType(), - invocationRange, - ) - if err != nil { - return nil, err - } - - compositeValue := value.(*interpreter.CompositeValue) - - return compositeValue, nil -} +const CryptoContractLocation = common.IdentifierLocation("Crypto") func cryptoAlgorithmEnumConstructorType[T sema.CryptoAlgorithm]( enumType *sema.CompositeType, diff --git a/runtime/stdlib/crypto_test.go b/runtime/stdlib/crypto_test.go deleted file mode 100644 index ff2dca5cf4..0000000000 --- a/runtime/stdlib/crypto_test.go +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Cadence - The resource-oriented smart contract programming language - * - * Copyright Flow Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package stdlib - -import ( - "testing" - - "github.com/stretchr/testify/require" - - "github.com/onflow/cadence/runtime/sema" -) - -func TestCryptoContract(t *testing.T) { - require.IsType(t, &sema.Checker{}, CryptoChecker()) -} diff --git a/runtime/stdlib/test.go b/runtime/stdlib/test.go index eb65c13985..0a7af89d5b 100644 --- a/runtime/stdlib/test.go +++ b/runtime/stdlib/test.go @@ -494,17 +494,6 @@ func NewTestInterpreterContractValueHandler( ) interpreter.ContractValue { switch compositeType.Location { - case CryptoCheckerLocation: - contract, err := NewCryptoContract( - inter, - constructorGenerator(common.ZeroAddress), - invocationRange, - ) - if err != nil { - panic(err) - } - return contract - case TestContractLocation: contract, err := GetTestContractType().NewTestContract( inter, diff --git a/tools/analysis/analysis.go b/tools/analysis/analysis.go index 4c5513a95a..d5ba872103 100644 --- a/tools/analysis/analysis.go +++ b/tools/analysis/analysis.go @@ -22,8 +22,11 @@ import ( "github.com/onflow/cadence/runtime/common" ) -func Load(config *Config, locations ...common.Location) (Programs, error) { - programs := make(Programs, len(locations)) +func Load(config *Config, locations ...common.Location) (*Programs, error) { + programs := &Programs{ + programs: make(map[common.Location]*Program, len(locations)), + cryptoContractElaboration: config.CryptoContractElaboration, + } for _, location := range locations { err := programs.Load(config, location) if err != nil { diff --git a/tools/analysis/analysis_test.go b/tools/analysis/analysis_test.go index d1321debf5..fb586a2e5f 100644 --- a/tools/analysis/analysis_test.go +++ b/tools/analysis/analysis_test.go @@ -89,8 +89,8 @@ func TestNeedSyntaxAndImport(t *testing.T) { programs, err := analysis.Load(config, txLocation) require.NoError(t, err) - require.NotNil(t, programs[txLocation]) - require.NotNil(t, programs[contractLocation]) + require.NotNil(t, programs.Get(txLocation)) + require.NotNil(t, programs.Get(contractLocation)) type locationRange struct { location common.Location @@ -99,7 +99,7 @@ func TestNeedSyntaxAndImport(t *testing.T) { var locationRanges []locationRange - for _, program := range programs { + for _, program := range programs.All() { require.NotNil(t, program.Program) require.NotNil(t, program.Checker) @@ -309,7 +309,10 @@ func TestHandledParserError(t *testing.T) { require.Equal(t, 1, handlerCalls) var parserError parser.Error - require.ErrorAs(t, programs[contractLocation].LoadError, &parserError) + require.ErrorAs(t, + programs.Get(contractLocation).LoadError, + &parserError, + ) } func TestHandledCheckerError(t *testing.T) { @@ -361,7 +364,10 @@ func TestHandledCheckerError(t *testing.T) { require.NoError(t, err) var checkerError *sema.CheckerError - require.ErrorAs(t, programs[contractLocation].LoadError, &checkerError) + require.ErrorAs(t, + programs.Get(contractLocation).LoadError, + &checkerError, + ) } // Tests that an error handled by the custom error handler is not returned @@ -429,12 +435,21 @@ func TestHandledLoadErrorImportedProgram(t *testing.T) { require.NoError(t, err) var checkerError *sema.CheckerError - require.ErrorAs(t, programs[contract1Location].LoadError, &checkerError) - require.ErrorAs(t, programs[contract2Location].LoadError, &checkerError) + require.ErrorAs(t, + programs.Get(contract1Location).LoadError, + &checkerError, + ) + require.ErrorAs(t, + programs.Get(contract2Location).LoadError, + &checkerError, + ) // Validate that parent checker receives the imported program error despite it being handled var importedProgramErr *sema.ImportedProgramError - require.ErrorAs(t, programs[contract1Location].LoadError, &importedProgramErr) + require.ErrorAs(t, + programs.Get(contract1Location).LoadError, + &importedProgramErr, + ) } func TestStdlib(t *testing.T) { diff --git a/tools/analysis/config.go b/tools/analysis/config.go index 3bf637f9f3..8e0386cf9b 100644 --- a/tools/analysis/config.go +++ b/tools/analysis/config.go @@ -45,6 +45,8 @@ type Config struct { HandleParserError func(err ParsingCheckingError, program *ast.Program) error // HandleCheckerError is called when a checker error occurs instead of returning it HandleCheckerError func(err ParsingCheckingError, checker *sema.Checker) error + // CryptoContractElaboration is the elaboration of the Crypto contract + CryptoContractElaboration *sema.Elaboration } func NewSimpleConfig( diff --git a/tools/analysis/programs.go b/tools/analysis/programs.go index 08ae11ae49..53bda6953b 100644 --- a/tools/analysis/programs.go +++ b/tools/analysis/programs.go @@ -26,11 +26,14 @@ import ( "github.com/onflow/cadence/runtime/stdlib" ) -type Programs map[common.Location]*Program +type Programs struct { + programs map[common.Location]*Program + cryptoContractElaboration *sema.Elaboration +} type importResolutionResults map[common.Location]bool -func (programs Programs) Load(config *Config, location common.Location) error { +func (programs *Programs) Load(config *Config, location common.Location) error { return programs.load( config, location, @@ -43,14 +46,14 @@ func (programs Programs) Load(config *Config, location common.Location) error { ) } -func (programs Programs) load( +func (programs *Programs) load( config *Config, location common.Location, importingLocation common.Location, importRange ast.Range, seenImports importResolutionResults, ) error { - if programs[location] != nil { + if programs.programs[location] != nil { return nil } @@ -104,7 +107,7 @@ func (programs Programs) load( } } - programs[location] = &Program{ + programs.programs[location] = &Program{ Location: location, Code: code, Program: program, @@ -115,7 +118,7 @@ func (programs Programs) load( return nil } -func (programs Programs) check( +func (programs *Programs) check( config *Config, program *ast.Program, location common.Location, @@ -153,9 +156,8 @@ func (programs Programs) check( var loadError error switch importedLocation { - case stdlib.CryptoCheckerLocation: - cryptoChecker := stdlib.CryptoChecker() - elaboration = cryptoChecker.Elaboration + case stdlib.CryptoContractLocation: + elaboration = programs.cryptoContractElaboration default: if seenImports[importedLocation] { @@ -172,7 +174,7 @@ func (programs Programs) check( return nil, err } - program := programs[importedLocation] + program := programs.programs[importedLocation] checker := program.Checker // If the imported program has a checker, use its elaboration for the import @@ -205,3 +207,15 @@ func (programs Programs) check( return checker, nil } + +func (programs *Programs) Get(location common.Location) *Program { + return programs.programs[location] +} + +func (programs *Programs) All() []*Program { + all := make([]*Program, 0, len(programs.programs)) + for _, program := range programs.programs { + all = append(all, program) + } + return all +} From 393e95547139475504f4dd91681b6b92c6405496 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20M=C3=BCller?= Date: Thu, 17 Oct 2024 16:49:48 -0700 Subject: [PATCH 06/46] call constructor for contracts loaded from identifier location, test --- runtime/environment.go | 36 +++++++++++---- runtime/runtime_test.go | 98 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 125 insertions(+), 9 deletions(-) diff --git a/runtime/environment.go b/runtime/environment.go index 2cf7a87c2e..89be3f8032 100644 --- a/runtime/environment.go +++ b/runtime/environment.go @@ -1092,14 +1092,32 @@ func (e *interpreterEnvironment) newCompositeValueFunctionsHandler() interpreter func (e *interpreterEnvironment) loadContract( inter *interpreter.Interpreter, compositeType *sema.CompositeType, - _ func(common.Address) *interpreter.HostFunctionValue, - _ ast.Range, + constructorGenerator func(common.Address) *interpreter.HostFunctionValue, + invocationRange ast.Range, ) *interpreter.CompositeValue { - var storedValue interpreter.Value + var contractValue interpreter.Value + + location := compositeType.Location + switch location := location.(type) { + case common.IdentifierLocation: + // Identifier locations are used for built-in contracts, + // and are not stored in storage + + constructorGenerator := constructorGenerator(common.ZeroAddress) + var err error + contractValue, err = inter.InvokeFunctionValue( + constructorGenerator, + nil, + nil, + nil, + compositeType, + invocationRange, + ) + if err != nil { + panic(err) + } - switch location := compositeType.Location.(type) { - // TODO: support e.g. CryptoContractLocation case common.AddressLocation: storageMap := e.storage.GetStorageMap( location.Address, @@ -1107,15 +1125,15 @@ func (e *interpreterEnvironment) loadContract( false, ) if storageMap != nil { - storedValue = storageMap.ReadValue(inter, interpreter.StringStorageMapKey(location.Name)) + contractValue = storageMap.ReadValue(inter, interpreter.StringStorageMapKey(location.Name)) } } - if storedValue == nil { - panic(errors.NewDefaultUserError("failed to load contract: %s", compositeType.Location)) + if contractValue == nil { + panic(errors.NewDefaultUserError("failed to load contract: %s", location)) } - return storedValue.(*interpreter.CompositeValue) + return contractValue.(*interpreter.CompositeValue) } func (e *interpreterEnvironment) newOnFunctionInvocationHandler() func(_ *interpreter.Interpreter) { diff --git a/runtime/runtime_test.go b/runtime/runtime_test.go index cfd7fd69e8..4e63c44413 100644 --- a/runtime/runtime_test.go +++ b/runtime/runtime_test.go @@ -11561,3 +11561,101 @@ func TestResultRedeclared(t *testing.T) { }) } +func TestRuntimeContractValueLocation(t *testing.T) { + + t.Parallel() + + signerAddress := common.MustBytesToAddress([]byte{0x42}) + + const fooContractName = "Foo" + fooIdentifierLocation := common.IdentifierLocation(fooContractName) + + fooContract := []byte(` + access(all) + contract Foo { + access(all) var answer: Int + + init() { + self.answer = 42 + } + } + `) + + accountCodes := map[Location][]byte{} + var events []cadence.Event + + runtimeInterface := &TestRuntimeInterface{ + Storage: NewTestLedger(nil, nil), + OnGetSigningAccounts: func() ([]Address, error) { + return []Address{signerAddress}, nil + }, + OnResolveLocation: func(identifiers []Identifier, location Location) ([]ResolvedLocation, error) { + assert.Empty(t, identifiers) + assert.Equal(t, fooIdentifierLocation, location) + + return []ResolvedLocation{ + { + Location: location, + Identifiers: identifiers, + }, + }, nil + }, + OnGetAccountContractCode: func(location common.AddressLocation) (code []byte, err error) { + return accountCodes[location], nil + }, + OnUpdateAccountContractCode: func(location common.AddressLocation, code []byte) error { + accountCodes[location] = code + return nil + }, + OnEmitEvent: func(event cadence.Event) error { + events = append(events, event) + return nil + }, + OnGetCode: func(location Location) ([]byte, error) { + assert.Equal(t, fooIdentifierLocation, location) + return fooContract, nil + }, + } + + runtime := NewTestInterpreterRuntime() + + nextTransactionLocation := NewTransactionLocationGenerator() + nextScriptLocation := NewScriptLocationGenerator() + + // Deploy + + deploy := DeploymentTransaction(fooContractName, fooContract) + + err := runtime.ExecuteTransaction( + Script{ + Source: deploy, + }, + Context{ + Interface: runtimeInterface, + Location: nextTransactionLocation(), + }, + ) + require.NoError(t, err) + + // Test + + result, err := runtime.ExecuteScript( + Script{ + Source: []byte(` + import Foo + + access(all) + fun main(): Int { + return Foo.answer + } + `), + }, + Context{ + Interface: runtimeInterface, + Location: nextScriptLocation(), + }, + ) + require.NoError(t, err) + + assert.Equal(t, cadence.NewInt(42), result) +} From bc51dde5af18680803c8d2687d333b934802cc47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20M=C3=BCller?= Date: Thu, 17 Oct 2024 17:01:01 -0700 Subject: [PATCH 07/46] remove Flow CLI and testing from CI job --- .github/workflows/ci.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 634088911f..c778cde165 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -39,18 +39,12 @@ jobs: go-version: ${{ env.GO_VERSION }} cache: true - - name: Install Flow CLI - run: sh -ci "$(curl -fsSL https://raw.githubusercontent.com/onflow/flow-cli/master/install.sh)" - - name: Build run: make -j8 build - name: Test run: make ci - - name: Cadence Testing Framework - run: cd runtime/stdlib/contracts && flow test --cover --covercode="contracts" crypto_test.cdc - - name: Upload coverage report uses: codecov/codecov-action@v2 with: From 4f3e6fa5b74dfe5a63723928dc9b0f72125c5453 Mon Sep 17 00:00:00 2001 From: Raymond Zhang Date: Fri, 18 Oct 2024 10:21:59 -0400 Subject: [PATCH 08/46] Remove unused code, always use latest flow-go version. --- compat/main.py | 602 +--------------------------------------- compat/requirements.txt | 1 - 2 files changed, 13 insertions(+), 590 deletions(-) diff --git a/compat/main.py b/compat/main.py index a428a0af89..9a973e9a80 100644 --- a/compat/main.py +++ b/compat/main.py @@ -1,44 +1,22 @@ from __future__ import annotations -import dataclasses -import html -import json import logging import os -import re import shlex import shutil import stat import subprocess -import sys -import textwrap -from collections import defaultdict from contextlib import contextmanager from dataclasses import dataclass, field -from enum import Enum, unique from pathlib import Path -from typing import List, Optional, Collection, Dict, IO, Any -from typing_extensions import Protocol, Literal +from typing import List, Optional, Collection, Dict import click as click import coloredlogs -import tabulate import yaml -from click.utils import LazyFile from dacite import from_dict SUITE_PATH = Path("suite").resolve() -CMD_PATH = Path("../runtime/cmd").resolve() -PARSER_PATH = Path("parse").resolve() -CHECKER_PATH = Path("check").resolve() - -ansi_escape_pattern = re.compile(r'\x1b[^m]*m') - - -class Openable(Protocol): - def open(self) -> IO: - pass - @contextmanager def cwd(path): @@ -49,64 +27,6 @@ def cwd(path): finally: os.chdir(oldpwd) - -@dataclass -class File: - path: str - prepare: Optional[str] - member_account_access: List[str] = field(default_factory=list) - - def rewrite(self, path: Path): - if not isinstance(self.prepare, str): - return - - logger.info(f"Preparing {path}") - - source: str - with path.open(mode="r") as f: - source = f.read() - - def replace(pattern, replacement): - nonlocal source - source = re.sub(pattern, replacement, source) - - variables = {"replace": replace} - with cwd(str(path.parent.absolute())): - exec(self.prepare, variables) - - with path.open(mode="w") as f: - f.write(source) - - @staticmethod - def _run( - tool_path: Path, - verb: str, - path: Path, - use_json: bool, - bench: bool, - extra_args: List[str] = None - ) -> (bool, Optional): - logger.info(f"{verb} {path}") - json_args = ["-json"] if use_json else [] - bench_args = ["-bench"] if bench else [] - args = json_args + bench_args + (extra_args or []) - - completed_process = subprocess.run( - [tool_path, *args, path], - cwd=str(path.parent), - capture_output=use_json - ) - result = None - if use_json: - result = json.loads(completed_process.stdout) - - if completed_process.returncode != 0: - logger.error(f"{verb} failed: {path}") - return False, result - - return True, result - - @dataclass class GoTest: path: str @@ -116,19 +36,20 @@ def run(self, working_dir: Path, prepare: bool, cadence_version: Optional[str], if cadence_version: cadence_replacement = f'github.com/onflow/cadence@{cadence_version}' else: - cadence_replacement = Path.cwd().parent.absolute().resolve().as_posix() + # default: point to local cadence repo + cadence_replacement = shlex.quote(Path.cwd().parent.absolute().resolve().as_posix()) if flowgo_version: flowgo_replacement = f'github.com/onflow/flow-go@{flowgo_version}' else: - # default flow-go version is 0.37.16 the one corresponding to cadence v1.0.0 - flowgo_replacement = f'github.com/onflow/flow-go@v0.37.16' + # default: use the newest version of flow-go available + flowgo_replacement = f'github.com/onflow/flow-go@latest' with cwd(working_dir / self.path): if prepare: logger.info("Editing dependencies") subprocess.run([ - "go", "mod", "edit", "-replace", f'github.com/onflow/flow-go={flowgo_replacement}', + "go", "get", flowgo_replacement, ]) subprocess.run([ "go", "mod", "edit", "-replace", f'github.com/onflow/cadence={cadence_replacement}', @@ -141,40 +62,6 @@ def run(self, working_dir: Path, prepare: bool, cadence_version: Optional[str], result = subprocess.run(shlex.split(self.command)) return result.returncode == 0 - -@dataclass -class BenchmarkResult: - iterations: int - time: int - - -@dataclass -class ParseResult: - error: Optional[Any] = field(default=None) - bench: Optional[BenchmarkResult] = field(default=None) - - @classmethod - def from_dict(cls, data: Dict): - return from_dict(data_class=cls, data=data) - - -@dataclass -class CheckResult: - error: Optional[Any] = field(default=None) - bench: Optional[BenchmarkResult] = field(default=None) - - @classmethod - def from_dict(cls, data: Dict): - return from_dict(data_class=cls, data=data) - - -@dataclass -class Result: - path: str - parse_result: ParseResult - check_result: Optional[CheckResult] = field(default=None) - - def load_index(path: Path) -> List[str]: logger.info(f"Loading suite index from {path} ...") with path.open(mode="r") as f: @@ -185,7 +72,6 @@ class Description: description: str url: str branch: str - files: List[File] = field(default_factory=list) go_tests: List[GoTest] = field(default_factory=list) @staticmethod @@ -216,20 +102,16 @@ def run( self, name: str, prepare: bool, - use_json: bool, - bench: bool, - check: bool, go_test: bool, cadence_version: Optional[str], flowgo_version: Optional[str], - ) -> (bool, List[Result]): + ) -> (bool): working_dir = SUITE_PATH / name if prepare: self._clone(working_dir) - results: List[Result] = [] go_tests_succeeded = True if go_test: for test in self.go_tests: @@ -238,7 +120,7 @@ def run( succeeded = go_tests_succeeded - return succeeded, results + return succeeded class Git: @@ -266,365 +148,6 @@ def checkout(ref: str): raise Exception(f'failed to checkout ref {ref}') -def build(name): - logger.info(f"Building {name}") - subprocess.run(["go", "build", CMD_PATH / name]) - - -class EnhancedJSONEncoder(json.JSONEncoder): - def default(self, o): - if dataclasses.is_dataclass(o): - return dataclasses.asdict(o) - if isinstance(o, Enum): - return o.value - return super().default(o) - - -def indent(text: str) -> str: - return textwrap.indent(text, " ") - - -def format_markdown_details(details: str) -> str: - stripped = ansi_escape_pattern.sub('', details) - escaped = html.escape(stripped).replace("\n", "
") - return f"
Details
{escaped}
" - - -@dataclass -class Comparisons: - parse_error_comparisons: Dict[str, ErrorComparison] - parse_bench_comparisons: Optional[Dict[str, BenchComparison]] - check_error_comparisons: Dict[str, ErrorComparison] - check_bench_comparisons: Optional[Dict[str, BenchComparison]] - - @classmethod - def from_results(cls, - other_results: List[Result], - current_results: List[Result], - bench: bool, - delta_threshold: float - ) -> Comparisons: - - parse_error_comparisons: Dict[str, ErrorComparison] = {} - check_error_comparisons: Dict[str, ErrorComparison] = {} - - parse_bench_comparisons: Optional[Dict[str, BenchComparison]] = None - check_bench_comparisons: Optional[Dict[str, BenchComparison]] = None - if bench: - parse_bench_comparisons: Dict[str, BenchComparison] = {} - check_bench_comparisons: Dict[str, BenchComparison] = {} - - other_results.sort(key=lambda result: result.path) - current_results.sort(key=lambda result: result.path) - - for other_result, current_result in zip(other_results, current_results): - path = other_result.path - assert current_result.path == path - - parse_error_comparisons[path] = ErrorComparison( - other_result.parse_result.error, - current_result.parse_result.error - ) - check_error_comparisons[path] = ErrorComparison( - other_result.check_result.error, - current_result.check_result.error - ) - - if bench: - if other_result.parse_result.bench and current_result.parse_result.bench: - parse_bench_comparisons[path] = BenchComparison( - other_result.parse_result.bench, - current_result.parse_result.bench, - delta_threshold=delta_threshold - ) - - if other_result.check_result.bench and current_result.check_result.bench: - check_bench_comparisons[path] = BenchComparison( - other_result.check_result.bench, - current_result.check_result.bench, - delta_threshold=delta_threshold - ) - - return Comparisons( - parse_error_comparisons, - parse_bench_comparisons, - check_error_comparisons, - check_bench_comparisons - ) - - def write(self, output: IO, format: Format): - - result: Optional[str] = None - if format in ("pretty", "markdown"): - - output.write("\n## Parser Errors\n\n") - self._write_error_comparisons(self.parse_error_comparisons, output, format) - if self.parse_bench_comparisons: - output.write("\n## Parser Benchmarks\n\n") - self._write_bench_comparisons(self.parse_bench_comparisons, output, format) - - output.write("\n## Checker Errors\n\n") - self._write_error_comparisons(self.check_error_comparisons, output, format) - if self.check_bench_comparisons: - output.write("\n## Checker Benchmarks\n\n") - self._write_bench_comparisons(self.check_bench_comparisons, output, format) - - if format == "json": - result = json_serialize(self) - - if result: - output.write(result) - - @staticmethod - def _write_error_comparisons(comparisons: Dict[str, ErrorComparison], output: IO, format: Format): - - def write_table(data, headers): - output.write(tabulate.tabulate(data, headers, tablefmt="pipe")) - output.write("\n\n") - - groups = defaultdict(list) - - for path, comparison in comparisons.items(): - relative_path = Path(path).relative_to(SUITE_PATH) - groups[comparison.category].append((relative_path, comparison)) - - for category in ( - ErrorCategory.REGRESSION, - ErrorCategory.STILL_FAIL, - ErrorCategory.CHANGE, - ErrorCategory.IMPROVEMENT, - ErrorCategory.STILL_SUCCESS, - ): - - category_comparisons = groups.get(category, []) - - if not len(category_comparisons): - continue - - if format == "pretty": - - if category == ErrorCategory.REGRESSION: - output.write("😭 Regressions\n") - output.write("-------------\n") - - for path, comparison in category_comparisons: - output.write(f"- {path}:\n") - output.write(indent(comparison.current)) - output.write("\n\n") - - elif category == ErrorCategory.STILL_FAIL: - output.write("😢 Still failing\n") - output.write("---------------\n") - - for path, comparison in category_comparisons: - output.write(f"- {path}:\n") - output.write(indent(comparison.current)) - output.write("\n\n") - - elif category == ErrorCategory.CHANGE: - output.write("😕 Changed\n") - output.write("---------\n") - - for path, comparison in category_comparisons: - output.write(f"- {path}:\n") - output.write(" Before:\n") - output.write(indent(comparison.other)) - output.write("\n") - output.write(" Now:\n") - output.write(indent(comparison.current)) - output.write("\n\n") - - elif category == ErrorCategory.IMPROVEMENT: - output.write("🎉 Improvements\n") - output.write("--------------\n") - - for path, comparison in category_comparisons: - output.write(f"- {path}\n") - - elif category == ErrorCategory.STILL_SUCCESS: - output.write("🙂 Still succeeding\n") - output.write("------------------\n") - - for path, comparison in category_comparisons: - output.write(f"- {path}\n") - - output.write("\n") - - elif format == "markdown": - - if category == ErrorCategory.REGRESSION: - data = [] - headers = ["😭 Regressions", "Details"] - for path, comparison in category_comparisons: - data.append([path, format_markdown_details(comparison.current)]) - - write_table(data, headers) - - elif category == ErrorCategory.STILL_FAIL: - data = [] - headers = ["😢 Still failing", "Details"] - for path, comparison in category_comparisons: - data.append([path, format_markdown_details(comparison.current)]) - - write_table(data, headers) - - elif category == ErrorCategory.CHANGE: - data = [] - headers = ["😕 Changed", "Before", "Now"] - for path, comparison in category_comparisons: - data.append([ - path, - format_markdown_details(comparison.other), - format_markdown_details(comparison.current) - ]) - - write_table(data, headers) - - elif category == ErrorCategory.IMPROVEMENT: - data = [] - headers = ["🎉 Improvements"] - for path, comparison in category_comparisons: - data.append([path]) - - write_table(data, headers) - - elif category == ErrorCategory.STILL_SUCCESS: - data = [] - headers = ["🙂 Still succeeding"] - for path, comparison in category_comparisons: - data.append([path]) - - write_table(data, headers) - - @classmethod - def _write_bench_comparisons(cls, comparisons: Dict[str, BenchComparison], output: IO, format: Format): - - def write_table(data, headers): - output.write(tabulate.tabulate(data, headers, tablefmt="pipe")) - output.write("\n\n") - - groups = defaultdict(list) - - for path, comparison in comparisons.items(): - relative_path = Path(path).relative_to(SUITE_PATH) - groups[comparison.category].append((relative_path, comparison)) - - for category in ( - BenchCategory.REGRESSION, - BenchCategory.IMPROVEMENT, - BenchCategory.SAME, - ): - - category_comparisons = groups.get(category, []) - - if not len(category_comparisons): - continue - - title = "" - if category == BenchCategory.REGRESSION: - title = "😭 Regressions" - elif category == BenchCategory.IMPROVEMENT: - title = "🎉 Improvements" - elif category == BenchCategory.SAME: - title = "🙂 Same" - - data = [] - headers = [title, "OLD", "NEW", "DELTA", "RATIO"] - for path, comparison in category_comparisons: - data.append([ - path, - cls._time_markdown(comparison.other.time), - cls._time_markdown(comparison.current.time), - cls._delta_markdown(comparison.delta), - cls._ratio_markdown(comparison.ratio) - ]) - - write_table(data, headers) - - @staticmethod - def _time_markdown(time: int) -> str: - return f'{time / 1000000:.2f}' - - @staticmethod - def _delta_markdown(delta: float) -> str: - result = f'{delta:.2f}%' - if result[0] != '-': - result = '+' + result - return result - - @staticmethod - def _ratio_markdown(ratio: float) -> str: - return f'**{ratio:.2f}x**' - - -@unique -class ErrorCategory(Enum): - REGRESSION = "Regression" - IMPROVEMENT = "Improvement" - CHANGE = "Change" - STILL_SUCCESS = "Still succeeding" - STILL_FAIL = "Still failing" - - -@dataclass -class ErrorComparison: - other: Optional[str] - current: Optional[str] - category: ErrorCategory = field(init=False) - - def __post_init__(self): - self.category = self._category() - - def _category(self) -> ErrorCategory: - if self.other != self.current: - return ErrorCategory.CHANGE - elif not self.other and self.current: - return ErrorCategory.REGRESSION - elif self.other and not self.current: - return ErrorCategory.IMPROVEMENT - elif self.other: - return ErrorCategory.STILL_FAIL - else: - return ErrorCategory.STILL_SUCCESS - - -@unique -class BenchCategory(Enum): - REGRESSION = "Regression" - IMPROVEMENT = "Improvement" - SAME = "Same" - - -@dataclass -class BenchComparison: - other: BenchmarkResult - current: BenchmarkResult - delta_threshold: float - ratio: float = field(init=False) - delta: float = field(init=False) - category: BenchCategory = field(init=False) - - def __post_init__(self): - self.ratio = self.other.time / self.current.time - self.delta = -(((self.current.time * 100) / self.other.time) - 100) - self.category = self._category() - - def _category(self) -> BenchCategory: - if abs(self.delta) > self.delta_threshold: - if self.delta > 0: - return BenchCategory.IMPROVEMENT - if self.delta < 0: - return BenchCategory.REGRESSION - - return BenchCategory.SAME - - -Format = Literal["pretty", "json", "markdown"] - - -def json_serialize(data) -> str: - return json.dumps(data, indent=4, cls=EnhancedJSONEncoder) - @click.command() @click.option( "--rerun", @@ -632,24 +155,6 @@ def json_serialize(data) -> str: default=False, help="Rerun without cloning and preparing the suites" ) -@click.option( - "--format", - type=click.Choice(["pretty", "json", "markdown"], case_sensitive=False), - default="pretty", - help="output format", -) -@click.option( - "--bench/--no-bench", - is_flag=True, - default=False, - help="Run benchmarks" -) -@click.option( - "--check/--no-check", - is_flag=True, - default=True, - help="Parse and check the suite files" -) @click.option( "--go-test/--no-go-test", is_flag=True, @@ -666,135 +171,56 @@ def json_serialize(data) -> str: default=None, help="version of flow-go for Go tests" ) -@click.option( - "--output", - default=None, - type=click.File("w"), - help="Write output to given path. Standard output by default" -) -@click.option( - "--compare-ref", - "other_ref", - help="Compare with another Git ref (e.g. commit or branch)" -) -@click.option( - "--delta-threshold", - default=4, - type=float, - help="Delta threshold to consider a benchmark result a change" -) @click.argument( "names", nargs=-1, ) def main( rerun: bool, - format: Format, - bench: bool, - check: bool, go_test: bool, cadence_version: str, flowgo_version: str, - output: Optional[LazyFile], - other_ref: Optional[str], - delta_threshold: float, names: Collection[str] ): - if other_ref is None and format not in ("pretty", "json"): - raise Exception(f"unsupported format: {format}") prepare = not rerun - output: IO = output.open() if output else sys.stdout - - # Comparison of different runs is only possible when using JSON - - use_json_for_run = format != "pretty" or (other_ref is not None) - # Run for the current checkout - current_success, current_results = run( + current_success = run( prepare=prepare, - use_json=use_json_for_run, - bench=bench, - check=check, go_test=go_test, cadence_version=cadence_version, flowgo_version=flowgo_version, names=names ) - # Run for the other checkout, if any - - if other_ref: - current_ref = Git.get_head_ref() - try: - Git.checkout(other_ref) - - _, other_results = run( - # suite repositories were already cloned in the previous run - prepare=False, - use_json=use_json_for_run, - bench=bench, - check=check, - go_test=go_test, - names=names - ) - - comparisons = Comparisons.from_results( - other_results, - current_results, - bench=bench, - delta_threshold=delta_threshold, - ) - - comparisons.write(output, format) - - finally: - Git.checkout(current_ref) - - else: - - if format == "json": - results_json = json_serialize(current_results) - output.write(results_json) - - output.close() - if not current_success: exit(1) def run( prepare: bool, - use_json: bool, - bench: bool, - check: bool, go_test: bool, cadence_version: str, flowgo_version: str, names: Collection[str] -) -> (bool, List[Result]): +) -> (bool): all_succeeded = True - logger.info(f'Chosen versions: cadence@{ cadence_version if cadence_version else "local version" }, flow-go@{flowgo_version if flowgo_version else "v0.37.16"}') + logger.info(f'Chosen versions: cadence@{ cadence_version if cadence_version else "local version" }, flow-go@{flowgo_version if flowgo_version else "latest"}') if not names: names = load_index(SUITE_PATH / "index.yaml") - all_results: List[Result] = [] - for name in names: description = Description.load(name) - run_succeeded, results = description.run( + run_succeeded = description.run( name, prepare=prepare, - use_json=use_json, - bench=bench, - check=check, go_test=go_test, cadence_version=cadence_version, flowgo_version=flowgo_version, @@ -803,9 +229,7 @@ def run( if not run_succeeded: all_succeeded = False - all_results.extend(results) - - return all_succeeded, all_results + return all_succeeded if __name__ == "__main__": diff --git a/compat/requirements.txt b/compat/requirements.txt index c83c2d82a8..83eccf7636 100644 --- a/compat/requirements.txt +++ b/compat/requirements.txt @@ -3,4 +3,3 @@ coloredlogs==14.0 dacite==1.5.1 PyYAML==5.4 typing-extensions==3.7.4.3 -tabulate==0.8.7 From 2fcd4c52e31b0703a0f9a712f2e891ce53a43062 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20M=C3=BCller?= Date: Fri, 18 Oct 2024 09:57:15 -0700 Subject: [PATCH 09/46] fix dependencies / breakage due to restructuring --- tools/storage-explorer/addresses.go | 2 +- tools/storage-explorer/go.mod | 4 +--- tools/storage-explorer/go.sum | 14 +++++--------- tools/storage-explorer/main.go | 5 +++-- tools/storage-explorer/storagemaps.go | 6 +++--- tools/storage-explorer/type.go | 4 ++-- tools/storage-explorer/value.go | 4 ++-- 7 files changed, 17 insertions(+), 22 deletions(-) diff --git a/tools/storage-explorer/addresses.go b/tools/storage-explorer/addresses.go index 6fb06cdc47..8a291d7a75 100644 --- a/tools/storage-explorer/addresses.go +++ b/tools/storage-explorer/addresses.go @@ -24,7 +24,7 @@ import ( "github.com/onflow/flow-go/cmd/util/ledger/util/registers" - "github.com/onflow/cadence/common" + "github.com/onflow/cadence/runtime/common" ) func addressesJSON(registersByAccount *registers.ByAccount) ([]byte, error) { diff --git a/tools/storage-explorer/go.mod b/tools/storage-explorer/go.mod index e29530edb8..f706377729 100644 --- a/tools/storage-explorer/go.mod +++ b/tools/storage-explorer/go.mod @@ -4,7 +4,7 @@ go 1.22 require ( github.com/gorilla/mux v1.8.1 - github.com/onflow/atree v0.8.0-rc.6 + github.com/onflow/atree v0.8.0 github.com/onflow/cadence v1.0.0-preview.52 github.com/onflow/flow-go v0.37.10 github.com/rs/zerolog v1.32.0 @@ -214,5 +214,3 @@ require ( lukechampine.com/blake3 v1.3.0 // indirect rsc.io/tmplfunc v0.0.3 // indirect ) - -replace github.com/onflow/cadence => ../.. diff --git a/tools/storage-explorer/go.sum b/tools/storage-explorer/go.sum index 54aea1efc8..728dc28555 100644 --- a/tools/storage-explorer/go.sum +++ b/tools/storage-explorer/go.sum @@ -970,7 +970,6 @@ github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/OneOfOne/xxhash v1.2.8 h1:31czK/TI9sNkxIKfaUfGlU47BAxQ0ztGgd9vPyqimf8= github.com/OneOfOne/xxhash v1.2.8/go.mod h1:eZbhyaAYD41SGSSsnmcpxVoRiQ/MPUTjUdIIOT9Um7Q= -github.com/PuerkitoBio/goquery v1.5.0/go.mod h1:qD2PgZ9lccMbQlc7eEOjaeRlFQON7xY8kdmcsrnKqMg= github.com/SaveTheRbtz/mph v0.1.1-0.20240117162131-4166ec7869bc h1:DCHzPQOcU/7gwDTWbFQZc5qHMPS1g0xTO56k8NXsv9M= github.com/SaveTheRbtz/mph v0.1.1-0.20240117162131-4166ec7869bc/go.mod h1:LJM5a3zcIJ/8TmZwlUczvROEJT8ntOdhdG9jjcR1B0I= github.com/Shopify/goreferrer v0.0.0-20181106222321-ec9c9a553398/go.mod h1:a1uqRtAwp2Xwc6WNPJEufxJ7fx3npB4UV/JOLmbu5I0= @@ -998,7 +997,6 @@ github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156 h1:eMwmnE/GDgah github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM= github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8= github.com/andybalholm/brotli v1.0.4/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= -github.com/andybalholm/cascadia v1.0.0/go.mod h1:GsXiBklL0woXo1j/WYWtSYYC4ouU9PqHO0sqidkEA4Y= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/apache/arrow/go/arrow v0.0.0-20191024131854-af6fa24be0db/go.mod h1:VTxUBvSJ3s3eHAg65PNgrsn5BtqCRPdmyXh6rAfdxN0= github.com/apache/arrow/go/v10 v10.0.1/go.mod h1:YvhnlEePVnBS4+0z3fhPfUy7W1Ikj0Ih0vcRo/gZ1M0= @@ -1663,8 +1661,6 @@ github.com/iris-contrib/blackfriday v2.0.0+incompatible/go.mod h1:UzZ2bDEoaSGPbk github.com/iris-contrib/go.uuid v2.0.0+incompatible/go.mod h1:iz2lgM/1UnEf1kP0L/+fafWORmlnuysV2EMP8MW+qe0= github.com/iris-contrib/i18n v0.0.0-20171121225848-987a633949d0/go.mod h1:pMCz62A0xJL6I+umB2YTlFRwWXaDFA0jy+5HzGiJjqI= github.com/iris-contrib/schema v0.0.1/go.mod h1:urYA3uvUNG1TIIjOSCzHr9/LmbQo8LrOcOqfqxa4hXw= -github.com/itchyny/gojq v0.12.14/go.mod h1:y1G7oO7XkcR1LPZO59KyoCRy08T3j9vDYRV0GgYSS+s= -github.com/itchyny/timefmt-go v0.1.5/go.mod h1:nEP7L+2YmAbT2kZ2HfSs1d8Xtw9LY8D2stDBckWakZ8= github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7BdWus= github.com/jackpal/go-nat-pmp v1.0.2/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc= github.com/jbenet/go-cienv v0.1.0/go.mod h1:TqNnHUmJgXau0nCzC7kXWeotg3J9W34CUv5Djy1+FlA= @@ -1734,7 +1730,6 @@ github.com/klauspost/cpuid/v2 v2.2.6 h1:ndNyv040zDGIDh8thGkXYjnFtiN02M1PVVF+JE/4 github.com/klauspost/cpuid/v2 v2.2.6/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= github.com/klauspost/crc32 v0.0.0-20161016154125-cb6bfca970f6/go.mod h1:+ZoRqAPRLkC4NPOvfYeR5KNOrY6TD+/sAC3HXPZgDYg= github.com/klauspost/pgzip v1.0.2-0.20170402124221-0bf5dcad4ada/go.mod h1:Ch1tH69qFZu15pkjo5kYi6mth2Zzwzt50oCQKQE9RUs= -github.com/kodova/html-to-markdown v1.0.1/go.mod h1:NhDrT7QdSrdpezFg/0EQx9zeobCHR5oAguzrKrC6mVU= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= @@ -1908,8 +1903,11 @@ github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/onflow/atree v0.6.1-0.20230711151834-86040b30171f/go.mod h1:xvP61FoOs95K7IYdIYRnNcYQGf4nbF/uuJ0tHf4DRuM= -github.com/onflow/atree v0.8.0-rc.6 h1:GWgaylK24b5ta2Hq+TvyOF7X5tZLiLzMMn7lEt59fsA= -github.com/onflow/atree v0.8.0-rc.6/go.mod h1:yccR+LR7xc1Jdic0mrjocbHvUD7lnVvg8/Ct1AA5zBo= +github.com/onflow/atree v0.8.0 h1:qg5c6J1gVDNObughpEeWm8oxqhPGdEyGrda121GM4u0= +github.com/onflow/atree v0.8.0/go.mod h1:yccR+LR7xc1Jdic0mrjocbHvUD7lnVvg8/Ct1AA5zBo= +github.com/onflow/cadence v1.0.0-M3/go.mod h1:odXGZZ/wGNA5mwT8bC9v8u8EXACHllB2ABSZK65TGL8= +github.com/onflow/cadence v1.0.0-preview.52 h1:hZ92e6lL2+PQa3C1i5jJh0zZYFdW89+X1MS0Bkd6Ayo= +github.com/onflow/cadence v1.0.0-preview.52/go.mod h1:7wvvecnAZtYOspLOS3Lh+FuAmMeSrXhAWiycC3kQ1UU= github.com/onflow/crypto v0.25.0/go.mod h1:C8FbaX0x8y+FxWjbkHy0Q4EASCDR9bSPWZqlpCLYyVI= github.com/onflow/crypto v0.25.2 h1:GjHunqVt+vPcdqhxxhAXiMIF3YiLX7gTuTR5O+VG2ns= github.com/onflow/crypto v0.25.2/go.mod h1:fY7eLqUdMKV8EGOw301unP8h7PvLVy8/6gVR++/g0BY= @@ -2372,7 +2370,6 @@ golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA= golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= -golang.org/x/net v0.0.0-20180218175443-cbe0f9307d01/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -2392,7 +2389,6 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20191109021931-daa7c04131f5/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= diff --git a/tools/storage-explorer/main.go b/tools/storage-explorer/main.go index 62f55539ae..fe4f80504f 100644 --- a/tools/storage-explorer/main.go +++ b/tools/storage-explorer/main.go @@ -35,10 +35,11 @@ import ( "github.com/onflow/flow-go/model/flow" "github.com/rs/zerolog" - "github.com/onflow/cadence/common" + "github.com/onflow/cadence/runtime/interpreter" + jsoncdc "github.com/onflow/cadence/encoding/json" - "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/runtime" + "github.com/onflow/cadence/runtime/common" ) func main() { diff --git a/tools/storage-explorer/storagemaps.go b/tools/storage-explorer/storagemaps.go index e173291865..ba0ca4ed91 100644 --- a/tools/storage-explorer/storagemaps.go +++ b/tools/storage-explorer/storagemaps.go @@ -24,10 +24,10 @@ import ( "github.com/onflow/atree" - "github.com/onflow/cadence/common" - "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/runtime" - "github.com/onflow/cadence/stdlib" + "github.com/onflow/cadence/runtime/common" + "github.com/onflow/cadence/runtime/interpreter" + "github.com/onflow/cadence/runtime/stdlib" ) type KnownStorageMap struct { diff --git a/tools/storage-explorer/type.go b/tools/storage-explorer/type.go index 7d1b413078..24a7a93416 100644 --- a/tools/storage-explorer/type.go +++ b/tools/storage-explorer/type.go @@ -21,9 +21,9 @@ package main import ( "github.com/onflow/cadence" jsoncdc "github.com/onflow/cadence/encoding/json" - "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/runtime" - "github.com/onflow/cadence/sema" + "github.com/onflow/cadence/runtime/interpreter" + "github.com/onflow/cadence/runtime/sema" ) func prepareType(value interpreter.Value, inter *interpreter.Interpreter) (result any, description string) { diff --git a/tools/storage-explorer/value.go b/tools/storage-explorer/value.go index a7545ae5d3..9355456417 100644 --- a/tools/storage-explorer/value.go +++ b/tools/storage-explorer/value.go @@ -23,9 +23,9 @@ import ( "sort" jsoncdc "github.com/onflow/cadence/encoding/json" - "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/runtime" - "github.com/onflow/cadence/sema" + "github.com/onflow/cadence/runtime/interpreter" + "github.com/onflow/cadence/runtime/sema" ) type Value interface { From 02b9413c7a0e08624462238c986db157c5b752be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20M=C3=BCller?= Date: Fri, 18 Oct 2024 10:10:08 -0700 Subject: [PATCH 10/46] remove All function again, export field instead --- tools/analysis/analysis.go | 4 ++-- tools/analysis/analysis_test.go | 2 +- tools/analysis/programs.go | 22 +++++++--------------- 3 files changed, 10 insertions(+), 18 deletions(-) diff --git a/tools/analysis/analysis.go b/tools/analysis/analysis.go index 79ef89ed44..eb179774de 100644 --- a/tools/analysis/analysis.go +++ b/tools/analysis/analysis.go @@ -24,8 +24,8 @@ import ( func Load(config *Config, locations ...common.Location) (*Programs, error) { programs := &Programs{ - programs: make(map[common.Location]*Program, len(locations)), - cryptoContractElaboration: config.CryptoContractElaboration, + Programs: make(map[common.Location]*Program, len(locations)), + CryptoContractElaboration: config.CryptoContractElaboration, } for _, location := range locations { err := programs.Load(config, location) diff --git a/tools/analysis/analysis_test.go b/tools/analysis/analysis_test.go index 92c2f6e2c2..61e1d54ec4 100644 --- a/tools/analysis/analysis_test.go +++ b/tools/analysis/analysis_test.go @@ -99,7 +99,7 @@ func TestNeedSyntaxAndImport(t *testing.T) { var locationRanges []locationRange - for _, program := range programs.All() { + for _, program := range programs.Programs { require.NotNil(t, program.Program) require.NotNil(t, program.Checker) diff --git a/tools/analysis/programs.go b/tools/analysis/programs.go index 4adcb6e16f..58599bb589 100644 --- a/tools/analysis/programs.go +++ b/tools/analysis/programs.go @@ -27,8 +27,8 @@ import ( ) type Programs struct { - programs map[common.Location]*Program - cryptoContractElaboration *sema.Elaboration + Programs map[common.Location]*Program + CryptoContractElaboration *sema.Elaboration } type importResolutionResults map[common.Location]bool @@ -53,7 +53,7 @@ func (programs *Programs) load( importRange ast.Range, seenImports importResolutionResults, ) error { - if programs.programs[location] != nil { + if programs.Programs[location] != nil { return nil } @@ -107,7 +107,7 @@ func (programs *Programs) load( } } - programs.programs[location] = &Program{ + programs.Programs[location] = &Program{ Location: location, Code: code, Program: program, @@ -157,7 +157,7 @@ func (programs *Programs) check( switch importedLocation { case stdlib.CryptoContractLocation: - elaboration = programs.cryptoContractElaboration + elaboration = programs.CryptoContractElaboration default: if seenImports[importedLocation] { @@ -174,7 +174,7 @@ func (programs *Programs) check( return nil, err } - program := programs.programs[importedLocation] + program := programs.Programs[importedLocation] checker := program.Checker // If the imported program has a checker, use its elaboration for the import @@ -209,13 +209,5 @@ func (programs *Programs) check( } func (programs *Programs) Get(location common.Location) *Program { - return programs.programs[location] -} - -func (programs *Programs) All() []*Program { - all := make([]*Program, 0, len(programs.programs)) - for _, program := range programs.programs { - all = append(all, program) - } - return all + return programs.Programs[location] } From 8805722f95b1b0f1feb0e2149ef0def3c7a45ea3 Mon Sep 17 00:00:00 2001 From: Raymond Zhang Date: Fri, 18 Oct 2024 13:13:49 -0400 Subject: [PATCH 11/46] Remove unused files property. --- compat/suite/flow-core-contracts.yaml | 130 -------------------------- compat/suite/flow-ft.yaml | 79 ---------------- compat/suite/flow-nft.yaml | 54 ----------- compat/suite/nba-smart-contracts.yaml | 81 ---------------- 4 files changed, 344 deletions(-) diff --git a/compat/suite/flow-core-contracts.yaml b/compat/suite/flow-core-contracts.yaml index e7607d8573..2b3cdcaa10 100644 --- a/compat/suite/flow-core-contracts.yaml +++ b/compat/suite/flow-core-contracts.yaml @@ -7,133 +7,3 @@ branch: master go_tests: - path: lib/go/test command: make test -files: -- path: contracts/FlowToken.cdc - # language=Python prefix="replace: Callable[[str, str], None]\n" - prepare: | - from pathlib import Path - - replace( - 'import FungibleToken from 0xFUNGIBLETOKENADDRESS', - f'import FungibleToken from "{Path("../../flow-ft/contracts/FungibleToken.cdc").resolve()}"' - ) - -- path: contracts/FlowFees.cdc - # language=Python prefix="replace: Callable[[str, str], None]\n" - prepare: | - from pathlib import Path - - replace( - 'import FungibleToken from 0xFUNGIBLETOKENADDRESS', - f'import FungibleToken from "{Path("../../flow-ft/contracts/FungibleToken.cdc").resolve()}"' - ) - replace( - 'import FlowToken from 0xFLOWTOKENADDRESS', - f'import FlowToken from "{Path("FlowToken.cdc").resolve()}"' - ) - -- path: contracts/FlowIDTableStaking.cdc - # language=Python prefix="replace: Callable[[str, str], None]\n" - prepare: | - from pathlib import Path - - replace( - 'import FungibleToken from 0xFUNGIBLETOKENADDRESS', - f'import FungibleToken from "{Path("../../flow-ft/contracts/FungibleToken.cdc").resolve()}"' - ) - replace( - 'import FlowToken from 0xFLOWTOKENADDRESS', - f'import FlowToken from "{Path("FlowToken.cdc").resolve()}"' - ) - -- path: contracts/FlowStorageFees.cdc - # language=Python prefix="replace: Callable[[str, str], None]\n" - prepare: | - from pathlib import Path - - replace( - 'import FungibleToken from 0xFUNGIBLETOKENADDRESS', - f'import FungibleToken from "{Path("../../flow-ft/contracts/FungibleToken.cdc").resolve()}"' - ) - replace( - 'import FlowToken from 0xFLOWTOKENADDRESS', - f'import FlowToken from "{Path("FlowToken.cdc").resolve()}"' - ) - -- path: contracts/FlowServiceAccount.cdc - # language=Python prefix="replace: Callable[[str, str], None]\n" - prepare: | - from pathlib import Path - - replace( - 'import FungibleToken from 0xFUNGIBLETOKENADDRESS', - f'import FungibleToken from "{Path("../../flow-ft/contracts/FungibleToken.cdc").resolve()}"' - ) - replace( - 'import FlowToken from 0xFLOWTOKENADDRESS', - f'import FlowToken from "{Path("FlowToken.cdc").resolve()}"' - ) - replace( - 'import FlowFees from 0xFLOWFEESADDRESS', - f'import FlowFees from "{Path("FlowFees.cdc").resolve()}"' - ) - replace( - 'import FlowStorageFees from 0xFLOWSTORAGEFEESADDRESS', - f'import FlowStorageFees from "{Path("FlowStorageFees.cdc").resolve()}"' - ) - -- path: contracts/StakingProxy.cdc - -- path: contracts/LockedTokens.cdc - # language=Python prefix="replace: Callable[[str, str], None]\n" - prepare: | - from pathlib import Path - - replace( - 'import FlowToken from 0xFLOWTOKENADDRESS', - f'import FlowToken from "{Path("FlowToken.cdc").resolve()}"' - ) - replace( - 'import FungibleToken from 0xFUNGIBLETOKENADDRESS', - f'import FungibleToken from "{Path("../../flow-ft/contracts/FungibleToken.cdc").resolve()}"' - ) - replace( - 'import FlowIDTableStaking from 0xFLOWIDTABLESTAKINGADDRESS', - f'import FlowIDTableStaking from "{Path("FlowIDTableStaking.cdc").resolve()}"' - ) - replace( - 'import FlowStorageFees from 0xFLOWSTORAGEFEESADDRESS', - f'import FlowStorageFees from "{Path("FlowStorageFees.cdc").resolve()}"' - ) - replace( - 'import StakingProxy from 0xSTAKINGPROXYADDRESS', - f'import StakingProxy from "{Path("StakingProxy.cdc").resolve()}"' - ) - -- path: contracts/FlowStakingCollection.cdc - member_account_access: - - 'LockedTokens.cdc' - # language=Python prefix="replace: Callable[[str, str], None]\n" - prepare: | - from pathlib import Path - - replace( - 'import FungibleToken from 0xFUNGIBLETOKENADDRESS', - f'import FungibleToken from "{Path("../../flow-ft/contracts/FungibleToken.cdc").resolve()}"' - ) - replace( - 'import FlowToken from 0xFLOWTOKENADDRESS', - f'import FlowToken from "{Path("FlowToken.cdc").resolve()}"' - ) - replace( - 'import FlowIDTableStaking from 0xFLOWIDTABLESTAKINGADDRESS', - f'import FlowIDTableStaking from "{Path("FlowIDTableStaking.cdc").resolve()}"' - ) - replace( - 'import LockedTokens from 0xLOCKEDTOKENSADDRESS', - f'import LockedTokens from "{Path("LockedTokens.cdc").resolve()}"' - ) - replace( - 'import FlowStorageFees from 0xFLOWSTORAGEFEESADDRESS', - f'import FlowStorageFees from "{Path("FlowStorageFees.cdc").resolve()}"' - ) diff --git a/compat/suite/flow-ft.yaml b/compat/suite/flow-ft.yaml index 1fd621a3d5..3b872d692d 100644 --- a/compat/suite/flow-ft.yaml +++ b/compat/suite/flow-ft.yaml @@ -7,82 +7,3 @@ branch: master go_tests: - path: lib/go/test command: make test -files: -- path: contracts/FungibleToken.cdc -- path: contracts/utilityContracts/TokenForwarding.cdc - # language=Python prefix="replace: Callable[[str, str], None]\n" - prepare: | - from pathlib import Path - - replace( - 'import FungibleToken from 0xFUNGIBLETOKENADDRESS', - f'import FungibleToken from "{Path("../FungibleToken.cdc").resolve()}"' - ) - -- path: contracts/ExampleToken.cdc - # language=Python prefix="replace: Callable[[str, str], None]\n" - prepare: | - from pathlib import Path - - replace( - 'import FungibleToken from 0xFUNGIBLETOKENADDRESS', - f'import FungibleToken from "{Path("FungibleToken.cdc").resolve()}"' - ) - -- path: transactions/transfer_tokens.cdc - # language=Python prefix="replace: Callable[[str, str], None]\n" - prepare: | - from pathlib import Path - - replace( - 'import FungibleToken from 0xFUNGIBLETOKENADDRESS', - f'import FungibleToken from "{Path("../contracts/FungibleToken.cdc").resolve()}"' - ) - replace( - 'import ExampleToken from 0xTOKENADDRESS', - f'import ExampleToken from "{Path("../contracts/ExampleToken.cdc").resolve()}"' - ) - -- path: transactions/setup_account.cdc - # language=Python prefix="replace: Callable[[str, str], None]\n" - prepare: | - from pathlib import Path - - replace( - 'import FungibleToken from 0xFUNGIBLETOKENADDRESS', - f'import FungibleToken from "{Path("../contracts/FungibleToken.cdc").resolve()}"' - ) - replace( - 'import ExampleToken from 0xTOKENADDRESS', - f'import ExampleToken from "{Path("../contracts/ExampleToken.cdc").resolve()}"' - ) - -- path: transactions/mint_tokens.cdc - # language=Python prefix="replace: Callable[[str, str], None]\n" - prepare: | - from pathlib import Path - - replace( - 'import FungibleToken from 0xFUNGIBLETOKENADDRESS', - f'import FungibleToken from "{Path("../contracts/FungibleToken.cdc").resolve()}"' - ) - replace( - 'import ExampleToken from 0xTOKENADDRESS', - f'import ExampleToken from "{Path("../contracts/ExampleToken.cdc").resolve()}"' - ) - - -- path: transactions/burn_tokens.cdc - # language=Python prefix="replace: Callable[[str, str], None]\n" - prepare: | - from pathlib import Path - - replace( - 'import FungibleToken from 0xFUNGIBLETOKENADDRESS', - f'import FungibleToken from "{Path("../contracts/FungibleToken.cdc").resolve()}"' - ) - replace( - 'import ExampleToken from 0xTOKENADDRESS', - f'import ExampleToken from "{Path("../contracts/ExampleToken.cdc").resolve()}"' - ) - diff --git a/compat/suite/flow-nft.yaml b/compat/suite/flow-nft.yaml index c6d93cc7bd..958f72f5bb 100644 --- a/compat/suite/flow-nft.yaml +++ b/compat/suite/flow-nft.yaml @@ -7,57 +7,3 @@ branch: master go_tests: - path: lib/go/test command: make test -files: -- path: contracts/NonFungibleToken.cdc -- path: contracts/ExampleNFT.cdc - # language=Python prefix="replace: Callable[[str, str], None]\n" - prepare: | - from pathlib import Path - - replace( - 'import NonFungibleToken from 0x02', - f'import NonFungibleToken from "{Path("NonFungibleToken.cdc").resolve()}"' - ) - - -- path: transactions/mint_nft.cdc - # language=Python prefix="replace: Callable[[str, str], None]\n" - prepare: | - from pathlib import Path - - replace( - 'import NonFungibleToken from 0xNFTADDRESS', - f'import NonFungibleToken from "{Path("../contracts/NonFungibleToken.cdc").resolve()}"' - ) - replace( - 'import ExampleNFT from 0xNFTCONTRACTADDRESS', - f'import ExampleNFT from "{Path("../contracts/ExampleNFT.cdc").resolve()}"' - ) - -- path: transactions/setup_account.cdc - # language=Python prefix="replace: Callable[[str, str], None]\n" - prepare: | - from pathlib import Path - - replace( - 'import NonFungibleToken from 0xNFTADDRESS', - f'import NonFungibleToken from "{Path("../contracts/NonFungibleToken.cdc").resolve()}"' - ) - replace( - 'import ExampleNFT from 0xNFTCONTRACTADDRESS', - f'import ExampleNFT from "{Path("../contracts/ExampleNFT.cdc").resolve()}"' - ) - -- path: transactions/transfer_nft.cdc - # language=Python prefix="replace: Callable[[str, str], None]\n" - prepare: | - from pathlib import Path - - replace( - 'import NonFungibleToken from 0xNFTADDRESS', - f'import NonFungibleToken from "{Path("../contracts/NonFungibleToken.cdc").resolve()}"' - ) - replace( - 'import ExampleNFT from 0xNFTCONTRACTADDRESS', - f'import ExampleNFT from "{Path("../contracts/ExampleNFT.cdc").resolve()}"' - ) \ No newline at end of file diff --git a/compat/suite/nba-smart-contracts.yaml b/compat/suite/nba-smart-contracts.yaml index f56ebbfcee..8e44b443f3 100644 --- a/compat/suite/nba-smart-contracts.yaml +++ b/compat/suite/nba-smart-contracts.yaml @@ -7,84 +7,3 @@ branch: master go_tests: - path: lib/go/test command: make test -files: -- path: contracts/TopShot.cdc - # language=Python prefix="replace: Callable[[str, str], None]\n" - prepare: | - from pathlib import Path - - replace( - 'import NonFungibleToken from 0xNFTADDRESS', - f'import NonFungibleToken from "{Path("../../flow-nft/contracts/NonFungibleToken.cdc").resolve()}"' - ) - -- path: contracts/MarketTopShot.cdc - # language=Python prefix="replace: Callable[[str, str], None]\n" - prepare: | - from pathlib import Path - - replace( - 'import FungibleToken from 0xFUNGIBLETOKENADDRESS', - f'import FungibleToken from "{Path("../../flow-ft/contracts/FungibleToken.cdc").resolve()}"' - ) - - replace( - 'import NonFungibleToken from 0xNFTADDRESS', - f'import NonFungibleToken from "{Path("../../flow-nft/contracts/NonFungibleToken.cdc").resolve()}"' - ) - - replace( - 'import TopShot from 0xTOPSHOTADDRESS', - f'import TopShot from "{Path("TopShot.cdc").resolve()}"' - ) - -- path: contracts/TopShotMarketV2.cdc - # language=Python prefix="replace: Callable[[str, str], None]\n" - prepare: | - from pathlib import Path - - replace( - 'import FungibleToken from 0xFUNGIBLETOKENADDRESS', - f'import FungibleToken from "{Path("../../flow-ft/contracts/FungibleToken.cdc").resolve()}"' - ) - - replace( - 'import NonFungibleToken from 0xNFTADDRESS', - f'import NonFungibleToken from "{Path("../../flow-nft/contracts/NonFungibleToken.cdc").resolve()}"' - ) - - replace( - 'import TopShot from 0xTOPSHOTADDRESS', - f'import TopShot from "{Path("TopShot.cdc").resolve()}"' - ) - -- path: contracts/TopShotShardedCollection.cdc - # language=Python prefix="replace: Callable[[str, str], None]\n" - prepare: | - from pathlib import Path - - replace( - 'import NonFungibleToken from 0xNFTADDRESS', - f'import NonFungibleToken from "{Path("../../flow-nft/contracts/NonFungibleToken.cdc").resolve()}"' - ) - - replace( - 'import TopShot from 0xTOPSHOTADDRESS', - f'import TopShot from "{Path("TopShot.cdc").resolve()}"' - ) - -- path: contracts/TopshotAdminReceiver.cdc - # language=Python prefix="replace: Callable[[str, str], None]\n" - prepare: | - from pathlib import Path - - replace( - 'import TopShotShardedCollection from 0xSHARDEDADDRESS', - f'import TopShotShardedCollection from "{Path("TopShotShardedCollection.cdc").resolve()}"' - ) - - replace( - 'import TopShot from 0xTOPSHOTADDRESS', - f'import TopShot from "{Path("TopShot.cdc").resolve()}"' - ) - From 2e72919b18ac6e217b9bfb7212203b386ca24e75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20M=C3=BCller?= Date: Fri, 18 Oct 2024 10:33:27 -0700 Subject: [PATCH 12/46] revert 393e95547139475504f4dd91681b6b92c6405496: use resolve location to rewrite import --- runtime/environment.go | 32 ++++++++------------------------ tests/runtime_test.go | 13 ++++++++++--- 2 files changed, 18 insertions(+), 27 deletions(-) diff --git a/runtime/environment.go b/runtime/environment.go index ce0b5edae0..ff71d25c08 100644 --- a/runtime/environment.go +++ b/runtime/environment.go @@ -1092,40 +1092,24 @@ func (e *interpreterEnvironment) newCompositeValueFunctionsHandler() interpreter func (e *interpreterEnvironment) loadContract( inter *interpreter.Interpreter, compositeType *sema.CompositeType, - constructorGenerator func(common.Address) *interpreter.HostFunctionValue, - invocationRange ast.Range, + _ func(common.Address) *interpreter.HostFunctionValue, + _ ast.Range, ) *interpreter.CompositeValue { var contractValue interpreter.Value location := compositeType.Location - switch location := location.(type) { - case common.IdentifierLocation: - // Identifier locations are used for built-in contracts, - // and are not stored in storage - - constructorGenerator := constructorGenerator(common.ZeroAddress) - var err error - contractValue, err = inter.InvokeFunctionValue( - constructorGenerator, - nil, - nil, - nil, - compositeType, - invocationRange, - ) - if err != nil { - panic(err) - } - - case common.AddressLocation: + if addressLocation, ok := location.(common.AddressLocation); ok { storageMap := e.storage.GetStorageMap( - location.Address, + addressLocation.Address, StorageDomainContract, false, ) if storageMap != nil { - contractValue = storageMap.ReadValue(inter, interpreter.StringStorageMapKey(location.Name)) + contractValue = storageMap.ReadValue( + inter, + interpreter.StringStorageMapKey(addressLocation.Name), + ) } } diff --git a/tests/runtime_test.go b/tests/runtime_test.go index 12b16557cc..3a80d0c83d 100644 --- a/tests/runtime_test.go +++ b/tests/runtime_test.go @@ -11561,7 +11561,8 @@ func TestResultRedeclared(t *testing.T) { }) } -func TestRuntimeContractValueLocation(t *testing.T) { + +func TestRuntimeIdentifierLocationToAddressLocationRewrite(t *testing.T) { t.Parallel() @@ -11569,6 +11570,10 @@ func TestRuntimeContractValueLocation(t *testing.T) { const fooContractName = "Foo" fooIdentifierLocation := common.IdentifierLocation(fooContractName) + fooAddressLocation := common.AddressLocation{ + Address: signerAddress, + Name: fooContractName, + } fooContract := []byte(` access(all) @@ -11593,6 +11598,9 @@ func TestRuntimeContractValueLocation(t *testing.T) { assert.Empty(t, identifiers) assert.Equal(t, fooIdentifierLocation, location) + // NOTE: rewrite identifier location to address location + location = fooAddressLocation + return []ResolvedLocation{ { Location: location, @@ -11612,8 +11620,7 @@ func TestRuntimeContractValueLocation(t *testing.T) { return nil }, OnGetCode: func(location Location) ([]byte, error) { - assert.Equal(t, fooIdentifierLocation, location) - return fooContract, nil + return nil, errors.New("GetCode should not be called") }, } From 009255f04aeea462c45779b7fa7f93f581936254 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20M=C3=BCller?= Date: Fri, 18 Oct 2024 10:40:28 -0700 Subject: [PATCH 13/46] bring back license header --- stdlib/crypto.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/stdlib/crypto.go b/stdlib/crypto.go index 6728047285..c8838a474b 100644 --- a/stdlib/crypto.go +++ b/stdlib/crypto.go @@ -1,3 +1,21 @@ +/* + * Cadence - The resource-oriented smart contract programming language + * + * Copyright Flow Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package stdlib import ( From db075f755f5dc9e1a75fab189dd31eafa9529c08 Mon Sep 17 00:00:00 2001 From: SupunS Date: Fri, 18 Oct 2024 19:04:22 +0000 Subject: [PATCH 14/46] v1.1.0 --- npm-packages/cadence-parser/package.json | 2 +- version.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/npm-packages/cadence-parser/package.json b/npm-packages/cadence-parser/package.json index fc893be423..bce9c0aabf 100644 --- a/npm-packages/cadence-parser/package.json +++ b/npm-packages/cadence-parser/package.json @@ -1,6 +1,6 @@ { "name": "@onflow/cadence-parser", - "version": "1.0.0-preview.52", + "version": "1.1.0-preview.52", "description": "The Cadence parser", "homepage": "https://github.com/onflow/cadence", "repository": { diff --git a/version.go b/version.go index ec1468a4d3..27ab641f5d 100644 --- a/version.go +++ b/version.go @@ -21,4 +21,4 @@ package cadence -const Version = "v1.0.0" +const Version = "v1.1.0" From bd46d4feb27cb8f9f8428a1d876211fbf6ffc183 Mon Sep 17 00:00:00 2001 From: Supun Setunga Date: Fri, 18 Oct 2024 12:31:35 -0700 Subject: [PATCH 15/46] Update release docs with a section for versioning strategy --- docs/releasing.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docs/releasing.md b/docs/releasing.md index 38321f7155..b6cdb8e15d 100644 --- a/docs/releasing.md +++ b/docs/releasing.md @@ -1,3 +1,13 @@ +# Versioning + +Versioning of Cadence releases follows the below strategy: +- A language-breaking change (which is rare) would be a major version change. + - e.g: If the current version is `1.0.0` then the new version should be `v2.0.0`. +- Any other changes that are not bug fixes, (feature additions, Go API changes, etc.) would be a minor version change. + - e.g: If the current version is `1.0.0` then the new version should be `v1.1.0`. +- Bug fixes are patch versions. + - e.g: If the current version is `1.0.0` then the new version should be `v1.0.1`. + # Release Process Assume releasing Cadence version `v0.21.2` from `master` branch. From cf0472b0b94e3179f9ac71bceb8cfbd49f78c555 Mon Sep 17 00:00:00 2001 From: Supun Setunga Date: Fri, 18 Oct 2024 14:06:00 -0700 Subject: [PATCH 16/46] Cleanup outdated FT/NFT related contract codes and tests --- ast/inspector_test.go | 24 +- tests/checker/interface_test.go | 126 ---- tests/checker/nft_test.go | 992 -------------------------- tests/examples/examples.go | 82 --- tests/interpreter/interpreter_test.go | 76 -- 5 files changed, 22 insertions(+), 1278 deletions(-) delete mode 100644 tests/checker/nft_test.go delete mode 100644 tests/examples/examples.go diff --git a/ast/inspector_test.go b/ast/inspector_test.go index 17979ef95f..5b1ee8c0c8 100644 --- a/ast/inspector_test.go +++ b/ast/inspector_test.go @@ -25,7 +25,6 @@ import ( "github.com/onflow/cadence/ast" "github.com/onflow/cadence/parser" - "github.com/onflow/cadence/tests/examples" ) // TestInspector_Elements compares Inspector against Inspect. @@ -33,9 +32,30 @@ func TestInspector_Elements(t *testing.T) { t.Parallel() + const code = ` + access(all) contract interface FungibleToken { + + access(all) resource interface Provider { + access(all) fun withdraw(amount: Int): @Vault + } + + access(all) resource interface Receiver { + access(all) fun deposit(vault: @Vault) + } + + access(all) resource interface Vault: Provider, Receiver { + access(all) balance: Int + } + + access(all) fun absorb(vault: @Vault) + + access(all) fun sprout(balance: Int): @Vault + } + ` + program, err := parser.ParseProgram( nil, - []byte(examples.FungibleTokenContractInterface), + []byte(code), parser.Config{}, ) require.NoError(t, err) diff --git a/tests/checker/interface_test.go b/tests/checker/interface_test.go index d0943d0fb0..fd453b789a 100644 --- a/tests/checker/interface_test.go +++ b/tests/checker/interface_test.go @@ -27,11 +27,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/errors" - "github.com/onflow/cadence/parser" "github.com/onflow/cadence/sema" - "github.com/onflow/cadence/stdlib" - "github.com/onflow/cadence/tests/examples" - . "github.com/onflow/cadence/tests/utils" ) func constructorArguments(compositeKind common.CompositeKind) string { @@ -1630,128 +1626,6 @@ func TestCheckInvalidTypeRequirementDeclaration(t *testing.T) { }) } -// TODO: re-enable this test with the v2 fungible token contract -/* func TestCheckContractInterfaceFungibleToken(t *testing.T) { - - t.Parallel() - - const code = examples.FungibleTokenContractInterface - - _, err := ParseAndCheck(t, code) - require.NoError(t, err) -} */ - -// TODO: re-enable this test with the v2 fungible token contract -/* func TestCheckContractInterfaceFungibleTokenConformance(t *testing.T) { - - t.Parallel() - - code := examples.FungibleTokenContractInterface + "\n" + examples.ExampleFungibleTokenContract - - _, err := ParseAndCheckWithPanic(t, code) - require.NoError(t, err) -} */ - -func BenchmarkContractInterfaceFungibleToken(b *testing.B) { - - const code = examples.FungibleTokenContractInterface - - program, err := parser.ParseProgram(nil, []byte(code), parser.Config{}) - if err != nil { - b.Fatal(err) - } - - b.ReportAllocs() - b.ResetTimer() - - for i := 0; i < b.N; i++ { - checker, err := sema.NewChecker( - program, - TestLocation, - nil, - &sema.Config{ - AccessCheckMode: sema.AccessCheckModeNotSpecifiedUnrestricted, - }, - ) - if err != nil { - b.Fatal(err) - } - err = checker.Check() - if err != nil { - b.Fatal(err) - } - } -} - -func BenchmarkCheckContractInterfaceFungibleTokenConformance(b *testing.B) { - - code := examples.FungibleTokenContractInterface + "\n" + examples.ExampleFungibleTokenContract - - program, err := parser.ParseProgram(nil, []byte(code), parser.Config{}) - if err != nil { - b.Fatal(err) - } - - baseValueActivation := sema.NewVariableActivation(sema.BaseValueActivation) - baseValueActivation.DeclareValue(stdlib.PanicFunction) - - config := &sema.Config{ - AccessCheckMode: sema.AccessCheckModeNotSpecifiedUnrestricted, - BaseValueActivationHandler: func(_ common.Location) *sema.VariableActivation { - return baseValueActivation - }, - } - - b.ReportAllocs() - b.ResetTimer() - - for i := 0; i < b.N; i++ { - checker, err := sema.NewChecker( - program, - TestLocation, - nil, - config, - ) - if err != nil { - b.Fatal(err) - } - err = checker.Check() - if err != nil { - b.Fatal(err) - } - } -} - -// TODO: re-enable this test with the v2 fungible token contract -/* func TestCheckContractInterfaceFungibleTokenUse(t *testing.T) { - - t.Parallel() - - code := examples.FungibleTokenContractInterface + "\n" + - examples.ExampleFungibleTokenContract + "\n" + ` - - fun test(): Int { - let publisher <- ExampleToken.sprout(balance: 100) - let receiver <- ExampleToken.sprout(balance: 0) - - let withdrawn <- publisher.withdraw(amount: 60) - receiver.deposit(vault: <-withdrawn) - - let publisherBalance = publisher.balance - let receiverBalance = receiver.balance - - destroy publisher - destroy receiver - - return receiverBalance - } - ` - - _, err := ParseAndCheckWithPanic(t, code) - - require.NoError(t, err) -} */ - // TestCheckInvalidInterfaceUseAsTypeSuggestion tests that an interface // can not be used as a type, and the suggestion to fix it is correct func TestCheckInvalidInterfaceUseAsTypeSuggestion(t *testing.T) { diff --git a/tests/checker/nft_test.go b/tests/checker/nft_test.go deleted file mode 100644 index 41374e7903..0000000000 --- a/tests/checker/nft_test.go +++ /dev/null @@ -1,992 +0,0 @@ -/* - * Cadence - The resource-oriented smart contract programming language - * - * Copyright Flow Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package checker - -// TODO: re-enable this test with the v2 fungible token contract -/* -const realNonFungibleTokenContractInterface = ` - -// The main NFT contract interface. Other NFT contracts will -// import and implement this interface -// -access(all) contract interface NonFungibleToken { - - // The total number of tokens of this type in existence - access(all) var totalSupply: UInt64 - - // Event that emitted when the NFT contract is initialized - // - access(all) event ContractInitialized() - - // Event that is emitted when a token is withdrawn, - // indicating the owner of the collection that it was withdrawn from. - // - // If the collection is not in an account's storage, from will be nil. - // - access(all) event Withdraw(id: UInt64, from: Address?) - - // Event that emitted when a token is deposited to a collection. - // - // It indicates the owner of the collection that it was deposited to. - // - access(all) event Deposit(id: UInt64, to: Address?) - - // Interface that the NFTs have to conform to - // - access(all) resource interface INFT { - // The unique ID that each NFT has - access(all) let id: UInt64 - } - - // Requirement that all conforming NFT smart contracts have - // to define a resource called NFT that conforms to INFT - access(all) resource NFT: INFT { - access(all) let id: UInt64 - } - - // entitles references to withdraw: - // TODO: https://github.com/onflow/cadence/issues/2503 - entitlement Withdrawable - - // Interface to mediate withdraws from the Collection - // - access(all) resource interface Provider { - // withdraw removes an NFT from the collection and moves it to the caller - access(Withdrawable) fun withdraw(withdrawID: UInt64): @NFT { - post { - result.id == withdrawID: "The ID of the withdrawn token must be the same as the requested ID" - } - } - } - - // Interface to mediate deposits to the Collection - // - access(all) resource interface Receiver { - - // deposit takes an NFT as an argument and adds it to the Collection - // - access(all) fun deposit(token: @NFT) - } - - // Interface that an account would commonly - // publish for their collection - access(all) resource interface CollectionPublic { - access(all) fun deposit(token: @NFT) - access(all) fun getIDs(): [UInt64] - access(all) fun borrowNFT(id: UInt64): &NFT - } - - // Requirement for the the concrete resource type - // to be declared in the implementing contract - // - access(all) resource Collection: Provider, Receiver, CollectionPublic { - - // Dictionary to hold the NFTs in the Collection - access(all) var ownedNFTs: @{UInt64: NFT} - - // withdraw removes an NFT from the collection and moves it to the caller - access(Withdrawable) fun withdraw(withdrawID: UInt64): @NFT - - // deposit takes a NFT and adds it to the collections dictionary - // and adds the ID to the id array - access(all) fun deposit(token: @NFT) - - // getIDs returns an array of the IDs that are in the collection - access(all) fun getIDs(): [UInt64] - - // Returns a borrowed reference to an NFT in the collection - // so that the caller can read data and call methods from it - access(all) fun borrowNFT(id: UInt64): &NFT { - pre { - self.ownedNFTs[id] != nil: "NFT does not exist in the collection!" - } - } - } - - // createEmptyCollection creates an empty Collection - // and returns it to the caller so that they can own NFTs - access(all) fun createEmptyCollection(): @Collection { - post { - result.ownedNFTs.length == 0: "The created collection must be empty!" - } - } -} -` -const topShotContract = ` - -import NonFungibleToken from 0x1 - -access(all) contract TopShot: NonFungibleToken { - - // ----------------------------------------------------------------------- - // TopShot contract Events - // ----------------------------------------------------------------------- - - // Emitted when the TopShot contract is created - access(all) event ContractInitialized() - - // Emitted when a new Play struct is created - access(all) event PlayCreated(id: UInt32, metadata: {String:String}) - // Emitted when a new series has been triggered by an admin - access(all) event NewSeriesStarted(newCurrentSeries: UInt32) - - // Events for Set-Related actions - // - // Emitted when a new Set is created - access(all) event SetCreated(setID: UInt32, series: UInt32) - // Emitted when a new Play is added to a Set - access(all) event PlayAddedToSet(setID: UInt32, playID: UInt32) - // Emitted when a Play is retired from a Set and cannot be used to mint - access(all) event PlayRetiredFromSet(setID: UInt32, playID: UInt32, numMoments: UInt32) - // Emitted when a Set is locked, meaning Plays cannot be added - access(all) event SetLocked(setID: UInt32) - // Emitted when a Moment is minted from a Set - access(all) event MomentMinted(momentID: UInt64, playID: UInt32, setID: UInt32, serialNumber: UInt32) - - // Events for Collection-related actions - // - // Emitted when a moment is withdrawn from a Collection - access(all) event Withdraw(id: UInt64, from: Address?) - // Emitted when a moment is deposited into a Collection - access(all) event Deposit(id: UInt64, to: Address?) - - // Emitted when a Moment is destroyed - access(all) event MomentDestroyed(id: UInt64) - - // ----------------------------------------------------------------------- - // TopShot contract-level fields. - // These contain actual values that are stored in the smart contract. - // ----------------------------------------------------------------------- - - // Series that this Set belongs to. - // Series is a concept that indicates a group of Sets through time. - // Many Sets can exist at a time, but only one series. - access(all) var currentSeries: UInt32 - - // Variable size dictionary of Play structs - access(self) var playDatas: {UInt32: Play} - - // Variable size dictionary of SetData structs - access(self) var setDatas: {UInt32: SetData} - - // Variable size dictionary of Set resources - access(self) var sets: @{UInt32: Set} - - // The ID that is used to create Plays. - // Every time a Play is created, playID is assigne - // to the new Play's ID and then is incremented by 1. - access(all) var nextPlayID: UInt32 - - // The ID that is used to create Sets. Every time a Set is created - // setID is assigned to the new set's ID and then is incremented by 1. - access(all) var nextSetID: UInt32 - - // The total number of Top shot Moment NFTs that have been created - // Because NFTs can be destroyed, it doesn't necessarily mean that this - // reflects the total number of NFTs in existence, just the number that - // have been minted to date. Also used as global moment IDs for minting. - access(all) var totalSupply: UInt64 - - // ----------------------------------------------------------------------- - // TopShot contract-level Composite Type definitions - // ----------------------------------------------------------------------- - // These are just *definitions* for Types that this contract - // and other accounts can use. These definitions do not contain - // actual stored values, but an instance (or object) of one of these Types - // can be created by this contract that contains stored values. - // ----------------------------------------------------------------------- - - // Play is a Struct that holds metadata associated - // with a specific NBA play, like the legendary moment when - // Ray Allen hit the 3 to tie the Heat and Spurs in the 2013 finals game 6 - // or when Lance Stephenson blew in the ear of Lebron James. - // - // Moment NFTs will all reference a single play as the owner of - // its metadata. The plays are publicly accessible, so anyone can - // read the metadata associated with a specific play ID - // - access(all) struct Play { - - // The unique ID for the Play - access(all) let playID: UInt32 - - // Stores all the metadata about the play as a string mapping - // This is not the long term way NFT metadata will be stored. It's a temporary - // construct while we figure out a better way to do metadata. - // - access(all) let metadata: {String: String} - - init(metadata: {String: String}) { - pre { - metadata.length != 0: "New Play metadata cannot be empty" - } - self.playID = TopShot.nextPlayID - self.metadata = metadata - - // Increment the ID so that it isn't used again - TopShot.nextPlayID = TopShot.nextPlayID + UInt32(1) - - emit PlayCreated(id: self.playID, metadata: metadata) - } - } - - // A Set is a grouping of Plays that have occurred in the real world - // that make up a related group of collectibles, like sets of baseball - // or Magic cards. A Play can exist in multiple different sets. - // - // SetData is a struct that is stored in a field of the contract. - // Anyone can query the constant information - // about a set by calling various getters located - // at the end of the contract. Only the admin has the ability - // to modify any data in the private Set resource. - // - access(all) struct SetData { - - // Unique ID for the Set - access(all) let setID: UInt32 - - // Name of the Set - // ex. "Times when the Toronto Raptors choked in the playoffs" - access(all) let name: String - - // Series that this Set belongs to. - // Series is a concept that indicates a group of Sets through time. - // Many Sets can exist at a time, but only one series. - access(all) let series: UInt32 - - init(name: String) { - pre { - name.length > 0: "New Set name cannot be empty" - } - self.setID = TopShot.nextSetID - self.name = name - self.series = TopShot.currentSeries - - // Increment the setID so that it isn't used again - TopShot.nextSetID = TopShot.nextSetID + UInt32(1) - - emit SetCreated(setID: self.setID, series: self.series) - } - } - - // Set is a resource type that contains the functions to add and remove - // Plays from a set and mint Moments. - // - // It is stored in a private field in the contract so that - // the admin resource can call its methods. - // - // The admin can add Plays to a Set so that the set can mint Moments - // that reference that playdata. - // The Moments that are minted by a Set will be listed as belonging to - // the Set that minted it, as well as the Play it references. - // - // Admin can also retire Plays from the Set, meaning that the retired - // Play can no longer have Moments minted from it. - // - // If the admin locks the Set, no more Plays can be added to it, but - // Moments can still be minted. - // - // If retireAll() and lock() are called back-to-back, - // the Set is closed off forever and nothing more can be done with it. - access(all) resource Set { - - // Unique ID for the set - access(all) let setID: UInt32 - - // Array of plays that are a part of this set. - // When a play is added to the set, its ID gets appended here. - // The ID does not get removed from this array when a Play is retired. - access(all) var plays: [UInt32] - - // Map of Play IDs that Indicates if a Play in this Set can be minted. - // When a Play is added to a Set, it is mapped to false (not retired). - // When a Play is retired, this is set to true and cannot be changed. - access(all) var retired: {UInt32: Bool} - - // Indicates if the Set is currently locked. - // When a Set is created, it is unlocked - // and Plays are allowed to be added to it. - // When a set is locked, Plays cannot be added. - // A Set can never be changed from locked to unlocked, - // the decision to lock a Set it is final. - // If a Set is locked, Plays cannot be added, but - // Moments can still be minted from Plays - // that exist in the Set. - access(all) var locked: Bool - - // Mapping of Play IDs that indicates the number of Moments - // that have been minted for specific Plays in this Set. - // When a Moment is minted, this value is stored in the Moment to - // show its place in the Set, eg. 13 of 60. - access(all) var numberMintedPerPlay: {UInt32: UInt32} - - init(name: String) { - self.setID = TopShot.nextSetID - self.plays = [] - self.retired = {} - self.locked = false - self.numberMintedPerPlay = {} - - // Create a new SetData for this Set and store it in contract storage - TopShot.setDatas[self.setID] = SetData(name: name) - } - - // addPlay adds a play to the set - // - // Parameters: playID: The ID of the Play that is being added - // - // Pre-Conditions: - // The Play needs to be an existing play - // The Set needs to be not locked - // The Play can't have already been added to the Set - // - access(all) fun addPlay(playID: UInt32) { - pre { - TopShot.playDatas[playID] != nil: "Cannot add the Play to Set: Play doesn't exist." - !self.locked: "Cannot add the play to the Set after the set has been locked." - self.numberMintedPerPlay[playID] == nil: "The play has already beed added to the set." - } - - // Add the Play to the array of Plays - self.plays.append(playID) - - // Open the Play up for minting - self.retired[playID] = false - - // Initialize the Moment count to zero - self.numberMintedPerPlay[playID] = 0 - - emit PlayAddedToSet(setID: self.setID, playID: playID) - } - - // addPlays adds multiple Plays to the Set - // - // Parameters: playIDs: The IDs of the Plays that are being added - // as an array - // - access(all) fun addPlays(playIDs: [UInt32]) { - for play in playIDs { - self.addPlay(playID: play) - } - } - - // retirePlay retires a Play from the Set so that it can't mint new Moments - // - // Parameters: playID: The ID of the Play that is being retired - // - // Pre-Conditions: - // The Play is part of the Set and not retired (available for minting). - // - access(all) fun retirePlay(playID: UInt32) { - pre { - self.retired[playID] != nil: "Cannot retire the Play: Play doesn't exist in this set!" - } - - if !self.retired[playID]! { - self.retired[playID] = true - - emit PlayRetiredFromSet(setID: self.setID, playID: playID, numMoments: self.numberMintedPerPlay[playID]!) - } - } - - // retireAll retires all the plays in the Set - // Afterwards, none of the retired Plays will be able to mint new Moments - // - access(all) fun retireAll() { - for play in self.plays { - self.retirePlay(playID: play) - } - } - - // lock() locks the Set so that no more Plays can be added to it - // - // Pre-Conditions: - // The Set should not be locked - access(all) fun lock() { - if !self.locked { - self.locked = true - emit SetLocked(setID: self.setID) - } - } - - // mintMoment mints a new Moment and returns the newly minted Moment - // - // Parameters: playID: The ID of the Play that the Moment references - // - // Pre-Conditions: - // The Play must exist in the Set and be allowed to mint new Moments - // - // Returns: The NFT that was minted - // - access(all) fun mintMoment(playID: UInt32): @NFT { - pre { - self.retired[playID] != nil: "Cannot mint the moment: This play doesn't exist." - !self.retired[playID]!: "Cannot mint the moment from this play: This play has been retired." - } - - // Gets the number of Moments that have been minted for this Play - // to use as this Moment's serial number - let numInPlay = self.numberMintedPerPlay[playID]! - - // Mint the new moment - let newMoment: @NFT <- create NFT(serialNumber: numInPlay + UInt32(1), - playID: playID, - setID: self.setID) - - // Increment the count of Moments minted for this Play - self.numberMintedPerPlay[playID] = numInPlay + UInt32(1) - - return <-newMoment - } - - // batchMintMoment mints an arbitrary quantity of Moments - // and returns them as a Collection - // - // Parameters: playID: the ID of the Play that the Moments are minted for - // quantity: The quantity of Moments to be minted - // - // Returns: Collection object that contains all the Moments that were minted - // - access(all) fun batchMintMoment(playID: UInt32, quantity: UInt64): @Collection { - let newCollection <- create Collection() - - var i: UInt64 = 0 - while i < quantity { - newCollection.deposit(token: <-self.mintMoment(playID: playID)) - i = i + UInt64(1) - } - - return <-newCollection - } - } - - access(all) struct MomentData { - - // The ID of the Set that the Moment comes from - access(all) let setID: UInt32 - - // The ID of the Play that the Moment references - access(all) let playID: UInt32 - - // The place in the edition that this Moment was minted - // Otherwise know as the serial number - access(all) let serialNumber: UInt32 - - init(setID: UInt32, playID: UInt32, serialNumber: UInt32) { - self.setID = setID - self.playID = playID - self.serialNumber = serialNumber - } - - } - - // The resource that represents the Moment NFTs - // - access(all) resource NFT: NonFungibleToken.INFT { - - // Global unique moment ID - access(all) let id: UInt64 - - // Struct of Moment metadata - access(all) let data: MomentData - - init(serialNumber: UInt32, playID: UInt32, setID: UInt32) { - // Increment the global Moment IDs - TopShot.totalSupply = TopShot.totalSupply + UInt64(1) - - self.id = TopShot.totalSupply - - // Set the metadata struct - self.data = MomentData(setID: setID, playID: playID, serialNumber: serialNumber) - - emit MomentMinted(momentID: self.id, playID: playID, setID: self.data.setID, serialNumber: self.data.serialNumber) - } - } - - // Admin is a special authorization resource that - // allows the owner to perform important functions to modify the - // various aspects of the Plays, Sets, and Moments - // - access(all) resource Admin { - - // createPlay creates a new Play struct - // and stores it in the Plays dictionary in the TopShot smart contract - // - // Parameters: metadata: A dictionary mapping metadata titles to their data - // example: {"Player Name": "Kevin Durant", "Height": "7 feet"} - // (because we all know Kevin Durant is not 6'9") - // - // Returns: the ID of the new Play object - // - access(all) fun createPlay(metadata: {String: String}): UInt32 { - // Create the new Play - var newPlay = Play(metadata: metadata) - let newID = newPlay.playID - - // Store it in the contract storage - TopShot.playDatas[newID] = newPlay - - return newID - } - - // createSet creates a new Set resource and stores it - // in the sets mapping in the TopShot contract - // - // Parameters: name: The name of the Set - // - access(all) fun createSet(name: String) { - // Create the new Set - var newSet <- create Set(name: name) - - // Store it in the sets mapping field - TopShot.sets[newSet.setID] <-! newSet - } - - // borrowSet returns a reference to a set in the TopShot - // contract so that the admin can call methods on it - // - // Parameters: setID: The ID of the Set that you want to - // get a reference to - // - // Returns: A reference to the Set with all of the fields - // and methods exposed - // - access(all) fun borrowSet(setID: UInt32): &Set { - pre { - TopShot.sets[setID] != nil: "Cannot borrow Set: The Set doesn't exist" - } - - // Get a reference to the Set and return it - // use & to indicate the reference to the object and type - return (&TopShot.sets[setID] as &Set?)! - } - - // startNewSeries ends the current series by incrementing - // the series number, meaning that Moments minted after this - // will use the new series number - // - // Returns: The new series number - // - access(all) fun startNewSeries(): UInt32 { - // End the current series and start a new one - // by incrementing the TopShot series number - TopShot.currentSeries = TopShot.currentSeries + UInt32(1) - - emit NewSeriesStarted(newCurrentSeries: TopShot.currentSeries) - - return TopShot.currentSeries - } - - // createNewAdmin creates a new Admin resource - // - access(all) fun createNewAdmin(): @Admin { - return <-create Admin() - } - } - - // This is the interface that users can cast their Moment Collection as - // to allow others to deposit Moments into their Collection. It also allows for reading - // the IDs of Moments in the Collection. - access(all) resource interface MomentCollectionPublic { - access(all) fun deposit(token: @NonFungibleToken.NFT) - access(all) fun batchDeposit(tokens: @NonFungibleToken.Collection) - access(all) fun getIDs(): [UInt64] - access(all) fun borrowNFT(id: UInt64): &NonFungibleToken.NFT - access(all) fun borrowMoment(id: UInt64): &TopShot.NFT? { - // If the result isn't nil, the id of the returned reference - // should be the same as the argument to the function - post { - (result == nil) || (result?.id == id): - "Cannot borrow Moment reference: The ID of the returned reference is incorrect" - } - } - } - - // Collection is a resource that every user who owns NFTs - // will store in their account to manage their NFTS - // - access(all) resource Collection: MomentCollectionPublic, NonFungibleToken.Provider, NonFungibleToken.Receiver, NonFungibleToken.CollectionPublic { - // Dictionary of Moment conforming tokens - // NFT is a resource type with a UInt64 ID field - access(all) var ownedNFTs: @{UInt64: NonFungibleToken.NFT} - - init() { - self.ownedNFTs <- {} - } - - // withdraw removes an Moment from the Collection and moves it to the caller - // - // Parameters: withdrawID: The ID of the NFT - // that is to be removed from the Collection - // - // returns: @NonFungibleToken.NFT the token that was withdrawn - access(NonFungibleToken.Withdrawable) fun withdraw(withdrawID: UInt64): @NonFungibleToken.NFT { - - // Remove the nft from the Collection - let token <- self.ownedNFTs.remove(key: withdrawID) - ?? panic("Cannot withdraw: Moment does not exist in the collection") - - emit Withdraw(id: token.id, from: self.owner?.address) - - // Return the withdrawn token - return <-token - } - - // batchWithdraw withdraws multiple tokens and returns them as a Collection - // - // Parameters: ids: An array of IDs to withdraw - // - // Returns: @NonFungibleToken.Collection: A collection that contains - // the withdrawn moments - // - access(all) fun batchWithdraw(ids: [UInt64]): @NonFungibleToken.Collection { - // Create a new empty Collection - var batchCollection <- create Collection() - - // Iterate through the ids and withdraw them from the Collection - for id in ids { - batchCollection.deposit(token: <-self.withdraw(withdrawID: id)) - } - - // Return the withdrawn tokens - return <-batchCollection - } - - // deposit takes a Moment and adds it to the Collections dictionary - // - // Parameters: token: the NFT to be deposited in the collection - // - access(all) fun deposit(token: @NonFungibleToken.NFT) { - - // Cast the deposited token as a TopShot NFT to make sure - // it is the correct type - let token <- token as! @TopShot.NFT - - // Get the token's ID - let id = token.id - - // Add the new token to the dictionary - let oldToken <- self.ownedNFTs[id] <- token - - // Only emit a deposit event if the Collection - // is in an account's storage - if self.owner?.address != nil { - emit Deposit(id: id, to: self.owner?.address) - } - - // Destroy the empty old token that was "removed" - destroy oldToken - } - - // batchDeposit takes a Collection object as an argument - // and deposits each contained NFT into this Collection - access(all) fun batchDeposit(tokens: @NonFungibleToken.Collection) { - - // Get an array of the IDs to be deposited - let keys = tokens.getIDs() - - // Iterate through the keys in the collection and deposit each one - for key in keys { - self.deposit(token: <-tokens.withdraw(withdrawID: key)) - } - - // Destroy the empty Collection - destroy tokens - } - - // getIDs returns an array of the IDs that are in the Collection - access(all) fun getIDs(): [UInt64] { - return self.ownedNFTs.keys - } - - // borrowNFT Returns a borrowed reference to a Moment in the Collection - // so that the caller can read its ID - // - // Parameters: id: The ID of the NFT to get the reference for - // - // Returns: A reference to the NFT - // - // Note: This only allows the caller to read the ID of the NFT, - // not any topshot specific data. Please use borrowMoment to - // read Moment data. - // - access(all) fun borrowNFT(id: UInt64): &NonFungibleToken.NFT { - return (&self.ownedNFTs[id] as &NonFungibleToken.NFT?)! - } - - // borrowMoment returns a borrowed reference to a Moment - // so that the caller can read data and call methods from it. - // They can use this to read its setID, playID, serialNumber, - // or any of the setData or Play data associated with it by - // getting the setID or playID and reading those fields from - // the smart contract. - // - // Parameters: id: The ID of the NFT to get the reference for - // - // Returns: A reference to the NFT - access(all) fun borrowMoment(id: UInt64): &TopShot.NFT? { - if self.ownedNFTs[id] != nil { - let ref = (&self.ownedNFTs[id] as &NonFungibleToken.NFT?)! - return ref as! &TopShot.NFT - } else { - return nil - } - } - } - - // ----------------------------------------------------------------------- - // TopShot contract-level function definitions - // ----------------------------------------------------------------------- - - // createEmptyCollection creates a new, empty Collection object so that - // a user can store it in their account storage. - // Once they have a Collection in their storage, they are able to receive - // Moments in transactions. - // - access(all) fun createEmptyCollection(): @NonFungibleToken.Collection { - return <-create TopShot.Collection() - } - - // getAllPlays returns all the plays in topshot - // - // Returns: An array of all the plays that have been created - access(all) fun getAllPlays(): [TopShot.Play] { - return TopShot.playDatas.values - } - - // getPlayMetaData returns all the metadata associated with a specific Play - // - // Parameters: playID: The id of the Play that is being searched - // - // Returns: The metadata as a String to String mapping optional - access(all) fun getPlayMetaData(playID: UInt32): {String: String}? { - return self.playDatas[playID]?.metadata - } - - // getPlayMetaDataByField returns the metadata associated with a - // specific field of the metadata - // Ex: field: "Team" will return something - // like "Memphis Grizzlies" - // - // Parameters: playID: The id of the Play that is being searched - // field: The field to search for - // - // Returns: The metadata field as a String Optional - access(all) fun getPlayMetaDataByField(playID: UInt32, field: String): String? { - // Don't force a revert if the playID or field is invalid - if let play = TopShot.playDatas[playID] { - return play.metadata[field] - } else { - return nil - } - } - - // getSetName returns the name that the specified Set - // is associated with. - // - // Parameters: setID: The id of the Set that is being searched - // - // Returns: The name of the Set - access(all) fun getSetName(setID: UInt32): String? { - // Don't force a revert if the setID is invalid - return TopShot.setDatas[setID]?.name - } - - // getSetSeries returns the series that the specified Set - // is associated with. - // - // Parameters: setID: The id of the Set that is being searched - // - // Returns: The series that the Set belongs to - access(all) fun getSetSeries(setID: UInt32): UInt32? { - // Don't force a revert if the setID is invalid - return TopShot.setDatas[setID]?.series - } - - // getSetIDsByName returns the IDs that the specified Set name - // is associated with. - // - // Parameters: setName: The name of the Set that is being searched - // - // Returns: An array of the IDs of the Set if it exists, or nil if doesn't - access(all) fun getSetIDsByName(setName: String): [UInt32]? { - var setIDs: [UInt32] = [] - - // Iterate through all the setDatas and search for the name - for setData in TopShot.setDatas.values { - if setName == setData.name { - // If the name is found, return the ID - setIDs.append(setData.setID) - } - } - - // If the name isn't found, return nil - // Don't force a revert if the setName is invalid - if setIDs.length == 0 { - return nil - } else { - return setIDs - } - } - - // getPlaysInSet returns the list of Play IDs that are in the Set - // - // Parameters: setID: The id of the Set that is being searched - // - // Returns: An array of Play IDs - access(all) fun getPlaysInSet(setID: UInt32): [UInt32]? { - // Don't force a revert if the setID is invalid - return TopShot.sets[setID]?.plays - } - - // isEditionRetired returns a boolean that indicates if a Set/Play combo - // (otherwise known as an edition) is retired. - // If an edition is retired, it still remains in the Set, - // but Moments can no longer be minted from it. - // - // Parameters: setID: The id of the Set that is being searched - // playID: The id of the Play that is being searched - // - // Returns: Boolean indicating if the edition is retired or not - access(all) fun isEditionRetired(setID: UInt32, playID: UInt32): Bool? { - // Don't force a revert if the set or play ID is invalid - // Remove the set from the dictionary to get its field - if let setToRead <- TopShot.sets.remove(key: setID) { - - // See if the Play is retired from this Set - let retired = setToRead.retired[playID] - - // Put the Set back in the contract storage - TopShot.sets[setID] <-! setToRead - - // Return the retired status - return retired - } else { - - // If the Set wasn't found, return nil - return nil - } - } - - // isSetLocked returns a boolean that indicates if a Set - // is locked. If it's locked, - // new Plays can no longer be added to it, - // but Moments can still be minted from Plays the set contains. - // - // Parameters: setID: The id of the Set that is being searched - // - // Returns: Boolean indicating if the Set is locked or not - access(all) fun isSetLocked(setID: UInt32): Bool? { - // Don't force a revert if the setID is invalid - return TopShot.sets[setID]?.locked - } - - // getNumMomentsInEdition return the number of Moments that have been - // minted from a certain edition. - // - // Parameters: setID: The id of the Set that is being searched - // playID: The id of the Play that is being searched - // - // Returns: The total number of Moments - // that have been minted from an edition - access(all) fun getNumMomentsInEdition(setID: UInt32, playID: UInt32): UInt32? { - // Don't force a revert if the Set or play ID is invalid - // Remove the Set from the dictionary to get its field - if let setToRead <- TopShot.sets.remove(key: setID) { - - // Read the numMintedPerPlay - let amount = setToRead.numberMintedPerPlay[playID] - - // Put the Set back into the Sets dictionary - TopShot.sets[setID] <-! setToRead - - return amount - } else { - // If the set wasn't found return nil - return nil - } - } - - // ----------------------------------------------------------------------- - // TopShot initialization function - // ----------------------------------------------------------------------- - // - init() { - // Initialize contract fields - self.currentSeries = 0 - self.playDatas = {} - self.setDatas = {} - self.sets <- {} - self.nextPlayID = 1 - self.nextSetID = 1 - self.totalSupply = 0 - - // Put a new Collection in storage - self.account.storage.save<@Collection>(<- create Collection(), to: /storage/MomentCollection) - - // Create a public capability for the Collection - let cap = self.account.capabilities.storage.issue<&{MomentCollectionPublic}>(/storage/MomentCollection) - self.account.capabilities.publish(cap, at: /public/MomentCollection) - - // Put the Minter in storage - self.account.storage.save<@Admin>(<- create Admin(), to: /storage/TopShotAdmin) - - emit ContractInitialized() - } -} -` - func TestCheckTopShotContract(t *testing.T) { - - t.Parallel() - - nftChecker, err := ParseAndCheckWithOptions(t, - realNonFungibleTokenContractInterface, - ParseAndCheckOptions{ - Location: common.AddressLocation{ - Address: common.MustBytesToAddress([]byte{0x1}), - Name: "NonFungibleToken", - }, - }, - ) - require.NoError(t, err) - - baseValueActivation := sema.NewVariableActivation(sema.BaseValueActivation) - baseValueActivation.DeclareValue(stdlib.PanicFunction) - - _, err = ParseAndCheckWithOptions(t, - topShotContract, - ParseAndCheckOptions{ - Location: common.AddressLocation{ - Address: common.MustBytesToAddress([]byte{0x2}), - Name: "TopShot", - }, - Config: &sema.Config{ - ImportHandler: func(_ *sema.Checker, _ common.Location, _ ast.Range) (sema.Import, error) { - return sema.ElaborationImport{ - Elaboration: nftChecker.Elaboration, - }, nil - }, - BaseValueActivationHandler: func(_ common.Location) *sema.VariableActivation { - return baseValueActivation - }, - }, - }, - ) - require.NoError(t, err) -} */ diff --git a/tests/examples/examples.go b/tests/examples/examples.go deleted file mode 100644 index 7a96b68337..0000000000 --- a/tests/examples/examples.go +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Cadence - The resource-oriented smart contract programming language - * - * Copyright Flow Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package examples - -const FungibleTokenContractInterface = ` - access(all) contract interface FungibleToken { - - access(all) resource interface Provider { - - access(all) fun withdraw(amount: Int): @Vault - } - - access(all) resource interface Receiver { - - access(all) fun deposit(vault: @Vault) - } - - access(all) resource Vault: Provider, Receiver { - - access(all) balance: Int - - init(balance: Int) - } - - access(all) fun absorb(vault: @Vault) - - access(all) fun sprout(balance: Int): @Vault - } -` - -const ExampleFungibleTokenContract = ` - access(all) contract ExampleToken: FungibleToken { - - access(all) resource Vault: FungibleToken.Receiver, FungibleToken.Provider { - - access(all) var balance: Int - - init(balance: Int) { - self.balance = balance - } - - access(all) fun withdraw(amount: Int): @FungibleToken.Vault { - self.balance = self.balance - amount - return <-create Vault(balance: amount) - } - - access(all) fun deposit(vault: @FungibleToken.Vault) { - if let exampleVault <- vault as? @Vault { - self.balance = self.balance + exampleVault.balance - destroy exampleVault - } else { - destroy vault - panic("deposited vault is not an ExampleToken.Vault") - } - } - } - - access(all) fun absorb(vault: @FungibleToken.Vault) { - destroy vault - } - - access(all) fun sprout(balance: Int): @FungibleToken.Vault { - return <-create Vault(balance: balance) - } - } -` diff --git a/tests/interpreter/interpreter_test.go b/tests/interpreter/interpreter_test.go index 29d4f11823..7c4c6d762f 100644 --- a/tests/interpreter/interpreter_test.go +++ b/tests/interpreter/interpreter_test.go @@ -8530,82 +8530,6 @@ func TestInterpretCompositeDeclarationNestedConstructor(t *testing.T) { ) } -// TODO: re-enable this test with the v2 fungible token contract -/* func TestInterpretFungibleTokenContract(t *testing.T) { - - t.Parallel() - - code := strings.Join( - []string{ - examples.FungibleTokenContractInterface, - examples.ExampleFungibleTokenContract, - ` - access(all) fun test(): [Int; 2] { - - let publisher <- ExampleToken.sprout(balance: 100) - let receiver <- ExampleToken.sprout(balance: 0) - - let withdrawn <- publisher.withdraw(amount: 60) - receiver.deposit(vault: <-withdrawn) - - let publisherBalance = publisher.balance - let receiverBalance = receiver.balance - - destroy publisher - destroy receiver - - return [publisherBalance, receiverBalance] - } - `, - }, - "\n", - ) - - baseValueActivation := sema.NewVariableActivation(sema.BaseValueActivation) - baseValueActivation.DeclareValue(stdlib.PanicFunction) - - baseActivation := activations.NewActivation(nil, interpreter.BaseActivation) - interpreter.Declare(baseActivation, stdlib.PanicFunction) - - inter, err := parseCheckAndInterpretWithOptions(t, - code, - ParseCheckAndInterpretOptions{ - Config: &interpreter.Config{ - BaseActivationHandler: func(_ common.Location) *interpreter.VariableActivation { - return baseActivation - }, - ContractValueHandler: makeContractValueHandler(nil, nil, nil), - }, - CheckerConfig: &sema.Config{ - BaseValueActivationHandler: func(_ common.Location) *sema.VariableActivation { - return baseValueActivation - }, - }, - }, - ) - require.NoError(t, err) - - value, err := inter.Invoke("test") - require.NoError(t, err) - - AssertValuesEqual( - t, - inter, - interpreter.NewArrayValue( - inter, - interpreter.EmptyLocationRange, - interpreter.ConstantSizedStaticType{ - Type: interpreter.PrimitiveStaticTypeInt, - Size: 2, - }, - common.ZeroAddress, - interpreter.NewUnmeteredIntValueFromInt64(40), - interpreter.NewUnmeteredIntValueFromInt64(60), - ), - value, - ) -} */ - func TestInterpretContractAccountFieldUse(t *testing.T) { t.Parallel() From f52a7ed0982d9b947a8766bcd80baa181e4665d5 Mon Sep 17 00:00:00 2001 From: Supun Setunga Date: Fri, 18 Oct 2024 14:56:09 -0700 Subject: [PATCH 17/46] Fix contracts backward compatibility checker --- .../compatibility-check/contracts_checker.go | 5 +- tools/compatibility-check/go.mod | 9 +-- tools/compatibility-check/go.sum | 57 ++++++------------- 3 files changed, 24 insertions(+), 47 deletions(-) diff --git a/tools/compatibility-check/contracts_checker.go b/tools/compatibility-check/contracts_checker.go index 4964e4edbc..6c5b2886d5 100644 --- a/tools/compatibility-check/contracts_checker.go +++ b/tools/compatibility-check/contracts_checker.go @@ -117,7 +117,10 @@ func (c *ContractsChecker) analyze( config *analysis.Config, locations []common.Location, ) { - programs := make(analysis.Programs, len(locations)) + programs := analysis.Programs{ + Programs: make(map[common.Location]*analysis.Program, len(locations)), + CryptoContractElaboration: config.CryptoContractElaboration, + } log.Println("Checking contracts ...") diff --git a/tools/compatibility-check/go.mod b/tools/compatibility-check/go.mod index b784d39da9..2386e4033e 100644 --- a/tools/compatibility-check/go.mod +++ b/tools/compatibility-check/go.mod @@ -14,18 +14,11 @@ require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/fxamacker/cbor/v2 v2.4.1-0.20230228173756-c0c9f774e40c // indirect github.com/fxamacker/circlehash v0.3.0 // indirect - github.com/k0kubun/pp v3.0.1+incompatible // indirect github.com/klauspost/cpuid/v2 v2.2.0 // indirect - github.com/kr/pretty v0.3.1 // indirect - github.com/kr/text v0.2.0 // indirect - github.com/logrusorgru/aurora v0.0.0-20200102142835-e9ef32dff381 // indirect github.com/logrusorgru/aurora/v4 v4.0.0 // indirect - github.com/mattn/go-colorable v0.1.13 // indirect - github.com/mattn/go-isatty v0.0.20 // indirect github.com/onflow/atree v0.8.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/rivo/uniseg v0.4.4 // indirect - github.com/rogpeppe/go-internal v1.9.0 // indirect github.com/texttheater/golang-levenshtein/levenshtein v0.0.0-20200805054039-cae8b0eaed6c // indirect github.com/turbolent/prettier v0.0.0-20220320183459-661cc755135d // indirect github.com/x448/float16 v0.8.4 // indirect @@ -38,3 +31,5 @@ require ( golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) + +replace github.com/onflow/cadence => ../../ diff --git a/tools/compatibility-check/go.sum b/tools/compatibility-check/go.sum index 7b7106c856..7ce9a514aa 100644 --- a/tools/compatibility-check/go.sum +++ b/tools/compatibility-check/go.sum @@ -1,28 +1,20 @@ github.com/SaveTheRbtz/mph v0.1.1-0.20240117162131-4166ec7869bc h1:DCHzPQOcU/7gwDTWbFQZc5qHMPS1g0xTO56k8NXsv9M= github.com/SaveTheRbtz/mph v0.1.1-0.20240117162131-4166ec7869bc/go.mod h1:LJM5a3zcIJ/8TmZwlUczvROEJT8ntOdhdG9jjcR1B0I= -github.com/bits-and-blooms/bitset v1.2.2 h1:J5gbX05GpMdBjCvQ9MteIg2KKDExr7DrgK+Yc15FvIk= -github.com/bits-and-blooms/bitset v1.2.2/go.mod h1:gIdJ4wp64HaoK2YrL1Q5/N7Y16edYb8uY+O0FJTyyDA= github.com/bits-and-blooms/bitset v1.5.0 h1:NpE8frKRLGHIcEzkR+gZhiioW1+WbYV6fKwD6ZIpQT8= github.com/bits-and-blooms/bitset v1.5.0/go.mod h1:gIdJ4wp64HaoK2YrL1Q5/N7Y16edYb8uY+O0FJTyyDA= github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= -github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/fxamacker/cbor/v2 v2.4.1-0.20220515183430-ad2eae63303f h1:dxTR4AaxCwuQv9LAVTAC2r1szlS+epeuPT5ClLKT6ZY= -github.com/fxamacker/cbor/v2 v2.4.1-0.20220515183430-ad2eae63303f/go.mod h1:TA1xS00nchWmaBnEIxPSE5oHLuJBAVvqrtAnWBwBCVo= github.com/fxamacker/cbor/v2 v2.4.1-0.20230228173756-c0c9f774e40c h1:5tm/Wbs9d9r+qZaUFXk59CWDD0+77PBqDREffYkyi5c= github.com/fxamacker/cbor/v2 v2.4.1-0.20230228173756-c0c9f774e40c/go.mod h1:TA1xS00nchWmaBnEIxPSE5oHLuJBAVvqrtAnWBwBCVo= github.com/fxamacker/circlehash v0.3.0 h1:XKdvTtIJV9t7DDUtsf0RIpC1OcxZtPbmgIH7ekx28WA= github.com/fxamacker/circlehash v0.3.0/go.mod h1:3aq3OfVvsWtkWMb6A1owjOQFA+TLsD5FgJflnaQwtMM= -github.com/go-test/deep v1.0.5 h1:AKODKU3pDH1RzZzm6YZu77YWtEAq6uh1rLIAQlay2qc= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg= +github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/k0kubun/pp v3.0.1+incompatible h1:3tqvf7QgUnZ5tXO6pNAZlrvHgl6DvifjDrd9g2S9Z40= github.com/k0kubun/pp v3.0.1+incompatible/go.mod h1:GWse8YhT0p8pT4ir3ZgBbfZild3tgzSScAn6HmfYukg= github.com/klauspost/cpuid/v2 v2.0.12/go.mod h1:g2LTdtYhdyuGPqyWyv7qRAmj1WBqxuObKfj5c0PQa7c= -github.com/klauspost/cpuid/v2 v2.0.14 h1:QRqdp6bb9M9S5yyKeYteXKuoKE4p0tGlra81fKOpWH8= -github.com/klauspost/cpuid/v2 v2.0.14/go.mod h1:g2LTdtYhdyuGPqyWyv7qRAmj1WBqxuObKfj5c0PQa7c= github.com/klauspost/cpuid/v2 v2.2.0 h1:4ZexSFt8agMNzNisrsilL6RClWDC5YJnLHNIfTy4iuc= github.com/klauspost/cpuid/v2 v2.2.0/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8tyFgg4nqhuY= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= @@ -30,29 +22,20 @@ github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3x github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/leanovate/gopter v0.2.9 h1:fQjYxZaynp97ozCzfOyOuAGOU4aU/z37zf/tOujFk7c= -github.com/logrusorgru/aurora v0.0.0-20200102142835-e9ef32dff381 h1:bqDmpDG49ZRnB5PcgP0RXtQvnMSgIF14M7CBd2shtXs= -github.com/logrusorgru/aurora v0.0.0-20200102142835-e9ef32dff381/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4= +github.com/leanovate/gopter v0.2.9/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2Sh+Jxxv8= github.com/logrusorgru/aurora/v4 v4.0.0 h1:sRjfPpun/63iADiSvGGjgA1cAYegEWMPCJdUpJYn9JA= github.com/logrusorgru/aurora/v4 v4.0.0/go.mod h1:lP0iIa2nrnT/qoFXcOZSrZQpJ1o6n2CUf/hyHi2Q4ZQ= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= -github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= -github.com/onflow/atree v0.4.0 h1:+TbNisavAkukAKhgQ4plWnvR9o5+SkwPIsi3jaeAqKs= -github.com/onflow/atree v0.4.0/go.mod h1:7Qe1xaW0YewvouLXrugzMFUYXNoRQ8MT/UsVAWx1Ndo= github.com/onflow/atree v0.8.0 h1:qg5c6J1gVDNObughpEeWm8oxqhPGdEyGrda121GM4u0= github.com/onflow/atree v0.8.0/go.mod h1:yccR+LR7xc1Jdic0mrjocbHvUD7lnVvg8/Ct1AA5zBo= -github.com/onflow/cadence v0.31.2-0.20230207221811-9eb6e7fe4121 h1:pOJOFoX1fEwoXyzhU9Q8VtGUlZUnMCj4LcuOJdBnLgk= -github.com/onflow/cadence v0.31.2-0.20230207221811-9eb6e7fe4121/go.mod h1:hhktaaXlJmxnfLgH2HG0cftcUWScdfjO/CTZkzaom/g= -github.com/onflow/cadence v1.0.1-0.20241017195911-152088fcbb15 h1:qZSN0Y90zNyjzW6uN+XRKgF5BEb8JBJ7TziOSIC8td4= -github.com/onflow/cadence v1.0.1-0.20241017195911-152088fcbb15/go.mod h1:fJxxOAp1wnWDfOHT8GOc1ypsU0RR5E3z51AhG8Yf5jg= -github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= +github.com/onflow/crypto v0.25.0 h1:BeWbLsh3ZD13Ej+Uky6kg1PL1ZIVBDVX+2MVBNwqddg= +github.com/onflow/crypto v0.25.0/go.mod h1:C8FbaX0x8y+FxWjbkHy0Q4EASCDR9bSPWZqlpCLYyVI= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/rivo/uniseg v0.2.1-0.20211004051800-57c86be7915a h1:s7GrsqeorVkFR1vGmQ6WVL9nup0eyQCC+YVUeSQLH/Q= -github.com/rivo/uniseg v0.2.1-0.20211004051800-57c86be7915a/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rivo/uniseg v0.4.4 h1:8TfxU8dW6PdqD27gjM8MVNuicgxIjxpm4K7x4jp8sis= github.com/rivo/uniseg v0.4.4/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= @@ -60,12 +43,8 @@ github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/f github.com/rs/xid v1.3.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= github.com/rs/zerolog v1.26.1 h1:/ihwxqH+4z8UxyI70wM1z9yCvkWcfz/a3mj48k/Zngc= github.com/rs/zerolog v1.26.1/go.mod h1:/wSSJWX7lVrsOwlbyTRSOJvqRlc+WjWlfes+CiJ+tmc= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.4.0 h1:M2gUjqZET1qApGOWNSnZ49BAIMX4F/1plDv3+l31EJ4= -github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.3 h1:dAm0YRdRQlWojc3CrCRgPBzG5f941d0zvAKu7qY4e+I= -github.com/stretchr/testify v1.7.3/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/texttheater/golang-levenshtein/levenshtein v0.0.0-20200805054039-cae8b0eaed6c h1:HelZ2kAFadG0La9d+4htN4HzQ68Bm2iM9qKMSMES6xg= @@ -75,8 +54,9 @@ github.com/turbolent/prettier v0.0.0-20220320183459-661cc755135d/go.mod h1:Nlx5Y github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM= github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg= github.com/yuin/goldmark v1.4.0/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= -github.com/zeebo/assert v1.1.0 h1:hU1L1vLTHsnO8x8c9KAR5GmM5QscxHg5RNU5z5qbUWY= github.com/zeebo/assert v1.1.0/go.mod h1:Pq9JiuJQpG8JLJdtkwrJESF0Foym2/D9XMU5ciN/wJ0= +github.com/zeebo/assert v1.3.0 h1:g7C04CbJuIDKNPFHmsk4hwZDO5O+kntRxzaUoNXj+IQ= +github.com/zeebo/assert v1.3.0/go.mod h1:Pq9JiuJQpG8JLJdtkwrJESF0Foym2/D9XMU5ciN/wJ0= github.com/zeebo/blake3 v0.2.3 h1:TFoLXsjeXqRNFxSbk35Dk4YtszE/MQQGK10BH4ptoTg= github.com/zeebo/blake3 v0.2.3/go.mod h1:mjJjZpnsyIVtVgTOSpJ9vmRE4wgDeyt2HU3qXvvKCaQ= github.com/zeebo/pcg v1.0.1 h1:lyqfGeWiv4ahac6ttHs+I5hwtH/+1mrhlCtVNQM2kHo= @@ -84,18 +64,19 @@ github.com/zeebo/pcg v1.0.1/go.mod h1:09F0S9iiKrwn9rlI5yjLkmrug154/YRW6KnnXVDM/l go.opentelemetry.io/otel v1.8.0 h1:zcvBFizPbpa1q7FehvFiHbQwGzmPILebO0tyqIR5Djg= go.opentelemetry.io/otel v1.8.0/go.mod h1:2pkj+iMj0o03Y+cW6/m8Y4WkRdYN3AvCXCnzRMp9yvM= go.uber.org/goleak v1.1.10 h1:z+mqJhf6ss6BSfSM671tgKyZBFPTTJM+HLxnhPC3wu0= +go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20211215165025-cf75a172585e/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8= golang.org/x/crypto v0.1.0 h1:MDRAIl0xIo9Io2xV565hzXHw3zVseKrJKodhohM5CjU= golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw= -golang.org/x/exp v0.0.0-20221126150942-6ab00d035af9 h1:yZNXmy+j/JpX19vZkVktWqAo7Gny4PBWYYK3zskGpx4= -golang.org/x/exp v0.0.0-20221126150942-6ab00d035af9/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= golang.org/x/exp v0.0.0-20240103183307-be819d1f06fc h1:ao2WRsKSzW6KuUY9IWPwWahcHCgR0s52IfwutMfEbdM= golang.org/x/exp v0.0.0-20240103183307-be819d1f06fc/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= golang.org/x/lint v0.0.0-20200302205851-738671d3881b h1:Wh+f8QHJXR411sJR8/vRBTZ7YapZaRvUcLFFJhusH0k= +golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.6.0 h1:b9gGHsz9/HhJ3HF5DHQytPpuwocVTChQJK3AvoLRD5I= +golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0= +golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= @@ -108,10 +89,6 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.1.0 h1:kunALQeHf1/185U1i0GOB/fy1IPRDDpuoOOqRReG57U= -golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= @@ -123,15 +100,17 @@ golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.7/go.mod h1:LGqMHiF4EqQNHR1JncWGqT5BVaXmza+X+BDGol+dOxo= -golang.org/x/tools v0.2.0 h1:G6AHpWxTMGY1KyEYoAQ5WTtIekUUvDNjan3ugu60JvE= +golang.org/x/tools v0.16.0 h1:GO788SKMRunPIBCXiQyo2AaexLstOrVhuAL5YwsckQM= +golang.org/x/tools v0.16.0/go.mod h1:kYVVN6I1mBNoB1OX+noeBjbRk4IUEPa7JJ+TJMEooJ0= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +gonum.org/v1/gonum v0.6.1 h1:/LSrTrgZtpbXyAR6+0e152SROCkJJSh7goYWVmdPFGc= +gonum.org/v1/gonum v0.6.1/go.mod h1:9mxDZsDKxgMAuccQkewq682L+0eCu4dCN2yonUJTCLU= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -lukechampine.com/blake3 v1.1.7 h1:GgRMhmdsuK8+ii6UZFDL8Nb+VyMwadAgcJyfYHxG6n0= +lukechampine.com/blake3 v1.3.0 h1:sJ3XhFINmHSrYCgl958hscfIa3bw8x4DqMP3u1YvoYE= +lukechampine.com/blake3 v1.3.0/go.mod h1:0OFRp7fBtAylGVCO40o87sbupkyIGgbpv1+M1k1LM6k= From 2ee8c641e144700383ae6902c78c296c9166bb9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20M=C3=BCller?= Date: Fri, 18 Oct 2024 16:01:35 -0700 Subject: [PATCH 18/46] re-enable and update the Source Compatiblity Suite GitHub action --- .github/workflows/compat.yaml | 24 ++++++++++++++++++ .github/workflows/compat.yaml.disabled | 34 -------------------------- compat/main.py | 4 +-- compat/requirements.txt | 2 +- 4 files changed, 27 insertions(+), 37 deletions(-) create mode 100644 .github/workflows/compat.yaml delete mode 100644 .github/workflows/compat.yaml.disabled diff --git a/.github/workflows/compat.yaml b/.github/workflows/compat.yaml new file mode 100644 index 0000000000..ec22c71cf0 --- /dev/null +++ b/.github/workflows/compat.yaml @@ -0,0 +1,24 @@ +name: Source Compatibility Suite +on: + schedule: + - cron: '0 12 * * *' + workflow_dispatch: + inputs: + +jobs: + source-compat: + runs-on: ubuntu-latest + steps: + - name: Clone + uses: actions/checkout@v4 + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: '3.12' + cache: 'pip' + - name: Install dependencies + working-directory: compat + run: pip3 install -r requirements.txt + - name: Run + working-directory: compat + run: "python3 main.py" diff --git a/.github/workflows/compat.yaml.disabled b/.github/workflows/compat.yaml.disabled deleted file mode 100644 index 779ab60b88..0000000000 --- a/.github/workflows/compat.yaml.disabled +++ /dev/null @@ -1,34 +0,0 @@ -name: Source Compatibility Suite -on: - schedule: - - cron: '0 12 * * *' - workflow_dispatch: - inputs: - goTestRef: - - -jobs: - source-compat: - runs-on: ubuntu-20.04 - steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - uses: actions/setup-go@v2 - with: - go-version: '1.18.x' - - uses: actions/setup-python@v2 - with: - python-version: '3.x' - - uses: actions/cache@v1 - with: - path: ~/go/pkg/mod - key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-go- - - name: Install dependencies - working-directory: compat - run: pip3 install -r requirements.txt - - name: Check - working-directory: compat - run: "python3 main.py --format=pretty --check --go-test --go-test-ref=${{ github.event.inputs.goTestRef }}" diff --git a/compat/main.py b/compat/main.py index 9a973e9a80..999d451fbd 100644 --- a/compat/main.py +++ b/compat/main.py @@ -43,7 +43,7 @@ def run(self, working_dir: Path, prepare: bool, cadence_version: Optional[str], flowgo_replacement = f'github.com/onflow/flow-go@{flowgo_version}' else: # default: use the newest version of flow-go available - flowgo_replacement = f'github.com/onflow/flow-go@latest' + flowgo_replacement = 'github.com/onflow/flow-go@latest' with cwd(working_dir / self.path): if prepare: @@ -87,7 +87,7 @@ def from_dict(cls, data: Dict): def _clone(self, working_dir: Path): if working_dir.exists(): - for root, dirs, files in os.walk(working_dir): + for root, dirs, files in os.walk(working_dir): for dir in dirs: os.chmod(os.path.join(root, dir), stat.S_IRUSR | stat.S_IWUSR) for file in files: diff --git a/compat/requirements.txt b/compat/requirements.txt index 83eccf7636..f53480675e 100644 --- a/compat/requirements.txt +++ b/compat/requirements.txt @@ -1,5 +1,5 @@ click==7.1.2 coloredlogs==14.0 dacite==1.5.1 -PyYAML==5.4 +PyYAML>=6.0.1 typing-extensions==3.7.4.3 From e020579a8e4099b9ebfc3974333283ea31afb4b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20M=C3=BCller?= Date: Fri, 18 Oct 2024 16:06:14 -0700 Subject: [PATCH 19/46] update email addresses --- compat/suite/flow-core-contracts.yaml | 4 ++-- compat/suite/flow-ft.yaml | 4 ++-- compat/suite/flow-nft.yaml | 4 ++-- compat/suite/nba-smart-contracts.yaml | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/compat/suite/flow-core-contracts.yaml b/compat/suite/flow-core-contracts.yaml index 2b3cdcaa10..0be3807e9f 100644 --- a/compat/suite/flow-core-contracts.yaml +++ b/compat/suite/flow-core-contracts.yaml @@ -1,7 +1,7 @@ description: Flow Core Contracts maintainers: -- bastian@dapperlabs.com -- joshua.hannan@dapperlabs.com + - bastian.mueller@flowfoundation.org + - joshua.hannan@flowfoundation.org url: https://github.com/onflow/flow-core-contracts.git branch: master go_tests: diff --git a/compat/suite/flow-ft.yaml b/compat/suite/flow-ft.yaml index 3b872d692d..d0818d0b0b 100644 --- a/compat/suite/flow-ft.yaml +++ b/compat/suite/flow-ft.yaml @@ -1,7 +1,7 @@ description: Flow Fungible Token maintainers: -- bastian@dapperlabs.com -- joshua.hannan@dapperlabs.com + - bastian.mueller@flowfoundation.org + - joshua.hannan@flowfoundation.org url: https://github.com/onflow/flow-ft.git branch: master go_tests: diff --git a/compat/suite/flow-nft.yaml b/compat/suite/flow-nft.yaml index 958f72f5bb..eb57fb60df 100644 --- a/compat/suite/flow-nft.yaml +++ b/compat/suite/flow-nft.yaml @@ -1,7 +1,7 @@ description: Flow Non-Fungible Token maintainers: -- bastian@dapperlabs.com -- joshua.hannan@dapperlabs.com + - bastian.mueller@flowfoundation.org + - joshua.hannan@flowfoundation.org url: https://github.com/onflow/flow-nft.git branch: master go_tests: diff --git a/compat/suite/nba-smart-contracts.yaml b/compat/suite/nba-smart-contracts.yaml index 8e44b443f3..f0ec168994 100644 --- a/compat/suite/nba-smart-contracts.yaml +++ b/compat/suite/nba-smart-contracts.yaml @@ -1,7 +1,7 @@ description: NBA Top Shot maintainers: -- bastian@dapperlabs.com -- joshua.hannan@dapperlabs.com + - bastian.mueller@flowfoundation.org + - joshua.hannan@flowfoundation.org url: https://github.com/dapperlabs/nba-smart-contracts.git branch: master go_tests: From 4934d4ad464ab9c68d9d3aba646435b08b799156 Mon Sep 17 00:00:00 2001 From: turbolent Date: Mon, 21 Oct 2024 17:49:23 +0000 Subject: [PATCH 20/46] v1.2.0 --- npm-packages/cadence-parser/package.json | 2 +- version.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/npm-packages/cadence-parser/package.json b/npm-packages/cadence-parser/package.json index bce9c0aabf..3d91318063 100644 --- a/npm-packages/cadence-parser/package.json +++ b/npm-packages/cadence-parser/package.json @@ -1,6 +1,6 @@ { "name": "@onflow/cadence-parser", - "version": "1.1.0-preview.52", + "version": "1.2.0-preview.52", "description": "The Cadence parser", "homepage": "https://github.com/onflow/cadence", "repository": { diff --git a/version.go b/version.go index 27ab641f5d..3ebbeae8ff 100644 --- a/version.go +++ b/version.go @@ -21,4 +21,4 @@ package cadence -const Version = "v1.1.0" +const Version = "v1.2.0" From cfd6412917aee4a9d78265a8eccc935b7bb2daba Mon Sep 17 00:00:00 2001 From: Supun Setunga Date: Mon, 21 Oct 2024 10:56:58 -0700 Subject: [PATCH 21/46] Fix resolving crypto contract --- .../compatibility-check-template.yml | 2 +- Makefile | 21 +- tools/analysis/programs.go | 22 + .../cmd/check_contracts/main.go | 15 +- .../compatibility-check/contracts_checker.go | 20 +- .../contracts_checker_test.go | 44 +- tools/compatibility-check/go.mod | 73 +- tools/compatibility-check/go.sum | 647 ++++++++++++++++++ 8 files changed, 820 insertions(+), 24 deletions(-) diff --git a/.github/workflows/compatibility-check-template.yml b/.github/workflows/compatibility-check-template.yml index fc6845f3a5..7a35ddbf72 100644 --- a/.github/workflows/compatibility-check-template.yml +++ b/.github/workflows/compatibility-check-template.yml @@ -97,7 +97,7 @@ jobs: run: | GOPROXY=direct go mod edit -replace github.com/onflow/cadence=github.com/${{ inputs.repo }}@`git rev-parse origin/${{ inputs.base-branch }}` go mod tidy - go run ./cmd/check_contracts/main.go ../../tmp/contracts.csv ../../tmp/output-old.txt + go run ./cmd/check_contracts/main.go flow-${{ inputs.chain }} ../../tmp/contracts.csv ../../tmp/output-old.txt # Upload checking results for later use diff --git a/Makefile b/Makefile index e0914ca4e1..c14880b9f5 100644 --- a/Makefile +++ b/Makefile @@ -45,7 +45,7 @@ build: build-tools ./cmd/parse/parse ./cmd/parse/parse.wasm ./cmd/check/check ./ go build -o $@ ./cmd/main .PHONY: build-tools -build-tools: build-analysis build-get-contracts +build-tools: build-analysis build-get-contracts build-compatibility-check .PHONY: build-analysis build-analysis: @@ -55,6 +55,10 @@ build-analysis: build-get-contracts: (cd ./tools/get-contracts && go build .) +.PHONY: build-compatibility-check +build-compatibility-check: + (cd ./tools/compatibility-check && go build .) + .PHONY: ci ci: # test all packages @@ -65,9 +69,18 @@ ci: sed -i -e 's/^.* 0 0$$//' coverage.txt .PHONY: test -test: - # test all packages - go test -parallel 8 ./... +test: test-all-packages test-tools + +.PHONY: test-all-packages +test-all-packages: + (go test -parallel 8 ./...) + +.PHONY: test-tools +test-tools: + (cd ./tools/analysis && go test -parallel 8 ./) + (cd ./tools/compatibility-check && go test -parallel 8 ./) + (cd ./tools/constructorcheck && go test -parallel 8 ./) + (cd ./tools/maprange && go test -parallel 8 ./) .PHONY: lint-github-actions lint-github-actions: build-linter diff --git a/tools/analysis/programs.go b/tools/analysis/programs.go index 58599bb589..3c62a2d932 100644 --- a/tools/analysis/programs.go +++ b/tools/analysis/programs.go @@ -19,6 +19,7 @@ package analysis import ( + "fmt" "github.com/onflow/cadence/ast" "github.com/onflow/cadence/common" "github.com/onflow/cadence/parser" @@ -29,6 +30,7 @@ import ( type Programs struct { Programs map[common.Location]*Program CryptoContractElaboration *sema.Elaboration + CryptoContractLocation func() common.Location } type importResolutionResults map[common.Location]bool @@ -157,8 +159,28 @@ func (programs *Programs) check( switch importedLocation { case stdlib.CryptoContractLocation: + // If the elaboration for the crypto contract is available, take it. elaboration = programs.CryptoContractElaboration + if elaboration != nil { + break + } + + // Otherwise, if the location for the Crypto contract is provided, + // then resolve the source code from that location and continue as + // any other contract. + cryptoLocation := programs.CryptoContractLocation + if cryptoLocation == nil { + return nil, fmt.Errorf("cannot find crypto contract") + } + + importedLocation = cryptoLocation() + + // Memoize the crypto contract's elaboration, for subsequent uses. + defer func() { + programs.CryptoContractElaboration = elaboration + }() + fallthrough default: if seenImports[importedLocation] { return nil, &sema.CyclicImportsError{ diff --git a/tools/compatibility-check/cmd/check_contracts/main.go b/tools/compatibility-check/cmd/check_contracts/main.go index 4e472c2e00..ec6b008c41 100644 --- a/tools/compatibility-check/cmd/check_contracts/main.go +++ b/tools/compatibility-check/cmd/check_contracts/main.go @@ -24,16 +24,21 @@ import ( "github.com/rs/zerolog/log" "github.com/onflow/cadence/tools/compatibility_check" + + "github.com/onflow/flow-go/model/flow" ) func main() { - if len(os.Args) < 2 { - log.Error().Msg("not enough arguments. Usage: csv_path output_path") + if len(os.Args) < 3 { + log.Error().Msg("not enough arguments. Usage: ") return } - csvPath := os.Args[1] - outputPath := os.Args[2] + chainName := os.Args[1] + csvPath := os.Args[2] + outputPath := os.Args[3] + + chain := flow.ChainID(chainName).Chain() csvFile, err := os.Open(csvPath) if err != nil { @@ -53,6 +58,6 @@ func main() { _ = outputFile.Close() }() - checker := compatibility_check.NewContractChecker(outputFile) + checker := compatibility_check.NewContractChecker(chain, outputFile) checker.CheckCSV(csvFile) } diff --git a/tools/compatibility-check/contracts_checker.go b/tools/compatibility-check/contracts_checker.go index 6c5b2886d5..a531cf5ddd 100644 --- a/tools/compatibility-check/contracts_checker.go +++ b/tools/compatibility-check/contracts_checker.go @@ -31,20 +31,26 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/parser" "github.com/onflow/cadence/sema" + "github.com/onflow/cadence/stdlib" "github.com/onflow/cadence/tools/analysis" + + "github.com/onflow/flow-go/fvm/systemcontracts" + "github.com/onflow/flow-go/model/flow" ) const LoadMode = analysis.NeedTypes type ContractsChecker struct { + chain flow.Chain Codes map[common.Location][]byte outputWriter io.StringWriter } -func NewContractChecker(outputWriter io.StringWriter) *ContractsChecker { +func NewContractChecker(chain flow.Chain, outputWriter io.StringWriter) *ContractsChecker { checker := &ContractsChecker{ Codes: map[common.Location][]byte{}, outputWriter: outputWriter, + chain: chain, } return checker @@ -117,9 +123,17 @@ func (c *ContractsChecker) analyze( config *analysis.Config, locations []common.Location, ) { + + sc := systemcontracts.SystemContractsForChain(c.chain.ChainID()) + programs := analysis.Programs{ - Programs: make(map[common.Location]*analysis.Program, len(locations)), - CryptoContractElaboration: config.CryptoContractElaboration, + Programs: make(map[common.Location]*analysis.Program, len(locations)), + CryptoContractLocation: func() common.Location { + return common.AddressLocation{ + Address: common.Address(sc.Crypto.Address), + Name: string(stdlib.CryptoContractLocation), + } + }, } log.Println("Checking contracts ...") diff --git a/tools/compatibility-check/contracts_checker_test.go b/tools/compatibility-check/contracts_checker_test.go index 55d25d844a..5dfb44f9c7 100644 --- a/tools/compatibility-check/contracts_checker_test.go +++ b/tools/compatibility-check/contracts_checker_test.go @@ -20,17 +20,25 @@ package compatibility_check import ( "bytes" + "fmt" "testing" "github.com/stretchr/testify/assert" + + "github.com/onflow/flow-go/fvm/systemcontracts" + "github.com/onflow/flow-go/model/flow" ) func TestCyclicImport(t *testing.T) { + t.Parallel() + var output bytes.Buffer var input bytes.Buffer - checker := NewContractChecker(&output) + chain := flow.Testnet.Chain() + + checker := NewContractChecker(chain, &output) input.Write([]byte(`location,code A.0000000000000001.Foo,"import Bar from 0x0000000000000001 @@ -49,3 +57,37 @@ access(all) contract Foo {}" assert.Contains(t, outputStr, "Bar:16(1:16):*sema.ImportedProgramError") assert.Contains(t, outputStr, "Baz:16(1:16):*sema.ImportedProgramError") } + +func TestCryptoImport(t *testing.T) { + + t.Parallel() + + var output bytes.Buffer + var input bytes.Buffer + + chainID := flow.Testnet + + checker := NewContractChecker(chainID.Chain(), &output) + + sc := systemcontracts.SystemContractsForChain(chainID) + cryptoLocation := sc.Crypto.Location() + + contractsCSV := fmt.Sprintf( + `location,code +A.0000000000000001.Foo,"import Crypto +access(all) contract Foo {}" +%s,"access(all) contract Crypto {}" +A.0000000000000001.Bar,"import Crypto +access(all) contract Bar {}" +`, + cryptoLocation.ID(), + ) + + input.Write([]byte(contractsCSV)) + + checker.CheckCSV(&input) + + outputStr := output.String() + + assert.Empty(t, outputStr) +} diff --git a/tools/compatibility-check/go.mod b/tools/compatibility-check/go.mod index 2386e4033e..d811668cd8 100644 --- a/tools/compatibility-check/go.mod +++ b/tools/compatibility-check/go.mod @@ -3,33 +3,86 @@ module github.com/onflow/cadence/tools/compatibility_check go 1.22 require ( - github.com/onflow/cadence v1.0.1-0.20241017195911-152088fcbb15 - github.com/rs/zerolog v1.26.1 + github.com/onflow/cadence v1.1.1-0.20241018202510-7f1b6fbc57c2 + github.com/rs/zerolog v1.29.0 github.com/stretchr/testify v1.9.0 ) require ( github.com/SaveTheRbtz/mph v0.1.1-0.20240117162131-4166ec7869bc // indirect - github.com/bits-and-blooms/bitset v1.5.0 // indirect + github.com/bits-and-blooms/bitset v1.10.0 // indirect + github.com/btcsuite/btcd/btcec/v2 v2.3.4 // indirect + github.com/coreos/go-semver v0.3.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect + github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect + github.com/ethereum/go-ethereum v1.13.10 // indirect + github.com/fsnotify/fsnotify v1.6.0 // indirect github.com/fxamacker/cbor/v2 v2.4.1-0.20230228173756-c0c9f774e40c // indirect github.com/fxamacker/circlehash v0.3.0 // indirect - github.com/klauspost/cpuid/v2 v2.2.0 // indirect + github.com/golang/protobuf v1.5.4 // indirect + github.com/hashicorp/hcl v1.0.0 // indirect + github.com/holiman/uint256 v1.3.0 // indirect + github.com/inconshreveable/mousetrap v1.1.0 // indirect + github.com/ipfs/go-cid v0.4.1 // indirect + github.com/k0kubun/pp v3.0.1+incompatible // indirect + github.com/kevinburke/go-bindata v3.24.0+incompatible // indirect + github.com/klauspost/cpuid/v2 v2.2.6 // indirect + github.com/kr/pretty v0.3.1 // indirect + github.com/kr/text v0.2.0 // indirect github.com/logrusorgru/aurora/v4 v4.0.0 // indirect + github.com/magiconair/properties v1.8.7 // indirect + github.com/mattn/go-colorable v0.1.13 // indirect + github.com/mattn/go-isatty v0.0.20 // indirect + github.com/minio/sha256-simd v1.0.1 // indirect + github.com/mitchellh/mapstructure v1.5.0 // indirect + github.com/mr-tron/base58 v1.2.0 // indirect + github.com/multiformats/go-base32 v0.1.0 // indirect + github.com/multiformats/go-base36 v0.2.0 // indirect + github.com/multiformats/go-multibase v0.2.0 // indirect + github.com/multiformats/go-multihash v0.2.3 // indirect + github.com/multiformats/go-varint v0.0.7 // indirect github.com/onflow/atree v0.8.0 // indirect + github.com/onflow/crypto v0.25.2 // indirect + github.com/onflow/flow-core-contracts/lib/go/templates v1.3.3-0.20241017220455-79fdc6c8ba53 // indirect + github.com/onflow/flow-ft/lib/go/templates v1.0.1 // indirect + github.com/onflow/flow-go v0.38.0-preview.0.0.20241018215103-774056466e36 // indirect + github.com/onflow/flow-go-sdk v1.1.0 // indirect + github.com/onflow/flow-nft/lib/go/templates v1.2.1 // indirect + github.com/onflow/flow/protobuf/go/flow v0.4.7 // indirect + github.com/onflow/go-ethereum v1.14.7 // indirect + github.com/pelletier/go-toml/v2 v2.0.6 // indirect + github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/psiemens/sconfig v0.1.0 // indirect github.com/rivo/uniseg v0.4.4 // indirect + github.com/rogpeppe/go-internal v1.10.0 // indirect + github.com/spaolacci/murmur3 v1.1.0 // indirect + github.com/spf13/afero v1.10.0 // indirect + github.com/spf13/cast v1.5.0 // indirect + github.com/spf13/cobra v1.8.0 // indirect + github.com/spf13/jwalterweatherman v1.1.0 // indirect + github.com/spf13/pflag v1.0.5 // indirect + github.com/spf13/viper v1.15.0 // indirect + github.com/subosito/gotenv v1.4.2 // indirect github.com/texttheater/golang-levenshtein/levenshtein v0.0.0-20200805054039-cae8b0eaed6c // indirect github.com/turbolent/prettier v0.0.0-20220320183459-661cc755135d // indirect + github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect + github.com/vmihailenco/msgpack/v4 v4.3.11 // indirect + github.com/vmihailenco/tagparser v0.1.1 // indirect github.com/x448/float16 v0.8.4 // indirect github.com/zeebo/blake3 v0.2.3 // indirect - go.opentelemetry.io/otel v1.8.0 // indirect - golang.org/x/crypto v0.1.0 // indirect - golang.org/x/exp v0.0.0-20240103183307-be819d1f06fc // indirect - golang.org/x/sys v0.15.0 // indirect - golang.org/x/text v0.4.0 // indirect - golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect + go.opentelemetry.io/otel v1.24.0 // indirect + golang.org/x/crypto v0.26.0 // indirect + golang.org/x/exp v0.0.0-20240119083558-1b970713d09a // indirect + golang.org/x/sys v0.23.0 // indirect + golang.org/x/text v0.17.0 // indirect + golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect + gonum.org/v1/gonum v0.14.0 // indirect + google.golang.org/appengine v1.6.8 // indirect + google.golang.org/protobuf v1.33.0 // indirect + gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect + lukechampine.com/blake3 v1.3.0 // indirect ) replace github.com/onflow/cadence => ../../ diff --git a/tools/compatibility-check/go.sum b/tools/compatibility-check/go.sum index 7ce9a514aa..3c5fe3edeb 100644 --- a/tools/compatibility-check/go.sum +++ b/tools/compatibility-check/go.sum @@ -1,59 +1,373 @@ +cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= +cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU= +cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= +cloud.google.com/go v0.44.3/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= +cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc= +cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0= +cloud.google.com/go v0.50.0/go.mod h1:r9sluTvynVuxRIOHXQEHMFffphuXHOMZMycpNR5e6To= +cloud.google.com/go v0.52.0/go.mod h1:pXajvRH/6o3+F9jDHZWQ5PbGhn+o8w9qiu/CffaVdO4= +cloud.google.com/go v0.53.0/go.mod h1:fp/UouUEsRkN6ryDKNW/Upv/JBKnv6WDthjR6+vze6M= +cloud.google.com/go v0.54.0/go.mod h1:1rq2OEkV3YMf6n/9ZvGWI3GWw0VoqH/1x2nd8Is/bPc= +cloud.google.com/go v0.56.0/go.mod h1:jr7tqZxxKOVYizybht9+26Z/gUq7tiRzu+ACVAMbKVk= +cloud.google.com/go v0.57.0/go.mod h1:oXiQ6Rzq3RAkkY7N6t3TcE6jE+CIBBbA36lwQ1JyzZs= +cloud.google.com/go v0.62.0/go.mod h1:jmCYTdRCQuc1PHIIJ/maLInMho30T/Y0M4hTdTShOYc= +cloud.google.com/go v0.65.0/go.mod h1:O5N8zS7uWy9vkA9vayVHs65eM1ubvY4h553ofrNHObY= +cloud.google.com/go v0.72.0/go.mod h1:M+5Vjvlc2wnp6tjzE102Dw08nGShTscUx2nZMufOKPI= +cloud.google.com/go v0.74.0/go.mod h1:VV1xSbzvo+9QJOxLDaJfTjx5e+MePCpCWwvftOeQmWk= +cloud.google.com/go v0.75.0/go.mod h1:VGuuCn7PG0dwsd5XPVm2Mm3wlh3EL55/79EKB6hlPTY= +cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= +cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE= +cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc= +cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg= +cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc= +cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ= +cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= +cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= +cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= +cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw= +cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA= +cloud.google.com/go/pubsub v1.3.1/go.mod h1:i+ucay31+CNRpDW4Lu78I4xXG+O1r/MAHgjpRVR+TSU= +cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= +cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos= +cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk= +cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= +cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= +cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo= +dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= +github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/SaveTheRbtz/mph v0.1.1-0.20240117162131-4166ec7869bc h1:DCHzPQOcU/7gwDTWbFQZc5qHMPS1g0xTO56k8NXsv9M= github.com/SaveTheRbtz/mph v0.1.1-0.20240117162131-4166ec7869bc/go.mod h1:LJM5a3zcIJ/8TmZwlUczvROEJT8ntOdhdG9jjcR1B0I= +github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= +github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= +github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= +github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/bits-and-blooms/bitset v1.5.0 h1:NpE8frKRLGHIcEzkR+gZhiioW1+WbYV6fKwD6ZIpQT8= github.com/bits-and-blooms/bitset v1.5.0/go.mod h1:gIdJ4wp64HaoK2YrL1Q5/N7Y16edYb8uY+O0FJTyyDA= +github.com/bits-and-blooms/bitset v1.10.0 h1:ePXTeiPEazB5+opbv5fr8umg2R/1NlzgDsyepwsSr88= +github.com/bits-and-blooms/bitset v1.10.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8= +github.com/btcsuite/btcd/btcec/v2 v2.3.4 h1:3EJjcN70HCu/mwqlUsGK8GcNVyLVxFDlWurTXGPFfiQ= +github.com/btcsuite/btcd/btcec/v2 v2.3.4/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04= +github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= +github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= +github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= +github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= +github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= +github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= +github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= +github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= +github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= +github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= +github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= +github.com/coreos/go-semver v0.3.0 h1:wkHLiw0WNATZnSG7epLsujiMCgPAc9xhjJ4tgnAxmfM= +github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= +github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= +github.com/coreos/go-systemd/v22 v22.3.3-0.20220203105225-a9a7ef127534/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= +github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= +github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= +github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 h1:8UrgZ3GkP4i/CLijOJx79Yu+etlyjdBU4sfcs2WYQMs= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0= +github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= +github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= +github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= +github.com/envoyproxy/go-control-plane v0.9.7/go.mod h1:cwu0lG7PUMfa9snN8LXBig5ynNVH9qI8YYLbd1fK2po= +github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= +github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/ethereum/go-ethereum v1.13.10 h1:Ppdil79nN+Vc+mXfge0AuUgmKWuVv4eMqzoIVSdqZek= +github.com/ethereum/go-ethereum v1.13.10/go.mod h1:sc48XYQxCzH3fG9BcrXCOOgQk2JfZzNAmIKnceogzsA= +github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= +github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= +github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= github.com/fxamacker/cbor/v2 v2.4.1-0.20230228173756-c0c9f774e40c h1:5tm/Wbs9d9r+qZaUFXk59CWDD0+77PBqDREffYkyi5c= github.com/fxamacker/cbor/v2 v2.4.1-0.20230228173756-c0c9f774e40c/go.mod h1:TA1xS00nchWmaBnEIxPSE5oHLuJBAVvqrtAnWBwBCVo= github.com/fxamacker/circlehash v0.3.0 h1:XKdvTtIJV9t7DDUtsf0RIpC1OcxZtPbmgIH7ekx28WA= github.com/fxamacker/circlehash v0.3.0/go.mod h1:3aq3OfVvsWtkWMb6A1owjOQFA+TLsD5FgJflnaQwtMM= +github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= +github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= +github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= +github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= +github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= +github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= +github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= +github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= +github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= +github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= +github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= +github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= +github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= +github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= +github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= +github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk= +github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= +github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= +github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= +github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= +github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= +github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= +github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= +github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= +github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg= github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= +github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= +github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= +github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= +github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= +github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20201023163331-3e6fc7fc9c4c/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20201218002935-b9804c9f04c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= +github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= +github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= +github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g= +github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= +github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= +github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= +github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= +github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= +github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= +github.com/holiman/uint256 v1.3.0 h1:4wdcm/tnd0xXdu7iS3ruNvxkWwrb4aeBQv19ayYn8F4= +github.com/holiman/uint256 v1.3.0/go.mod h1:EOMSn4q6Nyt9P6efbI3bueV4e1b3dGlUCXeiRV4ng7E= +github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= +github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= +github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= +github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= +github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= +github.com/ipfs/go-cid v0.4.1 h1:A/T3qGvxi4kpKWWcPC/PgbvDA2bjVLO7n4UeVwnbs/s= +github.com/ipfs/go-cid v0.4.1/go.mod h1:uQHwDeX4c6CtyrFwdqyhpNcxVewur1M7l7fNU7LKwZk= +github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= +github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= +github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= +github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/k0kubun/pp v3.0.1+incompatible h1:3tqvf7QgUnZ5tXO6pNAZlrvHgl6DvifjDrd9g2S9Z40= github.com/k0kubun/pp v3.0.1+incompatible/go.mod h1:GWse8YhT0p8pT4ir3ZgBbfZild3tgzSScAn6HmfYukg= +github.com/kevinburke/go-bindata v3.24.0+incompatible h1:qajFA3D0pH94OTLU4zcCCKCDgR+Zr2cZK/RPJHDdFoY= +github.com/kevinburke/go-bindata v3.24.0+incompatible/go.mod h1:/pEEZ72flUW2p0yi30bslSp9YqD9pysLxunQDdb2CPM= +github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/cpuid/v2 v2.0.12/go.mod h1:g2LTdtYhdyuGPqyWyv7qRAmj1WBqxuObKfj5c0PQa7c= github.com/klauspost/cpuid/v2 v2.2.0 h1:4ZexSFt8agMNzNisrsilL6RClWDC5YJnLHNIfTy4iuc= github.com/klauspost/cpuid/v2 v2.2.0/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8tyFgg4nqhuY= +github.com/klauspost/cpuid/v2 v2.2.6 h1:ndNyv040zDGIDh8thGkXYjnFtiN02M1PVVF+JE/48xc= +github.com/klauspost/cpuid/v2 v2.2.6/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= +github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= +github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/leanovate/gopter v0.2.9 h1:fQjYxZaynp97ozCzfOyOuAGOU4aU/z37zf/tOujFk7c= github.com/leanovate/gopter v0.2.9/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2Sh+Jxxv8= github.com/logrusorgru/aurora/v4 v4.0.0 h1:sRjfPpun/63iADiSvGGjgA1cAYegEWMPCJdUpJYn9JA= github.com/logrusorgru/aurora/v4 v4.0.0/go.mod h1:lP0iIa2nrnT/qoFXcOZSrZQpJ1o6n2CUf/hyHi2Q4ZQ= +github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= +github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= +github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= +github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= +github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= +github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= +github.com/minio/sha256-simd v1.0.1 h1:6kaan5IFmwTNynnKKpDHe6FWHohJOHhCPchzK49dzMM= +github.com/minio/sha256-simd v1.0.1/go.mod h1:Pz6AKMiUdngCLpeTL/RJY1M9rUuPMYujV5xJjtbRSN8= +github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= +github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= +github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= +github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +github.com/mr-tron/base58 v1.2.0 h1:T/HDJBh4ZCPbU39/+c3rRvE0uKBQlU27+QI8LJ4t64o= +github.com/mr-tron/base58 v1.2.0/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc= +github.com/multiformats/go-base32 v0.1.0 h1:pVx9xoSPqEIQG8o+UbAe7DNi51oej1NtK+aGkbLYxPE= +github.com/multiformats/go-base32 v0.1.0/go.mod h1:Kj3tFY6zNr+ABYMqeUNeGvkIC/UYgtWibDcT0rExnbI= +github.com/multiformats/go-base36 v0.2.0 h1:lFsAbNOGeKtuKozrtBsAkSVhv1p9D0/qedU9rQyccr0= +github.com/multiformats/go-base36 v0.2.0/go.mod h1:qvnKE++v+2MWCfePClUEjE78Z7P2a1UV0xHgWc0hkp4= +github.com/multiformats/go-multibase v0.2.0 h1:isdYCVLvksgWlMW9OZRYJEa9pZETFivncJHmHnnd87g= +github.com/multiformats/go-multibase v0.2.0/go.mod h1:bFBZX4lKCA/2lyOFSAoKH5SS6oPyjtnzK/XTFDPkNuk= +github.com/multiformats/go-multihash v0.2.3 h1:7Lyc8XfX/IY2jWb/gI7JP+o7JEq9hOa7BFvVU9RSh+U= +github.com/multiformats/go-multihash v0.2.3/go.mod h1:dXgKXCXjBzdscBLk9JkjINiEsCKRVch90MdaGiKsvSM= +github.com/multiformats/go-varint v0.0.7 h1:sWSGR+f/eu5ABZA2ZpYKBILXTTs9JWpdEM/nEGOHFS8= +github.com/multiformats/go-varint v0.0.7/go.mod h1:r8PUYw/fD/SjBCiKOoDlGF6QawOELpZAu9eioSos/OU= +github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= +github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= github.com/onflow/atree v0.8.0 h1:qg5c6J1gVDNObughpEeWm8oxqhPGdEyGrda121GM4u0= github.com/onflow/atree v0.8.0/go.mod h1:yccR+LR7xc1Jdic0mrjocbHvUD7lnVvg8/Ct1AA5zBo= github.com/onflow/crypto v0.25.0 h1:BeWbLsh3ZD13Ej+Uky6kg1PL1ZIVBDVX+2MVBNwqddg= github.com/onflow/crypto v0.25.0/go.mod h1:C8FbaX0x8y+FxWjbkHy0Q4EASCDR9bSPWZqlpCLYyVI= +github.com/onflow/crypto v0.25.2 h1:GjHunqVt+vPcdqhxxhAXiMIF3YiLX7gTuTR5O+VG2ns= +github.com/onflow/crypto v0.25.2/go.mod h1:fY7eLqUdMKV8EGOw301unP8h7PvLVy8/6gVR++/g0BY= +github.com/onflow/flow v0.3.4 h1:FXUWVdYB90f/rjNcY0Owo30gL790tiYff9Pb/sycXYE= +github.com/onflow/flow-core-contracts/lib/go/templates v1.3.3-0.20241017220455-79fdc6c8ba53 h1:swCMX7k//QjHatAZ3URX4GhfUWmLc6S/tmaw2mS/0ZU= +github.com/onflow/flow-core-contracts/lib/go/templates v1.3.3-0.20241017220455-79fdc6c8ba53/go.mod h1:pN768Al/wLRlf3bwugv9TyxniqJxMu4sxnX9eQJam64= +github.com/onflow/flow-ft/lib/go/templates v1.0.1 h1:FDYKAiGowABtoMNusLuRCILIZDtVqJ/5tYI4VkF5zfM= +github.com/onflow/flow-ft/lib/go/templates v1.0.1/go.mod h1:uQ8XFqmMK2jxyBSVrmyuwdWjTEb+6zGjRYotfDJ5pAE= +github.com/onflow/flow-go v0.38.0-preview.0.0.20241018215103-774056466e36 h1:Bt7WUgRd3C3o93A9KL+cuLwxzrMgfpqKGxTTZF97RJY= +github.com/onflow/flow-go v0.38.0-preview.0.0.20241018215103-774056466e36/go.mod h1:ZWA2u8gALTYLl5L9M+2ylotWu90kfDmm5RnLNezew/c= +github.com/onflow/flow-go-sdk v1.1.0 h1:DT8P3B3oAicOOXugdev4s1IEKHsiLS9T7MovFcTzB2s= +github.com/onflow/flow-go-sdk v1.1.0/go.mod h1:21g1pqP9Wy8RBXdenNsjzADwbtWNOViUCnfNZwr3trM= +github.com/onflow/flow-nft/lib/go/templates v1.2.1 h1:SAALMZPDw9Eb9p5kSLnmnFxjyig1MLiT4JUlLp0/bSE= +github.com/onflow/flow-nft/lib/go/templates v1.2.1/go.mod h1:W6hOWU0xltPqNpv9gQX8Pj8Jtf0OmRxc1XX2V0kzJaI= +github.com/onflow/flow/protobuf/go/flow v0.4.7 h1:iP6DFx4wZ3ETORsyeqzHu7neFT3d1CXF6wdK+AOOjmc= +github.com/onflow/flow/protobuf/go/flow v0.4.7/go.mod h1:NA2pX2nw8zuaxfKphhKsk00kWLwfd+tv8mS23YXO4Sk= +github.com/onflow/go-ethereum v1.14.7 h1:gg3awYqI02e3AypRdpJKEvNTJ6kz/OhAqRti0h54Wlc= +github.com/onflow/go-ethereum v1.14.7/go.mod h1:zV14QLrXyYu5ucvcwHUA0r6UaqveqbXaehAVQJlSW+I= +github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= +github.com/pelletier/go-toml/v2 v2.0.6 h1:nrzqCb7j9cDFj2coyLNLaZuJTLjWjlaz6nvTvIwycIU= +github.com/pelletier/go-toml/v2 v2.0.6/go.mod h1:eumQOmlWiOPt5WriQQqoM5y18pDHwha2N+QD+EUNTek= +github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= +github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/sftp v1.13.1/go.mod h1:3HaPG6Dq1ILlpPZRO0HVMrsydcdLt6HRDccSgb87qRg= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= +github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso= +github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= +github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= +github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= +github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= +github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= +github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= +github.com/psiemens/sconfig v0.1.0 h1:xfWqW+TRpih7mXZIqKYTmpRhlZLQ1kbxV8EjllPv76s= +github.com/psiemens/sconfig v0.1.0/go.mod h1:+MLKqdledP/8G3rOBpknbLh0IclCf4WneJUtS26JB2U= github.com/rivo/uniseg v0.4.4 h1:8TfxU8dW6PdqD27gjM8MVNuicgxIjxpm4K7x4jp8sis= github.com/rivo/uniseg v0.4.4/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= +github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= +github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= +github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= +github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= github.com/rs/xid v1.3.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= +github.com/rs/xid v1.4.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= github.com/rs/zerolog v1.26.1 h1:/ihwxqH+4z8UxyI70wM1z9yCvkWcfz/a3mj48k/Zngc= github.com/rs/zerolog v1.26.1/go.mod h1:/wSSJWX7lVrsOwlbyTRSOJvqRlc+WjWlfes+CiJ+tmc= +github.com/rs/zerolog v1.29.0/go.mod h1:NILgTygv/Uej1ra5XxGf82ZFSLk58MFGAUS2o6usyD0= +github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= +github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= +github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= +github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= +github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI= +github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= +github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= +github.com/spf13/afero v1.10.0 h1:EaGW2JJh15aKOejeuJ+wpFSHnbd7GE6Wvp3TsNhb6LY= +github.com/spf13/afero v1.10.0/go.mod h1:UBogFpq8E9Hx+xc5CNTTEpTnuHVmXDwZcZcE1eb/UhQ= +github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= +github.com/spf13/cast v1.5.0 h1:rj3WzYc11XZaIZMPKmwP96zkFEnnAmV8s6XbB2aY32w= +github.com/spf13/cast v1.5.0/go.mod h1:SpXXQ5YoyJw6s3/6cMTQuxvgRl3PCJiyaX9p6b155UU= +github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU= +github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0= +github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho= +github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= +github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk= +github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo= +github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= +github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= +github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s= +github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= +github.com/spf13/viper v1.15.0 h1:js3yy885G8xwJa6iOISGFwd+qlUo5AvyXb7CiihdtiU= +github.com/spf13/viper v1.15.0/go.mod h1:fFcTBJxvhhzSJiZy8n+PeW6t8l+KeT/uTARa0jHOQLA= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/subosito/gotenv v1.4.2 h1:X1TuBLAMDFbaTAChgCBLu3DU3UPyELpnF2jjJ2cz/S8= +github.com/subosito/gotenv v1.4.2/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0= github.com/texttheater/golang-levenshtein/levenshtein v0.0.0-20200805054039-cae8b0eaed6c h1:HelZ2kAFadG0La9d+4htN4HzQ68Bm2iM9qKMSMES6xg= github.com/texttheater/golang-levenshtein/levenshtein v0.0.0-20200805054039-cae8b0eaed6c/go.mod h1:JlzghshsemAMDGZLytTFY8C1JQxQPhnatWqNwUXjggo= +github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/turbolent/prettier v0.0.0-20220320183459-661cc755135d h1:5JInRQbk5UBX8JfUvKh2oYTLMVwj3p6n+wapDDm7hko= github.com/turbolent/prettier v0.0.0-20220320183459-661cc755135d/go.mod h1:Nlx5Y115XQvNcIdIy7dZXaNSUpzwBSge4/Ivk93/Yog= +github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc= +github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= +github.com/vmihailenco/msgpack v4.0.4+incompatible h1:dSLoQfGFAo3F6OoNhwUmLwVgaUXK79GlxNBwueZn0xI= +github.com/vmihailenco/msgpack v4.0.4+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= +github.com/vmihailenco/msgpack/v4 v4.3.11 h1:Q47CePddpNGNhk4GCnAx9DDtASi2rasatE0cd26cZoE= +github.com/vmihailenco/msgpack/v4 v4.3.11/go.mod h1:gborTTJjAo/GWTqqRjrLCn9pgNN+NXzzngzBKDPIqw4= +github.com/vmihailenco/tagparser v0.1.1 h1:quXMXlA39OCbd2wAdTsGDlK9RkOk6Wuw+x37wVyIuWY= +github.com/vmihailenco/tagparser v0.1.1/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI= github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM= github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg= +github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= +github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= +github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.4.0/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= +github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= github.com/zeebo/assert v1.1.0/go.mod h1:Pq9JiuJQpG8JLJdtkwrJESF0Foym2/D9XMU5ciN/wJ0= github.com/zeebo/assert v1.3.0 h1:g7C04CbJuIDKNPFHmsk4hwZDO5O+kntRxzaUoNXj+IQ= github.com/zeebo/assert v1.3.0/go.mod h1:Pq9JiuJQpG8JLJdtkwrJESF0Foym2/D9XMU5ciN/wJ0= @@ -61,56 +375,389 @@ github.com/zeebo/blake3 v0.2.3 h1:TFoLXsjeXqRNFxSbk35Dk4YtszE/MQQGK10BH4ptoTg= github.com/zeebo/blake3 v0.2.3/go.mod h1:mjJjZpnsyIVtVgTOSpJ9vmRE4wgDeyt2HU3qXvvKCaQ= github.com/zeebo/pcg v1.0.1 h1:lyqfGeWiv4ahac6ttHs+I5hwtH/+1mrhlCtVNQM2kHo= github.com/zeebo/pcg v1.0.1/go.mod h1:09F0S9iiKrwn9rlI5yjLkmrug154/YRW6KnnXVDM/l4= +go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= +go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= +go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= +go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= +go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= +go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= +go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= go.opentelemetry.io/otel v1.8.0 h1:zcvBFizPbpa1q7FehvFiHbQwGzmPILebO0tyqIR5Djg= go.opentelemetry.io/otel v1.8.0/go.mod h1:2pkj+iMj0o03Y+cW6/m8Y4WkRdYN3AvCXCnzRMp9yvM= +go.opentelemetry.io/otel v1.24.0 h1:0LAOdjNmQeSTzGBzduGe/rU4tZhMwL5rWgtp9Ku5Jfo= +go.opentelemetry.io/otel v1.24.0/go.mod h1:W7b9Ozg4nkF5tWI5zsXkaKKDjdVjpD4oAt9Qi/MArHo= +go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/goleak v1.1.10 h1:z+mqJhf6ss6BSfSM671tgKyZBFPTTJM+HLxnhPC3wu0= go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A= +go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= +go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= +golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20211215165025-cf75a172585e/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8= +golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.1.0 h1:MDRAIl0xIo9Io2xV565hzXHw3zVseKrJKodhohM5CjU= golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw= +golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw= +golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54= +golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= +golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek= +golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= +golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= +golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= +golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= +golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= +golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= golang.org/x/exp v0.0.0-20240103183307-be819d1f06fc h1:ao2WRsKSzW6KuUY9IWPwWahcHCgR0s52IfwutMfEbdM= golang.org/x/exp v0.0.0-20240103183307-be819d1f06fc/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= +golang.org/x/exp v0.0.0-20240119083558-1b970713d09a h1:Q8/wZp0KX97QFTc2ywcOE0YRjZPVIx+MXInMzdvQqcA= +golang.org/x/exp v0.0.0-20240119083558-1b970713d09a/go.mod h1:idGWGoKP1toJGkd5/ig9ZLuPcZBC3ewk7SzmH0uou08= +golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= +golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= +golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= +golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs= +golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/lint v0.0.0-20200302205851-738671d3881b h1:Wh+f8QHJXR411sJR8/vRBTZ7YapZaRvUcLFFJhusH0k= golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= +golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= +golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= +golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= +golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= +golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= +golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= +golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= +golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0= golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= +golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20201031054903-ff519b6c9102/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20201209123823-ac852fbbde11/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20201109201403-9fd604954f58/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210104204734-6f8348627aad/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210225134936-a50acf3fe073/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.23.0 h1:YfKFowiIMvtgl1UERQoTPPToxltDeZfbj4H7dVUCwmM= +golang.org/x/sys v0.23.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= golang.org/x/text v0.4.0 h1:BrVqGRd7+k1DiOgtnFvAkoQEWQvBc25ouMJM6429SFg= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc= +golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= +golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200117161641-43d50277825c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200122220014-bf1340f18c4a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200204074204-1cc6d1ef6c74/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200224181240-023911ca70b2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200227222343-706bc42d1f0d/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= +golang.org/x/tools v0.0.0-20200312045724-11d5b4c81c7d/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= +golang.org/x/tools v0.0.0-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8= +golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200904185747-39188db58858/go.mod h1:Cj7w3i3Rnn0Xh82ur9kSqwfTHTeVxaDqrfMjpcNT6bE= +golang.org/x/tools v0.0.0-20201110124207-079ba7bd75cd/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20201201161351-ac6f37ff4c2a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20201208233053-a543418bbed2/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20210108195828-e2f9c7f1fc8e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= golang.org/x/tools v0.1.7/go.mod h1:LGqMHiF4EqQNHR1JncWGqT5BVaXmza+X+BDGol+dOxo= +golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.16.0 h1:GO788SKMRunPIBCXiQyo2AaexLstOrVhuAL5YwsckQM= golang.org/x/tools v0.16.0/go.mod h1:kYVVN6I1mBNoB1OX+noeBjbRk4IUEPa7JJ+TJMEooJ0= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 h1:+cNy6SZtPcJQH3LJVLOSmiC7MMxXNOb3PU/VUEz+EhU= +golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028/go.mod h1:NDW/Ps6MPRej6fsCIbMTohpP40sJ/P/vI1MoTEGwX90= gonum.org/v1/gonum v0.6.1 h1:/LSrTrgZtpbXyAR6+0e152SROCkJJSh7goYWVmdPFGc= gonum.org/v1/gonum v0.6.1/go.mod h1:9mxDZsDKxgMAuccQkewq682L+0eCu4dCN2yonUJTCLU= +gonum.org/v1/gonum v0.14.0 h1:2NiG67LD1tEH0D7kM+ps2V+fXmsAnpUeec7n8tcr4S0= +gonum.org/v1/gonum v0.14.0/go.mod h1:AoWeoz0becf9QMWtE8iWXNXc27fK4fNeHNf/oMejGfU= +google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= +google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= +google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= +google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= +google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= +google.golang.org/api v0.14.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= +google.golang.org/api v0.15.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= +google.golang.org/api v0.17.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.18.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.19.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.20.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.22.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= +google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= +google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM= +google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz5138Fc= +google.golang.org/api v0.35.0/go.mod h1:/XrVsuzM0rZmrsbjJutiuftIzeuTQcEeaYcSk/mQ1dg= +google.golang.org/api v0.36.0/go.mod h1:+z5ficQTmoYpPn8LCUNVpK5I7hwkpjbcgqA7I34qYtE= +google.golang.org/api v0.40.0/go.mod h1:fYKFpnQN0DsDSKRVRcQSDQNtqWPfM9i+zNPxepjRCQ8= +google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= +google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAsM= +google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds= +google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= +google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20191115194625-c23dd37a84c9/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20191216164720-4f79533eabd1/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20191230161307-f3c370f40bfb/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20200115191322-ca5a22157cba/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20200122232147-0452cf42e150/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20200204135345-fa8e72b47b90/go.mod h1:GmwEX6Z4W5gMy59cAlVYjN9JhxgbQH6Gn+gFDQe2lzA= +google.golang.org/genproto v0.0.0-20200212174721-66ed5ce911ce/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200228133532-8c2c7df3a383/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U= +google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= +google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA= +google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20200904004341-0bd0a958aa1d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20201109203340-2640f1f9cdfb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20201201144952-b05cb90ed32e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20201210142538-e3217bee35cc/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20201214200347-8c77b98c765d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20210108203827-ffc7fda8c3d7/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20210226172003-ab064af71705/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= +google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= +google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= +google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= +google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60= +google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= +google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= +google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= +google.golang.org/grpc v1.31.1/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= +google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= +google.golang.org/grpc v1.34.0/go.mod h1:WotjhfgOW/POjDeRt8vscBtXq+2VjORFy659qA51WJ8= +google.golang.org/grpc v1.35.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= +google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= +google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= +google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= +google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= +google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= +google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= +google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= +google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= +google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= +gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= +gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= +gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= +gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= +gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= +honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= +honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= lukechampine.com/blake3 v1.3.0 h1:sJ3XhFINmHSrYCgl958hscfIa3bw8x4DqMP3u1YvoYE= lukechampine.com/blake3 v1.3.0/go.mod h1:0OFRp7fBtAylGVCO40o87sbupkyIGgbpv1+M1k1LM6k= +rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= +rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= +rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= From 03908ced565f2816f3fe6fed6f20311d4fe8989d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20M=C3=BCller?= Date: Mon, 21 Oct 2024 13:16:05 -0700 Subject: [PATCH 22/46] resolve location of imported values --- runtime/contract_function_executor.go | 1 + runtime/convertValues.go | 32 ++++++++ runtime/environment.go | 26 ++++--- runtime/runtime.go | 2 + tests/convertValues_test.go | 107 ++++++++++++++++++++++++++ tests/deployment_test.go | 1 + tests/runtime_utils/location.go | 8 +- tests/runtime_utils/testinterface.go | 8 +- 8 files changed, 161 insertions(+), 24 deletions(-) diff --git a/runtime/contract_function_executor.go b/runtime/contract_function_executor.go index e7f3cc7e24..8ba0f49bf8 100644 --- a/runtime/contract_function_executor.go +++ b/runtime/contract_function_executor.go @@ -273,6 +273,7 @@ func (executor *interpreterContractFunctionExecutor) convertArgument( inter, locationRange, environment, + environment.ResolveLocation, argument, argumentType, ) diff --git a/runtime/convertValues.go b/runtime/convertValues.go index 99ddbf18c3..0de6e52513 100644 --- a/runtime/convertValues.go +++ b/runtime/convertValues.go @@ -20,9 +20,11 @@ package runtime import ( "math/big" + "strings" _ "unsafe" "github.com/onflow/cadence" + "github.com/onflow/cadence/ast" "github.com/onflow/cadence/common" "github.com/onflow/cadence/errors" "github.com/onflow/cadence/interpreter" @@ -792,6 +794,7 @@ type valueImporter struct { inter *interpreter.Interpreter locationRange interpreter.LocationRange standardLibraryHandler stdlib.StandardLibraryHandler + resolveLocation sema.LocationHandlerFunc } // ImportValue converts a Cadence value to a runtime value. @@ -799,6 +802,7 @@ func ImportValue( inter *interpreter.Interpreter, locationRange interpreter.LocationRange, standardLibraryHandler stdlib.StandardLibraryHandler, + resolveLocation sema.LocationHandlerFunc, value cadence.Value, expectedType sema.Type, ) (interpreter.Value, error) { @@ -806,6 +810,7 @@ func ImportValue( inter: inter, locationRange: locationRange, standardLibraryHandler: standardLibraryHandler, + resolveLocation: resolveLocation, }.importValue(value, expectedType) } @@ -1509,6 +1514,33 @@ func (i valueImporter) importCompositeValue( inter := i.inter locationRange := i.locationRange + // Resolve the location if it is not nil (not a built-in type) + + if location != nil { + resolveLocation := i.resolveLocation + if resolveLocation != nil { + + rootIdentifier := strings.SplitN(qualifiedIdentifier, ".", 2)[0] + + resolvedLocations, err := resolveLocation( + []ast.Identifier{{Identifier: rootIdentifier}}, + location, + ) + if err != nil { + return nil, err + } + + if len(resolvedLocations) != 1 { + return nil, errors.NewDefaultUserError( + "cannot import value of type %s: location resolution failed", + qualifiedIdentifier, + ) + } + + location = resolvedLocations[0].Location + } + } + typeID := common.NewTypeIDFromQualifiedName(inter, location, qualifiedIdentifier) compositeType, typeErr := inter.GetCompositeType(location, qualifiedIdentifier, typeID) if typeErr != nil { diff --git a/runtime/environment.go b/runtime/environment.go index ff71d25c08..9aff5b329d 100644 --- a/runtime/environment.go +++ b/runtime/environment.go @@ -76,6 +76,8 @@ type Environment interface { ) CommitStorage(inter *interpreter.Interpreter) error NewAccountValue(inter *interpreter.Interpreter, address interpreter.AddressValue) interpreter.Value + + ResolveLocation(identifiers []ast.Identifier, location common.Location) ([]ResolvedLocation, error) } // interpreterEnvironmentReconfigured is the portion of interpreterEnvironment @@ -206,7 +208,7 @@ func (e *interpreterEnvironment) newCheckerConfig() *sema.Config { BaseValueActivationHandler: e.getBaseValueActivation, BaseTypeActivationHandler: e.getBaseTypeActivation, ValidTopLevelDeclarationsHandler: validTopLevelDeclarations, - LocationHandler: e.newLocationHandler(), + LocationHandler: e.ResolveLocation, ImportHandler: e.resolveImport, CheckHandler: e.newCheckHandler(), AttachmentsEnabled: e.config.AttachmentsEnabled, @@ -644,16 +646,20 @@ func (e *interpreterEnvironment) check( return elaboration, nil } -func (e *interpreterEnvironment) newLocationHandler() sema.LocationHandlerFunc { - return func(identifiers []Identifier, location Location) (res []ResolvedLocation, err error) { - errors.WrapPanic(func() { - res, err = e.runtimeInterface.ResolveLocation(identifiers, location) - }) - if err != nil { - err = interpreter.WrappedExternalError(err) - } - return +func (e *interpreterEnvironment) ResolveLocation( + identifiers []Identifier, + location Location, +) ( + res []ResolvedLocation, + err error, +) { + errors.WrapPanic(func() { + res, err = e.runtimeInterface.ResolveLocation(identifiers, location) + }) + if err != nil { + err = interpreter.WrappedExternalError(err) } + return } func (e *interpreterEnvironment) newCheckHandler() sema.CheckHandlerFunc { diff --git a/runtime/runtime.go b/runtime/runtime.go index 1bb4254d84..e385f2c0c7 100644 --- a/runtime/runtime.go +++ b/runtime/runtime.go @@ -357,6 +357,7 @@ func UserPanicToError(f func()) (returnedError error) { type ArgumentDecoder interface { stdlib.StandardLibraryHandler + ResolveLocation(identifiers []ast.Identifier, location common.Location) ([]ResolvedLocation, error) // DecodeArgument decodes a transaction/script argument against the given type. DecodeArgument(argument []byte, argumentType cadence.Type) (cadence.Value, error) @@ -414,6 +415,7 @@ func validateArgumentParams( inter, locationRange, decoder, + decoder.ResolveLocation, value, parameterType, ) diff --git a/tests/convertValues_test.go b/tests/convertValues_test.go index bbe37f6b3d..1ad217ad69 100644 --- a/tests/convertValues_test.go +++ b/tests/convertValues_test.go @@ -28,6 +28,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence" + "github.com/onflow/cadence/ast" "github.com/onflow/cadence/common" "github.com/onflow/cadence/encoding/json" "github.com/onflow/cadence/errors" @@ -628,6 +629,7 @@ func TestRuntimeImportValue(t *testing.T) { inter, interpreter.EmptyLocationRange, nil, + nil, tt.value, tt.expectedType, ) @@ -1367,6 +1369,7 @@ func TestImportInclusiveRangeValue(t *testing.T) { inter, interpreter.EmptyLocationRange, nil, + nil, value, sema.NewInclusiveRangeType(inter, sema.IntType), ) @@ -1401,6 +1404,7 @@ func TestImportInclusiveRangeValue(t *testing.T) { inter, interpreter.EmptyLocationRange, nil, + nil, value, sema.AnyStructType, ) @@ -1435,6 +1439,7 @@ func TestImportInclusiveRangeValue(t *testing.T) { inter, interpreter.EmptyLocationRange, nil, + nil, value, sema.AnyStructType, ) @@ -1465,6 +1470,7 @@ func TestImportInclusiveRangeValue(t *testing.T) { inter, interpreter.EmptyLocationRange, nil, + nil, value, sema.StringType, ) @@ -3489,6 +3495,7 @@ func TestRuntimeImportExportArrayValue(t *testing.T) { inter, interpreter.EmptyLocationRange, nil, + nil, value, sema.ByteArrayType, ) @@ -3559,6 +3566,7 @@ func TestRuntimeImportExportArrayValue(t *testing.T) { inter, interpreter.EmptyLocationRange, nil, + nil, value, &sema.VariableSizedType{ Type: sema.AnyStructType, @@ -3604,6 +3612,7 @@ func TestRuntimeImportExportArrayValue(t *testing.T) { inter, interpreter.EmptyLocationRange, nil, + nil, value, sema.AnyStructType, ) @@ -3693,6 +3702,7 @@ func TestRuntimeImportExportDictionaryValue(t *testing.T) { inter, interpreter.EmptyLocationRange, nil, + nil, value, &sema.DictionaryType{ KeyType: sema.StringType, @@ -3779,6 +3789,7 @@ func TestRuntimeImportExportDictionaryValue(t *testing.T) { inter, interpreter.EmptyLocationRange, nil, + nil, value, &sema.DictionaryType{ KeyType: sema.StringType, @@ -3843,6 +3854,7 @@ func TestRuntimeImportExportDictionaryValue(t *testing.T) { inter, interpreter.EmptyLocationRange, nil, + nil, value, sema.AnyStructType, ) @@ -3910,6 +3922,7 @@ func TestRuntimeImportExportDictionaryValue(t *testing.T) { inter, interpreter.EmptyLocationRange, nil, + nil, dictionaryWithHeterogenousKeys, sema.AnyStructType, ) @@ -5023,6 +5036,7 @@ func TestRuntimeImportExportComplex(t *testing.T) { inter, interpreter.EmptyLocationRange, nil, + nil, externalCompositeValue, semaCompositeType, ) @@ -5552,3 +5566,96 @@ func TestRuntimeExportInterfaceType(t *testing.T) { require.ErrorAs(t, err, &invalidReturnType) }) } +func TestRuntimeImportResolvedLocation(t *testing.T) { + + t.Parallel() + + addressLocation := common.AddressLocation{ + Address: common.MustBytesToAddress([]byte{42}), + Name: "Test", + } + + identifierLocation := common.IdentifierLocation("Test") + + storage := NewUnmeteredInMemoryStorage() + + program := &interpreter.Program{ + Elaboration: sema.NewElaboration(nil), + } + + inter, err := interpreter.NewInterpreter( + program, + addressLocation, + &interpreter.Config{ + Storage: storage, + AtreeValueValidationEnabled: true, + AtreeStorageValidationEnabled: true, + }, + ) + require.NoError(t, err) + + semaCompositeType := &sema.CompositeType{ + Location: addressLocation, + Identifier: "Foo", + Kind: common.CompositeKindStructure, + Members: &sema.StringMemberOrderedMap{}, + } + + program.Elaboration.SetCompositeType( + semaCompositeType.ID(), + semaCompositeType, + ) + + externalCompositeType := cadence.NewStructType( + identifierLocation, + "Foo", + []cadence.Field{}, + nil, + ) + + externalCompositeValue := cadence.NewStruct(nil). + WithType(externalCompositeType) + + resolveLocation := func( + identifiers []ast.Identifier, + location common.Location, + ) ([]sema.ResolvedLocation, error) { + require.Equal(t, identifierLocation, location) + + location = addressLocation + + return []sema.ResolvedLocation{ + { + Location: location, + Identifiers: identifiers, + }, + }, nil + } + + actual, err := ImportValue( + inter, + interpreter.EmptyLocationRange, + nil, + resolveLocation, + externalCompositeValue, + semaCompositeType, + ) + require.NoError(t, err) + + internalCompositeValue := interpreter.NewCompositeValue( + inter, + interpreter.EmptyLocationRange, + addressLocation, + "Foo", + common.CompositeKindStructure, + nil, + common.ZeroAddress, + ) + + AssertValuesEqual( + t, + inter, + internalCompositeValue, + actual, + ) +} diff --git a/tests/deployment_test.go b/tests/deployment_test.go index daa8845812..475cceb86f 100644 --- a/tests/deployment_test.go +++ b/tests/deployment_test.go @@ -71,6 +71,7 @@ func TestRuntimeTransactionWithContractDeployment(t *testing.T) { inter, interpreter.EmptyLocationRange, nil, + nil, codeHashValue, stdlib.HashType, ) diff --git a/tests/runtime_utils/location.go b/tests/runtime_utils/location.go index 8ae9b3614e..f9528eb4f6 100644 --- a/tests/runtime_utils/location.go +++ b/tests/runtime_utils/location.go @@ -49,13 +49,7 @@ func NewScriptLocationGenerator() func() common.ScriptLocation { return NewLocationGenerator[common.ScriptLocation]() } -func NewSingleIdentifierLocationResolver(t testing.TB) func( - identifiers []runtime.Identifier, - location runtime.Location, -) ( - []runtime.ResolvedLocation, - error, -) { +func NewSingleIdentifierLocationResolver(t testing.TB) sema.LocationHandlerFunc { return func( identifiers []runtime.Identifier, location runtime.Location, diff --git a/tests/runtime_utils/testinterface.go b/tests/runtime_utils/testinterface.go index afb24d97ca..9b3b8199e3 100644 --- a/tests/runtime_utils/testinterface.go +++ b/tests/runtime_utils/testinterface.go @@ -40,13 +40,7 @@ import ( type TestRuntimeInterface struct { Storage TestLedger - OnResolveLocation func( - identifiers []runtime.Identifier, - location runtime.Location, - ) ( - []runtime.ResolvedLocation, - error, - ) + OnResolveLocation sema.LocationHandlerFunc OnGetCode func(_ runtime.Location) ([]byte, error) OnGetAndSetProgram func( location runtime.Location, From 8408a3f0fdcb744c18f31fe883e07f312ea4964c Mon Sep 17 00:00:00 2001 From: Supun Setunga Date: Mon, 21 Oct 2024 14:13:38 -0700 Subject: [PATCH 23/46] Temporarily provide source code for Cypto contract --- tools/analysis/programs.go | 1 + tools/compatibility-check/contracts_checker.go | 15 +++++++++++---- .../compatibility-check/contracts_checker_test.go | 13 ++----------- tools/compatibility-check/go.mod | 3 +++ tools/compatibility-check/go.sum | 6 ++++++ 5 files changed, 23 insertions(+), 15 deletions(-) diff --git a/tools/analysis/programs.go b/tools/analysis/programs.go index 3c62a2d932..1ebf557961 100644 --- a/tools/analysis/programs.go +++ b/tools/analysis/programs.go @@ -20,6 +20,7 @@ package analysis import ( "fmt" + "github.com/onflow/cadence/ast" "github.com/onflow/cadence/common" "github.com/onflow/cadence/parser" diff --git a/tools/compatibility-check/contracts_checker.go b/tools/compatibility-check/contracts_checker.go index a531cf5ddd..887cb02a0c 100644 --- a/tools/compatibility-check/contracts_checker.go +++ b/tools/compatibility-check/contracts_checker.go @@ -36,6 +36,8 @@ import ( "github.com/onflow/flow-go/fvm/systemcontracts" "github.com/onflow/flow-go/model/flow" + + "github.com/onflow/flow-core-contracts/lib/go/contracts" ) const LoadMode = analysis.NeedTypes @@ -126,13 +128,18 @@ func (c *ContractsChecker) analyze( sc := systemcontracts.SystemContractsForChain(c.chain.ChainID()) + cryptoContractLocation := common.AddressLocation{ + Address: common.Address(sc.Crypto.Address), + Name: string(stdlib.CryptoContractLocation), + } + + // TODO: Remove once the Crypto contract is available on-chain. + c.Codes[cryptoContractLocation] = contracts.Crypto() + programs := analysis.Programs{ Programs: make(map[common.Location]*analysis.Program, len(locations)), CryptoContractLocation: func() common.Location { - return common.AddressLocation{ - Address: common.Address(sc.Crypto.Address), - Name: string(stdlib.CryptoContractLocation), - } + return cryptoContractLocation }, } diff --git a/tools/compatibility-check/contracts_checker_test.go b/tools/compatibility-check/contracts_checker_test.go index 5dfb44f9c7..bef2e761f7 100644 --- a/tools/compatibility-check/contracts_checker_test.go +++ b/tools/compatibility-check/contracts_checker_test.go @@ -20,12 +20,10 @@ package compatibility_check import ( "bytes" - "fmt" "testing" "github.com/stretchr/testify/assert" - "github.com/onflow/flow-go/fvm/systemcontracts" "github.com/onflow/flow-go/model/flow" ) @@ -69,19 +67,12 @@ func TestCryptoImport(t *testing.T) { checker := NewContractChecker(chainID.Chain(), &output) - sc := systemcontracts.SystemContractsForChain(chainID) - cryptoLocation := sc.Crypto.Location() - - contractsCSV := fmt.Sprintf( - `location,code + contractsCSV := `location,code A.0000000000000001.Foo,"import Crypto access(all) contract Foo {}" -%s,"access(all) contract Crypto {}" A.0000000000000001.Bar,"import Crypto access(all) contract Bar {}" -`, - cryptoLocation.ID(), - ) +` input.Write([]byte(contractsCSV)) diff --git a/tools/compatibility-check/go.mod b/tools/compatibility-check/go.mod index d811668cd8..44484aee7a 100644 --- a/tools/compatibility-check/go.mod +++ b/tools/compatibility-check/go.mod @@ -43,10 +43,13 @@ require ( github.com/multiformats/go-varint v0.0.7 // indirect github.com/onflow/atree v0.8.0 // indirect github.com/onflow/crypto v0.25.2 // indirect + github.com/onflow/flow-core-contracts/lib/go/contracts v1.4.0 // indirect github.com/onflow/flow-core-contracts/lib/go/templates v1.3.3-0.20241017220455-79fdc6c8ba53 // indirect + github.com/onflow/flow-ft/lib/go/contracts v1.0.1 // indirect github.com/onflow/flow-ft/lib/go/templates v1.0.1 // indirect github.com/onflow/flow-go v0.38.0-preview.0.0.20241018215103-774056466e36 // indirect github.com/onflow/flow-go-sdk v1.1.0 // indirect + github.com/onflow/flow-nft/lib/go/contracts v1.2.2 // indirect github.com/onflow/flow-nft/lib/go/templates v1.2.1 // indirect github.com/onflow/flow/protobuf/go/flow v0.4.7 // indirect github.com/onflow/go-ethereum v1.14.7 // indirect diff --git a/tools/compatibility-check/go.sum b/tools/compatibility-check/go.sum index 3c5fe3edeb..ee2555e618 100644 --- a/tools/compatibility-check/go.sum +++ b/tools/compatibility-check/go.sum @@ -253,14 +253,20 @@ github.com/onflow/crypto v0.25.0/go.mod h1:C8FbaX0x8y+FxWjbkHy0Q4EASCDR9bSPWZqlp github.com/onflow/crypto v0.25.2 h1:GjHunqVt+vPcdqhxxhAXiMIF3YiLX7gTuTR5O+VG2ns= github.com/onflow/crypto v0.25.2/go.mod h1:fY7eLqUdMKV8EGOw301unP8h7PvLVy8/6gVR++/g0BY= github.com/onflow/flow v0.3.4 h1:FXUWVdYB90f/rjNcY0Owo30gL790tiYff9Pb/sycXYE= +github.com/onflow/flow-core-contracts/lib/go/contracts v1.4.0 h1:R86HaOuk6vpuECZnriEUE7bw9inC2AtdSn8lL/iwQLQ= +github.com/onflow/flow-core-contracts/lib/go/contracts v1.4.0/go.mod h1:9asTBnB6Tw2UlVVtQKyS/egYv3xr4zVlJnJ75z1dfac= github.com/onflow/flow-core-contracts/lib/go/templates v1.3.3-0.20241017220455-79fdc6c8ba53 h1:swCMX7k//QjHatAZ3URX4GhfUWmLc6S/tmaw2mS/0ZU= github.com/onflow/flow-core-contracts/lib/go/templates v1.3.3-0.20241017220455-79fdc6c8ba53/go.mod h1:pN768Al/wLRlf3bwugv9TyxniqJxMu4sxnX9eQJam64= +github.com/onflow/flow-ft/lib/go/contracts v1.0.1 h1:Ts5ob+CoCY2EjEd0W6vdLJ7hLL3SsEftzXG2JlmSe24= +github.com/onflow/flow-ft/lib/go/contracts v1.0.1/go.mod h1:PwsL8fC81cjnUnTfmyL/HOIyHnyaw/JA474Wfj2tl6A= github.com/onflow/flow-ft/lib/go/templates v1.0.1 h1:FDYKAiGowABtoMNusLuRCILIZDtVqJ/5tYI4VkF5zfM= github.com/onflow/flow-ft/lib/go/templates v1.0.1/go.mod h1:uQ8XFqmMK2jxyBSVrmyuwdWjTEb+6zGjRYotfDJ5pAE= github.com/onflow/flow-go v0.38.0-preview.0.0.20241018215103-774056466e36 h1:Bt7WUgRd3C3o93A9KL+cuLwxzrMgfpqKGxTTZF97RJY= github.com/onflow/flow-go v0.38.0-preview.0.0.20241018215103-774056466e36/go.mod h1:ZWA2u8gALTYLl5L9M+2ylotWu90kfDmm5RnLNezew/c= github.com/onflow/flow-go-sdk v1.1.0 h1:DT8P3B3oAicOOXugdev4s1IEKHsiLS9T7MovFcTzB2s= github.com/onflow/flow-go-sdk v1.1.0/go.mod h1:21g1pqP9Wy8RBXdenNsjzADwbtWNOViUCnfNZwr3trM= +github.com/onflow/flow-nft/lib/go/contracts v1.2.2 h1:XFERNVUDGbZ4ViZjt7P1cGD80mO1PzUJYPfdhXFsGbQ= +github.com/onflow/flow-nft/lib/go/contracts v1.2.2/go.mod h1:eZ9VMMNfCq0ho6kV25xJn1kXeCfxnkhj3MwF3ed08gY= github.com/onflow/flow-nft/lib/go/templates v1.2.1 h1:SAALMZPDw9Eb9p5kSLnmnFxjyig1MLiT4JUlLp0/bSE= github.com/onflow/flow-nft/lib/go/templates v1.2.1/go.mod h1:W6hOWU0xltPqNpv9gQX8Pj8Jtf0OmRxc1XX2V0kzJaI= github.com/onflow/flow/protobuf/go/flow v0.4.7 h1:iP6DFx4wZ3ETORsyeqzHu7neFT3d1CXF6wdK+AOOjmc= From 237ddb7fc92c7fb386c21886a0a79e6f38610033 Mon Sep 17 00:00:00 2001 From: Supun Setunga Date: Mon, 21 Oct 2024 14:27:59 -0700 Subject: [PATCH 24/46] Pass chain-id as argument --- .github/workflows/compatibility-check-template.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/compatibility-check-template.yml b/.github/workflows/compatibility-check-template.yml index 7a35ddbf72..3a6b1c1130 100644 --- a/.github/workflows/compatibility-check-template.yml +++ b/.github/workflows/compatibility-check-template.yml @@ -88,7 +88,7 @@ jobs: run: | GOPROXY=direct go mod edit -replace github.com/onflow/cadence=github.com/${{ inputs.repo }}@${{ inputs.current-branch }} go mod tidy - go run ./cmd/check_contracts/main.go ../../tmp/contracts.csv ../../tmp/output-new.txt + go run ./cmd/check_contracts/main.go flow-${{ inputs.chain }} ../../tmp/contracts.csv ../../tmp/output-new.txt # Check contracts using base branch From 3002f18406df00b75e4cef6f641be2af7c42d6d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20M=C3=BCller?= Date: Mon, 21 Oct 2024 14:39:45 -0700 Subject: [PATCH 25/46] remove meeting notes --- meetings/2022-07-22.md | 106 ------- meetings/2022-08-30.md | 93 ------ meetings/2022-09-13.md | 214 -------------- meetings/2022-09-20-Extensions.md | 57 ---- meetings/2022-09-26 Capabilities.md | 151 ---------- meetings/2022-09-27.md | 118 -------- meetings/2022-10-11.md | 170 ----------- meetings/2022-11-02.md | 227 --------------- meetings/2022-11-16-Interface-Inheritance.md | 32 -- meetings/2023-01-10.md | 169 ----------- meetings/2023-02-23.md | 171 ----------- meetings/2023-04-13.md | 291 ------------------- meetings/2023-05-04.md | 167 ----------- meetings/2023-06-15.md | 274 ----------------- meetings/2023-08-15.md | 167 ----------- meetings/2023-09-12.md | 185 ------------ meetings/2023-10-24.md | 277 ------------------ meetings/2023-11-15.md | 120 -------- meetings/README.md | 3 + 19 files changed, 3 insertions(+), 2989 deletions(-) delete mode 100644 meetings/2022-07-22.md delete mode 100644 meetings/2022-08-30.md delete mode 100644 meetings/2022-09-13.md delete mode 100644 meetings/2022-09-20-Extensions.md delete mode 100644 meetings/2022-09-26 Capabilities.md delete mode 100644 meetings/2022-09-27.md delete mode 100644 meetings/2022-10-11.md delete mode 100644 meetings/2022-11-02.md delete mode 100644 meetings/2022-11-16-Interface-Inheritance.md delete mode 100644 meetings/2023-01-10.md delete mode 100644 meetings/2023-02-23.md delete mode 100644 meetings/2023-04-13.md delete mode 100644 meetings/2023-05-04.md delete mode 100644 meetings/2023-06-15.md delete mode 100644 meetings/2023-08-15.md delete mode 100644 meetings/2023-09-12.md delete mode 100644 meetings/2023-10-24.md delete mode 100644 meetings/2023-11-15.md create mode 100644 meetings/README.md diff --git a/meetings/2022-07-22.md b/meetings/2022-07-22.md deleted file mode 100644 index 85e76f7dd2..0000000000 --- a/meetings/2022-07-22.md +++ /dev/null @@ -1,106 +0,0 @@ - -# July 22, 2022 - -## External Mutability - -- FLIP that prevents external mutation was approved, implemented, and released in Secure Cadence: - [https://github.com/onflow/flow/pull/703](https://github.com/onflow/flow/pull/703) -- Open problems: - - Composites were not covered by the FLIP, only arrays and dictionaries - - Externally taking a reference to a field can circumvent the external mutability restriction -- New FLIP: [https://github.com/onflow/flow/pull/1056](https://github.com/onflow/flow/pull/1056) - - Purity/mutability modifier for functions - - Automatic analysis to determine if function has side-effects - -## Condition can currently have side effects -- https://github.com/onflow/cadence/issues/1805 -- Might be used for underhanded code: Post-condition might perform mutation. Example: FT withdrawal -- Might be solved by purity FLIP -- Can a pure function emit events? - - Does affect on-chain state, but is not observable -- Are other side-effecting functons like debugging logging allowed? -- "Pure" vs "no side-effects" - - "Pure" usually means no side-effects at all - - Have to be pragmatic -- Alternatives: - - Prevent calls in general - - Run-time errors if there are side-effects - -## Remove deprecated key API -- We currently have two key management APIs: - - `AuthAccount.addPublicKey`/`AuthAccount.removePublicKey`: - - Low-level, accepts encoded key as byte array - - Deprecated a year ago - - [`AuthAccount.keys.add`](https://docs.onflow.org/cadence/language/accounts/#add-account-keys)/`AuthAccount.keys.remove` - - High-level, accepts key as object (`PublicKey`) - - Added a year ago -- We attempted to remove the deprecated in the Secure Cadence release - - Rolled back, as it will break client applications if they use SDK which uses deprecated API -- Also: Events that are emitted when a key is added is inconsistent, depends on which API is used: https://github.com/onflow/cadence/issues/1796 -- Do we have metrics on how many SDKs are still using the deprecated API? -- Actionables: - - Add deprecation annotation to developer tooling - - Pragma, e.g. `#deprecated` - - Comment, e.g. `@deprecated` - - Add support in VS Code, render as ~~addPublicKey~~ - -## Interface default methods -- https://github.com/onflow/cadence/pull/1076 -- Proposed for NFT metadata standard -- Helps with preventing breakage in ecosystem -- Avoid copy/paste and boilerplate, making code reusable -- Does not help with FT/NFT rewrite proposal -- Useful for utility/convenience functions, reducing boilerplate -- Open Questions: - - Security implications? - - Related: - - Post-conditions with side-effects - - Mutability - - Restrict to pure functions? Potentially too restrictive, e.g. couldn’t provide - - Maybe allow opt out of mutating functions. But could also be used to opt-out of a fix - - Examples? - - Trust relationship problem - - Already have this problem with contract updates - - Modification of default implementation - - Would be useful to provide utility functions, like FT transfer - - It should not be possible to perform malicious code, as the same could be done in a non-default function -- Not a breaking change, could merge and ship before Stable Cadence -- When there is a conflict, e.g multiple interfaces provide default implementation: - - No "winner" is selected by default - - Instead, the user is required to provide an implementation -- Follow up feature: Interface requirements - - Declaration site: `CI1: CI2` - - Use-site would still have to explicitly declare conformance for all interfaces: `C: CI1, CI2` - -## Storage Querying/Iteration API -- https://github.com/onflow/cadence/issues/208 -- Finally added technical foundation a couple months ago: - Account storage data is now stored in [atree](https://github.com/onflow/atree) values - (atree is Cadence's storage layer) -- Issue lays out proposal for adding API to iterate over account paths/values -- Outstanding issues: - - Accounts may store a lot of data. Pagination iteration? Iterator, cursor, enumerator - - Concrete API proposal -- First use-case: Developer tools like the Emulator and Playground -- Need to show wallet developers how they can render information to users -- Mutability not necessarily a problem: Run script against block. - - Problem: data availability - - Might be solved in future by "historic" data node -- Storage Layer: - - Iteration over dictionary changes when mutated - - Keys are hashed -- Start with MVP -- Stages: - - 1. Even useful if pagination problem is not solved yet - - 2. Pagination for larger accounts - - 3. Support for handling mutation -- Also useful for e.g. dictionary, keys. Might be too large - - Keys on demand - - E.g. useful to pick a random key - -## Organisational - -- Should we move this meeting so it is not on a Friday evening for folks in Europe? - - Not Friday, not Monday - - Tuesday is best - - Same time (8am PT) diff --git a/meetings/2022-08-30.md b/meetings/2022-08-30.md deleted file mode 100644 index 1a4f9e22e2..0000000000 --- a/meetings/2022-08-30.md +++ /dev/null @@ -1,93 +0,0 @@ -# August 30, 2022 - -* We discussed the currently open FLIPs - -* **Remove public resource fields:** - * https://github.com/onflow/flow/pull/739 - * Status: - - No consensus - * Open problems: - - None - * Next steps: - - Ask author (Dete) - -* **Capability Controllers:** - * https://github.com/onflow/flow/pull/798 - * Status: - * More API discussions (delegation, revocation) - * Exploring how to make APIs/use-casess simpler to use/understand - * Sentiment: proposal OK, but also want to cover more use-cases - * Maybe split proposal? At least gather use-cases, maybe propose functionality in separate FLIP(s) - * Next steps: - * Meeting - * Finish use-case gathering - * Open problems: - * Should capabilities be resources? Agreement they should be values - * Relation to extensibility proposal → some use-cases could be covered by extensibility ([FLIP 1101](https://github.com/onflow/flow/pull/1101)) - * It would be great to have account identity (-> [FLIP 945](https://github.com/onflow/flow/pull/945)), do not have to be storable, only needs to prove - * Cons: tied to identity, not transferable between accounts owned by same person - * Alternative (?): wrapping/unwrapping (pattern instead of new language feature) - * Alternative (?): sharing using account - -* **Add identity to AuthAccount:** - * https://github.com/onflow/flow/pull/945 - * Status: - * Maybe not needed if capability controllers proposal gets added (?) - * Missing use-case / documentation - * Many cons, alternatives exist → need to be added to FLIP - * Next steps: - * Add cons to proposal - * Extend article with why identity resource is not a good alternative - * Promote safe patterns for identity/access control - * Open problems: - * "Too easy" to use instead of capabilities introduces a footgun. -But: just another tool for access control, useful for certain use-cases, still recommend capabilities - * Possible to pass on identity, potentially a malicious program pretends it has access - * But also *not* providing identity will cause developers to create their own potential unsafe. Cannot prevent it - * Alternative: instead of passing identity around, code wraps value for target, target has secret unwrapper - -* **Purity/mutability analysis:** - * https://github.com/onflow/flow/pull/1056 - * Status: - * Simplified original proposal - * Consensus - * Next steps: - * Merge PRs into feature branch, let people try it out - * Make decision on FLIP - * Notes: - * `pure` was changed to `view`, like in Solidity - * Open problems: - * None - -* **Extensibility:** - * https://github.com/onflow/flow/pull/1101 - * Status: - * Many open problems - * Unclear definition of problem - * Next steps: - * Meeting - * Clearly defining use-case / features - * Open problems: - * Current proposal has many open questions / edge cases - * Unclear what features should be provided by proposal - -* **Add fields during contract update:** - * https://github.com/onflow/flow/pull/1097 - * Status: - * Good start - * Need to answer outstanding questions - * Overall agreement, probably gets approved/implemented once details figured out - * Next steps: - * Meeting - * Open problems: - * Migration - * Field removal - * Syntax - -* **Invalidate references to transferred resources:** - * https://github.com/onflow/flow/pull/1043 - * Status: - * Paused discussion on this, hoped to have [FLIP 1056](https://github.com/onflow/flow/pull/1056) solve this - * Need to increase priority - * Open problems: - * ? diff --git a/meetings/2022-09-13.md b/meetings/2022-09-13.md deleted file mode 100644 index 6eb70b6fc4..0000000000 --- a/meetings/2022-09-13.md +++ /dev/null @@ -1,214 +0,0 @@ - -# Sept 13, 2022 - -## FLIPs - -* **Capability Controllers:** - * [https://github.com/onflow/flow/pull/798](https://github.com/onflow/flow/pull/798) - * Status: Scoping - * Open problems: - * What parts should be part of this FLIP? - * What should rather go in follow-up proposal(s)? - * How to provide better and easier to understand API? - * Next steps: - * At least define replacement for current API - * Solve bootstrapping problem in separate FLIP - * Meeting - -* **Add identity to AuthAccount:** - * [https://github.com/onflow/flow/pull/945](https://github.com/onflow/flow/pull/945) - * Status: Closed, replaced by capability publish/claim FLIP 1122 - -* **Publish and Claim Capabilities** - * [https://github.com/onflow/flow/pull/1122](https://github.com/onflow/flow/pull/1122) - * Purpose: Capability bootstrapping. Replacement for FLIP 945 - * Status: New, just published - * Open problems: - * Only for capabilities or anything? - * Off-chain or on-chain inspection? - * Next steps: Clarify/resolve open problems - -* **Extensibility**(see below) - * [https://github.com/onflow/flow/pull/1101](https://github.com/onflow/flow/pull/1101) - * Status: Impass, unclear scope/direction - * Open problems: - * Two different proposals with different pros/cons -(boxing/wrapping vs containment) - * Next steps: - * Meeting - -* **Add fields during contract update:** - * [https://github.com/onflow/flow/pull/1097](https://github.com/onflow/flow/pull/1097) - * Status: No update - * Open problems: - * Implementation details for migration (not impossible, just needs to be laid out) - * Next steps: - * Meeting - -* **Invalidate references to transferred resources:** - * [https://github.com/onflow/flow/pull/1043](https://github.com/onflow/flow/pull/1043) - * Status: - * Agreement for need - * Prototype implementation in progress - * Open problems: - * Concerns - * Next steps: - * Complete prototype - * Analyze impact - -* **Borrow Contract** - * [https://github.com/onflow/flow/pull/1071](https://github.com/onflow/flow/pull/1071) - * Status: - * Complete - * Needs minor edits - * Reference implementation in progress - * Open problems: - * Concern that static analysis is not possible anymore resolved: - * Already have run-time imports of contracts - * Concern for program cache invalidation: - * Implementation detail, not a concern, functionality basically already available - * Next steps: - * Needs approval/rejection - -* **Remove public resource fields:** - * [https://github.com/onflow/flow/pull/739](https://github.com/onflow/flow/pull/739) - * Status: No progress - * Open problems: None - * Next steps: Dete - -* **Purity/mutability analysis:** - * [https://github.com/onflow/flow/pull/1056](https://github.com/onflow/flow/pull/1056) - * Status: Accepted 🎉 - -## Extensions - -* [https://github.com/onflow/cadence/issues/357](https://github.com/onflow/cadence/issues/357) -* Context - * Long-requested feature: Add functionality and data to existing types, after the fact, without work from author of type. Controlled by user - * Prior community effort: [https://forum.onflow.org/t/extensibility/622](https://forum.onflow.org/t/extensibility/622) -* Open Questions: - * What are the use-cases that should be covered? - * Do we need to add support for extending fields? - * This significantly complicates extensions by requiring them to define new (or partial) initializers for their new data - * How limiting would it be to restrict extensions to be used only one at a time? - * Otherwise we need to consider how to handle extensions with overlapping data/methods. In other languages this is simple but in Cadence two extensions that define the same type but use it differently would be a security issue - * How can the same type interact with differently extended versions of itself? Can a CryptoKitty with a hat be used in places where only a CryptoKitty is expected? Can a CryptoKitty with a hat and a scarf be used as if it only had a scarf? - -## Account Storage Delta (hash) - -* [https://github.com/onflow/cadence/issues/1777](https://github.com/onflow/cadence/issues/1777) - -* Determine change on-chain was as expected - -* Accessible on-chain - -* Dry run: run transaction as script, get hash - -* Run transaction, ensure hash in post-condition - -* Related to iteration: detect invalidation due to mutation - -* Hash should be cheap, needs to be cheaper than comparison - -* Feedback: - - * Storage changes are not immediately effective, serialization is lazy -(end of transaction) - - * But: storageUsed materializes cache - - * Potential problem: more modifications after transaction end - - * Hash of what? Full account? All accounts? Just part of an account’s storage? - - * Can we use state proofs? - -* Next steps: - - * Ping FVM team - - * Atree/State trie additions? Ask Ramtin, Faye - - * Keep discussion in Github issue, determine details - - * → propose FLIP once clear how to implement - -## Prevent re-entrancy attacks - -* [https://github.com/onflow/cadence/issues/1543](https://github.com/onflow/cadence/issues/1543) - -* Large topic, low priority relative to other issues - -* Many different options - * Explicit vs implicit - * Granularity: whole type vs individual fields - * Static vs dynamic guarantees - -* Problems: - * Learning curve - * Ideally no-brainer or very easy to use - -* Ideas: - * Rust/Ocaml ref-cells - * Make cross-contract calls promises / asynchronous - * Async prepares for sharding in future - * Examples: Swift’s new actor system, Agoric, etc. - * JS developers still try to understand promises - * Does not handle all cases - * Implicit / hidden - -## Extend character set of identifier part in paths - -* [https://github.com/onflow/cadence/issues/419](https://github.com/onflow/cadence/issues/419) -* Allowing dots is parsing problems (conflict with field access) - -## Alternative to paths: Resolver functions - -* Not addressing by path, but by type (used to have this early on) -* What if multiple elements for one type? Array? Identifier? -* Resolver function for a type/name pair. E.g. FT + "default" -* For / instead of public domain -* Relation to capability controllers: - * Gets rid of private paths, not paths in general - * Could make use of this feature - -* Next steps: - * What use-cases/problems does this solve? - * Comparison to existing system - * Pros/cons - -## Initialization problem - -* Context - * How to ensure proper setup? e.g. linking, initialization of storage - * Lost+Found - -* Problem: - * Have bits and pieces - * No concrete full solution - -* Related: - * New FT + NFT standards have built-in info, collection data metadata - * Specific to FT/NFT, not a general solution - * Assumes collection is already stored - * "Transaction/interaction templates" proposal - * Setup (e.g. FT vault) + interactions (e.g. FT transfer) - -* Cadence-specific ideas: - * Scoped access to storage (e.g. by path) - * Related to granular capabilities for AuthAccount - -* Next steps: - * Create issue, not a FLIP yet - -## Error messages of assert/pre/post are eagerly evaulated - -* [https://github.com/onflow/cadence/issues/1838](https://github.com/onflow/cadence/issues/1838) - -* Should go into Stable Cadence - -* Encourage error messages - -* Workaround create custom wrapper: -assert(true, message: lazyMessage: ((): String)?) - diff --git a/meetings/2022-09-20-Extensions.md b/meetings/2022-09-20-Extensions.md deleted file mode 100644 index 9e3fed4df9..0000000000 --- a/meetings/2022-09-20-Extensions.md +++ /dev/null @@ -1,57 +0,0 @@ -# Extensions Meeting Notes - -FLIP: https://github.com/onflow/flow/pull/1101 - -## Two Paradigms -### Statically Checked -* Multiple different people could have the same extensions that do the same thing -* What if someone deletes the contract defining an extension? -### Dynamically Enforced -* Extensions would function like a “sub-resource”, method lookup would first happen on the extension, then fall back to the parent - - -# Discussion -* Microplatforms that can be extended - * Allow people to add features/functionality to their code without changing it, as this is the primary paradigm of smart contract development - * Better for composability - * People who add functionality should not be able to break the rules originally encoded into the base object - * This paradigm benefits from thinking about extensions as an attachment rather than a wrapper; this is independent of whether or not we have a static representation - * Owner of the resource **must** have control over what extensions are attached to the resource - -* Are these two proposals even that different? - * Static version may be the same as the dynamic version just with added static typing -* Should it be possible to override the behavior of the base resource? - * Potential to be dangerous, but also potential to be very powerful - * E.g. Vault that does automatic currency conversion - * This could also be done by just creating a different type that wraps a Vault (e.g. implementing Provider and Receiver), rather than extending the Vault type - * Assumption up to this point has been: extension can add new functionality but cannot change any old functionality - * Extended version of a type is no longer an instance of the old type, which makes overriding the old type safe - * Explicit casting -* Metadata - * Metadata should reflect the extensions that are present on the type, rather than only showing the base resource -* Extension adds method that is later added by the base resource - * What happens here? - * In static model, the extension’s method would need to be removed - * Could also require users to be explicit about which type (base or extension) they wish to use the method from (static dispatch) - * Type.foo(instance) - * Cadence’s flavor is more Pythonic than this very C++/Rust solution? Syntax is fundamentally different to what Cadence currently uses - * Could also have the composed version default to the extension’s method and must be casted to the base type to use the base type’s method - * Including the self pointer inside the definition of the extension itself - * Or super keyword for extensions to refer to its base type -* Benefit of extensions over a purely compositional model is extensions have information about what base type an extension is attached to (e.g. via a self pointer) -* Signature extensions should not be removable and attachable to another resource - * But it would make sense for a hat to be removable and given to another kitty - * Need to allow extensions to decide whether they can be transferable or not -* Having extensions be their own resources/NFTs that can be traded is a nice feature if it’s easy, but is not necessary - * Extension could just be a manager for a resource type, rather than the extension being the resource itself -* Object and its extensions should be independent types that can define conflicting methods - * E.g. metadata case - * Need some method to go from extension to base and vice versa - * While you have the extension, you only have access to those methods, and while you have the base you only have access to its methods - * Extension has a reference to its parent? - * Like trait objects in Rust -* Is this still extensions? Current proposal feels more like “attachments” rather than an extension of the base type -* Not the same as a dictionary of owned resources on the parent type - * Must have a backpointer from attachment to parent - * Use cases where the attachment should not be transferable - * For transferable cases, the attachment can be a manager that handles the resources, rather than the resource itself diff --git a/meetings/2022-09-26 Capabilities.md b/meetings/2022-09-26 Capabilities.md deleted file mode 100644 index 1babde82b0..0000000000 --- a/meetings/2022-09-26 Capabilities.md +++ /dev/null @@ -1,151 +0,0 @@ - -# Capabilities Meeting Notes - -## Capability bootstrapping proposal - -* FLIP: https://github.com/onflow/flow/pull/1122 - -* Publishing capabilities - -* Last problem: Spam - - * Off-chain or on-chain (events, iteration API) - - * Quantity - - * Message could be harassment - - * Ideas: - - * Maybe no default/built-in/system event, but a custom event? - - * Not concern of protocol, but level above: - - * Allow/Ignore-list in user agent (e.g wallet software) - - * User agent could default to everything, but have harassment/filtering feature - - * Events are for making systems aware of on-chain state changes - - * Warning in documentation: - - * Events should not be presented as-is to user - - * Having no events will result in user agents to repeatedly pull - - * Block explorer shows everything (today; could be extended, just like a user agent like a wallet) - - * Capabilities only? - - * Arbitrary publishing will result in avoiding capabilities - - * Should only be used to bridge to capabilities world - - * → design API so it can be extended to allow resources in the future in a backwards-compatible way - - * → only publish / claim / unpublish - - * Claim: - - * Event? - - * → Emit: - - * Not much harm - - * Useful in typical user agent (dashboard) - - * Need for reacting stays - - * Don’t emit: - - * Why? - - * Removal/unpublish? - - * Don’t remove: - - * No harm in staying - - * Removing seems implicit - - * Receiver may rely on cap existing in publisher - - * → Remove: - - * Optimize for standard case - - * No need to constantly clean up - - * Mailbox analogy: someone shows up and claims → gone, no further action required by publisher - - * Forces receiver to "move" the capability to their account - - * → Need good documentation with examples - - * E.g. Claim cap, get resource, store resource, throw away cap - - * Related: event API needs filtering and pagination - - * Concern: Capabilities can be copied - -## Capability Controllers - -* FLIP: https://github.com/onflow/flow/pull/798 - -* Revocation problem example (admin interface) - -* Capability creation only in publisher’s account? - -* Admins should be able to undo, even each others’ decisions - -* Not a problem of the language / API (should make it possible, something else can make it easier); capabilities API should be as simple (basic?) as possible - -* Problems can mostly be solved with (better) attenuation - -* Need delegation without changing type - -* Attenuation allows custom code → security issues? - -* Use cases for both concrete type and interface - -* Tags? - -* Mapping of names to IDs in contract? - -* Use own name for capability. Does it require re-lookup based on ID? - -* Keep reference count? - -* Remove retarget? - - * Security issue: retarget after check - - * Can only retarget to same type - - * Safety footgun - - * Problematic in two-step process - - * But always a problem - - * Examples: - - * Caps on interfaces, don’t care about concrete type, care about functionality - - * Concrete vault vs e.g pooling/split abstraction - -* Remove restore? - -* Struct, but non-storable - -* Don’t return status flags. Either idempotent or panic - -* → Attenuation out of scope - -* → Example for delegation - -* → Example for cap petnames - -* → Default function petname should be default → easy to add later, move ahead without - diff --git a/meetings/2022-09-27.md b/meetings/2022-09-27.md deleted file mode 100644 index 3cd8d2c2f4..0000000000 --- a/meetings/2022-09-27.md +++ /dev/null @@ -1,118 +0,0 @@ -# Sept 27, 2022 - -## FLIPs - -* **Capability Controllers:** - * https://github.com/onflow/flow/pull/798 - * Status: had meeting; scope clear, API design - * Open problems: - * None, mainly just API design - * Next steps: - * Move forward with API details - -* **Publish and Claim Capabilities** - * https://github.com/onflow/flow/pull/1122 - * Status: meeting resolved outstanding questions - * Open problems: - * None for FLIP, but related: might need improve event API - * Next steps: - * Have a final look - -* **Extensibility** - * https://github.com/onflow/flow/pull/1101 - * Status: Had meeting, still unclear what approach is best - * Open problems: - * Problem with extensions approach: changes in extension and extended type break code - * Use case: metadata - * Alternative: attachment-style proposal; requires iteration - * Next steps: - * Alternative FLIP for attachments - * Compare with existing extensions FLIP - * Pick one or find compromise - -* **Add fields during contract update** - * https://github.com/onflow/flow/pull/1097 - * Status: No update - * Open problems: - * Implementation details for migration (not impossible, just needs to be laid out) - * Next steps: - * Call? - -* **Invalidate references to transferred resources:** - * https://github.com/onflow/flow/pull/1043 - * Status: - * Agreement for need - * Prototype implementation: https://github.com/onflow/cadence/pull/1999 - * Agreement that any transfer (even stack-to-stack) invalidates - * Open problems: - * https://github.com/onflow/flow/pull/1043#issuecomment-1258742270 - * Maybe use stack depth check? - * Next steps: - * Analyze impact: analysis pass (also useful for breaking change analysis; hard to check) - * Note: this is about ephemeral references (lifetime of a transaction/script), not capabilities - -* **Borrow Contract** - * https://github.com/onflow/flow/pull/1071 - * Status: - * Complete - * Needs minor edits - * Have reference implementation: https://github.com/onflow/cadence/pull/1934 - * Open problems: - * Concern that static analysis is not possible anymore resolved, already have run-time imports of contracts - * Concern for cache invalidation - implementation detail, not a concern, functionality basically already available - * Next steps: - * Needs approval/rejection - -## Contract removal -* Was available until Secure Cadence release -* Problem: Removal + addition allows circumventing updatability checks - * E.g. change field type, change type kind, etc. -* Currently disabled, as it is unclear how to implement this safely -* Options: - * Don't have removal - * Revocation / tombstoning - * Keep old contract information and treat addition as update -* Unavailability of removal - * Hinders development of utility contracts - * Unable to clean up account storage -* Removal of contracts/types might leads to breakage -* Removal useful for "temporary" types, e.g. for capability attenuation - * Idea: Marking contracts as "public"/"internal"/"beta", cannot be shared/stored/etc -* It would be nice to have and expose instance count for types, allow removal if no instances - -## Scoped AuthAccounts / Account initialization -* https://github.com/onflow/flow/issues/1131 -* Solve the account initialization problem -* E.g. marketplace needs to know how to prepare user account -* Responsibility of initialization should be on dapp, not user agent - * However, power user might want to control where e.g. collection is stored, might have multiple - * Normally user does not care, wants "default". Still, user agent (wallet software) should take care, not contract -* Actors: user, asset creator, application developer - * Asset creator and application developer often tied together - * However, application developer might not be asset creator (e.g. marketplace) -* User should be in control, not asset creator or application developer. Might use user agent. Asset creator might propose requirements so it can function -* Analogy: User data vs system files (Installer asks where program should be installed) -* Scoped AuthAccount is basically attenuated AuthAccount -* Related (alternatives?): - * Bjarte's FLIP: https://github.com/onflow/flow/pull/748 - * Transaction interaction templates - * NFT catalog - * Return initialization information - * NFT Metadata: [https://github.com/onflow/flow-nft/blob/9877dccbd884e06bbd754a4f693b7169dd6dd62b/contracts/MetadataViews.cdc#L480-L537](https://github.com/onflow/flow-nft/blob/9877dccbd884e06bbd754a4f693b7169dd6dd62b/contracts/MetadataViews.cdc#L480-L537) - * New NFT feature: [https://github.com/onflow/flow-nft/pull/126#discussion_r981328645](https://github.com/onflow/flow-nft/pull/126#discussion_r981328645) - * Declaration in prepare block (?) - * Pass box which captures initialization - * Enforce limitation in type system (e.g. AuthAccount restricted to just storage, only certain path, only write, etc.) -* Approach axes: - * Limiting vs checking after the fact - * Imperative vs declarative -* Next steps: - * Agreement on responsibility, formalize - * Find solution that aligns - * Meeting with people involved with existing solutions - * Who? Dete, Austin (after 7th), Bjarte (other FLIP), Amit (NFT catalog, NFT Collection Metadata), Jeff (interaction templates) -* Additional discussion points from Amit: - * Fixing existing account links that have it wrong (and gracefully with an account that has it wrong). Currently its unlink -> link - * [Metadata views] aren't very useful on-chain because you have to make custom templated transactions regardless in order to make these links because we lack a way to link at runtime (see https://github.com/onflow/cadence/issues/1617) - * Having a way to allow a contract owner to be more prescriptive about what setup should be done (maybe past a single public link like the view provides). - diff --git a/meetings/2022-10-11.md b/meetings/2022-10-11.md deleted file mode 100644 index 278cb1e919..0000000000 --- a/meetings/2022-10-11.md +++ /dev/null @@ -1,170 +0,0 @@ -# Oct 11, 2022 - -## FLIPs - -### Capability Controllers - -* [https://github.com/onflow/flow/pull/798](https://github.com/onflow/flow/pull/798) -* Status: - * Ready for approval - * Hardest problem was bootstrapping, solved by publish/claim - * Want to potentially explore backward compatibility -* Open problems: - * Could emulate proposal / or existing API - * How to have both at the same time -* Next steps: - * Determine backward compatibility - * Other than that, ready to move to decision, mostly agreement - * Could maybe consider adjust proposal to allow for backward-compatibility - -### Extensibility - -* [https://github.com/onflow/flow/pull/1101](https://github.com/onflow/flow/pull/1101) -* [https://forum.onflow.org/t/flip-cadence-extensions-attachments/3645/2](https://forum.onflow.org/t/flip-cadence-extensions-attachments/3645/2) -* Status: - * Alternatively: [Attachments FLIP](https://github.com/onflow/flips/pull/11) - * FLIP discussions now in forum: [https://forum.onflow.org/t/flip-cadence-extensions-attachments/3645](https://forum.onflow.org/t/flip-cadence-extensions-attachments/3645) - * More dynamic, little static typing - * Benefits: - * Not prone to breakage on contract updates - * Disadvantages: - * Less ergonomic, less powerful -* Open problems: - * None (?) in both -* Next steps: - * Review/compare two FLIPs, make decisions on what matters - * Both doable, static slightly more work - * Most important is UX/use-cases for developers - * Attachments proposal matches more closely use-cases (?) - * Static guarantees / implicitness better - * Extensions proposal provides more static guarantees - * Extension can statically state requirements (type) - * Often more, dynamic requirements - * Can restrict which code can create instances - * Usually instantiation is unrestricted, it’s acceptance which is limited - * Openness VS security foot-gun - * Prefer openness - * Extensions more powerful, but also more complex - * Attachments simpler, covers less use-cases, but more common one - -### Add fields during contract update - -* [https://github.com/onflow/flow/pull/1097](https://github.com/onflow/flow/pull/1097) -* Status: No update -* Open problems: - * Implementation details for migration (not impossible, just needs to be laid out) -* Next steps: - * Call? - -### Invalidate references to transferred resources - -* [https://github.com/onflow/flow/pull/1043](https://github.com/onflow/flow/pull/1043) -* Status: - * Ready for decision - * Implementation mostly ready ([https://github.com/onflow/cadence/pull/1999](https://github.com/onflow/cadence/pull/1999)) - * Initially only planned dynamic checks - * Also added static checks to prevent bugs/problems early - * Static checks cover most use-cases discovered during analysis of Mainnet contracts -* Open problems: - * None -* Next steps: - * Make a decision, mostly agreement - -### Borrow Contract - -* [https://github.com/onflow/flow/pull/1071](https://github.com/onflow/flow/pull/1071) -* Status: - * Complete - * Have reference implementation ([https://github.com/onflow/cadence/pull/1934](https://github.com/onflow/cadence/pull/1934)) - * Needs some assistance on e.g. tests - * FLIP is up-to-date -* Open problems: - * Concern that static analysis is not possible anymore resolved, already have run-time imports of contracts - * Concern for cache invalidation – implementation detail, not a concern, functionality basically already available -* Next steps: - * Needs approval/rejection - -### Enforcing events / nested type requirements - -* We would like to remove the nested type requirements feature from Cadence -* However, the new FT/NFT standards plan to keep using the feature for enforcing the declaration of event -* Can we find an alternative to enforcing events without using nested type requirements? - * Events as nested type requirements are mostly just boilerplate - * Concrete type "needs" separate events, cannot emit events from interface - * Definitions in concrete type are not "useful" right now, cannot enforce they are emitted in a certain way - * Maybe just "inherit" event types from interface - * Feedback: Too implicit - * Contract-level events -> requires type field - * Maybe move events to resource-level, i.e. FT/NFT itself? - * Changing events significantly will affect existing off-chain systems - * Emit event always in post-condition of interface - * Currently (potentially unnecessarily) limited by new view-functions feature (conditions are view contexts) - * Requires allowing definition of concrete events in interfaces - * Might be easier to have "universal" event types with type field, instead of separate ones - * Related: filtering on API -* If we can't remove nested type requirements, can we maybe at least reduce the feature to just events? Only using the feature for events addresses at least some of the concerns we have with the feature, and we can still simplify the codebase a bit -* Next steps: - * Write example standard and derive required language changes (Deniz and Bjarte will look into it) - -### Additional Storage API functions - -* `clear`: [https://github.com/onflow/cadence/pull/1253](https://github.com/onflow/cadence/pull/1253) - * `fun clear(_ path: Path): Bool` - * Reason: sugar/helper - * This function deletes whatever is present at the specified path, destroying any resources, and returns whether anything was present originally. - * Concerns: implicitness, destruction without destroy - * Maybe name "destroyAt" -* `forceSave`: [https://github.com/onflow/cadence/pull/1252](https://github.com/onflow/cadence/pull/1252) - * `fun forceSave(_ value: T, to path: Path): Bool` - * This will save a value to the specified path, overwriting any data present (and destroying it if it is a resource). Returns whether or not any data was overwritten - * Reason: save fails when value exists - * Concerns: destruction without destroy - * Maybe name "destroyAndSave" -* Functionality exists already -* Prefer explicitness / keyword (enforce one way) -* Main use-case: avoiding path collisions -* Related: Removal of storage paths (replace with type + name pair) -* Concern: streamlining pattern we do not want to encourage -* → Put on pause until we discussed path changes - -### Alternative to paths - -* FLIP draft: [https://github.com/onflow/flow/pull/1130](https://github.com/onflow/flow/pull/1130) -* Cap Cons: - * Remove private (no longer needed, were only used for caps) - * Public for capabilities -* Problems with paths: - * Collisions - * Most common use-case: one value per type -* Type + name pair -* Problem: - * borrow can be for interface -* Idea/goal for paths: - * User’s account is controlled by user, UA mediates - * Dapp/contracts should not dictate - * Common user just has one value (e.g. default FT vault, NFT collection) - * Power users might have multiple (e.g. multiple FT vaults, NFT collections, for different purposes. Cf. checking vs savings account) - * Not (yet) a reality today, didn’t have necessary functionality - * Efforts: - * Interaction template library: Allow UA to inject path - * New proposal does not hinder the goal (right?) - * Goal requires introspection -* Path/name choosing, mediated by UA -* Related: account initialization (call on 2022-10-18) -* Application "state" in user account VS user data stored in user account - * Analogies: - * Windows Programs directory vs documents directory - * Mac/*nix /home vs /lib -* Interoperability easier with user-managed/stored data -* Next steps: continue discussion - * How does the proposal solve the problems? - * ? - -### Publish/claim capability use-cases? - -* Bootstrapping -* Outline ideal use-case -* Existing pattern of private push-inbox, in our case pull - * Example: n email inbox where emails are pushed through the inbox and handled according to rules (rate limiting, requiring payment or anti-sybil proof)[ https://petmail.lothar.com/design.html](https://petmail.lothar.com/design.html) -* Update best practices page -* Next step: Write up, discuss (Kate) diff --git a/meetings/2022-11-02.md b/meetings/2022-11-02.md deleted file mode 100644 index 342daba752..0000000000 --- a/meetings/2022-11-02.md +++ /dev/null @@ -1,227 +0,0 @@ -# Nov 2, 2022 - -## **Mainnet spork / Cadence release** - -We've achieved another big milestone! 🎉 - -https://forum.onflow.org/t/cadence-updates-for-the-nov-2022-mainnet-spork/3748 - -## FLIPs - -### Invalidate references to transferred resources - -* https://github.com/onflow/flow/pull/1043 -* Status: Accepted 🎉 - -### Capability Controllers - -* https://github.com/onflow/flow/pull/798 - -* Status: - * Figured out how to add API in backward-compatible way. - * Will allow deprecation instead of replacement - -* Open problems: - * None - -* Next steps: - * Vote! - -### Attachments - -* https://github.com/onflow/flips/pull/11 - -* Forum discussion: https://forum.onflow.org/t/flip-cadence-extensions-attachments/3645/2 - -* Status: - * No feedback if extensions or attachments are preferred. Assume extensions subsumed by attachments. - * Updated attachment proposal with feedback - -* Open problems: - * attach expression evaluation order: right-to-left. Would be nice to have natural language - * Currently: `attach A() to <-r` - * Probably won't matter practically - * Require it to be view? - * attach as postfix operator / function? - * Functions would not require separate handling - * Naming: attachments are managers/glue vs first-class values like fields - * Deniz: Attachment is a Manager ( Costume Manager vs Hat ), So maybe using the attachment proposal but naming it an extension can be a better choice. Attachment gives me a different feeling to me - * Access control / reference kind (auth) - * Not in the proposal - * Currently non-auth reference, for owned and non-owned case - * Iterating has this problem: &AnyAttachment + reflection - -* Next steps: - * Address expression order - * Address naming - * Address access control - -### Add fields during contract update - -* https://github.com/onflow/flow/pull/1097 - -* Status: No update - -* Open problems: - * Implementation details for migration (not impossible, just needs to be laid out) - -* Next steps: - * Call? - * Anyone else interested? - -### Borrow Contract - -* https://github.com/onflow/flow/pull/1071 - -* Status: - * Waiting for assistance on Tests on the Cadence implementation side - -* Open problems: - * None - -* Next steps: - * Assist with implementation - -### Change semantics of for-loops - -* https://github.com/onflow/flips/blob/main/cadence/2022-10-11-for-loop-semantics.md - -* Status: - * Ready for review - -* Open problems: - * None - -* Next steps: - * Vote! - - -### Change the syntax for function types - -* https://github.com/onflow/flips/pull/43 - -* Status: - * FLIP open, ready for review - -* Open problems: - * None - -* Next steps: - * Vote! - -### Interface Inheritance - -* https://github.com/onflow/flips/pull/40 - -* Forum discussion: https://forum.onflow.org/t/flip-interface-inheritance-in-cadence/3750 - -* Status: - * FLIP opened - * Implementation in progress - * Sentiment is positive for need - * Blocker is details - -* Open questions: - * How to resolve/handle conflicting default implementations? - * Do implementations of an interface also have to explicitly specify all inherited interfaces as well? - * Implicit or explicit conformance - * Definitely require implementation of all interfaces, inherited or not - * Maybe require explicit list, as acknowledgement - * Can conflict with default method resolution - * Related to first problem - * Should be consistent - * Multiple inheritance, lineralization - * E.g. Python: C3 - * Scala, Rust: explicit order, allow disambiguation - * Go? Struct embedding - * Kotlin: https://kotlinlang.org/docs/interfaces.html#resolving-overriding-conflicts - * Unique to Cadence, not in other languages: contract updatability - * Related: Condition ordering. Basically: order of execution for code in interfaces - * Conditions are view functions, so order "doesn't matter", but still needs to be deterministic (for reads, errors) - -* Next steps: - * Resolve open problems - * Document behaviour for current interface default functions => separate discussion - * Maybe have breakout session to speed up - * Who wants to join the discussion? - * Josh, Satyam, Austin, Bjarte - - -### Extend transaction format - -* https://github.com/onflow/flips/pull/41 - -* TLDR: - * Use-case: UA should allow users to choose e.g. storage location, etc. - * Broad scope / far-reaching (Cadence, UA, SDKs, etc.) - * Cadence: Multiple prepare blocks, field annotations ("roles"), multiple post blocks - * Benefits: Composition, safety - -* Status: - * FLIP open, looking for initial feedback - -* Open problems: - * Not attached to particular solution - * Complexity (many additions in multiple areas) - * Code generation functionality - -* Notes: - * Related to account initialization - * Austin will reach out to Jeff to align both efforts - -* Next steps: - * Needs more eyes, eventually have breakout session later - -## Behaviour of `Account.keys.forEach` - -* [https://github.com/onflow/cadence/pull/2038](https://github.com/onflow/cadence/pull/2038) - -* All keys or only revoked keys? -* Maybe indicate through naming? -* `AccountKey` has index -* User has the ability to filter revoked keys -* Currently: includes revoked keys, just like keys field -* Additional function for filtering revoked? - * Ideally index of all non-revoked keys in FVM -* Ordering? - * Maybe active first, revoked last - * Would ideally also be based on index in FVM -* Concern: feels like an array, so user/dev might assume certain ordering -* Documentation should (already does?) mention order -* Signal consideration of isRevoked by making it an additional parameter of the callback function? What about weight, that too (e.g. 0 weight)? -* (Keys are immutable, other than revocation; e.g. can't change weight) -* Next steps: - * Leave as-is - * Improve documentation - -## Removal/reduction of nested type requirements - -* Several options: - * Reduction to just events - * Removal; requires alternative - * Deniz' issue: https://github.com/onflow/cadence/issues/2069 - * "Global" events - * Could add additional information (originating contract) to global events - * https://github.com/onflow/cadence/issues/2081 - * https://github.com/onflow/cadence/issues/1161 - * Use interface default function implementation -* Related: additional feature to enforcing events are emitted -* Need to guarantee that only FTs emit events, and only "concrete" events -* Next steps: - * Session on new standards, then have better understanding about events - * e.g. separate vs shared event types - * Discussion in next Smart Contract Engineering Open House - * Evaluate options above, pros/cons - -## Resolving external mutation - -* https://github.com/dapperlabs/cadence-private-issues/issues/59 - -* Any solutions beyond the reference exploit may impact usability too negatively to be worth implementing? - -* Next step: - * Fill gap for references: dynamic check - * Does not need FLIP - * Maybe consider follow-up, address arbitrary mutating functions - * Remove public fields FLIP, was rejected - * Reconsider? Need to address outstanding problems diff --git a/meetings/2022-11-16-Interface-Inheritance.md b/meetings/2022-11-16-Interface-Inheritance.md deleted file mode 100644 index 8dc40689d4..0000000000 --- a/meetings/2022-11-16-Interface-Inheritance.md +++ /dev/null @@ -1,32 +0,0 @@ -# Nov 16, 2022 - -## Interface Inheritance Meeting Notes - -* FLIP: https://github.com/onflow/flips/pull/40 - -* Forum discussion: https://forum.onflow.org/t/flip-interface-inheritance-in-cadence/3750 - -* Open Questions: - * Functions with conditions: - * FLIP proposes to order them in a pre-determined order and run them all. - * No overriding is supported (because of security concerns). - * Is overriding needed? Potentially unsafe to do so. - - * Default functions: Two main concerns. - * Should allow overriding of default functions? - * Can be a security/safety concern. - * Someone in a middle of an inheritance chain can override a default function, which would change the behavior for downstream contracts. - * One solution is to make default functions to be 'view' only. - * Reduce the depth/impact of security concerns of overriding. - * Still going to need a way to resolve ambiguity. e.g: Two ‘getId()’ view functions are available; which of the two should be called? - * How to resolve ambiguity, when two or more default implementations are available for functions? - * Two potential solutions: - * Ask the user to solve it by overriding the method inside the concrete-type/interface which faces ambiguity - (This is what is proposed in the FLIP). - * Ambiguity resolution of default functions in concrete types also uses the same approach. - See: https://github.com/onflow/cadence/pull/1076#discussion_r675861413 - * Order/linearize the default functions and pick the one that is 'closest' to the current interface/concrete type. - * It is 'safe' only if the default functions are view only. - * Might be surprising to the user. - * Already disregarded this option for default functions ambiguity resolution in concrete implementations. - * Need to resolve ambiguity regardless of whether default function overriding is supported or not. diff --git a/meetings/2023-01-10.md b/meetings/2023-01-10.md deleted file mode 100644 index 558369152f..0000000000 --- a/meetings/2023-01-10.md +++ /dev/null @@ -1,169 +0,0 @@ -# Jan 10, 2023 - -## FLIPs - -### Capability Controllers - -[https://github.com/onflow/flow/pull/798](https://github.com/onflow/flow/pull/798) - -* Status: - * Final API discussions - * TODO: - * Compatibility with AuthAccount capabilities and Inbox API - * Emit events -* Open problems: - * None -* Next steps: - * Vote! - -### Auth fields and Safe Downcasting - -[https://github.com/onflow/flips/pull/54](https://github.com/onflow/flips/pull/54) - -* Status: - * New - * Spearheaded by Daniel, Dete, and Kate - * Discuss proposal -* Open problems: - * Migration is complex and widespread - -### Attachments - -[https://github.com/onflow/flips/pull/11](https://github.com/onflow/flips/pull/11) - -[https://forum.onflow.org/t/flip-cadence-extensions-attachments/3645/2](https://forum.onflow.org/t/flip-cadence-extensions-attachments/3645/2) - -* Status: - * Approved and implemented - * Preview release available to try out the new feature -* Next steps: - * Implement iteration - * This depends on whether we have safe downcasting as an alternative for reflection (see above, [https://github.com/onflow/flips/pull/54](https://github.com/onflow/flips/pull/54)) - * Allow declaring an attachment for restricted types ("set of interfaces") [https://github.com/onflow/cadence/issues/2224](https://github.com/onflow/cadence/issues/2224) - * Attachment access control based on base resource access - * Depends on [https://github.com/onflow/flips/pull/54](https://github.com/onflow/flips/pull/54) - -### Interface Inheritance - -[https://github.com/onflow/flips/pull/40](https://github.com/onflow/flips/pull/40) - -[https://forum.onflow.org/t/flip-interface-inheritance-in-cadence/3750](https://forum.onflow.org/t/flip-interface-inheritance-in-cadence/3750) - -* Status: - * Had separate break-out sessions, will need another one - * Implementation complete for the proposal. Would need changes for the parts of the proposal that would change. - * Sentiment is positive for need - * Blocker is details (default functions, in particular) - * Ideas currently being discussed: - * Forbid interface changes - * Change default function - -* Open questions: - * Meeting notes: [https://docs.google.com/document/d/1LUvRg0T09mdE2Ndgti6xI1AY_KPYGJr2ZRLVuqzGxFg/edit#heading=h.d4wc1pr484vi](https://docs.google.com/document/d/1LUvRg0T09mdE2Ndgti6xI1AY_KPYGJr2ZRLVuqzGxFg/edit#heading=h.d4wc1pr484vi) - -* Next steps: - * Schedule another session - * Is this still a blocker for NFT/FT v2? - -### Extend transaction format -[https://github.com/onflow/flips/pull/41](https://github.com/onflow/flips/pull/41) - -* Status: - * Got some feedback, needs more - * Large proposal affecting many components - * Small change, big (good) implications - * Had break-out sessions, resolved some open questions - * Need to resolve remaining open questions - -* Open problems: - * No concrete solution, many possibilities, proposal has just one incomplete solution - * Solution a bit more concrete (e.g. block syntax) - * Unclear how wallets code-gen and insert parts into transaction - -* Next steps: - * Get more feedback - * Another Breakout session - * Prioritize over e.g. reentrancy and external mutability improvements - * Start with prototyping in Cadence (parsing and type checking) - -### AuthAccount capabilities - -* [https://github.com/onflow/flips/pull/53](https://github.com/onflow/flips/pull/53) - -* Status - * Had break-out session - * Child account model is really useful - * However, should make it "harder" to perform such administrative tasks (linking account capability), also other operations like adding keys - * At the same time: add safe-guards, require "sudo" signature - -* Open problems: - * Safe guards - * Once available, wallets need to support for safe guards (e.g. flag "sudo" transaction to user) - -* Next steps: - * Wait with approval of FLIP until safe-guards are available - * Start on discussion for "sudo" operations in forum, evtl. have FLIP - * Enable on Testnet to enable demo/development of ecosystem - -## Other items for Stable Cadence? - -[https://forum.onflow.org/t/the-path-to-stable-cadence/2702](https://forum.onflow.org/t/the-path-to-stable-cadence/2702) - -We're mainly looking for changes, especially breaking ones. -We'll prioritize additional features after Stable Cadence. - -* Type aliases - -* Enable non-facade capability patterns, e.g. attenuation "building blocks" - * Currently possible, but heavy-weight (e.g. defining new type) - * Sugar for e.g. adding pre and post conditions, wrapping, filtering, etc. around methods for an object - * → auth modifier FLIP - * → CapCon FLIP - -* Consumption of `self` - * Currently: `resource R { fun foo() { … } }` - * Implicitly: `resource R { fun foo(self: auth &R) { … } }` - * Could be explicit: `resource R { fun foo(self: @R) { … } }` - -* Cannot return/export certain types, cannot emit events - * Used to be a problem for function types, references, etc. - * Should be resolved now, please report non-exportable issues - * Maybe add ability to override serialization, e.g. allow export of function call value - -* Related: Allow import of any value in script (e.g. resource, capability) - -* Import just deserialize - * `struct Foo { let bar: Int; init(bar: Int) { pre { self.bar > 0 } { … } }` - * Currently allow e.g. `{"type": “Foo”, “bar”: 0}` - * Call initializer instead? - * Maybe allow either/or - -* Block access to certain read-only functions? - * Data is assumed to be public - * Minimize EN’s exclusive access/knowledge - -* Broken contracts - * Skip in storage iteration - * Might just be partially broken - * → General problem/idea: Catch panics and resume - * Issues: - * Implementation complexity (snapshotting/rollback in storage system, in-memory objects, etc.) - * Security problems (assumption of rollback) - * Could allow in scripts - * Maybe nested transactions? - * Currently only have nested transactions, no rollback/resumption - * Recovery: - * Would be case-by-case (parsing, type checking, conformance, casting failure, etc.) - * Could e.g. allow reading of fields of stored data, disallow function calls. Useful? - -## Nested type requirements → emit events in interfaces? - -* FT/NFT standards v2 -* [https://github.com/onflow/cadence/issues/1283](https://github.com/onflow/cadence/issues/1283) -* [https://github.com/onflow/cadence/issues/2081](https://github.com/onflow/cadence/issues/2081) -* [https://github.com/onflow/cadence/issues/2069](https://github.com/onflow/cadence/issues/2069) - -## Allow deletion of storage values with broken types? - -- [https://github.com/onflow/cadence/issues/2170](https://github.com/onflow/cadence/issues/2170) - diff --git a/meetings/2023-02-23.md b/meetings/2023-02-23.md deleted file mode 100644 index c114c438ee..0000000000 --- a/meetings/2023-02-23.md +++ /dev/null @@ -1,171 +0,0 @@ - -# Feb 23, 2023 - -## FLIPs - -### Capability Controllers -[https://github.com/onflow/flow/pull/798](https://github.com/onflow/flow/pull/798) - -* Status: - * Had many breakout sessions - * Final API discussions - * TODO: - * Compatibility with AuthAccount capabilities - * Backwards compatibility / migration of existing data - * Emit events - * Pet names - -* Open problems: - * Backwards compatibility / migration of existing data - -* Next steps: - * Update proposal - * One more breakout session - * Vote! - -### Entitlements and Safe Downcasting -[https://github.com/onflow/flips/pull/54](https://github.com/onflow/flips/pull/54) - -* Status: - * Zeroing in on entitlements concept - * Getting close to final design - * Related: [account entitlements](https://forum.onflow.org/t/super-user-account/4088) - -* Open problems: - * How do nested composite fields work? - * Declaration syntax (resource-typed members) - -* Next steps: - * Breakout session for nested composite fields - * Asynchronous discussion for declaration syntax - * Vote! - -### Attachments - -[https://github.com/onflow/flips/pull/11](https://github.com/onflow/flips/pull/11) - -[https://forum.onflow.org/t/flip-cadence-extensions-attachments/3645/2](https://forum.onflow.org/t/flip-cadence-extensions-attachments/3645/2) - -* Status: - * Approved and implemented - * Preview release available to try out the new feature - * Second preview release - -* Open problems: - * Trolling attack - * Problem: - * Attachments introduce the problem of receiving arbitrary values - * What if attachment aborts in destructor? - * Multiple kinds of aborts: panic, infinite loops, etc. - * Owner cannot remove attachment - * Owner cannot destroy outer resource - * Solution ideas: - * Allow force delete? - * How? - * What if code assumes destructor succeeded? e.g. FT total supply - * Return to creator? - * What if data cannot be paid for? - * Return to "network lost and found"? - * Preventing destroy - * technically nearly impossible atm - * Limit destroy? - * Some destructors mutate, e.g. FT updates contract total supply - * Only allow "self-calls"? - * "Two-staged destructors"? - * In other languages? - -* Next steps: - * Address trolling attack? - * Breakout session - * Deploy to TN, not MN - * Not feature flagged, would need two separate flow-go builds - -### Interface Inheritance - -[https://github.com/onflow/flips/pull/40](https://github.com/onflow/flips/pull/40) - -[https://forum.onflow.org/t/flip-interface-inheritance-in-cadence/3750](https://forum.onflow.org/t/flip-interface-inheritance-in-cadence/3750) - -* Status: - * No further progress - * Currently at bottom of priorities - -* Open questions: - * Meeting notes: [https://docs.google.com/document/d/1LUvRg0T09mdE2Ndgti6xI1AY_KPYGJr2ZRLVuqzGxFg/edit#heading=h.d4wc1pr484vi](https://docs.google.com/document/d/1LUvRg0T09mdE2Ndgti6xI1AY_KPYGJr2ZRLVuqzGxFg/edit#heading=h.d4wc1pr484vi) - -* Next steps: - * Schedule another session - * Is this still a blocker for NFT/FT v2? - -### Extend transaction format -[https://github.com/onflow/flips/pull/41](https://github.com/onflow/flips/pull/41) - -* Status: - * Had many breakout sessions - * Zeroing role based syntax - * Roles have both prepare and resolve - -* Open problems: - * Unexplored corner: - * Useful for multi-sign use-cases - * Does model also make sense for single-sign use-cases? - * Signer assignment - * Mapping signatures to roles - * Currently Flow transaction signatures are sequential - * Action-based model? - -* Next steps: - * Another breakout session to continue conversation - * Update Extended Transaction Format FLIP with meeting notes from last breakout session - * Add information about new prepare/resolve mechanic proposed - -### AuthAccount capabilities - -[https://github.com/onflow/flips/pull/53](https://github.com/onflow/flips/pull/53) - -* Status - * Had break-out session - * Preview release - * Enabled on all networks but Mainnet - * Working on [account entitlements](https://forum.onflow.org/t/super-user-account/4088) - * Want to approve and - -* Open problems: - * Forbid Public? - * Could restrict for linkAccount - * What about CapCon issueAccount? introduce AccountCapability to allow distinguishing? - * How can we get it out to Mainnet? - * Add temporary mechanism, e.g. another type, like proposed originally in [https://forum.onflow.org/t/super-user-account/4088](https://forum.onflow.org/t/super-user-account/4088) ? - * Need to prevent accidental signing - -* Next steps: - * Brainstorm temporary solution - * Another breakout session - * Involve wallet folks (e.g. Dapper, Blocto, etc.) - -### External Mutability -[https://github.com/onflow/flips/pull/58](https://github.com/onflow/flips/pull/58) - -[https://github.com/onflow/flips/pull/59](https://github.com/onflow/flips/pull/59) - -* Status: - * Had breakout session - * Multiple alternatives / FLIPs - * FLIP 58: - * Add additional static checks - * Deemed overkill - * FLIP 59: - * Remove/restrict let fields - * Deemed better than 58 - * Impact analysis: - * Inner mutability used as a feature - * E.g. MetadataViews standard - * Need delegation functions for nested members - * More boilerplate - * Moves problem, but does not solve it - -* Open problems: - * Unclear how to proceed - -* Next steps: - * Breakout session to determine how to proceed diff --git a/meetings/2023-04-13.md b/meetings/2023-04-13.md deleted file mode 100644 index 80a5fad37b..0000000000 --- a/meetings/2023-04-13.md +++ /dev/null @@ -1,291 +0,0 @@ - -# Apr 13, 2023 - -* First fully open/public meeting 🎉 - -* Code coverage feature shipping in CLI 🎉 - - * Huge shoutout to Ardit Marku from Build Squad - -* New contributor: darkdrag00nv2 🎉 - -* Contribute: - * FLIPs - - * Cadence: [https://github.com/onflow/cadence/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3A%22Good+First+Issue%22](https://github.com/onflow/cadence/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3A%22Good+First+Issue%22) - - * Cadence tools: [https://github.com/onflow/cadence-tools/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3A%22Good+First+Issue%22](https://github.com/onflow/cadence-tools/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3A%22Good+First+Issue%22) - -## FLIPs - -### AuthAccount capabilities - -* [https://github.com/onflow/flips/pull/53](https://github.com/onflow/flips/pull/53) -* Status - * Approved and implemented 🎉 - -### Capability Controllers - -* FLIP: [https://github.com/onflow/flow/pull/798](https://github.com/onflow/flow/pull/798) - -* Status: - - * Had many breakout sessions - - * Final API discussions - - * Implementation in progress - - * No remaining concerns - -* Open problems: - - * API: Capability publishing - -* Next steps: - - * One more breakout session - - * **Vote!** - -### Entitlements and Safe Downcasting - -* FLIP: [https://github.com/onflow/flips/pull/54](https://github.com/onflow/flips/pull/54) - -* Status: - - * Had breakout session for nested entitlements. Consensus on solution - - * Implementation in progress - - * No remaining concerns - -* Open problems: - - * Attachments - -* Next steps: - - * Address remaining technical issues async - - * **Vote!** - -### Attachments - -* Attachments FLIP: [https://github.com/onflow/flips/pull/11](https://github.com/onflow/flips/pull/11) - -* Forum discussion: [https://forum.onflow.org/t/flip-cadence-extensions-attachments/3645/2](https://forum.onflow.org/t/flip-cadence-extensions-attachments/3645/2) - -* Status: - - * Approved and merged 🎉 - - * Deployed to Testnet - - * Receiving feedback - - * Discovering use-cases - - * Need mitigation for trolling attack - - * Mainnet blocked on solution for trolling attack - - * Had breakout session for trolling attack - - * Have idea for solution, but might depend on breaking change (Stable Cadence) - -* Open problem: - - * Trolling attack - -* Next steps: - - * Address trolling attack - - * Need breakout session - -### Interface Inheritance - -* FLIP: [https://github.com/onflow/flips/pull/40](https://github.com/onflow/flips/pull/40) - -* Forum discussion: [https://forum.onflow.org/t/flip-interface-inheritance-in-cadence/3750](https://forum.onflow.org/t/flip-interface-inheritance-in-cadence/3750) - -* Status: - - * Was on hold due to prioritization, planning to continue now, given other FLIPs done - - * Had breakout session - - * Implementation available - -* Open questions: - - * Multiple interface default functions (diamond problem) - - * Meeting notes: [https://docs.google.com/document/d/1LUvRg0T09mdE2Ndgti6xI1AY_KPYGJr2ZRLVuqzGxFg/edit#heading=h.d4wc1pr484vi](https://docs.google.com/document/d/1LUvRg0T09mdE2Ndgti6xI1AY_KPYGJr2ZRLVuqzGxFg/edit#heading=h.d4wc1pr484vi) - -* Next steps: - - * Schedule another breakout session - - * Is this still a blocker for NFT/FT v2? - - * Still being used, expected to be available - - * Not 100% required, but preferred. Less prone to errors - -### Extend transaction format - -* FLIP: [https://github.com/onflow/flips/pull/41](https://github.com/onflow/flips/pull/41) - -* Status: - - * No updates at the moment - - * Last breakout session was a while back - - * Planning to restart working group - -* Open problems: - - * Unexplored corner: - - * Useful for multi-sign use-cases - - * Does model also make sense for single-sign use-cases? - - * Signer assignment - - * Mapping signatures to roles - - * Currently Flow transaction signatures are sequential - - * Action-based model? - -* Next steps: - - * Have another breakout session - -### External Mutability - -* [https://github.com/onflow/flips/pull/58](https://github.com/onflow/flips/pull/58) - -* [https://github.com/onflow/flips/pull/59](https://github.com/onflow/flips/pull/59) - -* Status - - * Had breakout session - - * Multiple alternatives / FLIPs - - * FLIP 58: - - * Add additional static checks - - * Deemed overkill - - * FLIP 59: - - * Remove/restrict let fields - - * Deemed better than 58 - - * Impact analysis: - - * Inner mutability used as a feature - - * E.g. MetadataViews standard - - * Need delegation functions for nested members - - * More boilerplate - - * Moves problem, but does not solve it - - * Investigating another idea (entitlements, references to fields) - -* Open problems: - - * Usability - - * FLIPs have different compromises - -* Next steps: - - * Breakout session to determine how to proceed - -## Related FLIPs - -### Account linking standard - -* FLIP: [https://github.com/onflow/flips/pull/72](https://github.com/onflow/flips/pull/72) - -* Status: - - * Had breakout session - - * Great feedback - - * Implementation in progress: - - * [https://github.com/Flowtyio/restricted-child-account](https://github.com/Flowtyio/restricted-child-account) - - * Positive sentiment, thumbs up from e.g. Flowty, Niftory, Dapper, etc - - * Wallets like it, even though it is more work for them - -* Open problem: - - * Regulatory risk for application developers - - * Discussions with legal council, technical solution - - * Discovery of linked assets - -* Next steps: - - * Work out how to restrict access - - * Continue implementation - -### FT/NFT v2 standards - -* FLIP: [https://github.com/onflow/flips/pull/56](https://github.com/onflow/flips/pull/56) - -* Status: - - * Multiple breakout sessions - - * Several major changes: - - * [https://github.com/onflow/flow-nft/pull/126#issuecomment-1505864702](https://github.com/onflow/flow-nft/pull/126#issuecomment-1505864702) - -* Open problems: - - * Waiting on FLIP for emitting events from interfaces (would allow nested type requirements) - - * [https://github.com/onflow/cadence/issues/2069](https://github.com/onflow/cadence/issues/2069) - - * Need to open FLIP for removal of nested type requirements - - * Upgrade constraints - -* Next steps: - - * Breakout session for upgrade - - * Maybe needs storage migration - - * Open FLIP for removal of nested type requirements - -## Questions - -* Changelog for Stable Cadence? - - * Announcement of breaking changes Stable Cadence in forum - - * [https://forum.onflow.org/t/another-update-on-stable-cadence/3715](https://forum.onflow.org/t/another-update-on-stable-cadence/3715) - - * Preview release available, needs to be updated - - * Will create TN instance with changes diff --git a/meetings/2023-05-04.md b/meetings/2023-05-04.md deleted file mode 100644 index df84098a6a..0000000000 --- a/meetings/2023-05-04.md +++ /dev/null @@ -1,167 +0,0 @@ -# May 4th, 2023 - -## FLIPs - -### Capability Controllers - -* FLIP: [https://github.com/onflow/flow/pull/798](https://github.com/onflow/flow/pull/798) - -* Status: - * Final API adjustments - * Implementation nearing completion - * No remaining concerns - -* Open problems: - * None - -* Next steps: - * Update FLIP, no capcons for links - * Migration, rollout documentation - * Documentation around pattern (e.g. getCapability to construct, link later) - * Clarify migration: find storage path, storage path does not need to store anything - * **Accept, unless objections** - -### Entitlements and Safe Downcasting - -* FLIP: [https://github.com/onflow/flips/pull/54](https://github.com/onflow/flips/pull/54) - -* Status: - * Implementation done - * No remaining concerns - * Additional features requested → follow-up FLIPs - -* Open problems/concerns: - * Complexity - * Parts: entitlements, downcasting, mappings - * Syntax (comma, and, set) - * Migration? - * Current access control pattern: public declaration, *but* restricted type to gate access - * Maybe get rid of pub and priv? - * Type in existing capability - * Breakage is OK, security problem not. Maybe have contract be broken until fixed - -* Next steps: - * Details for migration, maybe breakout session - * Documentation and tutorials, for existing and new developers - * Demonstrate with e.g. AuthAccount/PublicAccount, standard library (arrays, dictionaries, etc.), FT, NFT, etc. - * Preview release for Stable Cadence: Emulator, Playground, etc. - * **Accept, unless objections** - * Maybe propose removal of restricted types, not "necessary" or very useful anymore - -### Attachments - -* FLIP: [https://github.com/onflow/flips/pull/11](https://github.com/onflow/flips/pull/11) - -* Forum discussion: [https://forum.onflow.org/t/flip-cadence-extensions-attachments/3645/2](https://forum.onflow.org/t/flip-cadence-extensions-attachments/3645/2) - -* Status: - * Approved and merged 🎉 - * Deployed to Testnet - * Receiving feedback - * Discovering use-cases - * Need mitigation for trolling attack - * Mainnet blocked on solution for trolling attack - * Had breakout session for trolling attack - * Have idea for solution, but might depend on breaking change (Stable Cadence) - -* Open problem: - * Trolling attack, blocking. Working on solution - -* Next steps: - * Address trolling attack - * Breakout session for contexts ("try-catch") in public - -### Interface Inheritance - -* FLIP: [https://github.com/onflow/flips/pull/40](https://github.com/onflow/flips/pull/40) - -* Forum discussion: [https://forum.onflow.org/t/flip-interface-inheritance-in-cadence/3750](https://forum.onflow.org/t/flip-interface-inheritance-in-cadence/3750) - -* Status: - * Had more breakout sessions, ironed out almost all last questions/problems - * Implementation available - -* Open questions/concerns: - * Explicit declaration of inherited interfaces? - * Declaration (conformance list) - * Also in restricted types? Subtyping relationship → clarify in FLIP - * No tooling required when reading contract - * Also helps author - * Verbosity / explicitness vs conciseness / implicitness - * Example: FT - -* Next steps: - * Resolve last question/concern - * **Accept, unless objections** - -### Extend transaction format - -* FLIP: [https://github.com/onflow/flips/pull/41](https://github.com/onflow/flips/pull/41) - -* Status: - * No updates at the moment - * Last breakout session was a while back - * Planning to restart working group - -* Open problems: - * Unexplored corner: - * Useful for multi-sign use-cases - * Does model also make sense for single-sign use-cases? - * Signer assignment - * Mapping signatures to roles - * Currently Flow transaction signatures are sequential - * Action-based model? - -* Next steps: - * Have another breakout session - * Contact Jeff - -### External Mutability - -* [https://github.com/onflow/flips/pull/58](https://github.com/onflow/flips/pull/58) - -* [https://github.com/onflow/flips/pull/59](https://github.com/onflow/flips/pull/59) - -* Status - * Had more breakout session - * Working on comparison and examples - -* Open problems: - * Usability - * FLIPs have different compromises - -* Next steps: - * Comparison of different solutions and examples - * Another breakout session - -### Interface Conformance Improvements - -* FLIP: [https://github.com/onflow/flips/pull/83](https://github.com/onflow/flips/pull/83) - -* Overview: - * Relaxation of existing restriction for interface conformance - * Default function in one interface + Conditions in another interface is currently rejected - * Proposal is to relax restriction and allow this case, given there is no conflict - -* Open problem: - * Conditions may currently have side-effects - * Delay until Stable Cadence? - -* Status: - * Discuss and approve asynchronous - -## Questions - -* Can/should we maybe wipe Testnet? - * Many broken/stale accounts and contracts - * Hadn’t come up before - * Maybe suggest, e.g. in GitHub discussions and/or forum - * Big disruption for some users - * Iteration broken (but shouldn’t be) - * More realistic? There will be always broken code / accounts etc - * Want to be able to test if dapp works with broken - * Testnet is "staging" for Mainnet - * Cannot wipe Mainnet - * After Stable Cadence, should be less of an issue - * Maybe FLIP? "Governance"? - * Should be able to force delete broken values (--> force delete problem, see above: attachment trolling problem) diff --git a/meetings/2023-06-15.md b/meetings/2023-06-15.md deleted file mode 100644 index 8f2ff0df6f..0000000000 --- a/meetings/2023-06-15.md +++ /dev/null @@ -1,274 +0,0 @@ -# June 15th, 2023 - -## FLIPs - -### Capability Controllers - -* FLIP: [https://github.com/onflow/flow/pull/798](https://github.com/onflow/flow/pull/798) - -* Status: - * FLIP approved and merged 🎉 - * Implemented - * Deployed on TN - * Need documentation - -### Entitlements and Safe Downcasting - -* FLIP: [https://github.com/onflow/flips/pull/54](https://github.com/onflow/flips/pull/54) - -* Status: - * FLIP approved and merged 🎉 - * Implementation almost complete (reference conversion) - * Plan for migration: [https://github.com/onflow/flips/pull/95](https://github.com/onflow/flips/pull/95) - -* Open problems/concerns: - * Migration - * Need to migrate values (run-time types) and need to e.g. re-hash in dictionary - -* Next steps: - * Merge last PR(s) - * Preview release for Stable Cadence: Emulator, Playground, etc. - -### Attachments - -* FLIP: [https://github.com/onflow/flips/pull/11](https://github.com/onflow/flips/pull/11) - -* Forum discussion: [https://forum.onflow.org/t/flip-cadence-extensions-attachments/3645/2](https://forum.onflow.org/t/flip-cadence-extensions-attachments/3645/2) - -* Status: - * FLIP approved and merged 🎉 - * Deployed to Testnet - * Receiving feedback - * Discovering use-cases - * Need mitigation for forced resource deletion - * Mainnet blocked on solution for forced resource deletion solution - * Had breakout session for resource deletion solution - * Have idea for solution, but might depend on breaking change (Stable Cadence) - -* Open problem: - * Resource deletion, blocking. Working on solution - * Maybe deploy to MN without solution? - -* Next steps: - * Resource deletion solution - -### Interface Inheritance - -* FLIP: [https://github.com/onflow/flips/pull/40](https://github.com/onflow/flips/pull/40) - -* Forum discussion: [https://forum.onflow.org/t/flip-interface-inheritance-in-cadence/3750](https://forum.onflow.org/t/flip-interface-inheritance-in-cadence/3750) - -* Status: - * FLIP approved and merged 🎉 - * Implemented - -### Interface Conformance Improvements - -* FLIP: [https://github.com/onflow/flips/pull/83](https://github.com/onflow/flips/pull/83) - -* Overview: - * For interface conformance - * Allow two interfaces, conditions + default function (currently prohibited) - -* Status: - * Positive sentiment - -* Open questions: - * None - -* Next steps: - - * **Approve, unless opposition** - -### Remove pub, pub(set) and priv - -* FLIP: [https://github.com/onflow/flips/pull/84](https://github.com/onflow/flips/pull/84) - -* Overview: - * Remove access modifiers - * Replacements already exist (access(all), access(self)) - -* Status: - * Positive sentiment - * Implementation drafted - -* Open questions: - * None - -* Next steps: - * **Approve, unless opposition** - -### Emit events from function conditions, allow concrete events in interfaces - -* FLIP: [https://github.com/onflow/flips/pull/111](https://github.com/onflow/flips/pull/111) - -* Overview: - * Originally proposed by Deniz - * Emit events from conditions - * Allow concrete events in interfaces, avoids need for redeclaration - * Depends on nested type requirements getting removed - -* Status: - * Positive sentiment - -* Open questions: - * None - -* Next steps: - * Discuss a bit more - * Approve, unless opposition - -### Remove restricted types - -* FLIP: [https://github.com/onflow/flips/pull/85](https://github.com/onflow/flips/pull/85) - -* Overview: - * Remove restricted types - * Used for access control (restricted references) - * Redundant with addition of entitlements - * Interface sets (intersection types) - -* Status: - * Positive sentiment - -* Open questions: - * None - -* Next steps: - * **Approve, unless opposition** - -### Account Type - -* FLIP: [https://github.com/onflow/flips/pull/92](https://github.com/onflow/flips/pull/92) - -* Overview: - * Replace AuthAccount and PublicAccount - * Originated in account linking FLIP - * Use entitlements - -* Status: - * Positive sentiment - -* Open problems: - * None - * Migration (effects on existing API, forced breakage) - * (Naming) - -* Next steps: - * Finish design for migration - * **Approve, unless opposition** - -### External Mutability - -* Vision: [https://github.com/onflow/flips/pull/97](https://github.com/onflow/flips/pull/97) - * Not a FLIP, but supporting document - * Bigger picture for FLIPs - * Update on previous proposals - * Looking at problem again: use entitlements - -* FLIPs: - - * **Change member access semantic** - * FLIP: [https://github.com/onflow/flips/pull/89](https://github.com/onflow/flips/pull/89) - - * Overview: - * Accessing a field on a reference returns a reference - - * Status: - * Positive sentiment - - * Open questions: - * None - - * Next steps: - * **Approve, unless opposition** - - * **Introduce built-in mutability entitlements** - - * FLIP: [https://github.com/onflow/flips/pull/86](https://github.com/onflow/flips/pull/86) - - * Overview: - * Built-in entitlements for mutating functions of containers (arrays, dictionaries) - * Can also used by user-defined types - - * Status: - * Positive sentiment - - * Open questions: - * Naming - - * Next steps: - * Maybe approve and refactor names later if needed (before release) - * **Approve, unless opposition** - - * **Improve entitlement mappings** - - * FLIP: [https://github.com/onflow/flips/pull/94](https://github.com/onflow/flips/pull/94) - - * Overview: - * Allow entitlement mappings for non-reference fields - * Improves "Change member access semantics" (FLIP 89) - - * Status: - * Positive sentiment - - * Open questions: - * None - - * Next steps: - * **Approve, unless opposition** - -### Add Range type - -* FLIP: [https://github.com/onflow/flips/pull/96](https://github.com/onflow/flips/pull/96) - -* Status: - * Design almost complete - * Implementation in progress - * Looking for feedback - * Positive sentiment, but details unclear - -* Open questions: - * Multiple types? - -* Next steps: - * Complete - * **Approve, unless opposition** - -### Extend transaction format - -* FLIP: [https://github.com/onflow/flips/pull/41](https://github.com/onflow/flips/pull/41) - -* Status: - * No updates at the moment - * Last breakout session was a while back - * Planning to restart working group - -* Open problems: - - * Unexplored corner: - * Useful for multi-sign use-cases - * Does model also make sense for single-sign use-cases? - - * Signer assignment - * Mapping signatures to roles - * Currently Flow transaction signatures are sequential - - * Action-based model? - -* Next steps: - * Have another breakout session - * Contact Jeff - -## Questions/Feedback - -* Indicate feature support in CLI - -* Applications to demo changes and additions - - * Candidates: - * Standards (FT, NFT) - * Core contracts - * Kitty Items (e.g. for marketplace) - * NFT Pawn Shop - * Asset Handover diff --git a/meetings/2023-08-15.md b/meetings/2023-08-15.md deleted file mode 100644 index f215b35d68..0000000000 --- a/meetings/2023-08-15.md +++ /dev/null @@ -1,167 +0,0 @@ -# Aug 14th, 2023 - -## Ways to contribute - -* Participate in [FLIP (Flow Improvement Proposal) discussions](https://github.com/onflow/flips) -* Contribute to Cadence implementation: ➡️[GitHub issues](https://github.com/onflow/cadence/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3A%22Good+First+Issue%22) -* Contribute Cadence tools: ➡️[GitHub issues](https://github.com/onflow/cadence-tools/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3A%22Good+First+Issue%22) - -## FLIPs - -### Interface Conformance Improvements - -* FLIP: [https://github.com/onflow/flips/pull/83](https://github.com/onflow/flips/pull/83) -* Status: - * FLIP approved and merged 🎉 - -### Remove pub, pub(set) and priv - -* FLIP: [https://github.com/onflow/flips/pull/84](https://github.com/onflow/flips/pull/84) -* Status: - * FLIP approved and merged 🎉 - -### Emit events from function conditions, allow concrete events in interfaces - -* FLIP: [https://github.com/onflow/flips/pull/111](https://github.com/onflow/flips/pull/111) -* Status: - * FLIP approved and merged 🎉 - -### Remove restricted types, interface set types - -* FLIP: [https://github.com/onflow/flips/pull/85](https://github.com/onflow/flips/pull/85) -* Status: - * FLIP approved and merged 🎉 - -### Add Range type - -* FLIP: [https://github.com/onflow/flips/pull/96](https://github.com/onflow/flips/pull/96) -* Status: - * FLIP approved and merged 🎉 - -### External Mutability - -* Vision: [https://github.com/onflow/flips/pull/97](https://github.com/onflow/flips/pull/97) -* FLIPs: - * **Change member access semantic** - * FLIP: [https://github.com/onflow/flips/pull/89](https://github.com/onflow/flips/pull/89) - * Status: - * FLIP approved and merged 🎉 - * **Improve entitlement mappings** - * FLIP: [https://github.com/onflow/flips/pull/94](https://github.com/onflow/flips/pull/94) - * Status: - * FLIP approved and merged 🎉 - * **Introduce built-in mutability entitlements** - * FLIP: [https://github.com/onflow/flips/pull/86](https://github.com/onflow/flips/pull/86) - * Status: - * Positive sentiment - * No new feedback in last few weeks - * Implementation and documentation ready - * Last conversation was about naming convention for entitlements - * Open problems: - * None - * Next steps: - * **Approved** - -### Account Type - -* FLIP: [https://github.com/onflow/flips/pull/92](https://github.com/onflow/flips/pull/92) -* Status: - * Positive sentiment - * No new feedback in last few weeks - * Implementation ready -* Open problems: - * None -* Next steps: - * **Approved** - -### Remove nested type requirements - -* FLIP: [https://github.com/onflow/flips/pull/118](https://github.com/onflow/flips/pull/118) -* Overview: - * Remove nested type requirements - * Allow declaration of events in interfaces as concrete types (used in core contracts) -* Status: - * Positive sentiment - * No new feedback in last few weeks - * Implementation ready (2 PRs) -* Open problems: - * None -* Next steps: - * **Approved** - -### Random function - -* FLIP: [https://github.com/onflow/flips/pull/118](https://github.com/onflow/flips/pull/118) -* Overview: - * Rename unsafeRandom to random, underlying implementation has been secured using Flow protocol native random beacon - * Update the interface to a safer and more convenient one (generalized types and a modulo parameter) - * Rollout: add random, deprecate unsafeRandom, finally remove in SC release -* Status: - * Positive sentiment for random -* Open problems: - * Behavior in scripts - * Should not panic - * Several options - * Naming: - * Potential for misuse by developers. Unsafe → safe renaming might be confusing - * Maybe addressed by commit-reveal scheme FLIP: [https://github.com/onflow/flips/pull/123](https://github.com/onflow/flips/pull/123) -* Next steps: - * Determine script behavior, maybe propose in separate FLIP - * Schedule breakout session - * Deniz - * You? Leave a comment! -* Feedback: - * Just switch unsafeRandom to safe random generator for now - * Different name/indicator to prevent misuse? - * Trigger developers to check documentation, see/use commit-reveal scheme design pattern to use returned safe random properly - * `random(iReadTheDocs: Bool)` - * Our bar is very high, other systems isn't - -### Commit-reveal scheme for non-reverted randomness - -* FLIP: [https://github.com/onflow/flips/pull/123](https://github.com/onflow/flips/pull/123) -* Overview: - * Provide a safe pattern to address transaction abortion after a random is revealed - * Commit to block - * In the future, query history of past randoms - * Use past, committed seed for new random -* Status: - * Positive sentiment - * Waiting for feedback -* Open problems: - * None -* Next steps: - * Gather more feedback - -### Remove custom destructors - -* FLIP: [https://github.com/onflow/flips/pull/131](https://github.com/onflow/flips/pull/131) -* Overview: - * Proposal to address inability for users to destroy resources they own - * One of the discussed options (others: try/catch, etc.) - * Originated from attachments feature (attachment might prevent destruction of whole resource) - * Remove destroy - * Allows users to always destroy resources -* Status: - * New - * Very much an RFC! -* Open problems: - * Philosophical question (sending to "burner account") - * Existing code / applications - * "Migration" path for use-cases like FT total supply -* Next steps: - * Discuss - * Breakout session - * You? Leave a comment! - * Publish resource destruction options document, add to FLIP -* Feedback: - * Provide details on impact on applications, e.g. core contracts like FT/NFT - * Chicken-and-egg problem: need more data on how feature is used, can then figure out if/what alternative is - * Even if exploit vector isn’t used today, it should be addressed/prevented - * If important use-case exists, also not worth it to remove - * Emitting events could maybe be allowed - * Given impact, reach out to more developers / gather more feedback - -## Related FLIPs / forum discussions - -* [https://forum.onflow.org/t/storage-fees-improvements-and-few-random-ideas-on-the-way/5104](https://forum.onflow.org/t/storage-fees-improvements-and-few-random-ideas-on-the-way/5104) \ No newline at end of file diff --git a/meetings/2023-09-12.md b/meetings/2023-09-12.md deleted file mode 100644 index 0b2f11dc0f..0000000000 --- a/meetings/2023-09-12.md +++ /dev/null @@ -1,185 +0,0 @@ - -## Sep 12th, 2023 - -### Ways to contribute - -* Participate in [FLIP (Flow Improvement Proposal) discussions](https://github.com/onflow/flips) - -* Contribute to Cadence implementation: ➡️[GitHub issues](https://github.com/onflow/cadence/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3A%22Good+First+Issue%22) - -* Contribute Cadence tools: ➡️[GitHub issues](https://github.com/onflow/cadence-tools/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3A%22Good+First+Issue%22) - -### Website - -[https://cadence-lang.org/](https://cadence-lang.org/) 👀 - -### Progress on Cadence 1.0 - -[https://forum.onflow.org/t/update-on-cadence-1-0/5197](https://forum.onflow.org/t/update-on-cadence-1-0/5197) 🎉 - -### FLIPs - -#### Relax interface conformance restrictions - -* FLIP: [https://github.com/onflow/flips/pull/134](https://github.com/onflow/flips/pull/134) - -* Overview: - - * Follow up on interface conformance improvements ([https://github.com/onflow/flips/pull/83](https://github.com/onflow/flips/pull/83)). - - * Proposes to allow empty function declaration defined in one interface to coexist with a default function implementation defined in another interface. - - * Currently the same is allowed if the empty declaration has a pre/post condition. - - * When interface default functions were introduced, interface inheritance did not exist yet - - * Current behavior was intentional, tried to avoid interface author breaking implementations by adding function implementation (default function) - -* Status: - - * FLIP is waiting for a final decision - - * Reference implementation is complete: [https://github.com/onflow/cadence/pull/2725](https://github.com/onflow/cadence/pull/2725) - -* Next steps: - - * Would like to get more feedback - - * Provide means / explanation to try out - -#### Random function - -* FLIP: [https://github.com/onflow/flips/pull/120](https://github.com/onflow/flips/pull/120) - -* Overview: - - * Rename unsafeRandom to random, underlying implementation has been secured using Flow protocol native random beacon - - * Update the interface to a safer and more convenient one (generalized types and a modulo parameter) - - * Rollout: add random, deprecate unsafeRandom, finally remove in SC release - -* Status: - - * Positive sentiment for random - - * Renamed to revertibleRandom - -* Open problems: - - * Behavior in scripts - - * Should not panic - - * Several options - - * Naming: - - * Potential for misuse by developers. Unsafe → safe renaming might be confusing - - * Maybe addressed by commit-reveal scheme FLIP: [https://github.com/onflow/flips/pull/123](https://github.com/onflow/flips/pull/123) - -* Next steps: - - * Voted, approved 🎉 - -#### Commit-reveal scheme for non-reverted randomness - -* FLIP: [https://github.com/onflow/flips/pull/123](https://github.com/onflow/flips/pull/123) - -* Overview: - - * Provide a safe pattern to address transaction abortion after a random is revealed - - * Commit to block - - * In the future, query history of past randoms - - * Use past, committed seed for new random - -* Status: - - * Positive sentiment - - * Waiting for feedback - -* Open problems: - - * Storage/sharing of state, see below - -* Next steps: - - * Gather more feedback - - * Maybe have breakout session to discuss concerns - -* Feedback: - - * Why stored on-chain? - - * What is the concern? - - * Should be stored in protocol state - - * Details on how data is shared/stored - - * If just implementation detail, make it explicit - - * Where else? - -#### Remove custom destructors - -* FLIP: [https://github.com/onflow/flips/pull/131](https://github.com/onflow/flips/pull/131) - -* Overview: - - * Proposal to address inability for users to destroy resources they own - - * One of the discussed options (others: try/catch, etc.) - - * Originated from attachments feature (attachment might prevent destruction of whole resource) - - * Remove destroy - - * Allows users to always destroy resources - -* Status: - - * Breakout session: Came up open problem - - * Synced with execution team, discussed tombstoning (marking data as deleted, "garbage collection") - - * Updated FLIP with default events - - * FLIP ready for another round of discussion - -* Open problems: - - * Philosophical question (sending to "burner account") - - * Existing code / applications - - * "Migration" path for use-cases like FT total supply - - * Tombstoning implementation - -* Next steps: - - * Need to discuss implementation approach more - - * Implementation is not blocking Stable Cadence release, but can vote on change itself, removal of custom destructors - - * Do not need a solution for "large resource deletion" problem - - * Breakout session next week, after giving time to read through updated proposal - -* Feedback: - -### Related FLIPs / forum discussions - -* [https://forum.onflow.org/t/idea-wasm-execution-engine-in-cadence/5164](https://forum.onflow.org/t/idea-wasm-execution-engine-in-cadence/5164) - -* [https://forum.onflow.org/t/storage-fees-improvements-and-few-random-ideas-on-the-way/5104](https://forum.onflow.org/t/storage-fees-improvements-and-few-random-ideas-on-the-way/5104) - -* [https://forum.onflow.org/t/seeking-feedback-on-cadence-cookbook-modernization/5200/2](https://forum.onflow.org/t/seeking-feedback-on-cadence-cookbook-modernization/5200/2) - diff --git a/meetings/2023-10-24.md b/meetings/2023-10-24.md deleted file mode 100644 index b8822d054e..0000000000 --- a/meetings/2023-10-24.md +++ /dev/null @@ -1,277 +0,0 @@ - -## Oct 24th, 2023 - -### FLIPs - -#### 134: Relax interface conformance restrictions - -* FLIP: [https://github.com/onflow/flips/pull/134](https://github.com/onflow/flips/pull/134) - -* Overview: - - * Follow up on interface conformance improvements ([https://github.com/onflow/flips/pull/83](https://github.com/onflow/flips/pull/83)). - - * Proposes to allow empty function declaration defined in one interface to coexist with a default function implementation defined in another interface. - - * Currently the same is allowed if the empty declaration has a pre/post condition. - - * When interface default functions were introduced, interface inheritance did not exist yet - - * Current behavior was intentional, tried to avoid interface author breaking implementations by adding function implementation (default function) - -* Status: - - * FLIP is waiting for a final decision - - * Reference implementation is complete: [https://github.com/onflow/cadence/pull/2725](https://github.com/onflow/cadence/pull/2725) - -* Next steps: - - * Would like to get more feedback - - * Provide means / explanation to try out - -* Notes: - - * Accepted - -#### 210: Improvement to entitlement mapping syntax - -* FLIP: [https://github.com/onflow/flips/pull/210](https://github.com/onflow/flips/pull/210) - -* Overview: - - * Got some feedback that visually entitlements and entitlement mappings appear too similar when used in an `access` modifier. This can be confusing to developers because the former cannot be accessed on an unentitled reference, while the latter can be (and produces an unentitled output) - - * Proposed needing a `mapping` keyword in access modifiers: e.g. `access(mapping M)` - -* Status: - - * FLIP proposed, has general approval - -* Next Steps: - - * Accept FLIP, merge implementation? - -* Notes: - - * Approved - -#### 196: Restrict Capabilities Publish - -* FLIP: [https://github.com/onflow/flips/pull/197](https://github.com/onflow/flips/pull/197) - -* Overview: - - * Current Cap Cons API allows publishing capabilities of another account - - * Was not possible with linking API - - * Could lead to confusion for developers (e.g. query balance, but balance is from another account) - -* Status: - - * Ready for vote - -* Next Steps: - -* Notes: - - * Approved - -#### 212: Reject references to references - -* FLIP: [https://github.com/onflow/flips/pull/212](https://github.com/onflow/flips/pull/212) - -* Overview: - - * It is currently possible to create references to references, e.g. &&T - - * Such references are not useful - - * In Cadence 1.0, additional work is requires to keep them working - - * Proposal is to forbid them - -* Status: - - * Ready for vote - -* Next Steps: - -* Notes: - - * Approved - -#### 131: Remove custom destructors - -* FLIP: [https://github.com/onflow/flips/pull/131](https://github.com/onflow/flips/pull/131) - -* Overview: - - * Proposal to address inability for users to destroy resources they own - - * One of the discussed options (others: try/catch, etc.) - - * Originated from attachments feature (attachment might prevent destruction of whole resource) - - * Remove destroy - - * Allows users to always destroy resources - -* Status: - - * Updated FLIP with default events - - * Discovered that introduction of attachments would require additional code in e.g. Vault.deposit to prevent exploit - - * FLIP ready for another round of discussion - -* Open problems: - - * Philosophical question (sending to "burner account") - - * Existing code / applications - - * "Migration" path for use-cases like FT total supply - - * Tombstoning implementation - -* Next steps: - - * Need to discuss implementation approach more - - * Implementation is not blocking Stable Cadence release, but can vote on change itself, removal of custom destructors - - * Do not need a solution for "large resource deletion" problem - - * Breakout session next week, after giving time to read through updated proposal - -* Feedback: - - * Non-mutable contraction mainnet using custom destructor - - * Overhead creating workaround - - * Will USDC implement a workaround ? - -* Notes: - - * Approved - -#### 95: Entitlements migration - -* FLIP: [https://github.com/onflow/flips/pull/95](https://github.com/onflow/flips/pull/95) - -* Overview: - -* Status: - -* Next Steps: - -#### 179: Staged Contract Updates - -* FLIP: [https://github.com/onflow/flips/pull/179](https://github.com/onflow/flips/pull/179) - -* Overview: - - * Contract mechanism to define contract update deployments and execute updates in stages at/beyond a block height. Execution can also be delegated to a third party via Capabilities - -* Status: - - * Proposed & approved by Jerome & Josh - - * Was hoping for community approval on the FLIP before moving to approval, but only feedback provided so far - -* Next Steps: - - * Approve unless recent feedback is opposed - - * Merge tryUpdate() to finalize v0 implementation & build out tests - - * Design automated update solution so delegated updates can be executed immediately post-spork - - * Begin to address callouts around: - - * Creating update configuration - - * Emulating configured updates - - * Monitoring update status - -### Other - -#### Discuss changes to attachments - -* Overview - - * Problem: - - * Attachments are able to declare what entitlements they need, to perform operations on base - - * A *third-party* might prepare a value with an attachment. With the transfer of the value, also the attachment and thus the permissions on the base, are transferred - - * The receiver might not realize - - * Reference to base stays "alive" beyond TX/script - - * Running example: - - * Currency converter on vault, can deposit and withdraw - - * Proposal: - - * Remove support for requirement of entitlements - - * Only allow public access to begin with - - * Later: Add support for entitled access, - - * e.g. through - - * Entitlement mapping - - * `access(M) attachment A for S {}` - - * Privilege escalation through mapping? - E.g. Deposit → Withdraw - - * ```cadence - mapping M { - X -> Y - } - - access(Y) fun foo() { - // can use X on base - } - ``` - - * Maybe hardcode to Identity mapping? - - * `access(X) fun foo() { … }` - - * no mapping - - * Requirements on per-function level (instead of whole attachment) - - * Do not want to require splitting attachments into parts - - * Alternative: Sanitization - - * Doesn’t scale, too easy to forget, footgun ("malicious USB stick") - -* Status: - - * Decide if this / what should be proposed in a FLIP - -* Next steps: - - * Propose FLIP for - - * Requirement removal - - * Propose unentitled access to start with - - * Can add entitled access later (see above) - - * Examples for proposals which allow entitlements diff --git a/meetings/2023-11-15.md b/meetings/2023-11-15.md deleted file mode 100644 index ea6c8018e5..0000000000 --- a/meetings/2023-11-15.md +++ /dev/null @@ -1,120 +0,0 @@ - -# Nov 15th, 2023 - -## FLIPs - -### 179: Staged Contract Updates - -* FLIP: [https://github.com/onflow/flips/pull/179](https://github.com/onflow/flips/pull/179) - -* Overview: - - * Contract mechanism to define contract update deployments and execute updates in stages at/beyond a block height. Execution can also be delegated to a third party via Capabilities - -* Status: - - * Approved - -### 217: New behavior for attachments with entitlements - -* FLIP: [https://github.com/onflow/flips/pull/213](https://github.com/onflow/flips/pull/213) - -* Overview: - - * Current attachment feature, requiring entitlements, allows third-parties to "sneak in" permissions into the base value - - * Proposal removes entitlement requirements, entitlements are derived from reference on base - - * Simple compromise - - * Tradeoff between power and safety. Only use-case that is no longer possible is read-escalation - -* Status: - - * "Audit" from security researcher - - * No open problems, proposal is complete and looking for feedback - -* Next Steps: - - * Accept unless there is no further feedback until end of next week - -## Other - -### Cadence 1.0 feedback - -* Austin reached out to community, asked for awareness - - * Very little awareness - - * Surprise of breaking changes - - * Breaking changes are not that big of a deal - - * But fact of breaking is scary - -* Going to talk to top 20 projects, with Andrea and Albert - - * Awareness - - * Get feedback - - * Support - -* Have not "advertised" it much so far - -* With rollout plan and environments, tools, etc. "ready", more announcements - -* Cadence 1.0 hackathon? (both projects and bug hunting / bug bash) - - * Example: OpenSea Sea Port bug bash - -* Cadence 1.0 office hours - -* Incentivize update? - -* Blackout periods? Awareness through disruption - - * TN - - * How to even do that on MN? Downtime would be brutal - - * Maybe depend on update staged? - -* How to amplify message? - - * In tooling like CLI, Emulator, etc. - - * In tools/projects like Flowdiver - - * On Website - -* Should not hide / make it very clear that this release is breaking - - * But also explain why the breaking changes are made (security, features, locked down contracts, etc.) - -### Cadence 1.0 migration plan - -* Had breakout session - -* Use Sandboxnet, clean network - - * Run pre-1.0 for a while, allow community to seed the environment with contracts and data - - * Then switch over - -* Is a clean Sandboxnet with 1.0 adding much value over Emulator? - - * Not really? For most developers Emulator is enough - - * Some developers don’t bother with the Emulator, go directly to TN - - * Some projects are relying on other projects (e.g FIND on FLOAT) - - * Difficult to have all dependencies deployed themselves in e.g. Emulator or even SN - - * Bringing up clean SN is not much effort - - * Bringing up SN from TN state is a lot of effort - - * "Seeding-period SN" solution good tradeoff diff --git a/meetings/README.md b/meetings/README.md new file mode 100644 index 0000000000..6d300c351c --- /dev/null +++ b/meetings/README.md @@ -0,0 +1,3 @@ +# Cadence Language and Execution Working Group + +Meeting notes moved to https://github.com/onflow/Flow-Working-Groups/tree/main/cadence_language_and_execution_working_group From 1bae18bcbc80128ea841c82cd435ba47c0eee6de Mon Sep 17 00:00:00 2001 From: turbolent Date: Mon, 21 Oct 2024 21:42:16 +0000 Subject: [PATCH 26/46] v1.2.1 --- npm-packages/cadence-parser/package.json | 2 +- version.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/npm-packages/cadence-parser/package.json b/npm-packages/cadence-parser/package.json index 3d91318063..a3c6ba8a53 100644 --- a/npm-packages/cadence-parser/package.json +++ b/npm-packages/cadence-parser/package.json @@ -1,6 +1,6 @@ { "name": "@onflow/cadence-parser", - "version": "1.2.0-preview.52", + "version": "1.2.1-preview.52", "description": "The Cadence parser", "homepage": "https://github.com/onflow/cadence", "repository": { diff --git a/version.go b/version.go index 3ebbeae8ff..e72ee43566 100644 --- a/version.go +++ b/version.go @@ -21,4 +21,4 @@ package cadence -const Version = "v1.2.0" +const Version = "v1.2.1" From 95eb4723e1c9c0f29fd993e629cd8b6f93596cb9 Mon Sep 17 00:00:00 2001 From: Faye Amacker <33205765+fxamacker@users.noreply.github.com> Date: Tue, 22 Oct 2024 19:41:32 -0500 Subject: [PATCH 27/46] Update CCF CDDL for IntersectionType to match codec This updates CCF-related comments using CDDL notation to make them match the CCF codec implementation. --- encoding/ccf/decode_type.go | 6 ++---- encoding/ccf/encode.go | 3 +-- encoding/ccf/encode_type.go | 3 +-- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/encoding/ccf/decode_type.go b/encoding/ccf/decode_type.go index 6d8eb3ba13..4092a48c91 100644 --- a/encoding/ccf/decode_type.go +++ b/encoding/ccf/decode_type.go @@ -610,16 +610,14 @@ func (d *Decoder) decodeReferenceType( // // ; cbor-tag-intersection-type // #6.143([ -// type: inline-type / nil, -// types: [* inline-type] +// types: [+ inline-type] // ]) // // intersection-type-value = // // ; cbor-tag-intersection-type-value // #6.191([ -// type: type-value / nil, -// types: [* type-value] +// types: [+ type-value] // ]) // // NOTE: decodeTypeFn is responsible for decoding inline-type or type-value. diff --git a/encoding/ccf/encode.go b/encoding/ccf/encode.go index 1c79c148b9..f8b9a9b4e9 100644 --- a/encoding/ccf/encode.go +++ b/encoding/ccf/encode.go @@ -1569,8 +1569,7 @@ func (e *Encoder) encodeReferenceTypeValue(typ *cadence.ReferenceType, visited c // // ; cbor-tag-intersection-type-value // #6.191([ -// type: type-value / nil, -// types: [* type-value] +// types: [+ type-value] // ]) func (e *Encoder) encodeIntersectionTypeValue(typ *cadence.IntersectionType, visited ccfTypeIDByCadenceType) error { rawTagNum := []byte{0xd8, CBORTagIntersectionTypeValue} diff --git a/encoding/ccf/encode_type.go b/encoding/ccf/encode_type.go index d952fe6e93..223c6b22df 100644 --- a/encoding/ccf/encode_type.go +++ b/encoding/ccf/encode_type.go @@ -604,8 +604,7 @@ func (e *Encoder) encodeReferenceTypeWithRawTag( // // ; cbor-tag-intersection-type // #6.143([ -// type: inline-type / nil, -// types: [* inline-type] +// types: [+ inline-type] // ]) func (e *Encoder) encodeIntersectionType(typ *cadence.IntersectionType, tids ccfTypeIDByCadenceType) error { rawTagNum := []byte{0xd8, CBORTagIntersectionType} From d3403dc11ed73c8c6e728d7d2fe7c1444260c5e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20M=C3=BCller?= Date: Wed, 23 Oct 2024 09:56:36 -0700 Subject: [PATCH 28/46] flixkit-go is now v2 --- tools/update/config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/update/config.yaml b/tools/update/config.yaml index 3f6508e376..f41178de50 100644 --- a/tools/update/config.yaml +++ b/tools/update/config.yaml @@ -113,6 +113,6 @@ repos: - onflow/cadence-tools/test - onflow/cadence-tools/lint - onflow/cadence-tools/languageserver - - onflow/flixkit-go + - onflow/flixkit-go/v2 - onflow/flowkit/v2 - onflow/flow-evm-gateway From 0e1b932b7d6f15842584f53f5346913c679e6e52 Mon Sep 17 00:00:00 2001 From: Supun Setunga Date: Wed, 23 Oct 2024 11:44:12 -0700 Subject: [PATCH 29/46] 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 { From e3c382192bd76fbfafbe2fa2d2ef24ee04c3a8b6 Mon Sep 17 00:00:00 2001 From: Faye Amacker <33205765+fxamacker@users.noreply.github.com> Date: Wed, 23 Oct 2024 20:01:28 -0500 Subject: [PATCH 30/46] Fix and improve CCF CDDL in comments Changes to CDDL notation and other comments include: - Fix entitlement CCF CDDL - Remove deprecated path-capability CCF CDDL - Update inclusiverange-value CCF CDDL - and other minor improvements --- encoding/ccf/consts.go | 2 +- encoding/ccf/decode.go | 17 ++--------------- encoding/ccf/decode_type.go | 18 +++++++++--------- encoding/ccf/decode_typedef.go | 2 +- encoding/ccf/encode.go | 13 +++++++++---- encoding/ccf/encode_type.go | 18 +++++++++--------- 6 files changed, 31 insertions(+), 39 deletions(-) diff --git a/encoding/ccf/consts.go b/encoding/ccf/consts.go index f4d25b2d01..45124a131a 100644 --- a/encoding/ccf/consts.go +++ b/encoding/ccf/consts.go @@ -125,7 +125,7 @@ const ( CBORTagIntersectionTypeValue CBORTagCapabilityTypeValue CBORTagFunctionTypeValue - CBORTagInclusiveRangeTypeValue // InclusiveRange is stored as a composite value. + CBORTagInclusiveRangeTypeValue CBORTagEntitlementSetAuthorizationAccessTypeValue CBORTagEntitlementMapAuthorizationAccessTypeValue _ diff --git a/encoding/ccf/decode.go b/encoding/ccf/decode.go index db5ab6d09f..186bd738d7 100644 --- a/encoding/ccf/decode.go +++ b/encoding/ccf/decode.go @@ -369,8 +369,7 @@ func (d *Decoder) decodeTypeAndValue(types *cadenceTypeByCCFTypeID) (cadence.Val // / dict-value // / composite-value // / path-value -// / path-capability-value -// / id-capability-value +// / capability-value // / inclusiverange-value // / function-value // / type-value @@ -1446,24 +1445,12 @@ func (d *Decoder) decodePath() (cadence.Value, error) { // decodeCapability decodes encoded capability-value as // language=CDDL // -// capability-value = -// -// id-capability-value -// / path-capability-value -// -// id-capability-value = [ +// capability-value = [ // // address: address-value, // id: uint64-value // // ] -// -// path-capability-value = [ -// -// address: address-value, -// path: path-value -// -// ] func (d *Decoder) decodeCapability(typ *cadence.CapabilityType, types *cadenceTypeByCCFTypeID) (cadence.Value, error) { // typ can be different from runtime CapabilityType because borrow type can be nil. // In this case, runtime type is encoded with the value (as tag content for tag CBORTagTypeAndValue). diff --git a/encoding/ccf/decode_type.go b/encoding/ccf/decode_type.go index 4092a48c91..3fa743c6f9 100644 --- a/encoding/ccf/decode_type.go +++ b/encoding/ccf/decode_type.go @@ -361,14 +361,14 @@ func (d *Decoder) decodeCapabilityType( // // ; cbor-tag-entitlement-set-authorization-type // #6.146([ -// kind: uint8, -// entitlements: +[string] +// kind: uint, +// entitlements: [+ tstr], // ]) // // entitlement-map-authorization-type = // // ; cbor-tag-entitlement-map-authorization-type -// #6.147(entitlement: string) +// #6.147(tstr) // // authorization-type-value = // @@ -382,14 +382,14 @@ func (d *Decoder) decodeCapabilityType( // // ; cbor-tag-entitlement-set-authorization-type-value // #6.195([ -// kind: uint8, -// entitlements: +[string] +// kind: uint, +// entitlements: [+ tstr], // ]) // // entitlement-map-authorization-type-value = // // ; cbor-tag-entitlement-map-authorization-type-value -// #6.196(entitlement: string) +// #6.196(tstr) func (d *Decoder) decodeAuthorization(isType bool) (cadence.Authorization, error) { nt, err := d.dec.NextType() if err != nil { @@ -454,8 +454,8 @@ const entitlementSetAuthorizationArraySize = 2 // // ; cbor-tag-entitlement-set-authorization-type // #6.146([ -// kind: uint8, -// entitlements: +[string] +// kind: uint, +// entitlements: [+ tstr], // ]) func (d *Decoder) decodeEntitlementSetAuthorization() (cadence.Authorization, error) { @@ -569,7 +569,7 @@ func (d *Decoder) decodeEntitlementMapAuthorization() (cadence.Authorization, er // // ; cbor-tag-reference-type-value // #6.190([ -// authorized: authorization-type, +// authorized: authorization-type-value, // type: type-value, // ]) // diff --git a/encoding/ccf/decode_typedef.go b/encoding/ccf/decode_typedef.go index 192260d52e..efbff6b4ef 100644 --- a/encoding/ccf/decode_typedef.go +++ b/encoding/ccf/decode_typedef.go @@ -330,7 +330,7 @@ func (d *Decoder) decodeTypeDef( // fields: [ // * [ // field-name: tstr, -// field-type: inline-type +// field-type: inline-type, // ] // ] // diff --git a/encoding/ccf/encode.go b/encoding/ccf/encode.go index f8b9a9b4e9..224eadf4fb 100644 --- a/encoding/ccf/encode.go +++ b/encoding/ccf/encode.go @@ -423,8 +423,7 @@ func (e *Encoder) encodeTypeDefs(types []cadence.Type, tids ccfTypeIDByCadenceTy // / dict-value // / composite-value // / path-value -// / path-capability-value -// / id-capability-value +// / capability-value // / inclusiverange-value // / function-value // / type-value @@ -1030,7 +1029,13 @@ func encodeAndSortKeyValuePairs( // encodeInclusiveRange encodes cadence.InclusiveRange as // language=CDDL -// inclusiverange-value = [3*3 (key: value, value: value)] +// inclusiverange-value = [ +// +// start: value, +// stop: value, +// step: value, +// +// ] func (e *Encoder) encodeInclusiveRange(v *cadence.InclusiveRange, tids ccfTypeIDByCadenceType) error { staticElementType := v.InclusiveRangeType.ElementType @@ -1240,7 +1245,7 @@ func (e *Encoder) encodePath(x cadence.Path) error { // encodeCapability encodes cadence.Capability as // language=CDDL -// id-capability-value = [ +// capability-value = [ // // address: address-value, // id: uint64-value diff --git a/encoding/ccf/encode_type.go b/encoding/ccf/encode_type.go index 223c6b22df..509a6b4dd2 100644 --- a/encoding/ccf/encode_type.go +++ b/encoding/ccf/encode_type.go @@ -376,14 +376,14 @@ func (e *Encoder) encodeReferenceType( // // ; cbor-tag-entitlement-set-authorization-type // #6.146([ -// kind: uint8, -// entitlements: +[string] +// kind: uint, +// entitlements: [+ tstr], // ]) // // entitlement-map-authorization-type = // // ; cbor-tag-entitlement-map-authorization-type -// #6.147(entitlement: string) +// #6.147(tstr) // // authorization-type-value = // @@ -397,8 +397,8 @@ func (e *Encoder) encodeReferenceType( // // ; cbor-tag-entitlement-set-authorization-type-value // #6.195([ -// kind: uint8, -// entitlements: +[string] +// kind: uint, +// entitlements: [+ tstr], // ]) // // entitlement-map-authorization-type-value = @@ -442,8 +442,8 @@ func (e *Encoder) encodeAuthorization( // // ; cbor-tag-entitlement-set-authorization-type // #6.146([ -// kind: uint8, -// entitlements: +[string] +// kind: uint, +// entitlements: [+ tstr], // ]) // // or @@ -452,8 +452,8 @@ func (e *Encoder) encodeAuthorization( // // ; cbor-tag-entitlement-set-authorization-type-value // #6.195([ -// kind: uint8, -// entitlements: +[string] +// kind: uint, +// entitlements: [+ tstr], // ]) func (e *Encoder) encodeEntitlementSetAuthorizationWithRawTag( auth *cadence.EntitlementSetAuthorization, From babf34aadffd29a9bb920f7fe13c14d3bc5ec6ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20M=C3=BCller?= Date: Thu, 24 Oct 2024 15:29:26 -0700 Subject: [PATCH 31/46] run Cadence tests --- compat/main.py | 231 +++++++++++++++------ compat/suite/flow-core-contracts.yaml | 3 + compat/suite/green-goo-dao-flow-utils.yaml | 8 + 3 files changed, 175 insertions(+), 67 deletions(-) create mode 100644 compat/suite/green-goo-dao-flow-utils.yaml diff --git a/compat/main.py b/compat/main.py index 999d451fbd..e767937bba 100644 --- a/compat/main.py +++ b/compat/main.py @@ -17,6 +17,7 @@ from dacite import from_dict SUITE_PATH = Path("suite").resolve() +CLI_PATH = SUITE_PATH / "flow-cli" / "cmd" / "flow" @contextmanager def cwd(path): @@ -27,39 +28,78 @@ def cwd(path): finally: os.chdir(oldpwd) +def cadence_replacement(cadence_version: Optional[str]) -> str: + if cadence_version: + return f'github.com/onflow/cadence@{cadence_version}' + # default: point to local cadence repo + return shlex.quote(Path.cwd().parent.absolute().resolve().as_posix()) + +def flowgo_replacement(flowgo_version: Optional[str]) -> str: + if flowgo_version: + return f'github.com/onflow/flow-go@{flowgo_version}' + # default: use the newest version of flow-go available + return 'github.com/onflow/flow-go@latest' + +def build_cli( + cadence_version: Optional[str], + flowgo_version: Optional[str] +): + logger.info("Building CLI ...") + + with cwd(SUITE_PATH): + working_dir = SUITE_PATH / "flow-cli" + Git.clone("https://github.com/onflow/flow-cli.git", "master", working_dir) + with cwd(working_dir): + Go.replace_dependencies( + cadence_version=cadence_version, + flowgo_version=flowgo_version + ) + logger.info("Compiling CLI binary") + subprocess.run( + ["make", "binary"], + check=True + ) + + logger.info("Built CLI") + @dataclass class GoTest: path: str command: str - def run(self, working_dir: Path, prepare: bool, cadence_version: Optional[str], flowgo_version: Optional[str]) -> bool: - if cadence_version: - cadence_replacement = f'github.com/onflow/cadence@{cadence_version}' - else: - # default: point to local cadence repo - cadence_replacement = shlex.quote(Path.cwd().parent.absolute().resolve().as_posix()) - - if flowgo_version: - flowgo_replacement = f'github.com/onflow/flow-go@{flowgo_version}' - else: - # default: use the newest version of flow-go available - flowgo_replacement = 'github.com/onflow/flow-go@latest' + def run( + self, + working_dir: Path, + prepare: bool, + cadence_version: Optional[str], + flowgo_version: Optional[str] + ) -> bool: with cwd(working_dir / self.path): if prepare: - logger.info("Editing dependencies") - subprocess.run([ - "go", "get", flowgo_replacement, - ]) - subprocess.run([ - "go", "mod", "edit", "-replace", f'github.com/onflow/cadence={cadence_replacement}', - ]) - logger.info("Downloading dependencies") - subprocess.run([ - "go", "get", "-t", ".", - ]) - - result = subprocess.run(shlex.split(self.command)) + Go.replace_dependencies(cadence_version, flowgo_version) + + result = subprocess.run(self.command, shell=True) + return result.returncode == 0 + +@dataclass +class CadenceTest: + path: str + command: str + + def run( + self, + working_dir: Path, + prepare: bool, + cadence_version: Optional[str], + flowgo_version: Optional[str] + ) -> bool: + + env = os.environ.copy() + env["PATH"] = f"{shlex.quote(str(CLI_PATH))}:{env['PATH']}" + + with cwd(working_dir / self.path): + result = subprocess.run(self.command, shell=True, env=env) return result.returncode == 0 def load_index(path: Path) -> List[str]: @@ -73,6 +113,7 @@ class Description: url: str branch: str go_tests: List[GoTest] = field(default_factory=list) + cadence_tests: List[CadenceTest] = field(default_factory=list) @staticmethod def load(name: str) -> Description: @@ -85,69 +126,105 @@ def load(name: str) -> Description: def from_dict(cls, data: Dict): return from_dict(data_class=cls, data=data) - def _clone(self, working_dir: Path): - if working_dir.exists(): - for root, dirs, files in os.walk(working_dir): - for dir in dirs: - os.chmod(os.path.join(root, dir), stat.S_IRUSR | stat.S_IWUSR) - for file in files: - os.chmod(os.path.join(root, file), stat.S_IRUSR | stat.S_IWUSR) - shutil.rmtree(working_dir) - - logger.info(f"Cloning {self.url} ({self.branch})") - - Git.clone(self.url, self.branch, working_dir) - def run( self, name: str, prepare: bool, go_test: bool, + cadence_test: bool, cadence_version: Optional[str], flowgo_version: Optional[str], ) -> (bool): + logger.info(f"Running tests for {name} ...") + working_dir = SUITE_PATH / name if prepare: - self._clone(working_dir) + Git.clone(self.url, self.branch, working_dir) go_tests_succeeded = True if go_test: for test in self.go_tests: - if not test.run(working_dir, prepare=prepare, cadence_version=cadence_version, flowgo_version=flowgo_version): + if not test.run( + working_dir, + prepare=prepare, + cadence_version=cadence_version, + flowgo_version=flowgo_version + ): go_tests_succeeded = False - succeeded = go_tests_succeeded + cadence_tests_succeeded = True + if cadence_test: + for test in self.cadence_tests: + if not test.run( + working_dir, + prepare=prepare, + cadence_version=cadence_version, + flowgo_version=flowgo_version + ): + cadence_tests_succeeded = False + + return go_tests_succeeded and cadence_tests_succeeded - return succeeded +class Go: + + @staticmethod + def mod_replace(original: str, replacement: str): + subprocess.run( + ["go", "mod", "edit", "-replace", f'{original}={replacement}'], + check=True + ) + + @staticmethod + def mod_tidy(): + subprocess.run( + ["go", "mod", "tidy"], + check=True + ) + + @staticmethod + def replace_dependencies( + cadence_version: Optional[str], + flowgo_version: Optional[str] + ): + logger.info("Editing dependencies") + Go.mod_replace("github.com/onflow/cadence", cadence_replacement(cadence_version)) + Go.mod_replace("github.com/onflow/flow-go", flowgo_replacement(flowgo_version)) + Go.mod_tidy() class Git: @staticmethod def clone(url: str, branch: str, working_dir: Path): - subprocess.run([ - "git", "clone", "--depth", "1", "--branch", - branch, url, working_dir - ]) + if working_dir.exists(): + Git._clean(working_dir) + + logger.info(f"Cloning {url} ({branch})") + + subprocess.run( + ["git", "clone", "--depth", "1", "--branch", branch, url, working_dir], + check=True + ) + + @staticmethod + def _clean(working_dir: Path): + for root, dirs, files in os.walk(working_dir): + for dir in dirs: + os.chmod(os.path.join(root, dir), stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR) + for file in files: + os.chmod(os.path.join(root, file), stat.S_IRUSR | stat.S_IWUSR) + shutil.rmtree(working_dir) @staticmethod def get_head_ref() -> str: completed_process = subprocess.run( ["git", "rev-parse", "--abbrev-ref", "HEAD"], capture_output=True, + check=True ) - if completed_process.returncode != 0: - raise Exception('failed to get current Git ref') return completed_process.stdout.decode("utf-8").strip() - @staticmethod - def checkout(ref: str): - completed_process = subprocess.run(["git", "checkout", ref]) - if completed_process.returncode != 0: - raise Exception(f'failed to checkout ref {ref}') - - @click.command() @click.option( "--rerun", @@ -161,6 +238,12 @@ def checkout(ref: str): default=True, help="Run the suite Go tests" ) +@click.option( + "--cadence-test/--no-cadence-test", + is_flag=True, + default=True, + help="Run the suite Cadence tests" +) @click.option( "--cadence-version", default=None, @@ -176,20 +259,34 @@ def checkout(ref: str): nargs=-1, ) def main( - rerun: bool, - go_test: bool, - cadence_version: str, - flowgo_version: str, - names: Collection[str] + rerun: bool, + go_test: bool, + cadence_test: bool, + cadence_version: str, + flowgo_version: str, + names: Collection[str] ): + logger.info( + f'Chosen versions: ' + + f'cadence@{ cadence_version if cadence_version else "local version" }, ' + + f'flow-go@{flowgo_version if flowgo_version else "latest"}' + ) + prepare = not rerun + if cadence_test and prepare: + build_cli( + cadence_version=cadence_version, + flowgo_version=flowgo_version, + ) + # Run for the current checkout current_success = run( prepare=prepare, go_test=go_test, + cadence_test=cadence_test, cadence_version=cadence_version, flowgo_version=flowgo_version, names=names @@ -200,17 +297,16 @@ def main( def run( - prepare: bool, - go_test: bool, - cadence_version: str, - flowgo_version: str, - names: Collection[str] + prepare: bool, + go_test: bool, + cadence_test: bool, + cadence_version: str, + flowgo_version: str, + names: Collection[str] ) -> (bool): all_succeeded = True - logger.info(f'Chosen versions: cadence@{ cadence_version if cadence_version else "local version" }, flow-go@{flowgo_version if flowgo_version else "latest"}') - if not names: names = load_index(SUITE_PATH / "index.yaml") @@ -222,6 +318,7 @@ def run( name, prepare=prepare, go_test=go_test, + cadence_test=cadence_test, cadence_version=cadence_version, flowgo_version=flowgo_version, ) diff --git a/compat/suite/flow-core-contracts.yaml b/compat/suite/flow-core-contracts.yaml index 0be3807e9f..eee8583a9d 100644 --- a/compat/suite/flow-core-contracts.yaml +++ b/compat/suite/flow-core-contracts.yaml @@ -7,3 +7,6 @@ branch: master go_tests: - path: lib/go/test command: make test +cadence_tests: +- path: . + command: flow test tests/*.cdc diff --git a/compat/suite/green-goo-dao-flow-utils.yaml b/compat/suite/green-goo-dao-flow-utils.yaml new file mode 100644 index 0000000000..82f2925875 --- /dev/null +++ b/compat/suite/green-goo-dao-flow-utils.yaml @@ -0,0 +1,8 @@ +description: Green Goo Dao flow-utils +maintainers: + - bastian.mueller@flowfoundation.org +url: https://github.com/turbolent/flow-utils.git +branch: improvements +cadence_tests: +- path: . + command: npm i && ./run-tests.sh From 3fe049d0aeaa63fa3c3791462fe09cfcda93710d Mon Sep 17 00:00:00 2001 From: j pimmel Date: Fri, 25 Oct 2024 21:32:31 -0700 Subject: [PATCH 32/46] Update README.md --- npm-packages/cadence-parser/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/npm-packages/cadence-parser/README.md b/npm-packages/cadence-parser/README.md index 6315c24b5e..93e999ce23 100644 --- a/npm-packages/cadence-parser/README.md +++ b/npm-packages/cadence-parser/README.md @@ -11,8 +11,8 @@ import {CadenceParser} from "@onflow/cadence-parser" const parser = await CadenceParser.create("cadence-parser.wasm") const ast = parser.parse(` - pub contract HelloWorld { - pub fun hello() { + access(all) contract HelloWorld { + access(all) fun hello() { log("Hello, world!") } } From aa3809df32218e9bc40b85dbf3b872fc39c30f7a Mon Sep 17 00:00:00 2001 From: j pimmel Date: Fri, 25 Oct 2024 21:35:03 -0700 Subject: [PATCH 33/46] Update index.tsx --- tools/ast-explorer/src/index.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/ast-explorer/src/index.tsx b/tools/ast-explorer/src/index.tsx index 265465b82d..d825d56bd4 100644 --- a/tools/ast-explorer/src/index.tsx +++ b/tools/ast-explorer/src/index.tsx @@ -24,9 +24,9 @@ import { Data, TreeView } from "./tree"; import { createRoot } from 'react-dom/client'; const defaultCode = ` -pub contract C { - pub resource R {} - pub fun createR(): @R { +access(all) contract C { + access(all) resource R {} + access(all) fun createR(): @R { return <- create R() } } From aceb8845bc06ff01f44fca3c3c8807ce560cb76e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20M=C3=BCller?= Date: Mon, 28 Oct 2024 09:51:12 -0700 Subject: [PATCH 34/46] update old uses of pub and priv --- docs/cadence.ebnf | 6 ++---- docs/development.md | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/docs/cadence.ebnf b/docs/cadence.ebnf index 25f86ec3e6..89057552c7 100644 --- a/docs/cadence.ebnf +++ b/docs/cadence.ebnf @@ -106,9 +106,7 @@ importDeclaration access : (* Not specified *) - | Priv - | Pub ( '(' Set ')' )? - | Access '(' ( Self | Contract | Account | All ) ')' + | Access '(' ( Self | Contract | Account | All | identifier) ')' ; compositeDeclaration @@ -224,7 +222,7 @@ nominalType ; functionType - : Fun '(' + : Fun '(' ( typeAnnotation ( ',' typeAnnotation )* )? ')' ( ':' typeAnnotation )? diff --git a/docs/development.md b/docs/development.md index 4a166bba19..e3f5364736 100644 --- a/docs/development.md +++ b/docs/development.md @@ -73,7 +73,7 @@ contains command-line tools that are useful when working on the implementation f ``` ``` - $ echo 'pub fun main () { log("Hello, world!") }' > hello.cdc + $ echo 'access(all) fun main () { log("Hello, world!") }' > hello.cdc $ go run ./cmd/main hello.cdc "Hello, world!" ``` From a0ef085006b78ce3ca7fb15908048d8745af8202 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20M=C3=BCller?= Date: Mon, 28 Oct 2024 15:10:17 -0700 Subject: [PATCH 35/46] document Go patterns used in the codebase --- docs/go.md | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 docs/go.md diff --git a/docs/go.md b/docs/go.md new file mode 100644 index 0000000000..e799fd7ffd --- /dev/null +++ b/docs/go.md @@ -0,0 +1,42 @@ +# Go + +## Patterns + +- To ensure interface cannot be implemented in other packages, + add a private function (first character must be lower-case) named "is" + type name, + which takes no arguments, returns nothing, and has an empty body. + + For example: + + ```go + type I interface { + isI() + } + ``` + + See https://go.dev/doc/faq#guarantee_satisfies_interface + +- To ensure a type implements an interface at compile-time, + use the "interface guard" pattern: + Introduce a global variable named `_`, type it as the interface, + and assign an empty value of the concrete type to it. + + For example: + + ```go + type T struct { + //... + } + + var _ io.ReadWriter = (*T)(nil) + + func (t *T) Read(p []byte) (n int, err error) { + // ... + ``` + + See + - https://go.dev/doc/faq#guarantee_satisfies_interface + - https://rednafi.com/go/interface_guards/ + - https://github.com/uber-go/guide/blob/master/style.md#verify-interface-compliance + - https://medium.com/@matryer/golang-tip-compile-time-checks-to-ensure-your-type-satisfies-an-interface-c167afed3aae + From 52bbfa4150a442a05cb914a4eb0f36bcc16befa1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20M=C3=BCller?= Date: Mon, 28 Oct 2024 15:13:23 -0700 Subject: [PATCH 36/46] move architecture diagram to contributor documentation directory --- .../runtime.monopic => docs/architecture.monopic | Bin runtime/runtime.png => docs/architecture.png | Bin runtime/runtime.svg => docs/architecture.svg | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename runtime/runtime.monopic => docs/architecture.monopic (100%) rename runtime/runtime.png => docs/architecture.png (100%) rename runtime/runtime.svg => docs/architecture.svg (100%) diff --git a/runtime/runtime.monopic b/docs/architecture.monopic similarity index 100% rename from runtime/runtime.monopic rename to docs/architecture.monopic diff --git a/runtime/runtime.png b/docs/architecture.png similarity index 100% rename from runtime/runtime.png rename to docs/architecture.png diff --git a/runtime/runtime.svg b/docs/architecture.svg similarity index 100% rename from runtime/runtime.svg rename to docs/architecture.svg From dccae9affb09cae9cf861d0722842152b3e8c081 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20M=C3=BCller?= Date: Mon, 28 Oct 2024 15:36:25 -0700 Subject: [PATCH 37/46] move runtime tests --- {tests => runtime}/account_test.go | 2 +- {tests => runtime}/attachments_test.go | 2 +- {tests => runtime}/capabilities_test.go | 2 +- {tests => runtime}/capabilitycontrollers_test.go | 2 +- {tests => runtime}/contract_test.go | 2 +- {tests => runtime}/contract_update_test.go | 2 +- {tests => runtime}/contract_update_validation_test.go | 2 +- {tests => runtime}/convertTypes_test.go | 2 +- {tests => runtime}/convertValues_test.go | 4 ++-- {tests => runtime}/coverage_test.go | 2 +- {tests => runtime}/crypto_test.go | 2 +- {tests => runtime}/debugger_test.go | 2 +- {tests => runtime}/deployedcontract_test.go | 2 +- {tests => runtime}/deployment_test.go | 2 +- {tests => runtime}/entitlements_test.go | 2 +- {tests => runtime}/error_test.go | 2 +- {tests => runtime}/errors_test.go | 2 +- {tests => runtime}/ft_test.go | 2 +- {tests => runtime}/import_test.go | 2 +- {tests => runtime}/imported_values_memory_metering_test.go | 2 +- {tests => runtime}/inbox_test.go | 2 +- {tests => runtime}/literal_test.go | 2 +- {tests => runtime}/nft_test.go | 2 +- {tests => runtime}/predeclaredvalues_test.go | 2 +- {tests => runtime}/program_params_validation_test.go | 2 +- {tests => runtime}/resource_duplicate_test.go | 2 +- {tests => runtime}/resourcedictionary_test.go | 2 +- {tests => runtime}/rlp_test.go | 2 +- {tests => runtime}/runtime_memory_metering_test.go | 2 +- {tests => runtime}/runtime_test.go | 2 +- {tests => runtime}/sharedstate_test.go | 2 +- {tests => runtime}/storage_test.go | 2 +- {tests => runtime}/type_test.go | 2 +- {tests => runtime}/validation_test.go | 2 +- 34 files changed, 35 insertions(+), 35 deletions(-) rename {tests => runtime}/account_test.go (99%) rename {tests => runtime}/attachments_test.go (99%) rename {tests => runtime}/capabilities_test.go (99%) rename {tests => runtime}/capabilitycontrollers_test.go (99%) rename {tests => runtime}/contract_test.go (99%) rename {tests => runtime}/contract_update_test.go (99%) rename {tests => runtime}/contract_update_validation_test.go (99%) rename {tests => runtime}/convertTypes_test.go (99%) rename {tests => runtime}/convertValues_test.go (99%) rename {tests => runtime}/coverage_test.go (99%) rename {tests => runtime}/crypto_test.go (99%) rename {tests => runtime}/debugger_test.go (99%) rename {tests => runtime}/deployedcontract_test.go (99%) rename {tests => runtime}/deployment_test.go (99%) rename {tests => runtime}/entitlements_test.go (99%) rename {tests => runtime}/error_test.go (99%) rename {tests => runtime}/errors_test.go (99%) rename {tests => runtime}/ft_test.go (99%) rename {tests => runtime}/import_test.go (99%) rename {tests => runtime}/imported_values_memory_metering_test.go (99%) rename {tests => runtime}/inbox_test.go (99%) rename {tests => runtime}/literal_test.go (99%) rename {tests => runtime}/nft_test.go (99%) rename {tests => runtime}/predeclaredvalues_test.go (99%) rename {tests => runtime}/program_params_validation_test.go (99%) rename {tests => runtime}/resource_duplicate_test.go (99%) rename {tests => runtime}/resourcedictionary_test.go (99%) rename {tests => runtime}/rlp_test.go (99%) rename {tests => runtime}/runtime_memory_metering_test.go (99%) rename {tests => runtime}/runtime_test.go (99%) rename {tests => runtime}/sharedstate_test.go (99%) rename {tests => runtime}/storage_test.go (99%) rename {tests => runtime}/type_test.go (99%) rename {tests => runtime}/validation_test.go (99%) diff --git a/tests/account_test.go b/runtime/account_test.go similarity index 99% rename from tests/account_test.go rename to runtime/account_test.go index 3182684d35..ad8540f6e2 100644 --- a/tests/account_test.go +++ b/runtime/account_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package tests +package runtime_test import ( "fmt" diff --git a/tests/attachments_test.go b/runtime/attachments_test.go similarity index 99% rename from tests/attachments_test.go rename to runtime/attachments_test.go index cf3de8047c..e03c72dc22 100644 --- a/tests/attachments_test.go +++ b/runtime/attachments_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package tests +package runtime_test import ( "testing" diff --git a/tests/capabilities_test.go b/runtime/capabilities_test.go similarity index 99% rename from tests/capabilities_test.go rename to runtime/capabilities_test.go index f02f81c079..ade86c8d24 100644 --- a/tests/capabilities_test.go +++ b/runtime/capabilities_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package tests +package runtime_test import ( "testing" diff --git a/tests/capabilitycontrollers_test.go b/runtime/capabilitycontrollers_test.go similarity index 99% rename from tests/capabilitycontrollers_test.go rename to runtime/capabilitycontrollers_test.go index 2a9881d312..fbb0d924cc 100644 --- a/tests/capabilitycontrollers_test.go +++ b/runtime/capabilitycontrollers_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package tests +package runtime_test import ( "encoding/binary" diff --git a/tests/contract_test.go b/runtime/contract_test.go similarity index 99% rename from tests/contract_test.go rename to runtime/contract_test.go index 288424ea5c..5cc9579322 100644 --- a/tests/contract_test.go +++ b/runtime/contract_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package tests +package runtime_test import ( "encoding/hex" diff --git a/tests/contract_update_test.go b/runtime/contract_update_test.go similarity index 99% rename from tests/contract_update_test.go rename to runtime/contract_update_test.go index 7cee60bf24..c032eb7124 100644 --- a/tests/contract_update_test.go +++ b/runtime/contract_update_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package tests +package runtime_test import ( "testing" diff --git a/tests/contract_update_validation_test.go b/runtime/contract_update_validation_test.go similarity index 99% rename from tests/contract_update_validation_test.go rename to runtime/contract_update_validation_test.go index 0bebbb99a0..f4e77b8c85 100644 --- a/tests/contract_update_validation_test.go +++ b/runtime/contract_update_validation_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package tests +package runtime_test import ( "encoding/hex" diff --git a/tests/convertTypes_test.go b/runtime/convertTypes_test.go similarity index 99% rename from tests/convertTypes_test.go rename to runtime/convertTypes_test.go index 5d5ea6b2a9..fea1f8a697 100644 --- a/tests/convertTypes_test.go +++ b/runtime/convertTypes_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package tests +package runtime_test import ( "testing" diff --git a/tests/convertValues_test.go b/runtime/convertValues_test.go similarity index 99% rename from tests/convertValues_test.go rename to runtime/convertValues_test.go index 9637b6fb0e..22cd45c5bc 100644 --- a/tests/convertValues_test.go +++ b/runtime/convertValues_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package tests +package runtime_test import ( _ "embed" @@ -2322,7 +2322,7 @@ func TestRuntimeExportCompositeValueWithFunctionValueField(t *testing.T) { assert.Equal(t, expected, actual) } -//go:embed test-export-json-deterministic.txt +//go:embed ../tests/test-export-json-deterministic.txt var exportJsonDeterministicExpected string func TestRuntimeExportJsonDeterministic(t *testing.T) { diff --git a/tests/coverage_test.go b/runtime/coverage_test.go similarity index 99% rename from tests/coverage_test.go rename to runtime/coverage_test.go index 8877be16eb..2c244b4c4d 100644 --- a/tests/coverage_test.go +++ b/runtime/coverage_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package tests +package runtime_test import ( "encoding/json" diff --git a/tests/crypto_test.go b/runtime/crypto_test.go similarity index 99% rename from tests/crypto_test.go rename to runtime/crypto_test.go index 636cece7e9..71da0b283a 100644 --- a/tests/crypto_test.go +++ b/runtime/crypto_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package tests +package runtime_test import ( "encoding/hex" diff --git a/tests/debugger_test.go b/runtime/debugger_test.go similarity index 99% rename from tests/debugger_test.go rename to runtime/debugger_test.go index 3289668907..7d5d5f8907 100644 --- a/tests/debugger_test.go +++ b/runtime/debugger_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package tests +package runtime_test import ( "sync" diff --git a/tests/deployedcontract_test.go b/runtime/deployedcontract_test.go similarity index 99% rename from tests/deployedcontract_test.go rename to runtime/deployedcontract_test.go index 7090f7ad77..b73b16f71d 100644 --- a/tests/deployedcontract_test.go +++ b/runtime/deployedcontract_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package tests +package runtime_test import ( "testing" diff --git a/tests/deployment_test.go b/runtime/deployment_test.go similarity index 99% rename from tests/deployment_test.go rename to runtime/deployment_test.go index 475cceb86f..6b6cbe83bd 100644 --- a/tests/deployment_test.go +++ b/runtime/deployment_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package tests +package runtime_test import ( "encoding/hex" diff --git a/tests/entitlements_test.go b/runtime/entitlements_test.go similarity index 99% rename from tests/entitlements_test.go rename to runtime/entitlements_test.go index f0f5f7ea5f..8ffee3052b 100644 --- a/tests/entitlements_test.go +++ b/runtime/entitlements_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package tests +package runtime_test import ( "testing" diff --git a/tests/error_test.go b/runtime/error_test.go similarity index 99% rename from tests/error_test.go rename to runtime/error_test.go index 2a99de14ad..a27aecbcf2 100644 --- a/tests/error_test.go +++ b/runtime/error_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package tests +package runtime_test import ( "encoding/hex" diff --git a/tests/errors_test.go b/runtime/errors_test.go similarity index 99% rename from tests/errors_test.go rename to runtime/errors_test.go index 9fafcbf8fc..979a7c366e 100644 --- a/tests/errors_test.go +++ b/runtime/errors_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package tests +package runtime_test import ( "fmt" diff --git a/tests/ft_test.go b/runtime/ft_test.go similarity index 99% rename from tests/ft_test.go rename to runtime/ft_test.go index 2efce854de..5d7d78b5e6 100644 --- a/tests/ft_test.go +++ b/runtime/ft_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package tests +package runtime_test import ( "fmt" diff --git a/tests/import_test.go b/runtime/import_test.go similarity index 99% rename from tests/import_test.go rename to runtime/import_test.go index 2e75215a84..14a47febe0 100644 --- a/tests/import_test.go +++ b/runtime/import_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package tests +package runtime_test import ( "fmt" diff --git a/tests/imported_values_memory_metering_test.go b/runtime/imported_values_memory_metering_test.go similarity index 99% rename from tests/imported_values_memory_metering_test.go rename to runtime/imported_values_memory_metering_test.go index 8b24d84ae1..c3e7a882a8 100644 --- a/tests/imported_values_memory_metering_test.go +++ b/runtime/imported_values_memory_metering_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package tests +package runtime_test import ( "fmt" diff --git a/tests/inbox_test.go b/runtime/inbox_test.go similarity index 99% rename from tests/inbox_test.go rename to runtime/inbox_test.go index c2330bc954..00380e23e4 100644 --- a/tests/inbox_test.go +++ b/runtime/inbox_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package tests +package runtime_test import ( "fmt" diff --git a/tests/literal_test.go b/runtime/literal_test.go similarity index 99% rename from tests/literal_test.go rename to runtime/literal_test.go index 296488776f..e35033b250 100644 --- a/tests/literal_test.go +++ b/runtime/literal_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package tests +package runtime_test import ( "fmt" diff --git a/tests/nft_test.go b/runtime/nft_test.go similarity index 99% rename from tests/nft_test.go rename to runtime/nft_test.go index dd0f70db3d..fcaebdc473 100644 --- a/tests/nft_test.go +++ b/runtime/nft_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package tests +package runtime_test const modifiedNonFungibleTokenInterface = ` diff --git a/tests/predeclaredvalues_test.go b/runtime/predeclaredvalues_test.go similarity index 99% rename from tests/predeclaredvalues_test.go rename to runtime/predeclaredvalues_test.go index acefd56e08..58757a8bb7 100644 --- a/tests/predeclaredvalues_test.go +++ b/runtime/predeclaredvalues_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package tests +package runtime_test import ( "math/big" diff --git a/tests/program_params_validation_test.go b/runtime/program_params_validation_test.go similarity index 99% rename from tests/program_params_validation_test.go rename to runtime/program_params_validation_test.go index 827de1ebe5..f2ec7c4882 100644 --- a/tests/program_params_validation_test.go +++ b/runtime/program_params_validation_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package tests +package runtime_test import ( "fmt" diff --git a/tests/resource_duplicate_test.go b/runtime/resource_duplicate_test.go similarity index 99% rename from tests/resource_duplicate_test.go rename to runtime/resource_duplicate_test.go index 246f073a61..5f5f12c666 100644 --- a/tests/resource_duplicate_test.go +++ b/runtime/resource_duplicate_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package tests +package runtime_test import ( "testing" diff --git a/tests/resourcedictionary_test.go b/runtime/resourcedictionary_test.go similarity index 99% rename from tests/resourcedictionary_test.go rename to runtime/resourcedictionary_test.go index e1b939e74e..088d4e977f 100644 --- a/tests/resourcedictionary_test.go +++ b/runtime/resourcedictionary_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package tests +package runtime_test import ( "encoding/hex" diff --git a/tests/rlp_test.go b/runtime/rlp_test.go similarity index 99% rename from tests/rlp_test.go rename to runtime/rlp_test.go index 1aa9296eed..17582dceee 100644 --- a/tests/rlp_test.go +++ b/runtime/rlp_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package tests +package runtime_test import ( "testing" diff --git a/tests/runtime_memory_metering_test.go b/runtime/runtime_memory_metering_test.go similarity index 99% rename from tests/runtime_memory_metering_test.go rename to runtime/runtime_memory_metering_test.go index e2aac366fd..f7e91fd7bf 100644 --- a/tests/runtime_memory_metering_test.go +++ b/runtime/runtime_memory_metering_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package tests +package runtime_test import ( "fmt" diff --git a/tests/runtime_test.go b/runtime/runtime_test.go similarity index 99% rename from tests/runtime_test.go rename to runtime/runtime_test.go index de7487cab3..abee65f080 100644 --- a/tests/runtime_test.go +++ b/runtime/runtime_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package tests +package runtime_test import ( "crypto/rand" diff --git a/tests/sharedstate_test.go b/runtime/sharedstate_test.go similarity index 99% rename from tests/sharedstate_test.go rename to runtime/sharedstate_test.go index b5d37b29a3..660c439b1c 100644 --- a/tests/sharedstate_test.go +++ b/runtime/sharedstate_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package tests +package runtime_test import ( "testing" diff --git a/tests/storage_test.go b/runtime/storage_test.go similarity index 99% rename from tests/storage_test.go rename to runtime/storage_test.go index 3895ca2327..b82b77a2cb 100644 --- a/tests/storage_test.go +++ b/runtime/storage_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package tests +package runtime_test import ( "encoding/binary" diff --git a/tests/type_test.go b/runtime/type_test.go similarity index 99% rename from tests/type_test.go rename to runtime/type_test.go index 5ee6afc790..2ae870e408 100644 --- a/tests/type_test.go +++ b/runtime/type_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package tests +package runtime_test import ( "testing" diff --git a/tests/validation_test.go b/runtime/validation_test.go similarity index 99% rename from tests/validation_test.go rename to runtime/validation_test.go index b46b609df8..980654b941 100644 --- a/tests/validation_test.go +++ b/runtime/validation_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package tests +package runtime_test import ( "testing" From 08eae83676fec388dcfd3747f87721eb8d2524ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20M=C3=BCller?= Date: Mon, 28 Oct 2024 15:48:09 -0700 Subject: [PATCH 38/46] fix test expectation --- runtime/convertValues_test.go | 2 +- .../test-export-json-deterministic.json | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename tests/test-export-json-deterministic.txt => runtime/test-export-json-deterministic.json (100%) diff --git a/runtime/convertValues_test.go b/runtime/convertValues_test.go index 22cd45c5bc..bebbf750ca 100644 --- a/runtime/convertValues_test.go +++ b/runtime/convertValues_test.go @@ -2322,7 +2322,7 @@ func TestRuntimeExportCompositeValueWithFunctionValueField(t *testing.T) { assert.Equal(t, expected, actual) } -//go:embed ../tests/test-export-json-deterministic.txt +//go:embed test-export-json-deterministic.json var exportJsonDeterministicExpected string func TestRuntimeExportJsonDeterministic(t *testing.T) { diff --git a/tests/test-export-json-deterministic.txt b/runtime/test-export-json-deterministic.json similarity index 100% rename from tests/test-export-json-deterministic.txt rename to runtime/test-export-json-deterministic.json From ed36b6ccf59804199cd67dac11f7392e074e8814 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20M=C3=BCller?= Date: Mon, 28 Oct 2024 15:48:26 -0700 Subject: [PATCH 39/46] remove outdated gitattributes for old parser --- runtime/.gitattributes | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 runtime/.gitattributes diff --git a/runtime/.gitattributes b/runtime/.gitattributes deleted file mode 100644 index 7a38edbb9a..0000000000 --- a/runtime/.gitattributes +++ /dev/null @@ -1,9 +0,0 @@ -*.interp linguist-generated=true -*.tokens linguist-generated=true -parser/cadence_parser.go linguist-generated=true -parser/cadence_lexer.go linguist-generated=true -parser/cadence_base_listener.go linguist-generated=true -parser/cadence_base_visitor.go linguist-generated=true -parser/cadence_visitor.go linguist-generated=true -parser/cadence_listener.go linguist-generated=true - From 258b177c5c227e51f8d266a30ce8868293ba1c15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20M=C3=BCller?= Date: Mon, 28 Oct 2024 16:21:50 -0700 Subject: [PATCH 40/46] move checker tests to sema package --- cmd/info/main.go | 6 +- compiler/compiler_test.go | 4 +- encoding/ccf/ccf_test.go | 4 +- encoding/json/encoding_test.go | 4 +- interpreter/value_test.go | 10 +- runtime/account_test.go | 16 +- runtime/contract_test.go | 4 +- runtime/entitlements_test.go | 4 +- runtime/import_test.go | 16 +- runtime/predeclaredvalues_test.go | 4 +- runtime/program_params_validation_test.go | 22 +- runtime/runtime_test.go | 14 +- sema/access_test.go | 636 ------------------ .../access_test.go => sema/accesses_test.go | 3 +- {tests/checker => sema}/account_test.go | 3 +- {tests/checker => sema}/any_test.go | 3 +- .../arrays_dictionaries_test.go | 3 +- {tests/checker => sema}/assert_test.go | 3 +- {tests/checker => sema}/assignment_test.go | 3 +- {tests/checker => sema}/attachments_test.go | 3 +- {tests/checker => sema}/boolean_test.go | 3 +- .../checker => sema}/builtinfunctions_test.go | 3 +- .../capability_controller_test.go | 3 +- {tests/checker => sema}/capability_test.go | 4 +- {tests/checker => sema}/casting_test.go | 3 +- {tests/checker => sema}/character_test.go | 3 +- {tests/checker => sema}/composite_test.go | 3 +- {tests/checker => sema}/conditional_test.go | 3 +- {tests/checker => sema}/conditions_test.go | 3 +- {tests/checker => sema}/conformance_test.go | 3 +- {tests/checker => sema}/contract_test.go | 3 +- {tests/checker => sema}/crypto_test.go | 3 +- {tests/checker => sema}/declaration_test.go | 3 +- {tests/checker => sema}/dictionary_test.go | 3 +- .../checker => sema}/dynamic_casting_test.go | 3 +- {tests/checker => sema}/entitlements_test.go | 3 +- {tests/checker => sema}/entrypoint_test.go | 3 +- {tests/checker => sema}/enum_test.go | 3 +- .../error_handling_test.go | 3 +- {tests/checker => sema}/events_test.go | 9 +- .../external_mutation_test.go | 3 +- {tests/checker => sema}/fixedpoint_test.go | 3 +- {tests/checker => sema}/for_test.go | 3 +- {tests/checker => sema}/force_test.go | 3 +- .../function_expression_test.go | 3 +- {tests/checker => sema}/function_test.go | 3 +- sema/gen/golden_test.go | 10 +- .../checker => sema}/genericfunction_test.go | 3 +- .../checker => sema}/hashable_struct_test.go | 3 +- {tests/checker => sema}/if_test.go | 3 +- {tests/checker => sema}/import_test.go | 3 +- {tests/checker => sema}/indexing_test.go | 3 +- .../checker => sema}/initialization_test.go | 3 +- {tests/checker => sema}/integer_test.go | 3 +- {tests/checker => sema}/interface_test.go | 3 +- {tests/checker => sema}/intersection_test.go | 3 +- {tests/checker => sema}/invalid_test.go | 3 +- {tests/checker => sema}/invocation_test.go | 3 +- {tests/checker => sema}/member_test.go | 3 +- {tests/checker => sema}/metatype_test.go | 3 +- {tests/checker => sema}/move_test.go | 3 +- {tests/checker => sema}/nesting_test.go | 3 +- {tests/checker => sema}/never_test.go | 3 +- .../checker => sema}/nil_coalescing_test.go | 3 +- {tests/checker => sema}/occurrences_test.go | 3 +- {tests/checker => sema}/operations_test.go | 3 +- {tests/checker => sema}/optional_test.go | 3 +- {tests/checker => sema}/overloading_test.go | 3 +- {tests/checker => sema}/path_test.go | 3 +- {tests/checker => sema}/pragma_test.go | 3 +- .../predeclaredvalues_test.go | 3 +- {tests/checker => sema}/purity_test.go | 3 +- {tests/checker => sema}/range_test.go | 3 +- {tests/checker => sema}/range_value_test.go | 3 +- {tests/checker => sema}/reference_test.go | 3 +- .../resource_test.go | 3 +- {tests/checker => sema}/return_test.go | 3 +- {tests/checker => sema}/rlp_test.go | 3 +- {tests/checker => sema}/runtimetype_test.go | 3 +- {tests/checker => sema}/storable_test.go | 3 +- {tests/checker => sema}/string_test.go | 3 +- {tests/checker => sema}/swap_test.go | 3 +- {tests/checker => sema}/switch_test.go | 3 +- {tests/checker => sema}/transactions_test.go | 3 +- .../checker => sema}/type_inference_test.go | 3 +- {tests/checker => sema}/typeargument_test.go | 3 +- {tests/checker => sema}/utils_test.go | 3 +- {tests/checker => sema}/while_test.go | 3 +- stdlib/builtin_test.go | 26 +- stdlib/test_test.go | 36 +- tests/interpreter/condition_test.go | 4 +- tests/interpreter/function_test.go | 6 +- tests/interpreter/if_test.go | 4 +- tests/interpreter/import_test.go | 24 +- tests/interpreter/interpreter_test.go | 46 +- tests/interpreter/member_test.go | 10 +- tests/interpreter/memory_metering_test.go | 10 +- tests/interpreter/metering_test.go | 26 +- tests/interpreter/reference_test.go | 26 +- tests/interpreter/resources_test.go | 96 +-- tests/interpreter/switch_test.go | 10 +- tests/interpreter/transactions_test.go | 4 +- tests/interpreter/uuid_test.go | 10 +- tests/{checker => sema_utils}/utils.go | 2 +- tools/analysis/analysis_test.go | 6 +- 105 files changed, 383 insertions(+), 946 deletions(-) delete mode 100644 sema/access_test.go rename tests/checker/access_test.go => sema/accesses_test.go (99%) rename {tests/checker => sema}/account_test.go (99%) rename {tests/checker => sema}/any_test.go (96%) rename {tests/checker => sema}/arrays_dictionaries_test.go (99%) rename {tests/checker => sema}/assert_test.go (96%) rename {tests/checker => sema}/assignment_test.go (98%) rename {tests/checker => sema}/attachments_test.go (99%) rename {tests/checker => sema}/boolean_test.go (94%) rename {tests/checker => sema}/builtinfunctions_test.go (99%) rename {tests/checker => sema}/capability_controller_test.go (98%) rename {tests/checker => sema}/capability_test.go (99%) rename {tests/checker => sema}/casting_test.go (99%) rename {tests/checker => sema}/character_test.go (96%) rename {tests/checker => sema}/composite_test.go (99%) rename {tests/checker => sema}/conditional_test.go (98%) rename {tests/checker => sema}/conditions_test.go (99%) rename {tests/checker => sema}/conformance_test.go (99%) rename {tests/checker => sema}/contract_test.go (99%) rename {tests/checker => sema}/crypto_test.go (99%) rename {tests/checker => sema}/declaration_test.go (99%) rename {tests/checker => sema}/dictionary_test.go (95%) rename {tests/checker => sema}/dynamic_casting_test.go (99%) rename {tests/checker => sema}/entitlements_test.go (99%) rename {tests/checker => sema}/entrypoint_test.go (98%) rename {tests/checker => sema}/enum_test.go (98%) rename tests/checker/errors_test.go => sema/error_handling_test.go (98%) rename {tests/checker => sema}/events_test.go (99%) rename {tests/checker => sema}/external_mutation_test.go (99%) rename {tests/checker => sema}/fixedpoint_test.go (99%) rename {tests/checker => sema}/for_test.go (99%) rename {tests/checker => sema}/force_test.go (97%) rename {tests/checker => sema}/function_expression_test.go (95%) rename {tests/checker => sema}/function_test.go (99%) rename {tests/checker => sema}/genericfunction_test.go (99%) rename {tests/checker => sema}/hashable_struct_test.go (95%) rename {tests/checker => sema}/if_test.go (98%) rename {tests/checker => sema}/import_test.go (99%) rename {tests/checker => sema}/indexing_test.go (98%) rename {tests/checker => sema}/initialization_test.go (99%) rename {tests/checker => sema}/integer_test.go (99%) rename {tests/checker => sema}/interface_test.go (99%) rename {tests/checker => sema}/intersection_test.go (99%) rename {tests/checker => sema}/invalid_test.go (98%) rename {tests/checker => sema}/invocation_test.go (99%) rename {tests/checker => sema}/member_test.go (99%) rename {tests/checker => sema}/metatype_test.go (99%) rename {tests/checker => sema}/move_test.go (97%) rename {tests/checker => sema}/nesting_test.go (99%) rename {tests/checker => sema}/never_test.go (98%) rename {tests/checker => sema}/nil_coalescing_test.go (98%) rename {tests/checker => sema}/occurrences_test.go (99%) rename {tests/checker => sema}/operations_test.go (99%) rename {tests/checker => sema}/optional_test.go (99%) rename {tests/checker => sema}/overloading_test.go (96%) rename {tests/checker => sema}/path_test.go (98%) rename {tests/checker => sema}/pragma_test.go (98%) rename {tests/checker => sema}/predeclaredvalues_test.go (95%) rename {tests/checker => sema}/purity_test.go (99%) rename {tests/checker => sema}/range_test.go (99%) rename {tests/checker => sema}/range_value_test.go (99%) rename {tests/checker => sema}/reference_test.go (99%) rename tests/checker/resources_test.go => sema/resource_test.go (99%) rename {tests/checker => sema}/return_test.go (99%) rename {tests/checker => sema}/rlp_test.go (97%) rename {tests/checker => sema}/runtimetype_test.go (99%) rename {tests/checker => sema}/storable_test.go (99%) rename {tests/checker => sema}/string_test.go (99%) rename {tests/checker => sema}/swap_test.go (99%) rename {tests/checker => sema}/switch_test.go (99%) rename {tests/checker => sema}/transactions_test.go (99%) rename {tests/checker => sema}/type_inference_test.go (99%) rename {tests/checker => sema}/typeargument_test.go (99%) rename {tests/checker => sema}/utils_test.go (96%) rename {tests/checker => sema}/while_test.go (97%) rename tests/{checker => sema_utils}/utils.go (99%) diff --git a/cmd/info/main.go b/cmd/info/main.go index 5f737ba99c..62a91f8a6c 100644 --- a/cmd/info/main.go +++ b/cmd/info/main.go @@ -31,7 +31,7 @@ import ( "github.com/onflow/cadence/parser" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - "github.com/onflow/cadence/tests/checker" + "github.com/onflow/cadence/tests/sema_utils" ) type command struct { @@ -80,7 +80,7 @@ var commands = map[string]command{ func dumpBuiltinTypes() { - allBaseSemaTypes := checker.AllBaseSemaTypes() + allBaseSemaTypes := sema_utils.AllBaseSemaTypes() types := make([]sema.Type, 0, len(allBaseSemaTypes)) @@ -239,7 +239,7 @@ func dumpBuiltinValues() { ty sema.Type } - allBaseSemaValueTypes := checker.AllBaseSemaValueTypes() + allBaseSemaValueTypes := sema_utils.AllBaseSemaValueTypes() standardLibraryValues := stdlib.DefaultScriptStandardLibraryValues(nil) valueTypes := make([]valueType, 0, len(allBaseSemaValueTypes)+len(standardLibraryValues)) diff --git a/compiler/compiler_test.go b/compiler/compiler_test.go index 17acf177d1..60c96154aa 100644 --- a/compiler/compiler_test.go +++ b/compiler/compiler_test.go @@ -24,12 +24,12 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/compiler/ir" - "github.com/onflow/cadence/tests/checker" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCompilerSimple(t *testing.T) { - checker, err := checker.ParseAndCheck(t, ` + checker, err := ParseAndCheck(t, ` fun inc(a: Int): Int { let mod = 1 return a + mod diff --git a/encoding/ccf/ccf_test.go b/encoding/ccf/ccf_test.go index db427edd67..3332bbb065 100644 --- a/encoding/ccf/ccf_test.go +++ b/encoding/ccf/ccf_test.go @@ -38,8 +38,8 @@ import ( "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/runtime" "github.com/onflow/cadence/sema" - "github.com/onflow/cadence/tests/checker" "github.com/onflow/cadence/tests/runtime_utils" + . "github.com/onflow/cadence/tests/sema_utils" "github.com/onflow/cadence/tests/utils" ) @@ -4949,7 +4949,7 @@ func TestEncodeSortedDictionary(t *testing.T) { } func exportFromScript(t *testing.T, code string) cadence.Value { - checker, err := checker.ParseAndCheck(t, code) + checker, err := ParseAndCheck(t, code) require.NoError(t, err) var uuid uint64 diff --git a/encoding/json/encoding_test.go b/encoding/json/encoding_test.go index 5a22360dd0..308c8e0e7c 100644 --- a/encoding/json/encoding_test.go +++ b/encoding/json/encoding_test.go @@ -31,7 +31,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/runtime" - "github.com/onflow/cadence/tests/checker" + . "github.com/onflow/cadence/tests/sema_utils" "github.com/onflow/cadence" "github.com/onflow/cadence/sema" @@ -1123,7 +1123,7 @@ func TestEncodeDictionary(t *testing.T) { } func exportFromScript(t *testing.T, code string) cadence.Value { - checker, err := checker.ParseAndCheck(t, code) + checker, err := ParseAndCheck(t, code) require.NoError(t, err) var uuid uint64 = 0 diff --git a/interpreter/value_test.go b/interpreter/value_test.go index 1bfc7d3cc5..8f4df2bcc1 100644 --- a/interpreter/value_test.go +++ b/interpreter/value_test.go @@ -36,7 +36,7 @@ import ( . "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - checkerUtils "github.com/onflow/cadence/tests/checker" + . "github.com/onflow/cadence/tests/sema_utils" "github.com/onflow/cadence/tests/utils" ) @@ -1898,9 +1898,9 @@ func TestEphemeralReferenceTypeConformance(t *testing.T) { } }` - checker, err := checkerUtils.ParseAndCheckWithOptions(t, + checker, err := ParseAndCheckWithOptions(t, code, - checkerUtils.ParseAndCheckOptions{}, + ParseAndCheckOptions{}, ) require.NoError(t, err) @@ -3622,9 +3622,9 @@ func TestNonStorable(t *testing.T) { } ` - checker, err := checkerUtils.ParseAndCheckWithOptions(t, + checker, err := ParseAndCheckWithOptions(t, code, - checkerUtils.ParseAndCheckOptions{}, + ParseAndCheckOptions{}, ) require.NoError(t, err) diff --git a/runtime/account_test.go b/runtime/account_test.go index ad8540f6e2..371cbba4cb 100644 --- a/runtime/account_test.go +++ b/runtime/account_test.go @@ -35,8 +35,8 @@ import ( . "github.com/onflow/cadence/runtime" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - "github.com/onflow/cadence/tests/checker" . "github.com/onflow/cadence/tests/runtime_utils" + . "github.com/onflow/cadence/tests/sema_utils" "github.com/onflow/cadence/tests/utils" . "github.com/onflow/cadence/tests/utils" ) @@ -1717,7 +1717,7 @@ func TestRuntimePublicKey(t *testing.T) { } _, err := executeScript(script, runtimeInterface) - errs := checker.RequireCheckerErrors(t, err, 4) + errs := RequireCheckerErrors(t, err, 4) assert.IsType(t, &sema.InvalidAssignmentAccessError{}, errs[0]) assert.IsType(t, &sema.AssignmentToConstantMemberError{}, errs[1]) @@ -2360,7 +2360,7 @@ func TestRuntimeAuthAccountContracts(t *testing.T) { }, ) - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) assert.IsType(t, &sema.UnauthorizedReferenceAssignmentError{}, errs[0]) }) @@ -2402,7 +2402,7 @@ func TestRuntimeAuthAccountContracts(t *testing.T) { }, ) - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) assert.IsType(t, &sema.UnauthorizedReferenceAssignmentError{}, errs[0]) }) @@ -2614,7 +2614,7 @@ func TestRuntimeGetAuthAccount(t *testing.T) { }, ) - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) assert.IsType(t, &sema.TypeMismatchError{}, errs[0]) }) @@ -2642,7 +2642,7 @@ func TestRuntimeGetAuthAccount(t *testing.T) { }, ) - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) assert.IsType(t, &sema.InsufficientArgumentsError{}, errs[0]) }) @@ -2669,7 +2669,7 @@ func TestRuntimeGetAuthAccount(t *testing.T) { Location: common.ScriptLocation{0x1}, }, ) - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) assert.IsType(t, &sema.ExcessiveArgumentsError{}, errs[0]) }) @@ -2704,7 +2704,7 @@ func TestRuntimeGetAuthAccount(t *testing.T) { }, ) - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) assert.IsType(t, &sema.NotDeclaredError{}, errs[0]) }) diff --git a/runtime/contract_test.go b/runtime/contract_test.go index 5cc9579322..6cd2b4caaa 100644 --- a/runtime/contract_test.go +++ b/runtime/contract_test.go @@ -33,8 +33,8 @@ import ( . "github.com/onflow/cadence/runtime" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - "github.com/onflow/cadence/tests/checker" . "github.com/onflow/cadence/tests/runtime_utils" + . "github.com/onflow/cadence/tests/sema_utils" . "github.com/onflow/cadence/tests/utils" ) @@ -1234,7 +1234,7 @@ func TestRuntimeContractTryUpdate(t *testing.T) { ) RequireError(t, err) - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) var notExportedError *sema.NotExportedError require.ErrorAs(t, errs[0], ¬ExportedError) }) diff --git a/runtime/entitlements_test.go b/runtime/entitlements_test.go index 8ffee3052b..d241cb6c4d 100644 --- a/runtime/entitlements_test.go +++ b/runtime/entitlements_test.go @@ -28,8 +28,8 @@ import ( "github.com/onflow/cadence/interpreter" . "github.com/onflow/cadence/runtime" "github.com/onflow/cadence/sema" - "github.com/onflow/cadence/tests/checker" . "github.com/onflow/cadence/tests/runtime_utils" + . "github.com/onflow/cadence/tests/sema_utils" . "github.com/onflow/cadence/tests/utils" ) @@ -497,7 +497,7 @@ func TestRuntimeAccountEntitlementNamingConflict(t *testing.T) { var checkerErr *sema.CheckerError require.ErrorAs(t, err, &checkerErr) - errs := checker.RequireCheckerErrors(t, checkerErr, 1) + errs := RequireCheckerErrors(t, checkerErr, 1) var accessError *sema.InvalidAccessError require.ErrorAs(t, errs[0], &accessError) diff --git a/runtime/import_test.go b/runtime/import_test.go index 14a47febe0..295353b5f6 100644 --- a/runtime/import_test.go +++ b/runtime/import_test.go @@ -30,8 +30,8 @@ import ( "github.com/onflow/cadence/encoding/json" . "github.com/onflow/cadence/runtime" "github.com/onflow/cadence/sema" - "github.com/onflow/cadence/tests/checker" . "github.com/onflow/cadence/tests/runtime_utils" + . "github.com/onflow/cadence/tests/sema_utils" . "github.com/onflow/cadence/tests/utils" ) @@ -91,7 +91,7 @@ func TestRuntimeCyclicImport(t *testing.T) { var checkerErr *sema.CheckerError require.ErrorAs(t, err, &checkerErr) - errs := checker.RequireCheckerErrors(t, checkerErr, 1) + errs := RequireCheckerErrors(t, checkerErr, 1) var importedProgramErr *sema.ImportedProgramError require.ErrorAs(t, errs[0], &importedProgramErr) @@ -101,7 +101,7 @@ func TestRuntimeCyclicImport(t *testing.T) { var checkerErr2 *sema.CheckerError require.ErrorAs(t, importedProgramErr.Err, &checkerErr2) - errs = checker.RequireCheckerErrors(t, checkerErr2, 1) + errs = RequireCheckerErrors(t, checkerErr2, 1) var importedProgramErr2 *sema.ImportedProgramError require.ErrorAs(t, errs[0], &importedProgramErr2) @@ -111,7 +111,7 @@ func TestRuntimeCyclicImport(t *testing.T) { var checkerErr3 *sema.CheckerError require.ErrorAs(t, importedProgramErr2.Err, &checkerErr3) - errs = checker.RequireCheckerErrors(t, checkerErr3, 1) + errs = RequireCheckerErrors(t, checkerErr3, 1) require.IsType(t, &sema.CyclicImportsError{}, errs[0]) } @@ -201,7 +201,7 @@ func TestRuntimeCheckCyclicImportsAfterUpdate(t *testing.T) { var checkerErr *sema.CheckerError require.ErrorAs(t, err, &checkerErr) - errs := checker.RequireCheckerErrors(t, checkerErr, 1) + errs := RequireCheckerErrors(t, checkerErr, 1) var importedProgramErr *sema.ImportedProgramError require.ErrorAs(t, errs[0], &importedProgramErr) @@ -209,7 +209,7 @@ func TestRuntimeCheckCyclicImportsAfterUpdate(t *testing.T) { var nestedCheckerErr *sema.CheckerError require.ErrorAs(t, importedProgramErr.Err, &nestedCheckerErr) - errs = checker.RequireCheckerErrors(t, nestedCheckerErr, 1) + errs = RequireCheckerErrors(t, nestedCheckerErr, 1) require.IsType(t, &sema.CyclicImportsError{}, errs[0]) } @@ -318,7 +318,7 @@ func TestRuntimeCheckCyclicImportAddress(t *testing.T) { var checkerErr *sema.CheckerError require.ErrorAs(t, err, &checkerErr) - errs := checker.RequireCheckerErrors(t, checkerErr, 1) + errs := RequireCheckerErrors(t, checkerErr, 1) // Direct cycle, by importing `Foo` in `Foo` require.IsType(t, &sema.CyclicImportsError{}, errs[0]) @@ -403,7 +403,7 @@ func TestRuntimeCheckCyclicImportToSelfDuringDeploy(t *testing.T) { var checkerErr *sema.CheckerError require.ErrorAs(t, err, &checkerErr) - errs := checker.RequireCheckerErrors(t, checkerErr, 1) + errs := RequireCheckerErrors(t, checkerErr, 1) require.IsType(t, &sema.CyclicImportsError{}, errs[0]) } diff --git a/runtime/predeclaredvalues_test.go b/runtime/predeclaredvalues_test.go index 58757a8bb7..c60d3efb5b 100644 --- a/runtime/predeclaredvalues_test.go +++ b/runtime/predeclaredvalues_test.go @@ -33,8 +33,8 @@ import ( . "github.com/onflow/cadence/runtime" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - "github.com/onflow/cadence/tests/checker" . "github.com/onflow/cadence/tests/runtime_utils" + . "github.com/onflow/cadence/tests/sema_utils" . "github.com/onflow/cadence/tests/utils" ) @@ -245,7 +245,7 @@ func TestRuntimePredeclaredValues(t *testing.T) { require.ErrorAs(t, err, &checkerErr) assert.Equal(t, common.ScriptLocation{}, checkerErr.Location) - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) var notDeclaredErr *sema.NotDeclaredError require.ErrorAs(t, errs[0], ¬DeclaredErr) diff --git a/runtime/program_params_validation_test.go b/runtime/program_params_validation_test.go index f2ec7c4882..2e1a7f3ec1 100644 --- a/runtime/program_params_validation_test.go +++ b/runtime/program_params_validation_test.go @@ -30,8 +30,8 @@ import ( "github.com/onflow/cadence/encoding/json" . "github.com/onflow/cadence/runtime" "github.com/onflow/cadence/sema" - "github.com/onflow/cadence/tests/checker" . "github.com/onflow/cadence/tests/runtime_utils" + . "github.com/onflow/cadence/tests/sema_utils" . "github.com/onflow/cadence/tests/utils" ) @@ -346,7 +346,7 @@ func TestRuntimeScriptParameterTypeValidation(t *testing.T) { var checkerError *sema.CheckerError require.ErrorAs(t, err, &checkerError) - errs := checker.RequireCheckerErrors(t, checkerError, 1) + errs := RequireCheckerErrors(t, checkerError, 1) assert.IsType(t, &sema.InvalidTypeArgumentError{}, errs[0]) }) @@ -385,7 +385,7 @@ func TestRuntimeScriptParameterTypeValidation(t *testing.T) { var checkerError *sema.CheckerError require.ErrorAs(t, err, &checkerError) - errs := checker.RequireCheckerErrors(t, checkerError, 1) + errs := RequireCheckerErrors(t, checkerError, 1) assert.IsType(t, &sema.InvalidTypeArgumentError{}, errs[0]) }) @@ -811,7 +811,7 @@ func TestRuntimeTransactionParameterTypeValidation(t *testing.T) { err := executeTransaction(t, script, contracts, cadence.NewOptional(nil)) - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.InvalidNonImportableTransactionParameterTypeError{}, errs[0]) }) @@ -876,7 +876,7 @@ func TestRuntimeTransactionParameterTypeValidation(t *testing.T) { err := executeTransaction(t, script, contracts, cadence.NewOptional(nil)) - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.InvalidNonImportableTransactionParameterTypeError{}, errs[0]) }) @@ -903,7 +903,7 @@ func TestRuntimeTransactionParameterTypeValidation(t *testing.T) { err := executeTransaction(t, script, contracts, cadence.NewOptional(nil)) - errs := checker.RequireCheckerErrors(t, err, 2) + errs := RequireCheckerErrors(t, err, 2) require.IsType(t, &sema.InvalidNonImportableTransactionParameterTypeError{}, errs[0]) require.IsType(t, &sema.ResourceLossError{}, errs[1]) @@ -918,7 +918,7 @@ func TestRuntimeTransactionParameterTypeValidation(t *testing.T) { err := executeTransaction(t, script, nil, cadence.NewOptional(nil)) - errs := checker.RequireCheckerErrors(t, err, 2) + errs := RequireCheckerErrors(t, err, 2) require.IsType(t, &sema.InvalidNonImportableTransactionParameterTypeError{}, errs[0]) require.IsType(t, &sema.ResourceLossError{}, errs[1]) @@ -943,7 +943,7 @@ func TestRuntimeTransactionParameterTypeValidation(t *testing.T) { err := executeTransaction(t, script, contracts, cadence.NewOptional(nil)) - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.InvalidNonImportableTransactionParameterTypeError{}, errs[0]) }) @@ -968,7 +968,7 @@ func TestRuntimeTransactionParameterTypeValidation(t *testing.T) { err := executeTransaction(t, script, nil, cadence.NewArray([]cadence.Value{})) - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.InvalidNonImportableTransactionParameterTypeError{}, errs[0]) }) @@ -1004,7 +1004,7 @@ func TestRuntimeTransactionParameterTypeValidation(t *testing.T) { err := executeTransaction(t, script, nil, cadence.NewArray([]cadence.Value{})) - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.InvalidNonImportableTransactionParameterTypeError{}, errs[0]) }) @@ -1110,7 +1110,7 @@ func TestRuntimeTransactionParameterTypeValidation(t *testing.T) { if test.expectErrors { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.InvalidNonImportableTransactionParameterTypeError{}, errs[0]) } else { diff --git a/runtime/runtime_test.go b/runtime/runtime_test.go index abee65f080..07e76ce395 100644 --- a/runtime/runtime_test.go +++ b/runtime/runtime_test.go @@ -43,8 +43,8 @@ import ( . "github.com/onflow/cadence/runtime" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - "github.com/onflow/cadence/tests/checker" . "github.com/onflow/cadence/tests/runtime_utils" + . "github.com/onflow/cadence/tests/sema_utils" . "github.com/onflow/cadence/tests/utils" ) @@ -1773,7 +1773,7 @@ func TestRuntimeStorageMultipleTransactionsInclusiveRangeFunction(t *testing.T) var checkerErr *sema.CheckerError require.ErrorAs(t, err, &checkerErr) - errs := checker.RequireCheckerErrors(t, checkerErr, 1) + errs := RequireCheckerErrors(t, checkerErr, 1) assert.IsType(t, &sema.TypeMismatchError{}, errs[0]) @@ -4883,7 +4883,7 @@ func TestRuntimeTransactionTopLevelDeclarations(t *testing.T) { var checkerErr *sema.CheckerError require.ErrorAs(t, err, &checkerErr) - errs := checker.RequireCheckerErrors(t, checkerErr, 1) + errs := RequireCheckerErrors(t, checkerErr, 1) assert.IsType(t, &sema.InvalidTopLevelDeclarationError{}, errs[0]) }) @@ -7766,7 +7766,7 @@ func TestRuntimeImportTestStdlib(t *testing.T) { RequireError(t, err) - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) notDeclaredErr := &sema.NotDeclaredError{} require.ErrorAs(t, errs[0], ¬DeclaredErr) @@ -8539,7 +8539,7 @@ func TestRuntimeOptionalReferenceAttack(t *testing.T) { var checkerErr *sema.CheckerError require.ErrorAs(t, err, &checkerErr) - errs := checker.RequireCheckerErrors(t, checkerErr, 1) + errs := RequireCheckerErrors(t, checkerErr, 1) assert.IsType(t, &sema.TypeMismatchError{}, errs[0]) } @@ -9070,7 +9070,7 @@ func TestRuntimeTypesAndConversions(t *testing.T) { }) } - for name, ty := range checker.AllBaseSemaTypes() { + for name, ty := range AllBaseSemaTypes() { // Inclusive range is a dynamically created type. if _, isInclusiveRange := ty.(*sema.InclusiveRangeType); isInclusiveRange { continue @@ -9842,7 +9842,7 @@ func TestRuntimePreconditionDuplication(t *testing.T) { var checkerErr *sema.CheckerError require.ErrorAs(t, err, &checkerErr) - errs := checker.RequireCheckerErrors(t, checkerErr, 3) + errs := RequireCheckerErrors(t, checkerErr, 3) assert.IsType(t, &sema.PurityError{}, errs[0]) assert.IsType(t, &sema.InvalidInterfaceConditionResourceInvalidationError{}, errs[1]) diff --git a/sema/access_test.go b/sema/access_test.go deleted file mode 100644 index a5472f468c..0000000000 --- a/sema/access_test.go +++ /dev/null @@ -1,636 +0,0 @@ -/* - * Cadence - The resource-oriented smart contract programming language - * - * Copyright Flow Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package sema - -import ( - "testing" - - "github.com/stretchr/testify/assert" - - "github.com/onflow/cadence/ast" - "github.com/onflow/cadence/common" -) - -func TestPrimitiveAccess_QualifiedKeyword(t *testing.T) { - - t.Parallel() - - expected := map[ast.PrimitiveAccess]string{ - ast.AccessNotSpecified: "", - ast.AccessSelf: "access(self)", - ast.AccessAll: "access(all)", - ast.AccessAccount: "access(account)", - ast.AccessContract: "access(contract)", - ast.AccessPubSettableLegacy: "pub(set)", - ast.AccessNone: "inaccessible", - } - - for access := 0; access < ast.PrimitiveAccessCount(); access++ { - assert.Equal(t, - expected[ast.PrimitiveAccess(access)], - PrimitiveAccess(access).QualifiedKeyword(), - ) - } -} - -func TestNewEntitlementAccess(t *testing.T) { - - t.Parallel() - - t.Run("empty", func(t *testing.T) { - t.Parallel() - - assert.PanicsWithError(t, - "neither map entitlement nor set entitlements given", - func() { - newEntitlementAccess(nil, Conjunction) - }, - ) - }) - - t.Run("invalid", func(t *testing.T) { - t.Parallel() - - assert.PanicsWithError(t, - "invalid entitlement type: Void", - func() { - newEntitlementAccess([]Type{VoidType}, Conjunction) - }, - ) - }) - - t.Run("map + entitlement", func(t *testing.T) { - t.Parallel() - - assert.PanicsWithError(t, - "mixed entitlement types", - func() { - newEntitlementAccess( - []Type{ - IdentityType, - MutateType, - }, - Conjunction, - ) - }, - ) - }) - - t.Run("entitlement + map", func(t *testing.T) { - t.Parallel() - - assert.PanicsWithError(t, - "mixed entitlement types", - func() { - newEntitlementAccess( - []Type{ - MutateType, - IdentityType, - }, - Conjunction, - ) - }, - ) - }) - - t.Run("single entitlement", func(t *testing.T) { - t.Parallel() - - assert.Equal(t, - NewEntitlementSetAccess( - []*EntitlementType{ - MutateType, - }, - Conjunction, - ), - newEntitlementAccess( - []Type{ - MutateType, - }, - Conjunction, - ), - ) - }) - - t.Run("two entitlements, conjunction", func(t *testing.T) { - t.Parallel() - - assert.Equal(t, - NewEntitlementSetAccess( - []*EntitlementType{ - MutateType, - InsertType, - }, - Conjunction, - ), - newEntitlementAccess( - []Type{ - MutateType, - InsertType, - }, - Conjunction, - ), - ) - }) - - t.Run("two entitlements, disjunction", func(t *testing.T) { - t.Parallel() - - assert.Equal(t, - NewEntitlementSetAccess( - []*EntitlementType{ - MutateType, - InsertType, - }, - Disjunction, - ), - newEntitlementAccess( - []Type{ - MutateType, - InsertType, - }, - Disjunction, - ), - ) - }) - - t.Run("single map", func(t *testing.T) { - t.Parallel() - - assert.Equal(t, - NewEntitlementMapAccess( - IdentityType, - ), - newEntitlementAccess( - []Type{ - IdentityType, - }, - Conjunction, - ), - ) - }) - - t.Run("two maps", func(t *testing.T) { - t.Parallel() - - assert.PanicsWithError(t, - "extra entitlement map type", - func() { - newEntitlementAccess( - []Type{ - IdentityType, - AccountMappingType, - }, - Conjunction, - ) - }, - ) - }) -} - -func TestEntitlementSetAccess_QualifiedKeyword(t *testing.T) { - - t.Parallel() - - location := common.NewAddressLocation(nil, common.MustBytesToAddress([]byte{0x1}), "Foo") - - fooType := &CompositeType{ - Location: location, - Identifier: "Foo", - } - - barType := NewEntitlementType( - nil, - location, - "Bar", - ) - barType.SetContainerType(fooType) - - bazType := NewEntitlementType( - nil, - location, - "Baz", - ) - bazType.SetContainerType(fooType) - - assert.Equal(t, - "access(Foo.Bar | Foo.Baz)", - newEntitlementAccess( - []Type{ - barType, - bazType, - }, - Disjunction, - ).QualifiedKeyword(), - ) -} - -func TestEntitlementMapAccess_ID(t *testing.T) { - t.Parallel() - - testLocation := common.StringLocation("test") - - t.Run("top-level", func(t *testing.T) { - t.Parallel() - - access := NewEntitlementMapAccess(NewEntitlementMapType(nil, testLocation, "M")) - assert.Equal(t, TypeID("S.test.M"), access.ID()) - }) - - t.Run("nested", func(t *testing.T) { - t.Parallel() - - mapType := NewEntitlementMapType(nil, testLocation, "M") - - mapType.SetContainerType(&CompositeType{ - Location: testLocation, - Identifier: "C", - }) - - access := NewEntitlementMapAccess(mapType) - assert.Equal(t, TypeID("S.test.C.M"), access.ID()) - }) - -} - -func TestEntitlementMapAccess_String(t *testing.T) { - t.Parallel() - - testLocation := common.StringLocation("test") - - access := NewEntitlementMapAccess(NewEntitlementMapType(nil, testLocation, "M")) - assert.Equal(t, "M", access.String()) -} - -func TestEntitlementMapAccess_QualifiedString(t *testing.T) { - t.Parallel() - - testLocation := common.StringLocation("test") - - t.Run("top-level", func(t *testing.T) { - t.Parallel() - - access := NewEntitlementMapAccess(NewEntitlementMapType(nil, testLocation, "M")) - assert.Equal(t, "M", access.QualifiedString()) - }) - - t.Run("nested", func(t *testing.T) { - t.Parallel() - - mapType := NewEntitlementMapType(nil, testLocation, "M") - - mapType.SetContainerType(&CompositeType{ - Location: testLocation, - Identifier: "C", - }) - - access := NewEntitlementMapAccess(mapType) - assert.Equal(t, "C.M", access.QualifiedString()) - }) -} - -func TestEntitlementSetAccess_ID(t *testing.T) { - t.Parallel() - - testLocation := common.StringLocation("test") - - t.Run("single", func(t *testing.T) { - t.Parallel() - - access := NewEntitlementSetAccess( - []*EntitlementType{ - NewEntitlementType(nil, testLocation, "E"), - }, - Conjunction, - ) - assert.Equal(t, - TypeID("S.test.E"), - access.ID(), - ) - }) - - t.Run("two, conjunction", func(t *testing.T) { - t.Parallel() - - access := NewEntitlementSetAccess( - []*EntitlementType{ - // NOTE: order - NewEntitlementType(nil, testLocation, "E2"), - NewEntitlementType(nil, testLocation, "E1"), - }, - Conjunction, - ) - // NOTE: sorted - assert.Equal(t, - TypeID("S.test.E1,S.test.E2"), - access.ID(), - ) - }) - - t.Run("two, disjunction", func(t *testing.T) { - t.Parallel() - - access := NewEntitlementSetAccess( - []*EntitlementType{ - // NOTE: order - NewEntitlementType(nil, testLocation, "E2"), - NewEntitlementType(nil, testLocation, "E1"), - }, - Disjunction, - ) - // NOTE: sorted - assert.Equal(t, - TypeID("S.test.E1|S.test.E2"), - access.ID(), - ) - }) - - t.Run("three, conjunction", func(t *testing.T) { - t.Parallel() - - access := NewEntitlementSetAccess( - []*EntitlementType{ - // NOTE: order - NewEntitlementType(nil, testLocation, "E3"), - NewEntitlementType(nil, testLocation, "E2"), - NewEntitlementType(nil, testLocation, "E1"), - }, - Conjunction, - ) - // NOTE: sorted - assert.Equal(t, - TypeID("S.test.E1,S.test.E2,S.test.E3"), - access.ID(), - ) - }) - - t.Run("three, disjunction", func(t *testing.T) { - t.Parallel() - - access := NewEntitlementSetAccess( - []*EntitlementType{ - // NOTE: order - NewEntitlementType(nil, testLocation, "E3"), - NewEntitlementType(nil, testLocation, "E2"), - NewEntitlementType(nil, testLocation, "E1"), - }, - Disjunction, - ) - // NOTE: sorted - assert.Equal(t, - TypeID("S.test.E1|S.test.E2|S.test.E3"), - access.ID(), - ) - }) - -} - -func TestEntitlementSetAccess_String(t *testing.T) { - t.Parallel() - - testLocation := common.StringLocation("test") - - t.Run("single", func(t *testing.T) { - t.Parallel() - - access := NewEntitlementSetAccess( - []*EntitlementType{ - NewEntitlementType(nil, testLocation, "E"), - }, - Conjunction, - ) - assert.Equal(t, "E", access.String()) - }) - - t.Run("two, conjunction", func(t *testing.T) { - t.Parallel() - - access := NewEntitlementSetAccess( - []*EntitlementType{ - // NOTE: order - NewEntitlementType(nil, testLocation, "E2"), - NewEntitlementType(nil, testLocation, "E1"), - }, - Conjunction, - ) - // NOTE: order - assert.Equal(t, "E2, E1", access.String()) - }) - - t.Run("two, disjunction", func(t *testing.T) { - t.Parallel() - - access := NewEntitlementSetAccess( - []*EntitlementType{ - // NOTE: order - NewEntitlementType(nil, testLocation, "E2"), - NewEntitlementType(nil, testLocation, "E1"), - }, - Disjunction, - ) - // NOTE: order - assert.Equal(t, "E2 | E1", access.String()) - }) - - t.Run("three, conjunction", func(t *testing.T) { - t.Parallel() - - access := NewEntitlementSetAccess( - []*EntitlementType{ - // NOTE: order - NewEntitlementType(nil, testLocation, "E3"), - NewEntitlementType(nil, testLocation, "E2"), - NewEntitlementType(nil, testLocation, "E1"), - }, - Conjunction, - ) - // NOTE: order - assert.Equal(t, "E3, E2, E1", access.String()) - }) - - t.Run("three, disjunction", func(t *testing.T) { - t.Parallel() - - access := NewEntitlementSetAccess( - []*EntitlementType{ - // NOTE: order - NewEntitlementType(nil, testLocation, "E3"), - NewEntitlementType(nil, testLocation, "E2"), - NewEntitlementType(nil, testLocation, "E1"), - }, - Disjunction, - ) - // NOTE: order - assert.Equal(t, "E3 | E2 | E1", access.String()) - }) -} - -func TestEntitlementSetAccess_QualifiedString(t *testing.T) { - t.Parallel() - - testLocation := common.StringLocation("test") - - containerType := &CompositeType{ - Location: testLocation, - Identifier: "C", - } - - t.Run("single", func(t *testing.T) { - t.Parallel() - - entitlementType := NewEntitlementType(nil, testLocation, "E") - entitlementType.SetContainerType(containerType) - - access := NewEntitlementSetAccess( - []*EntitlementType{ - entitlementType, - }, - Conjunction, - ) - assert.Equal(t, "C.E", access.QualifiedString()) - }) - - t.Run("two, conjunction", func(t *testing.T) { - t.Parallel() - - entitlementType1 := NewEntitlementType(nil, testLocation, "E1") - entitlementType1.SetContainerType(containerType) - - entitlementType2 := NewEntitlementType(nil, testLocation, "E2") - entitlementType2.SetContainerType(containerType) - - access := NewEntitlementSetAccess( - []*EntitlementType{ - // NOTE: order - entitlementType2, - entitlementType1, - }, - Conjunction, - ) - // NOTE: order - assert.Equal(t, - "C.E2, C.E1", - access.QualifiedString(), - ) - }) - - t.Run("two, disjunction", func(t *testing.T) { - t.Parallel() - - entitlementType1 := NewEntitlementType(nil, testLocation, "E1") - entitlementType1.SetContainerType(containerType) - - entitlementType2 := NewEntitlementType(nil, testLocation, "E2") - entitlementType2.SetContainerType(containerType) - - access := NewEntitlementSetAccess( - []*EntitlementType{ - // NOTE: order - entitlementType2, - entitlementType1, - }, - Disjunction, - ) - // NOTE: order - assert.Equal(t, - "C.E2 | C.E1", - access.QualifiedString(), - ) - }) - - t.Run("three, conjunction", func(t *testing.T) { - t.Parallel() - - entitlementType1 := NewEntitlementType(nil, testLocation, "E1") - entitlementType1.SetContainerType(containerType) - - entitlementType2 := NewEntitlementType(nil, testLocation, "E2") - entitlementType2.SetContainerType(containerType) - - entitlementType3 := NewEntitlementType(nil, testLocation, "E3") - entitlementType3.SetContainerType(containerType) - - access := NewEntitlementSetAccess( - []*EntitlementType{ - // NOTE: order - entitlementType3, - entitlementType2, - entitlementType1, - }, - Conjunction, - ) - // NOTE: order - assert.Equal(t, - "C.E3, C.E2, C.E1", - access.QualifiedString(), - ) - }) - - t.Run("three, disjunction", func(t *testing.T) { - t.Parallel() - - entitlementType1 := NewEntitlementType(nil, testLocation, "E1") - entitlementType1.SetContainerType(containerType) - - entitlementType2 := NewEntitlementType(nil, testLocation, "E2") - entitlementType2.SetContainerType(containerType) - - entitlementType3 := NewEntitlementType(nil, testLocation, "E3") - entitlementType3.SetContainerType(containerType) - - access := NewEntitlementSetAccess( - []*EntitlementType{ - // NOTE: order - entitlementType3, - entitlementType2, - entitlementType1, - }, - Disjunction, - ) - // NOTE: order - assert.Equal(t, - "C.E3 | C.E2 | C.E1", - access.QualifiedString(), - ) - }) -} - -func TestEntitlementMapAccess_QualifiedKeyword(t *testing.T) { - - t.Parallel() - - location := common.NewAddressLocation(nil, common.MustBytesToAddress([]byte{0x1}), "Foo") - - fooType := &CompositeType{ - Location: location, - Identifier: "Foo", - } - - barType := NewEntitlementMapType( - nil, - location, - "Bar", - ) - barType.SetContainerType(fooType) - - assert.Equal(t, - "access(mapping Foo.Bar)", - NewEntitlementMapAccess(barType).QualifiedKeyword(), - ) -} diff --git a/tests/checker/access_test.go b/sema/accesses_test.go similarity index 99% rename from tests/checker/access_test.go rename to sema/accesses_test.go index 041fad225e..eaa4dc16a9 100644 --- a/tests/checker/access_test.go +++ b/sema/accesses_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "fmt" @@ -28,6 +28,7 @@ import ( "github.com/onflow/cadence/ast" "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) func expectSuccess(t *testing.T, err error) { diff --git a/tests/checker/account_test.go b/sema/account_test.go similarity index 99% rename from tests/checker/account_test.go rename to sema/account_test.go index 1fc36ef465..e993ed7303 100644 --- a/tests/checker/account_test.go +++ b/sema/account_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "fmt" @@ -27,6 +27,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" "github.com/onflow/cadence/tests/utils" ) diff --git a/tests/checker/any_test.go b/sema/any_test.go similarity index 96% rename from tests/checker/any_test.go rename to sema/any_test.go index fda0cd08b6..6e35846d12 100644 --- a/tests/checker/any_test.go +++ b/sema/any_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "testing" @@ -24,6 +24,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckAnyStruct(t *testing.T) { diff --git a/tests/checker/arrays_dictionaries_test.go b/sema/arrays_dictionaries_test.go similarity index 99% rename from tests/checker/arrays_dictionaries_test.go rename to sema/arrays_dictionaries_test.go index dea57fc1a6..20a306fe04 100644 --- a/tests/checker/arrays_dictionaries_test.go +++ b/sema/arrays_dictionaries_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "fmt" @@ -30,6 +30,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckDictionary(t *testing.T) { diff --git a/tests/checker/assert_test.go b/sema/assert_test.go similarity index 96% rename from tests/checker/assert_test.go rename to sema/assert_test.go index ea9591bcd9..2912bf380b 100644 --- a/tests/checker/assert_test.go +++ b/sema/assert_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "testing" @@ -26,6 +26,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckAssertWithoutMessage(t *testing.T) { diff --git a/tests/checker/assignment_test.go b/sema/assignment_test.go similarity index 98% rename from tests/checker/assignment_test.go rename to sema/assignment_test.go index 6342ae4174..3d415c16ee 100644 --- a/tests/checker/assignment_test.go +++ b/sema/assignment_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "testing" @@ -25,6 +25,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckInvalidUnknownDeclarationAssignment(t *testing.T) { diff --git a/tests/checker/attachments_test.go b/sema/attachments_test.go similarity index 99% rename from tests/checker/attachments_test.go rename to sema/attachments_test.go index de3e3dd406..c1609e8e0b 100644 --- a/tests/checker/attachments_test.go +++ b/sema/attachments_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "fmt" @@ -26,6 +26,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckAttachmentBasic(t *testing.T) { diff --git a/tests/checker/boolean_test.go b/sema/boolean_test.go similarity index 94% rename from tests/checker/boolean_test.go rename to sema/boolean_test.go index a6e5224581..6d4e0cde0d 100644 --- a/tests/checker/boolean_test.go +++ b/sema/boolean_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "testing" @@ -25,6 +25,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckBoolean(t *testing.T) { diff --git a/tests/checker/builtinfunctions_test.go b/sema/builtinfunctions_test.go similarity index 99% rename from tests/checker/builtinfunctions_test.go rename to sema/builtinfunctions_test.go index be7a0ba1d1..41a956d1d1 100644 --- a/tests/checker/builtinfunctions_test.go +++ b/sema/builtinfunctions_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "fmt" @@ -28,6 +28,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckToString(t *testing.T) { diff --git a/tests/checker/capability_controller_test.go b/sema/capability_controller_test.go similarity index 98% rename from tests/checker/capability_controller_test.go rename to sema/capability_controller_test.go index 98cd7ec076..d2ab30eda3 100644 --- a/tests/checker/capability_controller_test.go +++ b/sema/capability_controller_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "testing" @@ -26,6 +26,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckStorageCapabilityController(t *testing.T) { diff --git a/tests/checker/capability_test.go b/sema/capability_test.go similarity index 99% rename from tests/checker/capability_test.go rename to sema/capability_test.go index 3a9ffc013e..155442dc12 100644 --- a/tests/checker/capability_test.go +++ b/sema/capability_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "fmt" @@ -27,6 +27,8 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckCapability(t *testing.T) { diff --git a/tests/checker/casting_test.go b/sema/casting_test.go similarity index 99% rename from tests/checker/casting_test.go rename to sema/casting_test.go index d8f901c874..e107a4615b 100644 --- a/tests/checker/casting_test.go +++ b/sema/casting_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "fmt" @@ -26,6 +26,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckCastingIntLiteralToIntegerType(t *testing.T) { diff --git a/tests/checker/character_test.go b/sema/character_test.go similarity index 96% rename from tests/checker/character_test.go rename to sema/character_test.go index 816ae93159..318b101dbc 100644 --- a/tests/checker/character_test.go +++ b/sema/character_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "testing" @@ -25,6 +25,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckCharacterLiteral(t *testing.T) { diff --git a/tests/checker/composite_test.go b/sema/composite_test.go similarity index 99% rename from tests/checker/composite_test.go rename to sema/composite_test.go index 241a6ce50b..6598505d98 100644 --- a/tests/checker/composite_test.go +++ b/sema/composite_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "fmt" @@ -29,6 +29,7 @@ import ( "github.com/onflow/cadence/errors" "github.com/onflow/cadence/parser" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckInvalidCompositeRedeclaringType(t *testing.T) { diff --git a/tests/checker/conditional_test.go b/sema/conditional_test.go similarity index 98% rename from tests/checker/conditional_test.go rename to sema/conditional_test.go index 733c3fade3..98ec1a75a7 100644 --- a/tests/checker/conditional_test.go +++ b/sema/conditional_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "testing" @@ -25,6 +25,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckConditionalExpressionTest(t *testing.T) { diff --git a/tests/checker/conditions_test.go b/sema/conditions_test.go similarity index 99% rename from tests/checker/conditions_test.go rename to sema/conditions_test.go index 4c240510c9..d845c52c1d 100644 --- a/tests/checker/conditions_test.go +++ b/sema/conditions_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "testing" @@ -26,6 +26,7 @@ import ( "github.com/onflow/cadence/ast" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckFunctionTestConditions(t *testing.T) { diff --git a/tests/checker/conformance_test.go b/sema/conformance_test.go similarity index 99% rename from tests/checker/conformance_test.go rename to sema/conformance_test.go index 8bb29b7548..6109516c58 100644 --- a/tests/checker/conformance_test.go +++ b/sema/conformance_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "fmt" @@ -27,6 +27,7 @@ import ( "github.com/onflow/cadence/ast" "github.com/onflow/cadence/errors" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckEventNonTypeRequirementConformance(t *testing.T) { diff --git a/tests/checker/contract_test.go b/sema/contract_test.go similarity index 99% rename from tests/checker/contract_test.go rename to sema/contract_test.go index 9bb97a50d0..2de30e7d68 100644 --- a/tests/checker/contract_test.go +++ b/sema/contract_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "fmt" @@ -27,6 +27,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckInvalidContractAccountField(t *testing.T) { diff --git a/tests/checker/crypto_test.go b/sema/crypto_test.go similarity index 99% rename from tests/checker/crypto_test.go rename to sema/crypto_test.go index 191183d7a4..91397e95ea 100644 --- a/tests/checker/crypto_test.go +++ b/sema/crypto_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "fmt" @@ -27,6 +27,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckHashAlgorithmCases(t *testing.T) { diff --git a/tests/checker/declaration_test.go b/sema/declaration_test.go similarity index 99% rename from tests/checker/declaration_test.go rename to sema/declaration_test.go index 6d7cfd6fdc..738c4c6d34 100644 --- a/tests/checker/declaration_test.go +++ b/sema/declaration_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "fmt" @@ -27,6 +27,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckConstantAndVariableDeclarations(t *testing.T) { diff --git a/tests/checker/dictionary_test.go b/sema/dictionary_test.go similarity index 95% rename from tests/checker/dictionary_test.go rename to sema/dictionary_test.go index abb66fe3b8..900c53860e 100644 --- a/tests/checker/dictionary_test.go +++ b/sema/dictionary_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "testing" @@ -25,6 +25,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckIncompleteDictionaryType(t *testing.T) { diff --git a/tests/checker/dynamic_casting_test.go b/sema/dynamic_casting_test.go similarity index 99% rename from tests/checker/dynamic_casting_test.go rename to sema/dynamic_casting_test.go index ce7f2e38d7..15861bc8e7 100644 --- a/tests/checker/dynamic_casting_test.go +++ b/sema/dynamic_casting_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "fmt" @@ -28,6 +28,7 @@ import ( "github.com/onflow/cadence/ast" "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" "github.com/onflow/cadence/tests/utils" ) diff --git a/tests/checker/entitlements_test.go b/sema/entitlements_test.go similarity index 99% rename from tests/checker/entitlements_test.go rename to sema/entitlements_test.go index b546de5713..caa5dd36e4 100644 --- a/tests/checker/entitlements_test.go +++ b/sema/entitlements_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "fmt" @@ -27,6 +27,7 @@ import ( "github.com/onflow/cadence/ast" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckBasicEntitlementDeclaration(t *testing.T) { diff --git a/tests/checker/entrypoint_test.go b/sema/entrypoint_test.go similarity index 98% rename from tests/checker/entrypoint_test.go rename to sema/entrypoint_test.go index 4bbba80238..ac76190b26 100644 --- a/tests/checker/entrypoint_test.go +++ b/sema/entrypoint_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "testing" @@ -24,6 +24,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckEntryPointParameters(t *testing.T) { diff --git a/tests/checker/enum_test.go b/sema/enum_test.go similarity index 98% rename from tests/checker/enum_test.go rename to sema/enum_test.go index 671177fd5f..2fc3233336 100644 --- a/tests/checker/enum_test.go +++ b/sema/enum_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "fmt" @@ -27,6 +27,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckInvalidNonEnumCompositeEnumCases(t *testing.T) { diff --git a/tests/checker/errors_test.go b/sema/error_handling_test.go similarity index 98% rename from tests/checker/errors_test.go rename to sema/error_handling_test.go index 33da8bc032..cc84b43316 100644 --- a/tests/checker/errors_test.go +++ b/sema/error_handling_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "testing" @@ -27,6 +27,7 @@ import ( "github.com/onflow/cadence/ast" "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" "github.com/onflow/cadence/tests/utils" ) diff --git a/tests/checker/events_test.go b/sema/events_test.go similarity index 99% rename from tests/checker/events_test.go rename to sema/events_test.go index bf140bb749..d1c588392f 100644 --- a/tests/checker/events_test.go +++ b/sema/events_test.go @@ -16,22 +16,21 @@ * limitations under the License. */ -package checker +package sema_test import ( "fmt" "testing" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" "github.com/onflow/cadence/ast" "github.com/onflow/cadence/common" "github.com/onflow/cadence/errors" - "github.com/onflow/cadence/tests/utils" - - "github.com/stretchr/testify/require" - "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" + "github.com/onflow/cadence/tests/utils" ) func TestCheckEventDeclaration(t *testing.T) { diff --git a/tests/checker/external_mutation_test.go b/sema/external_mutation_test.go similarity index 99% rename from tests/checker/external_mutation_test.go rename to sema/external_mutation_test.go index bd56e9b039..3eabd29a5a 100644 --- a/tests/checker/external_mutation_test.go +++ b/sema/external_mutation_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "fmt" @@ -28,6 +28,7 @@ import ( "github.com/onflow/cadence/ast" "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckArrayUpdateIndexAccess(t *testing.T) { diff --git a/tests/checker/fixedpoint_test.go b/sema/fixedpoint_test.go similarity index 99% rename from tests/checker/fixedpoint_test.go rename to sema/fixedpoint_test.go index 2e7d514785..a1f0eb15e5 100644 --- a/tests/checker/fixedpoint_test.go +++ b/sema/fixedpoint_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "fmt" @@ -29,6 +29,7 @@ import ( "github.com/onflow/cadence/format" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckFixedPointLiteralTypeConversionInVariableDeclaration(t *testing.T) { diff --git a/tests/checker/for_test.go b/sema/for_test.go similarity index 99% rename from tests/checker/for_test.go rename to sema/for_test.go index d2b6a231d5..8e2f68dcb8 100644 --- a/tests/checker/for_test.go +++ b/sema/for_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "fmt" @@ -28,6 +28,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckForVariableSized(t *testing.T) { diff --git a/tests/checker/force_test.go b/sema/force_test.go similarity index 97% rename from tests/checker/force_test.go rename to sema/force_test.go index 2317ebc1fc..c3d0f41f5c 100644 --- a/tests/checker/force_test.go +++ b/sema/force_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "testing" @@ -25,6 +25,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckForce(t *testing.T) { diff --git a/tests/checker/function_expression_test.go b/sema/function_expression_test.go similarity index 95% rename from tests/checker/function_expression_test.go rename to sema/function_expression_test.go index 14f65c0e91..5bb0467941 100644 --- a/tests/checker/function_expression_test.go +++ b/sema/function_expression_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "testing" @@ -25,6 +25,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckInvalidFunctionExpressionReturnValue(t *testing.T) { diff --git a/tests/checker/function_test.go b/sema/function_test.go similarity index 99% rename from tests/checker/function_test.go rename to sema/function_test.go index 88edcf9306..334f1ee2c7 100644 --- a/tests/checker/function_test.go +++ b/sema/function_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "testing" @@ -28,6 +28,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/parser" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckReferenceInFunction(t *testing.T) { diff --git a/sema/gen/golden_test.go b/sema/gen/golden_test.go index bcb116fa0f..0053427d45 100644 --- a/sema/gen/golden_test.go +++ b/sema/gen/golden_test.go @@ -43,7 +43,7 @@ import ( _ "github.com/onflow/cadence/sema/gen/testdata/simple_struct" _ "github.com/onflow/cadence/sema/gen/testdata/storable" "github.com/onflow/cadence/stdlib" - "github.com/onflow/cadence/tests/checker" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestConstructor(t *testing.T) { @@ -57,11 +57,11 @@ func TestConstructor(t *testing.T) { Kind: common.DeclarationKindFunction, }) - _, err := checker.ParseAndCheckWithOptions(t, + _, err := ParseAndCheckWithOptions(t, ` let x = Foo(bar: 1) `, - checker.ParseAndCheckOptions{ + ParseAndCheckOptions{ Config: &sema.Config{ BaseValueActivationHandler: func(_ common.Location) *sema.VariableActivation { return baseValueActivation @@ -83,11 +83,11 @@ func TestContract(t *testing.T) { Kind: common.DeclarationKindContract, }) - _, err := checker.ParseAndCheckWithOptions(t, + _, err := ParseAndCheckWithOptions(t, ` let x = Test.Foo(bar: 1) `, - checker.ParseAndCheckOptions{ + ParseAndCheckOptions{ Config: &sema.Config{ BaseValueActivationHandler: func(_ common.Location) *sema.VariableActivation { return baseValueActivation diff --git a/tests/checker/genericfunction_test.go b/sema/genericfunction_test.go similarity index 99% rename from tests/checker/genericfunction_test.go rename to sema/genericfunction_test.go index 0d8dc3e805..6b3e443db1 100644 --- a/tests/checker/genericfunction_test.go +++ b/sema/genericfunction_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "fmt" @@ -30,6 +30,7 @@ import ( "github.com/onflow/cadence/parser" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" + . "github.com/onflow/cadence/tests/sema_utils" ) func parseAndCheckWithTestValue(t *testing.T, code string, ty sema.Type) (*sema.Checker, error) { diff --git a/tests/checker/hashable_struct_test.go b/sema/hashable_struct_test.go similarity index 95% rename from tests/checker/hashable_struct_test.go rename to sema/hashable_struct_test.go index 4ae190201e..51f432bf25 100644 --- a/tests/checker/hashable_struct_test.go +++ b/sema/hashable_struct_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "testing" @@ -24,6 +24,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckHashableStruct(t *testing.T) { diff --git a/tests/checker/if_test.go b/sema/if_test.go similarity index 98% rename from tests/checker/if_test.go rename to sema/if_test.go index 5681f8f111..0674d66d97 100644 --- a/tests/checker/if_test.go +++ b/sema/if_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "testing" @@ -25,6 +25,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckIfStatementTest(t *testing.T) { diff --git a/tests/checker/import_test.go b/sema/import_test.go similarity index 99% rename from tests/checker/import_test.go rename to sema/import_test.go index bc586139c6..9e92714fa9 100644 --- a/tests/checker/import_test.go +++ b/sema/import_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "fmt" @@ -30,6 +30,7 @@ import ( "github.com/onflow/cadence/errors" "github.com/onflow/cadence/parser" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" "github.com/onflow/cadence/tests/utils" ) diff --git a/tests/checker/indexing_test.go b/sema/indexing_test.go similarity index 98% rename from tests/checker/indexing_test.go rename to sema/indexing_test.go index 1e9bef01e1..5eabac65ff 100644 --- a/tests/checker/indexing_test.go +++ b/sema/indexing_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "testing" @@ -25,6 +25,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckArrayIndexingWithInteger(t *testing.T) { diff --git a/tests/checker/initialization_test.go b/sema/initialization_test.go similarity index 99% rename from tests/checker/initialization_test.go rename to sema/initialization_test.go index 48242a9b6c..832bb2724e 100644 --- a/tests/checker/initialization_test.go +++ b/sema/initialization_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "testing" @@ -25,6 +25,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) // TODO: test multiple initializers once overloading is supported diff --git a/tests/checker/integer_test.go b/sema/integer_test.go similarity index 99% rename from tests/checker/integer_test.go rename to sema/integer_test.go index 798b168393..1fdcf5963f 100644 --- a/tests/checker/integer_test.go +++ b/sema/integer_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "fmt" @@ -28,6 +28,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) var allIntegerTypesAndAddressType = common.Concat( diff --git a/tests/checker/interface_test.go b/sema/interface_test.go similarity index 99% rename from tests/checker/interface_test.go rename to sema/interface_test.go index fd453b789a..b43b4f7573 100644 --- a/tests/checker/interface_test.go +++ b/sema/interface_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "fmt" @@ -28,6 +28,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/errors" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) func constructorArguments(compositeKind common.CompositeKind) string { diff --git a/tests/checker/intersection_test.go b/sema/intersection_test.go similarity index 99% rename from tests/checker/intersection_test.go rename to sema/intersection_test.go index ee3b8bf94e..763d16f1b4 100644 --- a/tests/checker/intersection_test.go +++ b/sema/intersection_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "fmt" @@ -26,6 +26,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckIntersectionType(t *testing.T) { diff --git a/tests/checker/invalid_test.go b/sema/invalid_test.go similarity index 98% rename from tests/checker/invalid_test.go rename to sema/invalid_test.go index b5f058e34c..87e85d7a28 100644 --- a/tests/checker/invalid_test.go +++ b/sema/invalid_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "testing" @@ -24,6 +24,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckSpuriousIdentifierAssignmentInvalidValueTypeMismatch(t *testing.T) { diff --git a/tests/checker/invocation_test.go b/sema/invocation_test.go similarity index 99% rename from tests/checker/invocation_test.go rename to sema/invocation_test.go index ded43f11ae..11abdd4073 100644 --- a/tests/checker/invocation_test.go +++ b/sema/invocation_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "testing" @@ -28,6 +28,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" + . "github.com/onflow/cadence/tests/sema_utils" "github.com/onflow/cadence/tests/utils" ) diff --git a/tests/checker/member_test.go b/sema/member_test.go similarity index 99% rename from tests/checker/member_test.go rename to sema/member_test.go index c2778c7c18..94fd50858b 100644 --- a/tests/checker/member_test.go +++ b/sema/member_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "fmt" @@ -27,6 +27,7 @@ import ( "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckOptionalChainingNonOptionalFieldRead(t *testing.T) { diff --git a/tests/checker/metatype_test.go b/sema/metatype_test.go similarity index 99% rename from tests/checker/metatype_test.go rename to sema/metatype_test.go index cb9c5c1b7c..fcf185510f 100644 --- a/tests/checker/metatype_test.go +++ b/sema/metatype_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "testing" @@ -25,6 +25,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckMetaType(t *testing.T) { diff --git a/tests/checker/move_test.go b/sema/move_test.go similarity index 97% rename from tests/checker/move_test.go rename to sema/move_test.go index 848fc6c6e7..0791f6f744 100644 --- a/tests/checker/move_test.go +++ b/sema/move_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "testing" @@ -24,6 +24,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckInvalidMoves(t *testing.T) { diff --git a/tests/checker/nesting_test.go b/sema/nesting_test.go similarity index 99% rename from tests/checker/nesting_test.go rename to sema/nesting_test.go index 40ec6ab6e9..184e566224 100644 --- a/tests/checker/nesting_test.go +++ b/sema/nesting_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "fmt" @@ -29,6 +29,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckCompositeDeclarationNesting(t *testing.T) { diff --git a/tests/checker/never_test.go b/sema/never_test.go similarity index 98% rename from tests/checker/never_test.go rename to sema/never_test.go index 59c62020cc..5195786007 100644 --- a/tests/checker/never_test.go +++ b/sema/never_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "testing" @@ -25,6 +25,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckNever(t *testing.T) { diff --git a/tests/checker/nil_coalescing_test.go b/sema/nil_coalescing_test.go similarity index 98% rename from tests/checker/nil_coalescing_test.go rename to sema/nil_coalescing_test.go index 78a79677c0..0f7c0364fd 100644 --- a/tests/checker/nil_coalescing_test.go +++ b/sema/nil_coalescing_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "testing" @@ -25,6 +25,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckNilCoalescingNilIntToOptional(t *testing.T) { diff --git a/tests/checker/occurrences_test.go b/sema/occurrences_test.go similarity index 99% rename from tests/checker/occurrences_test.go rename to sema/occurrences_test.go index 462bb1e770..98f9403269 100644 --- a/tests/checker/occurrences_test.go +++ b/sema/occurrences_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "testing" @@ -26,6 +26,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" . "github.com/onflow/cadence/tests/utils" ) diff --git a/tests/checker/operations_test.go b/sema/operations_test.go similarity index 99% rename from tests/checker/operations_test.go rename to sema/operations_test.go index 3a198b4004..c5f460bc28 100644 --- a/tests/checker/operations_test.go +++ b/sema/operations_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "fmt" @@ -30,6 +30,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckInvalidUnaryBooleanNegationOfInteger(t *testing.T) { diff --git a/tests/checker/optional_test.go b/sema/optional_test.go similarity index 99% rename from tests/checker/optional_test.go rename to sema/optional_test.go index e502aa9f26..ea92b679e3 100644 --- a/tests/checker/optional_test.go +++ b/sema/optional_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "fmt" @@ -27,6 +27,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckOptional(t *testing.T) { diff --git a/tests/checker/overloading_test.go b/sema/overloading_test.go similarity index 96% rename from tests/checker/overloading_test.go rename to sema/overloading_test.go index d78bc4ba9b..77cdea966b 100644 --- a/tests/checker/overloading_test.go +++ b/sema/overloading_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "fmt" @@ -26,6 +26,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckInvalidCompositeInitializerOverloading(t *testing.T) { diff --git a/tests/checker/path_test.go b/sema/path_test.go similarity index 98% rename from tests/checker/path_test.go rename to sema/path_test.go index c21e313830..0b3fcd1215 100644 --- a/tests/checker/path_test.go +++ b/sema/path_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "fmt" @@ -27,6 +27,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckPath(t *testing.T) { diff --git a/tests/checker/pragma_test.go b/sema/pragma_test.go similarity index 98% rename from tests/checker/pragma_test.go rename to sema/pragma_test.go index 087ea1926a..1795e86df7 100644 --- a/tests/checker/pragma_test.go +++ b/sema/pragma_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "fmt" @@ -26,6 +26,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckPragmaExpression(t *testing.T) { diff --git a/tests/checker/predeclaredvalues_test.go b/sema/predeclaredvalues_test.go similarity index 95% rename from tests/checker/predeclaredvalues_test.go rename to sema/predeclaredvalues_test.go index 1ebcfb7d14..b402b49c80 100644 --- a/tests/checker/predeclaredvalues_test.go +++ b/sema/predeclaredvalues_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "testing" @@ -26,6 +26,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckPredeclaredValues(t *testing.T) { diff --git a/tests/checker/purity_test.go b/sema/purity_test.go similarity index 99% rename from tests/checker/purity_test.go rename to sema/purity_test.go index 16914158f5..2df908b4cd 100644 --- a/tests/checker/purity_test.go +++ b/sema/purity_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "testing" @@ -26,6 +26,7 @@ import ( "github.com/onflow/cadence/ast" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckPuritySubtyping(t *testing.T) { diff --git a/tests/checker/range_test.go b/sema/range_test.go similarity index 99% rename from tests/checker/range_test.go rename to sema/range_test.go index d72c798855..752cb93f64 100644 --- a/tests/checker/range_test.go +++ b/sema/range_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "strings" @@ -27,6 +27,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" "github.com/onflow/cadence/tests/utils" ) diff --git a/tests/checker/range_value_test.go b/sema/range_value_test.go similarity index 99% rename from tests/checker/range_value_test.go rename to sema/range_value_test.go index f93fd5a9c9..1598aee163 100644 --- a/tests/checker/range_value_test.go +++ b/sema/range_value_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "fmt" @@ -28,6 +28,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" + . "github.com/onflow/cadence/tests/sema_utils" ) type inclusiveRangeConstructionTest struct { diff --git a/tests/checker/reference_test.go b/sema/reference_test.go similarity index 99% rename from tests/checker/reference_test.go rename to sema/reference_test.go index ef4b92f33b..b05629424f 100644 --- a/tests/checker/reference_test.go +++ b/sema/reference_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "fmt" @@ -28,6 +28,7 @@ import ( "github.com/onflow/cadence/ast" "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" "github.com/onflow/cadence/tests/utils" ) diff --git a/tests/checker/resources_test.go b/sema/resource_test.go similarity index 99% rename from tests/checker/resources_test.go rename to sema/resource_test.go index 050a117a56..1bfe40da3b 100644 --- a/tests/checker/resources_test.go +++ b/sema/resource_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "fmt" @@ -29,6 +29,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/errors" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" . "github.com/onflow/cadence/tests/utils" ) diff --git a/tests/checker/return_test.go b/sema/return_test.go similarity index 99% rename from tests/checker/return_test.go rename to sema/return_test.go index 32b5cf4593..5f9b20ed5b 100644 --- a/tests/checker/return_test.go +++ b/sema/return_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "fmt" @@ -28,6 +28,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckInvalidReturnValue(t *testing.T) { diff --git a/tests/checker/rlp_test.go b/sema/rlp_test.go similarity index 97% rename from tests/checker/rlp_test.go rename to sema/rlp_test.go index 2f77cb0708..b079b03c33 100644 --- a/tests/checker/rlp_test.go +++ b/sema/rlp_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "testing" @@ -26,6 +26,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckRLPDecodeString(t *testing.T) { diff --git a/tests/checker/runtimetype_test.go b/sema/runtimetype_test.go similarity index 99% rename from tests/checker/runtimetype_test.go rename to sema/runtimetype_test.go index 7ee3c911e3..8d8b444c70 100644 --- a/tests/checker/runtimetype_test.go +++ b/sema/runtimetype_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "testing" @@ -25,6 +25,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckOptionalTypeConstructor(t *testing.T) { diff --git a/tests/checker/storable_test.go b/sema/storable_test.go similarity index 99% rename from tests/checker/storable_test.go rename to sema/storable_test.go index 5d1b97c2c5..3720107e70 100644 --- a/tests/checker/storable_test.go +++ b/sema/storable_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "fmt" @@ -29,6 +29,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckStorable(t *testing.T) { diff --git a/tests/checker/string_test.go b/sema/string_test.go similarity index 99% rename from tests/checker/string_test.go rename to sema/string_test.go index cc82a8ec00..23c0ff8001 100644 --- a/tests/checker/string_test.go +++ b/sema/string_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "testing" @@ -25,6 +25,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckCharacter(t *testing.T) { diff --git a/tests/checker/swap_test.go b/sema/swap_test.go similarity index 99% rename from tests/checker/swap_test.go rename to sema/swap_test.go index 28e708aceb..63fb658906 100644 --- a/tests/checker/swap_test.go +++ b/sema/swap_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "fmt" @@ -26,6 +26,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckInvalidUnknownDeclarationSwap(t *testing.T) { diff --git a/tests/checker/switch_test.go b/sema/switch_test.go similarity index 99% rename from tests/checker/switch_test.go rename to sema/switch_test.go index 0f34d0a506..38328f1645 100644 --- a/tests/checker/switch_test.go +++ b/sema/switch_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "testing" @@ -25,6 +25,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckSwitchStatementTest(t *testing.T) { diff --git a/tests/checker/transactions_test.go b/sema/transactions_test.go similarity index 99% rename from tests/checker/transactions_test.go rename to sema/transactions_test.go index 2dfde9d8c8..79b362d918 100644 --- a/tests/checker/transactions_test.go +++ b/sema/transactions_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "testing" @@ -25,6 +25,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckTransactions(t *testing.T) { diff --git a/tests/checker/type_inference_test.go b/sema/type_inference_test.go similarity index 99% rename from tests/checker/type_inference_test.go rename to sema/type_inference_test.go index 6aa900a98e..85a338eaf3 100644 --- a/tests/checker/type_inference_test.go +++ b/sema/type_inference_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "testing" @@ -26,6 +26,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckArrayElementTypeInference(t *testing.T) { diff --git a/tests/checker/typeargument_test.go b/sema/typeargument_test.go similarity index 99% rename from tests/checker/typeargument_test.go rename to sema/typeargument_test.go index 5c03e2794a..66895844d4 100644 --- a/tests/checker/typeargument_test.go +++ b/sema/typeargument_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "testing" @@ -27,6 +27,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckTypeArguments(t *testing.T) { diff --git a/tests/checker/utils_test.go b/sema/utils_test.go similarity index 96% rename from tests/checker/utils_test.go rename to sema/utils_test.go index 5aa262f30d..d65f31264d 100644 --- a/tests/checker/utils_test.go +++ b/sema/utils_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "testing" @@ -24,6 +24,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" + . "github.com/onflow/cadence/tests/sema_utils" ) func ParseAndCheckWithPanic(t *testing.T, code string) (*sema.Checker, error) { diff --git a/tests/checker/while_test.go b/sema/while_test.go similarity index 97% rename from tests/checker/while_test.go rename to sema/while_test.go index a6eaa55230..9d40353678 100644 --- a/tests/checker/while_test.go +++ b/sema/while_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_test import ( "testing" @@ -24,6 +24,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/tests/sema_utils" ) func TestCheckInvalidWhileTest(t *testing.T) { diff --git a/stdlib/builtin_test.go b/stdlib/builtin_test.go index 676603eaa5..46bbed8071 100644 --- a/stdlib/builtin_test.go +++ b/stdlib/builtin_test.go @@ -23,7 +23,7 @@ import ( "github.com/onflow/cadence/activations" "github.com/onflow/cadence/common" - "github.com/onflow/cadence/tests/checker" + . "github.com/onflow/cadence/tests/sema_utils" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -100,9 +100,9 @@ func TestCheckAssert(t *testing.T) { baseValueActivation.DeclareValue(AssertFunction) parseAndCheck := func(t *testing.T, code string) (*sema.Checker, error) { - return checker.ParseAndCheckWithOptions(t, + return ParseAndCheckWithOptions(t, code, - checker.ParseAndCheckOptions{ + ParseAndCheckOptions{ Config: &sema.Config{ BaseValueActivationHandler: func(_ common.Location) *sema.VariableActivation { return baseValueActivation @@ -116,7 +116,7 @@ func TestCheckAssert(t *testing.T) { _, err := parseAndCheck(t, `let _ = assert()`) - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, errs[0], &sema.InsufficientArgumentsError{}) }) @@ -124,7 +124,7 @@ func TestCheckAssert(t *testing.T) { _, err := parseAndCheck(t, `let _ = assert(1)`) - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, errs[0], &sema.TypeMismatchError{}) }) @@ -146,7 +146,7 @@ func TestCheckAssert(t *testing.T) { _, err := parseAndCheck(t, `let _ = assert(true, message: 1)`) - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, errs[0], &sema.TypeMismatchError{}) }) @@ -154,7 +154,7 @@ func TestCheckAssert(t *testing.T) { _, err := parseAndCheck(t, `let _ = assert(true, "")`) - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, errs[0], &sema.MissingArgumentLabelError{}) }) @@ -162,7 +162,7 @@ func TestCheckAssert(t *testing.T) { _, err := parseAndCheck(t, `let _ = assert(true, message: "foo", true)`) - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, errs[0], &sema.ExcessiveArgumentsError{}) }) } @@ -218,9 +218,9 @@ func TestCheckPanic(t *testing.T) { baseValueActivation.DeclareValue(PanicFunction) parseAndCheck := func(t *testing.T, code string) (*sema.Checker, error) { - return checker.ParseAndCheckWithOptions(t, + return ParseAndCheckWithOptions(t, code, - checker.ParseAndCheckOptions{ + ParseAndCheckOptions{ Config: &sema.Config{ BaseValueActivationHandler: func(_ common.Location) *sema.VariableActivation { return baseValueActivation @@ -234,7 +234,7 @@ func TestCheckPanic(t *testing.T) { _, err := parseAndCheck(t, `let _ = panic()`) - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, errs[0], &sema.InsufficientArgumentsError{}) }) @@ -250,7 +250,7 @@ func TestCheckPanic(t *testing.T) { _, err := parseAndCheck(t, `let _ = panic(true)`) - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, errs[0], &sema.TypeMismatchError{}) }) @@ -258,7 +258,7 @@ func TestCheckPanic(t *testing.T) { _, err := parseAndCheck(t, `let _ = panic("test", 1)`) - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, errs[0], &sema.ExcessiveArgumentsError{}) }) } diff --git a/stdlib/test_test.go b/stdlib/test_test.go index 19912f763c..47592a0de2 100644 --- a/stdlib/test_test.go +++ b/stdlib/test_test.go @@ -34,7 +34,7 @@ import ( "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/parser" "github.com/onflow/cadence/sema" - "github.com/onflow/cadence/tests/checker" + . "github.com/onflow/cadence/tests/sema_utils" "github.com/onflow/cadence/tests/utils" ) @@ -288,7 +288,7 @@ func TestTestNewMatcher(t *testing.T) { _, err := newTestContractInterpreter(t, script) - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) assert.IsType(t, &sema.TypeMismatchError{}, errs[0]) }) @@ -334,7 +334,7 @@ func TestTestNewMatcher(t *testing.T) { _, err := newTestContractInterpreter(t, script) - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) assert.IsType(t, &sema.TypeMismatchError{}, errs[0]) }) @@ -461,7 +461,7 @@ func TestTestEqualMatcher(t *testing.T) { _, err := newTestContractInterpreter(t, script) require.Error(t, err) - errs := checker.RequireCheckerErrors(t, err, 2) + errs := RequireCheckerErrors(t, err, 2) assert.IsType(t, &sema.TypeMismatchError{}, errs[0]) assert.IsType(t, &sema.TypeMismatchError{}, errs[1]) }) @@ -499,7 +499,7 @@ func TestTestEqualMatcher(t *testing.T) { _, err := newTestContractInterpreter(t, script) - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) assert.IsType(t, &sema.TypeMismatchError{}, errs[0]) }) @@ -671,7 +671,7 @@ func TestTestEqualMatcher(t *testing.T) { _, err := newTestContractInterpreter(t, script) - errs := checker.RequireCheckerErrors(t, err, 4) + errs := RequireCheckerErrors(t, err, 4) assert.IsType(t, &sema.TypeMismatchError{}, errs[0]) assert.IsType(t, &sema.TypeMismatchError{}, errs[1]) assert.IsType(t, &sema.TypeMismatchError{}, errs[2]) @@ -705,7 +705,7 @@ func TestTestEqualMatcher(t *testing.T) { _, err := newTestContractInterpreter(t, script) - errs := checker.RequireCheckerErrors(t, err, 3) + errs := RequireCheckerErrors(t, err, 3) assert.IsType(t, &sema.TypeMismatchError{}, errs[0]) assert.IsType(t, &sema.TypeMismatchError{}, errs[1]) assert.IsType(t, &sema.TypeMismatchError{}, errs[2]) @@ -990,7 +990,7 @@ func TestAssertEqual(t *testing.T) { _, err := newTestContractInterpreter(t, script) - errs := checker.RequireCheckerErrors(t, err, 2) + errs := RequireCheckerErrors(t, err, 2) assert.IsType(t, &sema.TypeMismatchError{}, errs[0]) assert.IsType(t, &sema.TypeMismatchError{}, errs[1]) }) @@ -1016,7 +1016,7 @@ func TestAssertEqual(t *testing.T) { _, err := newTestContractInterpreter(t, script) - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) assert.IsType(t, &sema.TypeMismatchError{}, errs[0]) }) @@ -1041,7 +1041,7 @@ func TestAssertEqual(t *testing.T) { _, err := newTestContractInterpreter(t, script) - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) assert.IsType(t, &sema.TypeMismatchError{}, errs[0]) }) } @@ -1931,7 +1931,7 @@ func TestTestExpect(t *testing.T) { _, err := newTestContractInterpreter(t, script) - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) assert.IsType(t, &sema.TypeMismatchError{}, errs[0]) }) @@ -1955,7 +1955,7 @@ func TestTestExpect(t *testing.T) { _, err := newTestContractInterpreter(t, script) - errs := checker.RequireCheckerErrors(t, err, 2) + errs := RequireCheckerErrors(t, err, 2) assert.IsType(t, &sema.TypeMismatchError{}, errs[0]) assert.IsType(t, &sema.TypeMismatchError{}, errs[1]) }) @@ -1981,7 +1981,7 @@ func TestTestExpect(t *testing.T) { _, err := newTestContractInterpreter(t, script) - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) assert.IsType(t, &sema.TypeMismatchError{}, errs[0]) }) @@ -2006,7 +2006,7 @@ func TestTestExpect(t *testing.T) { _, err := newTestContractInterpreter(t, script) - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) assert.IsType(t, &sema.TypeMismatchError{}, errs[0]) }) } @@ -2176,7 +2176,7 @@ func TestTestExpectFailure(t *testing.T) { ` _, err := newTestContractInterpreter(t, script) - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) assert.IsType(t, &sema.TypeMismatchError{}, errs[0]) }) @@ -2213,7 +2213,7 @@ func TestTestExpectFailure(t *testing.T) { ` _, err := newTestContractInterpreter(t, script) - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) assert.IsType(t, &sema.TypeMismatchError{}, errs[0]) }) } @@ -2377,7 +2377,7 @@ func TestBlockchain(t *testing.T) { } _, err := newTestContractInterpreterWithTestFramework(t, script, testFramework) - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) assert.IsType(t, &sema.TypeMismatchError{}, errs[0]) assert.False(t, resetInvoked) }) @@ -2481,7 +2481,7 @@ func TestBlockchain(t *testing.T) { } _, err := newTestContractInterpreterWithTestFramework(t, script, testFramework) - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) assert.IsType(t, &sema.TypeMismatchError{}, errs[0]) assert.False(t, moveTimeInvoked) }) diff --git a/tests/interpreter/condition_test.go b/tests/interpreter/condition_test.go index 34d56d2f14..74d1deabc9 100644 --- a/tests/interpreter/condition_test.go +++ b/tests/interpreter/condition_test.go @@ -31,7 +31,7 @@ import ( "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - "github.com/onflow/cadence/tests/checker" + . "github.com/onflow/cadence/tests/sema_utils" . "github.com/onflow/cadence/tests/utils" ) @@ -855,7 +855,7 @@ func TestInterpretInitializerWithInterfacePreCondition(t *testing.T) { ) } - checker, err := checker.ParseAndCheck(t, + checker, err := ParseAndCheck(t, fmt.Sprintf( ` access(all) diff --git a/tests/interpreter/function_test.go b/tests/interpreter/function_test.go index f2e4675e4e..e4e293fa9c 100644 --- a/tests/interpreter/function_test.go +++ b/tests/interpreter/function_test.go @@ -27,7 +27,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" - "github.com/onflow/cadence/tests/checker" + . "github.com/onflow/cadence/tests/sema_utils" "github.com/onflow/cadence/tests/utils" ) @@ -221,7 +221,7 @@ func TestInterpretResultVariable(t *testing.T) { ) require.NoError(t, err) require.Len(t, checkerErrors, 1) - checkerError := checker.RequireCheckerErrors(t, checkerErrors[0], 1) + checkerError := RequireCheckerErrors(t, checkerErrors[0], 1) require.IsType(t, &sema.PurityError{}, checkerError[0]) _, err = inter.Invoke("main") @@ -280,7 +280,7 @@ func TestInterpretResultVariable(t *testing.T) { ) require.NoError(t, err) require.Len(t, checkerErrors, 1) - checkerError := checker.RequireCheckerErrors(t, checkerErrors[0], 1) + checkerError := RequireCheckerErrors(t, checkerErrors[0], 1) require.IsType(t, &sema.PurityError{}, checkerError[0]) _, err = inter.Invoke("main") diff --git a/tests/interpreter/if_test.go b/tests/interpreter/if_test.go index cc7efb83c2..4242062e39 100644 --- a/tests/interpreter/if_test.go +++ b/tests/interpreter/if_test.go @@ -24,11 +24,11 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + . "github.com/onflow/cadence/tests/sema_utils" . "github.com/onflow/cadence/tests/utils" "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" - "github.com/onflow/cadence/tests/checker" ) func TestInterpretIfStatement(t *testing.T) { @@ -83,7 +83,7 @@ func TestInterpretIfStatement(t *testing.T) { `, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 2) + errs := RequireCheckerErrors(t, err, 2) assert.IsType(t, &sema.UnreachableStatementError{}, errs[0]) assert.IsType(t, &sema.UnreachableStatementError{}, errs[1]) diff --git a/tests/interpreter/import_test.go b/tests/interpreter/import_test.go index 45204a23c8..a5a2e808b7 100644 --- a/tests/interpreter/import_test.go +++ b/tests/interpreter/import_test.go @@ -29,7 +29,7 @@ import ( "github.com/onflow/cadence/common/orderedmap" "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" - "github.com/onflow/cadence/tests/checker" + . "github.com/onflow/cadence/tests/sema_utils" . "github.com/onflow/cadence/tests/utils" ) @@ -154,7 +154,7 @@ func TestInterpretImportMultipleProgramsFromLocation(t *testing.T) { address := common.MustBytesToAddress([]byte{0x1}) - importedCheckerA, err := checker.ParseAndCheckWithOptions(t, + importedCheckerA, err := ParseAndCheckWithOptions(t, ` // this function *SHOULD* be imported in the importing program access(all) fun a(): Int { @@ -166,7 +166,7 @@ func TestInterpretImportMultipleProgramsFromLocation(t *testing.T) { return 11 } `, - checker.ParseAndCheckOptions{ + ParseAndCheckOptions{ Location: common.AddressLocation{ Address: address, Name: "a", @@ -175,7 +175,7 @@ func TestInterpretImportMultipleProgramsFromLocation(t *testing.T) { ) require.NoError(t, err) - importedCheckerB, err := checker.ParseAndCheckWithOptions(t, + importedCheckerB, err := ParseAndCheckWithOptions(t, ` // this function *SHOULD* be imported in the importing program access(all) fun b(): Int { @@ -187,7 +187,7 @@ func TestInterpretImportMultipleProgramsFromLocation(t *testing.T) { return 22 } `, - checker.ParseAndCheckOptions{ + ParseAndCheckOptions{ Location: common.AddressLocation{ Address: address, Name: "b", @@ -196,7 +196,7 @@ func TestInterpretImportMultipleProgramsFromLocation(t *testing.T) { ) require.NoError(t, err) - importingChecker, err := checker.ParseAndCheckWithOptions(t, + importingChecker, err := ParseAndCheckWithOptions(t, ` import a, b from 0x1 @@ -204,7 +204,7 @@ func TestInterpretImportMultipleProgramsFromLocation(t *testing.T) { return a() + b() } `, - checker.ParseAndCheckOptions{ + ParseAndCheckOptions{ Config: &sema.Config{ LocationHandler: func(identifiers []ast.Identifier, location common.Location) (result []sema.ResolvedLocation, err error) { @@ -316,11 +316,11 @@ func TestInterpretResourceConstructionThroughIndirectImport(t *testing.T) { address := common.MustBytesToAddress([]byte{0x1}) - importedChecker, err := checker.ParseAndCheckWithOptions(t, + importedChecker, err := ParseAndCheckWithOptions(t, ` resource R {} `, - checker.ParseAndCheckOptions{ + ParseAndCheckOptions{ Location: common.AddressLocation{ Address: address, }, @@ -328,7 +328,7 @@ func TestInterpretResourceConstructionThroughIndirectImport(t *testing.T) { ) require.NoError(t, err) - importingChecker, err := checker.ParseAndCheckWithOptions(t, + importingChecker, err := ParseAndCheckWithOptions(t, ` import R from 0x1 @@ -337,7 +337,7 @@ func TestInterpretResourceConstructionThroughIndirectImport(t *testing.T) { destroy r } `, - checker.ParseAndCheckOptions{ + ParseAndCheckOptions{ Config: &sema.Config{ ImportHandler: func(checker *sema.Checker, importedLocation common.Location, _ ast.Range) (sema.Import, error) { require.IsType(t, common.AddressLocation{}, importedLocation) @@ -396,7 +396,7 @@ func TestInterpretResourceConstructionThroughIndirectImport(t *testing.T) { require.ErrorAs(t, err, &resourceConstructionError) assert.Equal(t, - checker.RequireGlobalType(t, importedChecker.Elaboration, "R"), + RequireGlobalType(t, importedChecker.Elaboration, "R"), resourceConstructionError.CompositeType, ) } diff --git a/tests/interpreter/interpreter_test.go b/tests/interpreter/interpreter_test.go index 6a697eff69..d3c3138580 100644 --- a/tests/interpreter/interpreter_test.go +++ b/tests/interpreter/interpreter_test.go @@ -39,7 +39,7 @@ import ( "github.com/onflow/cadence/runtime" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - "github.com/onflow/cadence/tests/checker" + . "github.com/onflow/cadence/tests/sema_utils" . "github.com/onflow/cadence/tests/utils" ) @@ -168,9 +168,9 @@ func parseCheckAndInterpretWithOptionsAndMemoryMetering( err error, ) { - checker, err := checker.ParseAndCheckWithOptionsAndMemoryMetering(t, + checker, err := ParseAndCheckWithOptionsAndMemoryMetering(t, code, - checker.ParseAndCheckOptions{ + ParseAndCheckOptions{ Config: options.CheckerConfig, }, memoryGauge, @@ -1208,7 +1208,7 @@ func TestInterpretReturns(t *testing.T) { `, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) assert.IsType(t, &sema.UnreachableStatementError{}, errs[0]) }, @@ -4207,19 +4207,19 @@ func TestInterpretImport(t *testing.T) { t.Parallel() - importedChecker, err := checker.ParseAndCheckWithOptions(t, + importedChecker, err := ParseAndCheckWithOptions(t, ` access(all) fun answer(): Int { return 42 } `, - checker.ParseAndCheckOptions{ + ParseAndCheckOptions{ Location: ImportedLocation, }, ) require.NoError(t, err) - importingChecker, err := checker.ParseAndCheckWithOptions(t, + importingChecker, err := ParseAndCheckWithOptions(t, ` import answer from "imported" @@ -4227,7 +4227,7 @@ func TestInterpretImport(t *testing.T) { return answer() } `, - checker.ParseAndCheckOptions{ + ParseAndCheckOptions{ Config: &sema.Config{ ImportHandler: func(_ *sema.Checker, importedLocation common.Location, _ ast.Range) (sema.Import, error) { assert.Equal(t, @@ -4298,9 +4298,9 @@ func TestInterpretImportError(t *testing.T) { baseValueActivation.DeclareValue(stdlib.PanicFunction) parseAndCheck := func(code string, location common.Location) *sema.Checker { - checker, err := checker.ParseAndCheckWithOptions(t, + checker, err := ParseAndCheckWithOptions(t, code, - checker.ParseAndCheckOptions{ + ParseAndCheckOptions{ Location: location, Config: &sema.Config{ BaseValueActivationHandler: func(_ common.Location) *sema.VariableActivation { @@ -6823,7 +6823,7 @@ func TestInterpretCompositeFunctionInvocationFromImportingProgram(t *testing.T) t.Parallel() - importedChecker, err := checker.ParseAndCheckWithOptions(t, + importedChecker, err := ParseAndCheckWithOptions(t, ` // function must have arguments access(all) fun x(x: Int) {} @@ -6836,13 +6836,13 @@ func TestInterpretCompositeFunctionInvocationFromImportingProgram(t *testing.T) } } `, - checker.ParseAndCheckOptions{ + ParseAndCheckOptions{ Location: ImportedLocation, }, ) require.NoError(t, err) - importingChecker, err := checker.ParseAndCheckWithOptions(t, + importingChecker, err := ParseAndCheckWithOptions(t, ` import Y from "imported" @@ -6851,7 +6851,7 @@ func TestInterpretCompositeFunctionInvocationFromImportingProgram(t *testing.T) Y().x() } `, - checker.ParseAndCheckOptions{ + ParseAndCheckOptions{ Config: &sema.Config{ ImportHandler: func(_ *sema.Checker, importedLocation common.Location, _ ast.Range) (sema.Import, error) { assert.Equal(t, @@ -7277,8 +7277,8 @@ func TestInterpretEmitEvent(t *testing.T) { _, err = inter.Invoke("test") require.NoError(t, err) - transferEventType := checker.RequireGlobalType(t, inter.Program.Elaboration, "Transfer") - transferAmountEventType := checker.RequireGlobalType(t, inter.Program.Elaboration, "TransferAmount") + transferEventType := RequireGlobalType(t, inter.Program.Elaboration, "Transfer") + transferAmountEventType := RequireGlobalType(t, inter.Program.Elaboration, "TransferAmount") fields1 := []interpreter.CompositeField{ { @@ -7420,7 +7420,7 @@ func TestInterpretReferenceEventParameter(t *testing.T) { _, err = inter.Invoke("test", ref) require.NoError(t, err) - eventType := checker.RequireGlobalType(t, inter.Program.Elaboration, "TestEvent") + eventType := RequireGlobalType(t, inter.Program.Elaboration, "TestEvent") expectedEvents := []interpreter.Value{ interpreter.NewCompositeValue( @@ -7758,7 +7758,7 @@ func TestInterpretEmitEventParameterTypes(t *testing.T) { _, err = inter.Invoke("test") require.NoError(t, err) - testType := checker.RequireGlobalType(t, inter.Program.Elaboration, "Test") + testType := RequireGlobalType(t, inter.Program.Elaboration, "Test") fields := []interpreter.CompositeField{ { @@ -8613,7 +8613,7 @@ func TestInterpretConformToImportedInterface(t *testing.T) { t.Parallel() - importedChecker, err := checker.ParseAndCheckWithOptions(t, + importedChecker, err := ParseAndCheckWithOptions(t, ` struct interface Foo { fun check(answer: Int) { @@ -8623,13 +8623,13 @@ func TestInterpretConformToImportedInterface(t *testing.T) { } } `, - checker.ParseAndCheckOptions{ + ParseAndCheckOptions{ Location: ImportedLocation, }, ) require.NoError(t, err) - importingChecker, err := checker.ParseAndCheckWithOptions(t, + importingChecker, err := ParseAndCheckWithOptions(t, ` import Foo from "imported" @@ -8642,7 +8642,7 @@ func TestInterpretConformToImportedInterface(t *testing.T) { bar.check(answer: 1) } `, - checker.ParseAndCheckOptions{ + ParseAndCheckOptions{ Config: &sema.Config{ ImportHandler: func(_ *sema.Checker, importedLocation common.Location, _ ast.Range) (sema.Import, error) { assert.Equal(t, @@ -10686,7 +10686,7 @@ func TestInterpretArrayFilter(t *testing.T) { `, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.PurityError{}, errs[0]) }, }, diff --git a/tests/interpreter/member_test.go b/tests/interpreter/member_test.go index 29d14e5b82..a7dd3c454a 100644 --- a/tests/interpreter/member_test.go +++ b/tests/interpreter/member_test.go @@ -25,7 +25,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/interpreter" - "github.com/onflow/cadence/tests/checker" + . "github.com/onflow/cadence/tests/sema_utils" . "github.com/onflow/cadence/tests/utils" ) @@ -407,7 +407,7 @@ func TestInterpretMemberAccessType(t *testing.T) { value, err := inter.Invoke("S") require.NoError(t, err) - sType := checker.RequireGlobalType(t, inter.Program.Elaboration, "S") + sType := RequireGlobalType(t, inter.Program.Elaboration, "S") ref := interpreter.NewUnmeteredEphemeralReferenceValue(inter, interpreter.UnauthorizedAccess, value, sType, interpreter.EmptyLocationRange) @@ -454,7 +454,7 @@ func TestInterpretMemberAccessType(t *testing.T) { value, err := inter.Invoke("S2") require.NoError(t, err) - sType := checker.RequireGlobalType(t, inter.Program.Elaboration, "S") + sType := RequireGlobalType(t, inter.Program.Elaboration, "S") ref := interpreter.NewUnmeteredEphemeralReferenceValue(inter, interpreter.UnauthorizedAccess, value, sType, interpreter.EmptyLocationRange) @@ -496,7 +496,7 @@ func TestInterpretMemberAccessType(t *testing.T) { value, err := inter.Invoke("S") require.NoError(t, err) - sType := checker.RequireGlobalType(t, inter.Program.Elaboration, "S") + sType := RequireGlobalType(t, inter.Program.Elaboration, "S") ref := interpreter.NewUnmeteredEphemeralReferenceValue(inter, interpreter.UnauthorizedAccess, value, sType, interpreter.EmptyLocationRange) @@ -541,7 +541,7 @@ func TestInterpretMemberAccessType(t *testing.T) { value, err := inter.Invoke("S2") require.NoError(t, err) - sType := checker.RequireGlobalType(t, inter.Program.Elaboration, "S") + sType := RequireGlobalType(t, inter.Program.Elaboration, "S") ref := interpreter.NewUnmeteredEphemeralReferenceValue(inter, interpreter.UnauthorizedAccess, value, sType, interpreter.EmptyLocationRange) diff --git a/tests/interpreter/memory_metering_test.go b/tests/interpreter/memory_metering_test.go index 5de97ddfe5..56fae49cb0 100644 --- a/tests/interpreter/memory_metering_test.go +++ b/tests/interpreter/memory_metering_test.go @@ -23,6 +23,7 @@ import ( "testing" "github.com/onflow/cadence/activations" + . "github.com/onflow/cadence/tests/sema_utils" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -32,7 +33,6 @@ import ( "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - "github.com/onflow/cadence/tests/checker" "github.com/onflow/cadence/tests/utils" ) @@ -8147,11 +8147,11 @@ func TestInterpretASTMetering(t *testing.T) { #pragma ` - importedChecker, err := checker.ParseAndCheckWithOptions(t, + importedChecker, err := ParseAndCheckWithOptions(t, ` let Foo = 1 `, - checker.ParseAndCheckOptions{ + ParseAndCheckOptions{ Location: utils.ImportedLocation, }, ) @@ -8444,12 +8444,12 @@ func TestInterpretASTMetering(t *testing.T) { import B from "string-location" ` - importedChecker, err := checker.ParseAndCheckWithOptions(t, + importedChecker, err := ParseAndCheckWithOptions(t, ` let A = 1 let B = 1 `, - checker.ParseAndCheckOptions{ + ParseAndCheckOptions{ Location: utils.ImportedLocation, }, ) diff --git a/tests/interpreter/metering_test.go b/tests/interpreter/metering_test.go index 243afdba05..a7ea9882d0 100644 --- a/tests/interpreter/metering_test.go +++ b/tests/interpreter/metering_test.go @@ -28,7 +28,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" - "github.com/onflow/cadence/tests/checker" + . "github.com/onflow/cadence/tests/sema_utils" "github.com/onflow/cadence/tests/utils" ) @@ -36,20 +36,20 @@ func TestInterpretStatementHandler(t *testing.T) { t.Parallel() - importedChecker, err := checker.ParseAndCheckWithOptions(t, + importedChecker, err := ParseAndCheckWithOptions(t, ` access(all) fun a() { true true } `, - checker.ParseAndCheckOptions{ + ParseAndCheckOptions{ Location: utils.ImportedLocation, }, ) require.NoError(t, err) - importingChecker, err := checker.ParseAndCheckWithOptions(t, + importingChecker, err := ParseAndCheckWithOptions(t, ` import a from "imported" @@ -69,7 +69,7 @@ func TestInterpretStatementHandler(t *testing.T) { true } `, - checker.ParseAndCheckOptions{ + ParseAndCheckOptions{ Config: &sema.Config{ ImportHandler: func(_ *sema.Checker, importedLocation common.Location, _ ast.Range) (sema.Import, error) { assert.Equal(t, @@ -163,7 +163,7 @@ func TestInterpretLoopIterationHandler(t *testing.T) { t.Parallel() - importedChecker, err := checker.ParseAndCheckWithOptions(t, + importedChecker, err := ParseAndCheckWithOptions(t, ` access(all) fun a() { var i = 1 @@ -174,11 +174,11 @@ func TestInterpretLoopIterationHandler(t *testing.T) { for n in [1, 2, 3, 4, 5] {} } `, - checker.ParseAndCheckOptions{}, + ParseAndCheckOptions{}, ) require.NoError(t, err) - importingChecker, err := checker.ParseAndCheckWithOptions(t, + importingChecker, err := ParseAndCheckWithOptions(t, ` import a from "imported" @@ -193,7 +193,7 @@ func TestInterpretLoopIterationHandler(t *testing.T) { a() } `, - checker.ParseAndCheckOptions{ + ParseAndCheckOptions{ Config: &sema.Config{ ImportHandler: func(_ *sema.Checker, importedLocation common.Location, _ ast.Range) (sema.Import, error) { assert.Equal(t, @@ -290,7 +290,7 @@ func TestInterpretFunctionInvocationHandler(t *testing.T) { t.Parallel() - importedChecker, err := checker.ParseAndCheckWithOptions(t, + importedChecker, err := ParseAndCheckWithOptions(t, ` access(all) fun a() {} @@ -302,13 +302,13 @@ func TestInterpretFunctionInvocationHandler(t *testing.T) { true } `, - checker.ParseAndCheckOptions{ + ParseAndCheckOptions{ Location: utils.ImportedLocation, }, ) require.NoError(t, err) - importingChecker, err := checker.ParseAndCheckWithOptions(t, + importingChecker, err := ParseAndCheckWithOptions(t, ` import b from "imported" @@ -328,7 +328,7 @@ func TestInterpretFunctionInvocationHandler(t *testing.T) { true } `, - checker.ParseAndCheckOptions{ + ParseAndCheckOptions{ Config: &sema.Config{ ImportHandler: func(_ *sema.Checker, importedLocation common.Location, _ ast.Range) (sema.Import, error) { assert.Equal(t, diff --git a/tests/interpreter/reference_test.go b/tests/interpreter/reference_test.go index 808ff46c83..7af848436c 100644 --- a/tests/interpreter/reference_test.go +++ b/tests/interpreter/reference_test.go @@ -28,7 +28,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" - "github.com/onflow/cadence/tests/checker" + . "github.com/onflow/cadence/tests/sema_utils" . "github.com/onflow/cadence/tests/utils" ) @@ -530,7 +530,7 @@ func TestInterpretResourceReferenceInvalidationOnMove(t *testing.T) { errorHandler := func(tt *testing.T) func(err error) { return func(err error) { - errors := checker.RequireCheckerErrors(tt, err, 1) + errors := RequireCheckerErrors(tt, err, 1) invalidatedRefError := &sema.InvalidatedResourceReferenceError{} assert.ErrorAs(tt, errors[0], &invalidatedRefError) } @@ -637,7 +637,7 @@ func TestInterpretResourceReferenceInvalidationOnMove(t *testing.T) { address := common.Address{0x1} - rType := checker.RequireGlobalType(t, inter.Program.Elaboration, "R").(*sema.CompositeType) + rType := RequireGlobalType(t, inter.Program.Elaboration, "R").(*sema.CompositeType) array := interpreter.NewArrayValue( inter, @@ -742,7 +742,7 @@ func TestInterpretResourceReferenceInvalidationOnMove(t *testing.T) { } `) - rType := checker.RequireGlobalType(t, inter.Program.Elaboration, "R").(*sema.CompositeType) + rType := RequireGlobalType(t, inter.Program.Elaboration, "R").(*sema.CompositeType) // Resource array in account 0x01 @@ -843,7 +843,7 @@ func TestInterpretResourceReferenceInvalidationOnMove(t *testing.T) { address := common.Address{0x1} - rType := checker.RequireGlobalType(t, inter.Program.Elaboration, "R").(*sema.CompositeType) + rType := RequireGlobalType(t, inter.Program.Elaboration, "R").(*sema.CompositeType) array := interpreter.NewArrayValue( inter, @@ -969,7 +969,7 @@ func TestInterpretResourceReferenceInvalidationOnMove(t *testing.T) { address := common.Address{0x1} - rType := checker.RequireGlobalType(t, inter.Program.Elaboration, "R").(*sema.CompositeType) + rType := RequireGlobalType(t, inter.Program.Elaboration, "R").(*sema.CompositeType) array := interpreter.NewArrayValue( inter, @@ -1524,7 +1524,7 @@ func TestInterpretResourceReferenceInvalidationOnDestroy(t *testing.T) { errorHandler := func(tt *testing.T) func(err error) { return func(err error) { - errors := checker.RequireCheckerErrors(tt, err, 1) + errors := RequireCheckerErrors(tt, err, 1) invalidatedRefError := &sema.InvalidatedResourceReferenceError{} assert.ErrorAs(tt, errors[0], &invalidatedRefError) } @@ -1747,7 +1747,7 @@ func TestInterpretReferenceToReference(t *testing.T) { } `, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.NestedReferenceError{}, errs[0]) }, }) @@ -1787,7 +1787,7 @@ func TestInterpretReferenceToReference(t *testing.T) { } `, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.NestedReferenceError{}, errs[0]) }, }) @@ -3040,7 +3040,7 @@ func TestInterpretDereference(t *testing.T) { `, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.InvalidUnaryOperandError{}, errs[0]) }, @@ -3071,7 +3071,7 @@ func TestInterpretDereference(t *testing.T) { `, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.InvalidUnaryOperandError{}, errs[0]) }, @@ -3208,7 +3208,7 @@ func TestInterpretHostFunctionReferenceInvalidation(t *testing.T) { result, err := inter.Invoke("main") require.NoError(t, err) - sType := checker.RequireGlobalType(t, inter.Program.Elaboration, "S").(*sema.CompositeType) + sType := RequireGlobalType(t, inter.Program.Elaboration, "S").(*sema.CompositeType) expectedResult := interpreter.NewArrayValue( inter, @@ -3281,7 +3281,7 @@ func TestInterpretHostFunctionReferenceInvalidation(t *testing.T) { result, err := inter.Invoke("main") require.NoError(t, err) - sType := checker.RequireGlobalType(t, inter.Program.Elaboration, "S").(*sema.CompositeType) + sType := RequireGlobalType(t, inter.Program.Elaboration, "S").(*sema.CompositeType) expectedResult := interpreter.NewTypeValue( inter, diff --git a/tests/interpreter/resources_test.go b/tests/interpreter/resources_test.go index f6d1b11283..fd639a5739 100644 --- a/tests/interpreter/resources_test.go +++ b/tests/interpreter/resources_test.go @@ -25,7 +25,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" - "github.com/onflow/cadence/tests/checker" + . "github.com/onflow/cadence/tests/sema_utils" . "github.com/onflow/cadence/tests/utils" "github.com/onflow/cadence/interpreter" @@ -321,7 +321,7 @@ func TestInterpretInvalidatedResourceValidation(t *testing.T) { `, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.ResourceUseAfterInvalidationError{}, errs[0]) }, }, @@ -367,7 +367,7 @@ func TestInterpretInvalidatedResourceValidation(t *testing.T) { `, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.ResourceUseAfterInvalidationError{}, errs[0]) }, }, @@ -413,7 +413,7 @@ func TestInterpretInvalidatedResourceValidation(t *testing.T) { `, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.ResourceUseAfterInvalidationError{}, errs[0]) }, }, @@ -459,7 +459,7 @@ func TestInterpretInvalidatedResourceValidation(t *testing.T) { `, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.ResourceUseAfterInvalidationError{}, errs[0]) }, }, @@ -502,7 +502,7 @@ func TestInterpretInvalidatedResourceValidation(t *testing.T) { `, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.ResourceUseAfterInvalidationError{}, errs[0]) }, }, @@ -542,7 +542,7 @@ func TestInterpretInvalidatedResourceValidation(t *testing.T) { `, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.ResourceUseAfterInvalidationError{}, errs[0]) }, }, @@ -582,7 +582,7 @@ func TestInterpretInvalidatedResourceValidation(t *testing.T) { `, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.ResourceUseAfterInvalidationError{}, errs[0]) }, }, @@ -622,7 +622,7 @@ func TestInterpretInvalidatedResourceValidation(t *testing.T) { `, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.ResourceUseAfterInvalidationError{}, errs[0]) }, }, @@ -664,7 +664,7 @@ func TestInterpretInvalidatedResourceValidation(t *testing.T) { `, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.ResourceUseAfterInvalidationError{}, errs[0]) }, }, @@ -705,7 +705,7 @@ func TestInterpretInvalidatedResourceValidation(t *testing.T) { `, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.ResourceUseAfterInvalidationError{}, errs[0]) }, }, @@ -743,7 +743,7 @@ func TestInterpretInvalidatedResourceValidation(t *testing.T) { `, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.ResourceUseAfterInvalidationError{}, errs[0]) }, }, @@ -776,7 +776,7 @@ func TestInterpretInvalidatedResourceValidation(t *testing.T) { `, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.ResourceUseAfterInvalidationError{}, errs[0]) }, }, @@ -809,7 +809,7 @@ func TestInterpretInvalidatedResourceValidation(t *testing.T) { `, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.ResourceUseAfterInvalidationError{}, errs[0]) }, }, @@ -840,7 +840,7 @@ func TestInterpretInvalidatedResourceValidation(t *testing.T) { `, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.ResourceUseAfterInvalidationError{}, errs[0]) }, }, @@ -891,7 +891,7 @@ func TestInterpretInvalidatedResourceValidation(t *testing.T) { `, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.ResourceUseAfterInvalidationError{}, errs[0]) }, }, @@ -936,7 +936,7 @@ func TestInterpretInvalidatedResourceValidation(t *testing.T) { `, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.ResourceUseAfterInvalidationError{}, errs[0]) }, }, @@ -981,7 +981,7 @@ func TestInterpretInvalidatedResourceValidation(t *testing.T) { `, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.ResourceUseAfterInvalidationError{}, errs[0]) }, }, @@ -1026,7 +1026,7 @@ func TestInterpretInvalidatedResourceValidation(t *testing.T) { `, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.ResourceUseAfterInvalidationError{}, errs[0]) }, }, @@ -1067,7 +1067,7 @@ func TestInterpretInvalidatedResourceValidation(t *testing.T) { `, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.ResourceUseAfterInvalidationError{}, errs[0]) }, }, @@ -1105,7 +1105,7 @@ func TestInterpretInvalidatedResourceValidation(t *testing.T) { `, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.ResourceUseAfterInvalidationError{}, errs[0]) }, }, @@ -1143,7 +1143,7 @@ func TestInterpretInvalidatedResourceValidation(t *testing.T) { `, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.ResourceUseAfterInvalidationError{}, errs[0]) }, }, @@ -1181,7 +1181,7 @@ func TestInterpretInvalidatedResourceValidation(t *testing.T) { `, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.ResourceUseAfterInvalidationError{}, errs[0]) }, }, @@ -1222,7 +1222,7 @@ func TestInterpretInvalidatedResourceValidation(t *testing.T) { `, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.ResourceUseAfterInvalidationError{}, errs[0]) }, }, @@ -1262,7 +1262,7 @@ func TestInterpretInvalidatedResourceValidation(t *testing.T) { `, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.ResourceUseAfterInvalidationError{}, errs[0]) }, }, @@ -1300,7 +1300,7 @@ func TestInterpretInvalidatedResourceValidation(t *testing.T) { `, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.ResourceUseAfterInvalidationError{}, errs[0]) }, }, @@ -1332,7 +1332,7 @@ func TestInterpretInvalidatedResourceValidation(t *testing.T) { `, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.ResourceUseAfterInvalidationError{}, errs[0]) }, }, @@ -1364,7 +1364,7 @@ func TestInterpretInvalidatedResourceValidation(t *testing.T) { `, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.ResourceUseAfterInvalidationError{}, errs[0]) }, }, @@ -1396,7 +1396,7 @@ func TestInterpretInvalidatedResourceValidation(t *testing.T) { `, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.ResourceUseAfterInvalidationError{}, errs[0]) }, }, @@ -1430,7 +1430,7 @@ func TestInterpretInvalidatedResourceValidation(t *testing.T) { }`, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.ResourceUseAfterInvalidationError{}, errs[0]) }, }, @@ -1458,7 +1458,7 @@ func TestInterpretInvalidatedResourceValidation(t *testing.T) { }`, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 2) + errs := RequireCheckerErrors(t, err, 2) require.IsType(t, &sema.ResourceLossError{}, errs[0]) require.IsType(t, &sema.ResourceUseAfterInvalidationError{}, errs[1]) }, @@ -1491,7 +1491,7 @@ func TestInterpretInvalidatedResourceValidation(t *testing.T) { }`, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 6) + errs := RequireCheckerErrors(t, err, 6) require.IsType(t, &sema.InvalidConditionalResourceOperandError{}, errs[0]) require.IsType(t, &sema.InvalidConditionalResourceOperandError{}, errs[1]) require.IsType(t, &sema.ResourceUseAfterInvalidationError{}, errs[2]) @@ -1525,7 +1525,7 @@ func TestInterpretInvalidatedResourceValidation(t *testing.T) { }`, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.ResourceUseAfterInvalidationError{}, errs[0]) }, }, @@ -1553,7 +1553,7 @@ func TestInterpretInvalidatedResourceValidation(t *testing.T) { }`, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.ResourceUseAfterInvalidationError{}, errs[0]) }, }, @@ -1585,7 +1585,7 @@ func TestInterpretInvalidatedResourceValidation(t *testing.T) { }`, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.ResourceUseAfterInvalidationError{}, errs[0]) }, }, @@ -1614,7 +1614,7 @@ func TestInterpretInvalidatedResourceValidation(t *testing.T) { }`, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.ResourceUseAfterInvalidationError{}, errs[0]) }, }, @@ -1643,7 +1643,7 @@ func TestInterpretInvalidatedResourceValidation(t *testing.T) { }`, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.ResourceUseAfterInvalidationError{}, errs[0]) }, }, @@ -1675,7 +1675,7 @@ func TestInterpretInvalidatedResourceValidation(t *testing.T) { }`, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 2) + errs := RequireCheckerErrors(t, err, 2) require.IsType(t, &sema.InvalidConditionalResourceOperandError{}, errs[0]) require.IsType(t, &sema.InvalidConditionalResourceOperandError{}, errs[1]) }, @@ -1708,7 +1708,7 @@ func TestInterpretInvalidatedResourceValidation(t *testing.T) { }`, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 2) + errs := RequireCheckerErrors(t, err, 2) require.IsType(t, &sema.InvalidConditionalResourceOperandError{}, errs[0]) require.IsType(t, &sema.InvalidConditionalResourceOperandError{}, errs[1]) }, @@ -1740,7 +1740,7 @@ func TestInterpretResourceInvalidationWithConditionalExprInDestroy(t *testing.T) }`, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 2) + errs := RequireCheckerErrors(t, err, 2) require.IsType(t, &sema.InvalidConditionalResourceOperandError{}, errs[0]) require.IsType(t, &sema.InvalidConditionalResourceOperandError{}, errs[0]) }, @@ -1782,7 +1782,7 @@ func TestInterpretResourceUseAfterInvalidation(t *testing.T) { }`, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 2) + errs := RequireCheckerErrors(t, err, 2) require.IsType(t, &sema.ResourceUseAfterInvalidationError{}, errs[0]) require.IsType(t, &sema.ResourceUseAfterInvalidationError{}, errs[1]) }, @@ -1820,7 +1820,7 @@ func TestInterpretResourceUseAfterInvalidation(t *testing.T) { }`, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) require.IsType(t, &sema.ResourceUseAfterInvalidationError{}, errs[0]) }, }, @@ -2158,7 +2158,7 @@ func TestInterpretResourceDestroyedInPreCondition(t *testing.T) { `, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 2) + errs := RequireCheckerErrors(t, err, 2) require.IsType(t, &sema.PurityError{}, errs[0]) require.IsType(t, &sema.InvalidInterfaceConditionResourceInvalidationError{}, errs[1]) }, @@ -2633,7 +2633,7 @@ func TestInterpretDefaultDestroyEventArgumentScoping(t *testing.T) { }, }, HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) assert.IsType(t, &sema.DefaultDestroyInvalidArgumentError{}, errs[0]) assert.Equal(t, errs[0].(*sema.DefaultDestroyInvalidArgumentError).Kind, sema.InvalidIdentifier) // ... @@ -2857,7 +2857,7 @@ func TestInterpretMovedResourceInOptionalBinding(t *testing.T) { } `, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) assert.IsType(t, &sema.ResourceUseAfterInvalidationError{}, errs[0]) }, }) @@ -2900,7 +2900,7 @@ func TestInterpretMovedResourceInSecondValue(t *testing.T) { } `, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) assert.IsType(t, &sema.ResourceUseAfterInvalidationError{}, errs[0]) }, }) @@ -3032,7 +3032,7 @@ func TestInterpretPreConditionResourceMove(t *testing.T) { }`, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - checkerErrors := checker.RequireCheckerErrors(t, err, 3) + checkerErrors := RequireCheckerErrors(t, err, 3) require.IsType(t, &sema.PurityError{}, checkerErrors[0]) require.IsType(t, &sema.InvalidInterfaceConditionResourceInvalidationError{}, checkerErrors[1]) require.IsType(t, &sema.PurityError{}, checkerErrors[2]) @@ -3566,7 +3566,7 @@ func TestInterpretInvalidNilCoalescingResourceDuplication(t *testing.T) { `, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) assert.IsType(t, &sema.InvalidNilCoalescingRightResourceOperandError{}, errs[0]) }, }, diff --git a/tests/interpreter/switch_test.go b/tests/interpreter/switch_test.go index 3d0dda4b90..0cbe894063 100644 --- a/tests/interpreter/switch_test.go +++ b/tests/interpreter/switch_test.go @@ -24,11 +24,11 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + . "github.com/onflow/cadence/tests/sema_utils" . "github.com/onflow/cadence/tests/utils" "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" - "github.com/onflow/cadence/tests/checker" ) func TestInterpretSwitchStatement(t *testing.T) { @@ -53,7 +53,7 @@ func TestInterpretSwitchStatement(t *testing.T) { `, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) assert.IsType(t, &sema.UnreachableStatementError{}, errs[0]) }, @@ -91,7 +91,7 @@ func TestInterpretSwitchStatement(t *testing.T) { `, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) assert.IsType(t, &sema.UnreachableStatementError{}, errs[0]) }, @@ -132,7 +132,7 @@ func TestInterpretSwitchStatement(t *testing.T) { `, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) assert.IsType(t, &sema.UnreachableStatementError{}, errs[0]) }, @@ -219,7 +219,7 @@ func TestInterpretSwitchStatement(t *testing.T) { `, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 1) + errs := RequireCheckerErrors(t, err, 1) assert.IsType(t, &sema.UnreachableStatementError{}, errs[0]) }, diff --git a/tests/interpreter/transactions_test.go b/tests/interpreter/transactions_test.go index 71680a184d..8a4167a0b1 100644 --- a/tests/interpreter/transactions_test.go +++ b/tests/interpreter/transactions_test.go @@ -29,7 +29,7 @@ import ( "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - "github.com/onflow/cadence/tests/checker" + . "github.com/onflow/cadence/tests/sema_utils" . "github.com/onflow/cadence/tests/utils" ) @@ -420,7 +420,7 @@ func TestRuntimeInvalidTransferInExecute(t *testing.T) { } `, ParseCheckAndInterpretOptions{ HandleCheckerError: func(err error) { - errs := checker.RequireCheckerErrors(t, err, 3) + errs := RequireCheckerErrors(t, err, 3) require.IsType(t, &sema.ResourceCapturingError{}, errs[0]) require.IsType(t, &sema.ResourceCapturingError{}, errs[1]) require.IsType(t, &sema.ResourceCapturingError{}, errs[2]) diff --git a/tests/interpreter/uuid_test.go b/tests/interpreter/uuid_test.go index 3e56037a5c..aa4154ff19 100644 --- a/tests/interpreter/uuid_test.go +++ b/tests/interpreter/uuid_test.go @@ -28,7 +28,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" - "github.com/onflow/cadence/tests/checker" + . "github.com/onflow/cadence/tests/sema_utils" . "github.com/onflow/cadence/tests/utils" ) @@ -36,7 +36,7 @@ func TestInterpretResourceUUID(t *testing.T) { t.Parallel() - importedChecker, err := checker.ParseAndCheckWithOptions(t, + importedChecker, err := ParseAndCheckWithOptions(t, ` access(all) resource R {} @@ -44,13 +44,13 @@ func TestInterpretResourceUUID(t *testing.T) { return <- create R() } `, - checker.ParseAndCheckOptions{ + ParseAndCheckOptions{ Location: ImportedLocation, }, ) require.NoError(t, err) - importingChecker, err := checker.ParseAndCheckWithOptions(t, + importingChecker, err := ParseAndCheckWithOptions(t, ` import createR from "imported" @@ -63,7 +63,7 @@ func TestInterpretResourceUUID(t *testing.T) { ] } `, - checker.ParseAndCheckOptions{ + ParseAndCheckOptions{ Config: &sema.Config{ ImportHandler: func(_ *sema.Checker, importedLocation common.Location, _ ast.Range) (sema.Import, error) { assert.Equal(t, diff --git a/tests/checker/utils.go b/tests/sema_utils/utils.go similarity index 99% rename from tests/checker/utils.go rename to tests/sema_utils/utils.go index 3afe516b80..23d1e7756e 100644 --- a/tests/checker/utils.go +++ b/tests/sema_utils/utils.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package checker +package sema_utils import ( "flag" diff --git a/tools/analysis/analysis_test.go b/tools/analysis/analysis_test.go index 61e1d54ec4..0baebceefa 100644 --- a/tools/analysis/analysis_test.go +++ b/tools/analysis/analysis_test.go @@ -29,7 +29,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/parser" "github.com/onflow/cadence/sema" - "github.com/onflow/cadence/tests/checker" + . "github.com/onflow/cadence/tests/sema_utils" "github.com/onflow/cadence/tools/analysis" ) @@ -558,7 +558,7 @@ func TestCyclicImports(t *testing.T) { var checkerError *sema.CheckerError require.ErrorAs(t, err, &checkerError) - errs := checker.RequireCheckerErrors(t, checkerError, 1) + errs := RequireCheckerErrors(t, checkerError, 1) var importedProgramErr *sema.ImportedProgramError require.ErrorAs(t, errs[0], &importedProgramErr) @@ -566,6 +566,6 @@ func TestCyclicImports(t *testing.T) { var nestedCheckerErr *sema.CheckerError require.ErrorAs(t, importedProgramErr.Err, &nestedCheckerErr) - errs = checker.RequireCheckerErrors(t, nestedCheckerErr, 1) + errs = RequireCheckerErrors(t, nestedCheckerErr, 1) require.IsType(t, &sema.CyclicImportsError{}, errs[0]) } From 0f5d513151ff53bbd3c14bb1d3a6324bb3152484 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20M=C3=BCller?= Date: Mon, 28 Oct 2024 16:25:19 -0700 Subject: [PATCH 41/46] move occurrence matcher --- .../occurrence_matcher.go => sema/occurrence_matcher_test.go | 2 +- sema/occurrences_test.go | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) rename tests/utils/occurrence_matcher.go => sema/occurrence_matcher_test.go (98%) diff --git a/tests/utils/occurrence_matcher.go b/sema/occurrence_matcher_test.go similarity index 98% rename from tests/utils/occurrence_matcher.go rename to sema/occurrence_matcher_test.go index 830af59c65..1f672755ac 100644 --- a/tests/utils/occurrence_matcher.go +++ b/sema/occurrence_matcher_test.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package utils +package sema_test import ( "github.com/onflow/cadence/common" diff --git a/sema/occurrences_test.go b/sema/occurrences_test.go index 98f9403269..a1854e5cef 100644 --- a/sema/occurrences_test.go +++ b/sema/occurrences_test.go @@ -27,7 +27,6 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" . "github.com/onflow/cadence/tests/sema_utils" - . "github.com/onflow/cadence/tests/utils" ) // TODO: implement occurrences for type references From a6da1a0620c76c67f1ff48dad164b54d91f03f5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20M=C3=BCller?= Date: Mon, 28 Oct 2024 16:33:18 -0700 Subject: [PATCH 42/46] move interpreter tests --- .../account_test.go | 0 .../arithmetic_test.go | 0 .../interpreter => interpreter}/array_test.go | 0 .../attachments_test.go | 0 .../bitwise_test.go | 0 .../builtinfunctions_test.go | 0 .../character_test.go | 0 .../composite_value_test.go | 0 .../condition_test.go | 0 .../container_mutation_test.go | 0 .../contract_test.go | 0 .../declaration_test.go | 0 interpreter/deepcopyremove_test.go | 34 ++++++++----------- .../dictionary_test.go | 0 .../dynamic_casting_test.go | 0 .../entitlements_test.go | 0 .../interpreter => interpreter}/enum_test.go | 0 .../equality_test.go | 0 .../fixedpoint_test.go | 0 .../interpreter => interpreter}/for_test.go | 0 .../function_test.go | 0 {tests/interpreter => interpreter}/if_test.go | 0 .../import_test.go | 0 .../indexing_test.go | 0 .../integers_test.go | 0 .../interface_test.go | 0 .../invocation_test.go | 0 .../member_test.go | 0 .../memory_metering_test.go | 0 .../metatype_test.go | 0 .../metering_test.go | 0 .../misc_test.go | 0 .../nesting_test.go | 0 .../interpreter => interpreter}/path_test.go | 0 .../pathcapability_test.go | 0 .../range_value_test.go | 0 .../reference_test.go | 0 .../resources_test.go | 0 .../runtimetype_test.go | 0 .../string_test.go | 0 .../switch_test.go | 0 .../transactions_test.go | 0 .../transfer_test.go | 0 .../interpreter => interpreter}/uuid_test.go | 0 .../values_test.go | 0 .../interpreter => interpreter}/while_test.go | 0 46 files changed, 15 insertions(+), 19 deletions(-) rename {tests/interpreter => interpreter}/account_test.go (100%) rename {tests/interpreter => interpreter}/arithmetic_test.go (100%) rename {tests/interpreter => interpreter}/array_test.go (100%) rename {tests/interpreter => interpreter}/attachments_test.go (100%) rename {tests/interpreter => interpreter}/bitwise_test.go (100%) rename {tests/interpreter => interpreter}/builtinfunctions_test.go (100%) rename {tests/interpreter => interpreter}/character_test.go (100%) rename {tests/interpreter => interpreter}/composite_value_test.go (100%) rename {tests/interpreter => interpreter}/condition_test.go (100%) rename {tests/interpreter => interpreter}/container_mutation_test.go (100%) rename {tests/interpreter => interpreter}/contract_test.go (100%) rename {tests/interpreter => interpreter}/declaration_test.go (100%) rename {tests/interpreter => interpreter}/dictionary_test.go (100%) rename {tests/interpreter => interpreter}/dynamic_casting_test.go (100%) rename {tests/interpreter => interpreter}/entitlements_test.go (100%) rename {tests/interpreter => interpreter}/enum_test.go (100%) rename {tests/interpreter => interpreter}/equality_test.go (100%) rename {tests/interpreter => interpreter}/fixedpoint_test.go (100%) rename {tests/interpreter => interpreter}/for_test.go (100%) rename {tests/interpreter => interpreter}/function_test.go (100%) rename {tests/interpreter => interpreter}/if_test.go (100%) rename {tests/interpreter => interpreter}/import_test.go (100%) rename {tests/interpreter => interpreter}/indexing_test.go (100%) rename {tests/interpreter => interpreter}/integers_test.go (100%) rename {tests/interpreter => interpreter}/interface_test.go (100%) rename {tests/interpreter => interpreter}/invocation_test.go (100%) rename {tests/interpreter => interpreter}/member_test.go (100%) rename {tests/interpreter => interpreter}/memory_metering_test.go (100%) rename {tests/interpreter => interpreter}/metatype_test.go (100%) rename {tests/interpreter => interpreter}/metering_test.go (100%) rename tests/interpreter/interpreter_test.go => interpreter/misc_test.go (100%) rename {tests/interpreter => interpreter}/nesting_test.go (100%) rename {tests/interpreter => interpreter}/path_test.go (100%) rename {tests/interpreter => interpreter}/pathcapability_test.go (100%) rename {tests/interpreter => interpreter}/range_value_test.go (100%) rename {tests/interpreter => interpreter}/reference_test.go (100%) rename {tests/interpreter => interpreter}/resources_test.go (100%) rename {tests/interpreter => interpreter}/runtimetype_test.go (100%) rename {tests/interpreter => interpreter}/string_test.go (100%) rename {tests/interpreter => interpreter}/switch_test.go (100%) rename {tests/interpreter => interpreter}/transactions_test.go (100%) rename {tests/interpreter => interpreter}/transfer_test.go (100%) rename {tests/interpreter => interpreter}/uuid_test.go (100%) rename {tests/interpreter => interpreter}/values_test.go (100%) rename {tests/interpreter => interpreter}/while_test.go (100%) diff --git a/tests/interpreter/account_test.go b/interpreter/account_test.go similarity index 100% rename from tests/interpreter/account_test.go rename to interpreter/account_test.go diff --git a/tests/interpreter/arithmetic_test.go b/interpreter/arithmetic_test.go similarity index 100% rename from tests/interpreter/arithmetic_test.go rename to interpreter/arithmetic_test.go diff --git a/tests/interpreter/array_test.go b/interpreter/array_test.go similarity index 100% rename from tests/interpreter/array_test.go rename to interpreter/array_test.go diff --git a/tests/interpreter/attachments_test.go b/interpreter/attachments_test.go similarity index 100% rename from tests/interpreter/attachments_test.go rename to interpreter/attachments_test.go diff --git a/tests/interpreter/bitwise_test.go b/interpreter/bitwise_test.go similarity index 100% rename from tests/interpreter/bitwise_test.go rename to interpreter/bitwise_test.go diff --git a/tests/interpreter/builtinfunctions_test.go b/interpreter/builtinfunctions_test.go similarity index 100% rename from tests/interpreter/builtinfunctions_test.go rename to interpreter/builtinfunctions_test.go diff --git a/tests/interpreter/character_test.go b/interpreter/character_test.go similarity index 100% rename from tests/interpreter/character_test.go rename to interpreter/character_test.go diff --git a/tests/interpreter/composite_value_test.go b/interpreter/composite_value_test.go similarity index 100% rename from tests/interpreter/composite_value_test.go rename to interpreter/composite_value_test.go diff --git a/tests/interpreter/condition_test.go b/interpreter/condition_test.go similarity index 100% rename from tests/interpreter/condition_test.go rename to interpreter/condition_test.go diff --git a/tests/interpreter/container_mutation_test.go b/interpreter/container_mutation_test.go similarity index 100% rename from tests/interpreter/container_mutation_test.go rename to interpreter/container_mutation_test.go diff --git a/tests/interpreter/contract_test.go b/interpreter/contract_test.go similarity index 100% rename from tests/interpreter/contract_test.go rename to interpreter/contract_test.go diff --git a/tests/interpreter/declaration_test.go b/interpreter/declaration_test.go similarity index 100% rename from tests/interpreter/declaration_test.go rename to interpreter/declaration_test.go diff --git a/interpreter/deepcopyremove_test.go b/interpreter/deepcopyremove_test.go index 5521332900..de16e42445 100644 --- a/interpreter/deepcopyremove_test.go +++ b/interpreter/deepcopyremove_test.go @@ -26,7 +26,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/common" - . "github.com/onflow/cadence/interpreter" + "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/tests/utils" ) @@ -38,49 +38,49 @@ func TestValueDeepCopyAndDeepRemove(t *testing.T) { storage := newUnmeteredInMemoryStorage() - inter, err := NewInterpreter( + inter, err := interpreter.NewInterpreter( nil, utils.TestLocation, - &Config{ + &interpreter.Config{ Storage: storage, }, ) require.NoError(t, err) - dictionaryStaticType := &DictionaryStaticType{ - KeyType: PrimitiveStaticTypeString, - ValueType: PrimitiveStaticTypeInt256, + dictionaryStaticType := &interpreter.DictionaryStaticType{ + KeyType: interpreter.PrimitiveStaticTypeString, + ValueType: interpreter.PrimitiveStaticTypeInt256, } - dictValueKey := NewUnmeteredStringValue( + dictValueKey := interpreter.NewUnmeteredStringValue( strings.Repeat("x", int(atree.MaxInlineMapKeySize()+1)), ) - dictValueValue := NewUnmeteredInt256ValueFromInt64(1) - dictValue := NewDictionaryValue( + dictValueValue := interpreter.NewUnmeteredInt256ValueFromInt64(1) + dictValue := interpreter.NewDictionaryValue( inter, - EmptyLocationRange, + interpreter.EmptyLocationRange, dictionaryStaticType, dictValueKey, dictValueValue, ) - arrayValue := NewArrayValue( + arrayValue := interpreter.NewArrayValue( inter, - EmptyLocationRange, - &VariableSizedStaticType{ + interpreter.EmptyLocationRange, + &interpreter.VariableSizedStaticType{ Type: dictionaryStaticType, }, common.ZeroAddress, dictValue, ) - optionalValue := NewUnmeteredSomeValueNonCopying(arrayValue) + optionalValue := interpreter.NewUnmeteredSomeValueNonCopying(arrayValue) compositeValue := newTestCompositeValue(inter, address) compositeValue.SetMember( inter, - EmptyLocationRange, + interpreter.EmptyLocationRange, "value", optionalValue, ) @@ -99,7 +99,3 @@ func TestValueDeepCopyAndDeepRemove(t *testing.T) { require.Equal(t, 1, count) } - -func newUnmeteredInMemoryStorage() InMemoryStorage { - return NewInMemoryStorage(nil) -} diff --git a/tests/interpreter/dictionary_test.go b/interpreter/dictionary_test.go similarity index 100% rename from tests/interpreter/dictionary_test.go rename to interpreter/dictionary_test.go diff --git a/tests/interpreter/dynamic_casting_test.go b/interpreter/dynamic_casting_test.go similarity index 100% rename from tests/interpreter/dynamic_casting_test.go rename to interpreter/dynamic_casting_test.go diff --git a/tests/interpreter/entitlements_test.go b/interpreter/entitlements_test.go similarity index 100% rename from tests/interpreter/entitlements_test.go rename to interpreter/entitlements_test.go diff --git a/tests/interpreter/enum_test.go b/interpreter/enum_test.go similarity index 100% rename from tests/interpreter/enum_test.go rename to interpreter/enum_test.go diff --git a/tests/interpreter/equality_test.go b/interpreter/equality_test.go similarity index 100% rename from tests/interpreter/equality_test.go rename to interpreter/equality_test.go diff --git a/tests/interpreter/fixedpoint_test.go b/interpreter/fixedpoint_test.go similarity index 100% rename from tests/interpreter/fixedpoint_test.go rename to interpreter/fixedpoint_test.go diff --git a/tests/interpreter/for_test.go b/interpreter/for_test.go similarity index 100% rename from tests/interpreter/for_test.go rename to interpreter/for_test.go diff --git a/tests/interpreter/function_test.go b/interpreter/function_test.go similarity index 100% rename from tests/interpreter/function_test.go rename to interpreter/function_test.go diff --git a/tests/interpreter/if_test.go b/interpreter/if_test.go similarity index 100% rename from tests/interpreter/if_test.go rename to interpreter/if_test.go diff --git a/tests/interpreter/import_test.go b/interpreter/import_test.go similarity index 100% rename from tests/interpreter/import_test.go rename to interpreter/import_test.go diff --git a/tests/interpreter/indexing_test.go b/interpreter/indexing_test.go similarity index 100% rename from tests/interpreter/indexing_test.go rename to interpreter/indexing_test.go diff --git a/tests/interpreter/integers_test.go b/interpreter/integers_test.go similarity index 100% rename from tests/interpreter/integers_test.go rename to interpreter/integers_test.go diff --git a/tests/interpreter/interface_test.go b/interpreter/interface_test.go similarity index 100% rename from tests/interpreter/interface_test.go rename to interpreter/interface_test.go diff --git a/tests/interpreter/invocation_test.go b/interpreter/invocation_test.go similarity index 100% rename from tests/interpreter/invocation_test.go rename to interpreter/invocation_test.go diff --git a/tests/interpreter/member_test.go b/interpreter/member_test.go similarity index 100% rename from tests/interpreter/member_test.go rename to interpreter/member_test.go diff --git a/tests/interpreter/memory_metering_test.go b/interpreter/memory_metering_test.go similarity index 100% rename from tests/interpreter/memory_metering_test.go rename to interpreter/memory_metering_test.go diff --git a/tests/interpreter/metatype_test.go b/interpreter/metatype_test.go similarity index 100% rename from tests/interpreter/metatype_test.go rename to interpreter/metatype_test.go diff --git a/tests/interpreter/metering_test.go b/interpreter/metering_test.go similarity index 100% rename from tests/interpreter/metering_test.go rename to interpreter/metering_test.go diff --git a/tests/interpreter/interpreter_test.go b/interpreter/misc_test.go similarity index 100% rename from tests/interpreter/interpreter_test.go rename to interpreter/misc_test.go diff --git a/tests/interpreter/nesting_test.go b/interpreter/nesting_test.go similarity index 100% rename from tests/interpreter/nesting_test.go rename to interpreter/nesting_test.go diff --git a/tests/interpreter/path_test.go b/interpreter/path_test.go similarity index 100% rename from tests/interpreter/path_test.go rename to interpreter/path_test.go diff --git a/tests/interpreter/pathcapability_test.go b/interpreter/pathcapability_test.go similarity index 100% rename from tests/interpreter/pathcapability_test.go rename to interpreter/pathcapability_test.go diff --git a/tests/interpreter/range_value_test.go b/interpreter/range_value_test.go similarity index 100% rename from tests/interpreter/range_value_test.go rename to interpreter/range_value_test.go diff --git a/tests/interpreter/reference_test.go b/interpreter/reference_test.go similarity index 100% rename from tests/interpreter/reference_test.go rename to interpreter/reference_test.go diff --git a/tests/interpreter/resources_test.go b/interpreter/resources_test.go similarity index 100% rename from tests/interpreter/resources_test.go rename to interpreter/resources_test.go diff --git a/tests/interpreter/runtimetype_test.go b/interpreter/runtimetype_test.go similarity index 100% rename from tests/interpreter/runtimetype_test.go rename to interpreter/runtimetype_test.go diff --git a/tests/interpreter/string_test.go b/interpreter/string_test.go similarity index 100% rename from tests/interpreter/string_test.go rename to interpreter/string_test.go diff --git a/tests/interpreter/switch_test.go b/interpreter/switch_test.go similarity index 100% rename from tests/interpreter/switch_test.go rename to interpreter/switch_test.go diff --git a/tests/interpreter/transactions_test.go b/interpreter/transactions_test.go similarity index 100% rename from tests/interpreter/transactions_test.go rename to interpreter/transactions_test.go diff --git a/tests/interpreter/transfer_test.go b/interpreter/transfer_test.go similarity index 100% rename from tests/interpreter/transfer_test.go rename to interpreter/transfer_test.go diff --git a/tests/interpreter/uuid_test.go b/interpreter/uuid_test.go similarity index 100% rename from tests/interpreter/uuid_test.go rename to interpreter/uuid_test.go diff --git a/tests/interpreter/values_test.go b/interpreter/values_test.go similarity index 100% rename from tests/interpreter/values_test.go rename to interpreter/values_test.go diff --git a/tests/interpreter/while_test.go b/interpreter/while_test.go similarity index 100% rename from tests/interpreter/while_test.go rename to interpreter/while_test.go From bc3bc62a1c1e1600b2d9f5dbcd39d22e0a5d5f7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20M=C3=BCller?= Date: Mon, 28 Oct 2024 16:36:09 -0700 Subject: [PATCH 43/46] bring back access tests --- sema/access_test.go | 636 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 636 insertions(+) create mode 100644 sema/access_test.go diff --git a/sema/access_test.go b/sema/access_test.go new file mode 100644 index 0000000000..a5472f468c --- /dev/null +++ b/sema/access_test.go @@ -0,0 +1,636 @@ +/* + * Cadence - The resource-oriented smart contract programming language + * + * Copyright Flow Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package sema + +import ( + "testing" + + "github.com/stretchr/testify/assert" + + "github.com/onflow/cadence/ast" + "github.com/onflow/cadence/common" +) + +func TestPrimitiveAccess_QualifiedKeyword(t *testing.T) { + + t.Parallel() + + expected := map[ast.PrimitiveAccess]string{ + ast.AccessNotSpecified: "", + ast.AccessSelf: "access(self)", + ast.AccessAll: "access(all)", + ast.AccessAccount: "access(account)", + ast.AccessContract: "access(contract)", + ast.AccessPubSettableLegacy: "pub(set)", + ast.AccessNone: "inaccessible", + } + + for access := 0; access < ast.PrimitiveAccessCount(); access++ { + assert.Equal(t, + expected[ast.PrimitiveAccess(access)], + PrimitiveAccess(access).QualifiedKeyword(), + ) + } +} + +func TestNewEntitlementAccess(t *testing.T) { + + t.Parallel() + + t.Run("empty", func(t *testing.T) { + t.Parallel() + + assert.PanicsWithError(t, + "neither map entitlement nor set entitlements given", + func() { + newEntitlementAccess(nil, Conjunction) + }, + ) + }) + + t.Run("invalid", func(t *testing.T) { + t.Parallel() + + assert.PanicsWithError(t, + "invalid entitlement type: Void", + func() { + newEntitlementAccess([]Type{VoidType}, Conjunction) + }, + ) + }) + + t.Run("map + entitlement", func(t *testing.T) { + t.Parallel() + + assert.PanicsWithError(t, + "mixed entitlement types", + func() { + newEntitlementAccess( + []Type{ + IdentityType, + MutateType, + }, + Conjunction, + ) + }, + ) + }) + + t.Run("entitlement + map", func(t *testing.T) { + t.Parallel() + + assert.PanicsWithError(t, + "mixed entitlement types", + func() { + newEntitlementAccess( + []Type{ + MutateType, + IdentityType, + }, + Conjunction, + ) + }, + ) + }) + + t.Run("single entitlement", func(t *testing.T) { + t.Parallel() + + assert.Equal(t, + NewEntitlementSetAccess( + []*EntitlementType{ + MutateType, + }, + Conjunction, + ), + newEntitlementAccess( + []Type{ + MutateType, + }, + Conjunction, + ), + ) + }) + + t.Run("two entitlements, conjunction", func(t *testing.T) { + t.Parallel() + + assert.Equal(t, + NewEntitlementSetAccess( + []*EntitlementType{ + MutateType, + InsertType, + }, + Conjunction, + ), + newEntitlementAccess( + []Type{ + MutateType, + InsertType, + }, + Conjunction, + ), + ) + }) + + t.Run("two entitlements, disjunction", func(t *testing.T) { + t.Parallel() + + assert.Equal(t, + NewEntitlementSetAccess( + []*EntitlementType{ + MutateType, + InsertType, + }, + Disjunction, + ), + newEntitlementAccess( + []Type{ + MutateType, + InsertType, + }, + Disjunction, + ), + ) + }) + + t.Run("single map", func(t *testing.T) { + t.Parallel() + + assert.Equal(t, + NewEntitlementMapAccess( + IdentityType, + ), + newEntitlementAccess( + []Type{ + IdentityType, + }, + Conjunction, + ), + ) + }) + + t.Run("two maps", func(t *testing.T) { + t.Parallel() + + assert.PanicsWithError(t, + "extra entitlement map type", + func() { + newEntitlementAccess( + []Type{ + IdentityType, + AccountMappingType, + }, + Conjunction, + ) + }, + ) + }) +} + +func TestEntitlementSetAccess_QualifiedKeyword(t *testing.T) { + + t.Parallel() + + location := common.NewAddressLocation(nil, common.MustBytesToAddress([]byte{0x1}), "Foo") + + fooType := &CompositeType{ + Location: location, + Identifier: "Foo", + } + + barType := NewEntitlementType( + nil, + location, + "Bar", + ) + barType.SetContainerType(fooType) + + bazType := NewEntitlementType( + nil, + location, + "Baz", + ) + bazType.SetContainerType(fooType) + + assert.Equal(t, + "access(Foo.Bar | Foo.Baz)", + newEntitlementAccess( + []Type{ + barType, + bazType, + }, + Disjunction, + ).QualifiedKeyword(), + ) +} + +func TestEntitlementMapAccess_ID(t *testing.T) { + t.Parallel() + + testLocation := common.StringLocation("test") + + t.Run("top-level", func(t *testing.T) { + t.Parallel() + + access := NewEntitlementMapAccess(NewEntitlementMapType(nil, testLocation, "M")) + assert.Equal(t, TypeID("S.test.M"), access.ID()) + }) + + t.Run("nested", func(t *testing.T) { + t.Parallel() + + mapType := NewEntitlementMapType(nil, testLocation, "M") + + mapType.SetContainerType(&CompositeType{ + Location: testLocation, + Identifier: "C", + }) + + access := NewEntitlementMapAccess(mapType) + assert.Equal(t, TypeID("S.test.C.M"), access.ID()) + }) + +} + +func TestEntitlementMapAccess_String(t *testing.T) { + t.Parallel() + + testLocation := common.StringLocation("test") + + access := NewEntitlementMapAccess(NewEntitlementMapType(nil, testLocation, "M")) + assert.Equal(t, "M", access.String()) +} + +func TestEntitlementMapAccess_QualifiedString(t *testing.T) { + t.Parallel() + + testLocation := common.StringLocation("test") + + t.Run("top-level", func(t *testing.T) { + t.Parallel() + + access := NewEntitlementMapAccess(NewEntitlementMapType(nil, testLocation, "M")) + assert.Equal(t, "M", access.QualifiedString()) + }) + + t.Run("nested", func(t *testing.T) { + t.Parallel() + + mapType := NewEntitlementMapType(nil, testLocation, "M") + + mapType.SetContainerType(&CompositeType{ + Location: testLocation, + Identifier: "C", + }) + + access := NewEntitlementMapAccess(mapType) + assert.Equal(t, "C.M", access.QualifiedString()) + }) +} + +func TestEntitlementSetAccess_ID(t *testing.T) { + t.Parallel() + + testLocation := common.StringLocation("test") + + t.Run("single", func(t *testing.T) { + t.Parallel() + + access := NewEntitlementSetAccess( + []*EntitlementType{ + NewEntitlementType(nil, testLocation, "E"), + }, + Conjunction, + ) + assert.Equal(t, + TypeID("S.test.E"), + access.ID(), + ) + }) + + t.Run("two, conjunction", func(t *testing.T) { + t.Parallel() + + access := NewEntitlementSetAccess( + []*EntitlementType{ + // NOTE: order + NewEntitlementType(nil, testLocation, "E2"), + NewEntitlementType(nil, testLocation, "E1"), + }, + Conjunction, + ) + // NOTE: sorted + assert.Equal(t, + TypeID("S.test.E1,S.test.E2"), + access.ID(), + ) + }) + + t.Run("two, disjunction", func(t *testing.T) { + t.Parallel() + + access := NewEntitlementSetAccess( + []*EntitlementType{ + // NOTE: order + NewEntitlementType(nil, testLocation, "E2"), + NewEntitlementType(nil, testLocation, "E1"), + }, + Disjunction, + ) + // NOTE: sorted + assert.Equal(t, + TypeID("S.test.E1|S.test.E2"), + access.ID(), + ) + }) + + t.Run("three, conjunction", func(t *testing.T) { + t.Parallel() + + access := NewEntitlementSetAccess( + []*EntitlementType{ + // NOTE: order + NewEntitlementType(nil, testLocation, "E3"), + NewEntitlementType(nil, testLocation, "E2"), + NewEntitlementType(nil, testLocation, "E1"), + }, + Conjunction, + ) + // NOTE: sorted + assert.Equal(t, + TypeID("S.test.E1,S.test.E2,S.test.E3"), + access.ID(), + ) + }) + + t.Run("three, disjunction", func(t *testing.T) { + t.Parallel() + + access := NewEntitlementSetAccess( + []*EntitlementType{ + // NOTE: order + NewEntitlementType(nil, testLocation, "E3"), + NewEntitlementType(nil, testLocation, "E2"), + NewEntitlementType(nil, testLocation, "E1"), + }, + Disjunction, + ) + // NOTE: sorted + assert.Equal(t, + TypeID("S.test.E1|S.test.E2|S.test.E3"), + access.ID(), + ) + }) + +} + +func TestEntitlementSetAccess_String(t *testing.T) { + t.Parallel() + + testLocation := common.StringLocation("test") + + t.Run("single", func(t *testing.T) { + t.Parallel() + + access := NewEntitlementSetAccess( + []*EntitlementType{ + NewEntitlementType(nil, testLocation, "E"), + }, + Conjunction, + ) + assert.Equal(t, "E", access.String()) + }) + + t.Run("two, conjunction", func(t *testing.T) { + t.Parallel() + + access := NewEntitlementSetAccess( + []*EntitlementType{ + // NOTE: order + NewEntitlementType(nil, testLocation, "E2"), + NewEntitlementType(nil, testLocation, "E1"), + }, + Conjunction, + ) + // NOTE: order + assert.Equal(t, "E2, E1", access.String()) + }) + + t.Run("two, disjunction", func(t *testing.T) { + t.Parallel() + + access := NewEntitlementSetAccess( + []*EntitlementType{ + // NOTE: order + NewEntitlementType(nil, testLocation, "E2"), + NewEntitlementType(nil, testLocation, "E1"), + }, + Disjunction, + ) + // NOTE: order + assert.Equal(t, "E2 | E1", access.String()) + }) + + t.Run("three, conjunction", func(t *testing.T) { + t.Parallel() + + access := NewEntitlementSetAccess( + []*EntitlementType{ + // NOTE: order + NewEntitlementType(nil, testLocation, "E3"), + NewEntitlementType(nil, testLocation, "E2"), + NewEntitlementType(nil, testLocation, "E1"), + }, + Conjunction, + ) + // NOTE: order + assert.Equal(t, "E3, E2, E1", access.String()) + }) + + t.Run("three, disjunction", func(t *testing.T) { + t.Parallel() + + access := NewEntitlementSetAccess( + []*EntitlementType{ + // NOTE: order + NewEntitlementType(nil, testLocation, "E3"), + NewEntitlementType(nil, testLocation, "E2"), + NewEntitlementType(nil, testLocation, "E1"), + }, + Disjunction, + ) + // NOTE: order + assert.Equal(t, "E3 | E2 | E1", access.String()) + }) +} + +func TestEntitlementSetAccess_QualifiedString(t *testing.T) { + t.Parallel() + + testLocation := common.StringLocation("test") + + containerType := &CompositeType{ + Location: testLocation, + Identifier: "C", + } + + t.Run("single", func(t *testing.T) { + t.Parallel() + + entitlementType := NewEntitlementType(nil, testLocation, "E") + entitlementType.SetContainerType(containerType) + + access := NewEntitlementSetAccess( + []*EntitlementType{ + entitlementType, + }, + Conjunction, + ) + assert.Equal(t, "C.E", access.QualifiedString()) + }) + + t.Run("two, conjunction", func(t *testing.T) { + t.Parallel() + + entitlementType1 := NewEntitlementType(nil, testLocation, "E1") + entitlementType1.SetContainerType(containerType) + + entitlementType2 := NewEntitlementType(nil, testLocation, "E2") + entitlementType2.SetContainerType(containerType) + + access := NewEntitlementSetAccess( + []*EntitlementType{ + // NOTE: order + entitlementType2, + entitlementType1, + }, + Conjunction, + ) + // NOTE: order + assert.Equal(t, + "C.E2, C.E1", + access.QualifiedString(), + ) + }) + + t.Run("two, disjunction", func(t *testing.T) { + t.Parallel() + + entitlementType1 := NewEntitlementType(nil, testLocation, "E1") + entitlementType1.SetContainerType(containerType) + + entitlementType2 := NewEntitlementType(nil, testLocation, "E2") + entitlementType2.SetContainerType(containerType) + + access := NewEntitlementSetAccess( + []*EntitlementType{ + // NOTE: order + entitlementType2, + entitlementType1, + }, + Disjunction, + ) + // NOTE: order + assert.Equal(t, + "C.E2 | C.E1", + access.QualifiedString(), + ) + }) + + t.Run("three, conjunction", func(t *testing.T) { + t.Parallel() + + entitlementType1 := NewEntitlementType(nil, testLocation, "E1") + entitlementType1.SetContainerType(containerType) + + entitlementType2 := NewEntitlementType(nil, testLocation, "E2") + entitlementType2.SetContainerType(containerType) + + entitlementType3 := NewEntitlementType(nil, testLocation, "E3") + entitlementType3.SetContainerType(containerType) + + access := NewEntitlementSetAccess( + []*EntitlementType{ + // NOTE: order + entitlementType3, + entitlementType2, + entitlementType1, + }, + Conjunction, + ) + // NOTE: order + assert.Equal(t, + "C.E3, C.E2, C.E1", + access.QualifiedString(), + ) + }) + + t.Run("three, disjunction", func(t *testing.T) { + t.Parallel() + + entitlementType1 := NewEntitlementType(nil, testLocation, "E1") + entitlementType1.SetContainerType(containerType) + + entitlementType2 := NewEntitlementType(nil, testLocation, "E2") + entitlementType2.SetContainerType(containerType) + + entitlementType3 := NewEntitlementType(nil, testLocation, "E3") + entitlementType3.SetContainerType(containerType) + + access := NewEntitlementSetAccess( + []*EntitlementType{ + // NOTE: order + entitlementType3, + entitlementType2, + entitlementType1, + }, + Disjunction, + ) + // NOTE: order + assert.Equal(t, + "C.E3 | C.E2 | C.E1", + access.QualifiedString(), + ) + }) +} + +func TestEntitlementMapAccess_QualifiedKeyword(t *testing.T) { + + t.Parallel() + + location := common.NewAddressLocation(nil, common.MustBytesToAddress([]byte{0x1}), "Foo") + + fooType := &CompositeType{ + Location: location, + Identifier: "Foo", + } + + barType := NewEntitlementMapType( + nil, + location, + "Bar", + ) + barType.SetContainerType(fooType) + + assert.Equal(t, + "access(mapping Foo.Bar)", + NewEntitlementMapAccess(barType).QualifiedKeyword(), + ) +} From 782db6c79268b469c215b130ea0fb6943918d840 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20M=C3=BCller?= Date: Mon, 28 Oct 2024 17:41:23 -0700 Subject: [PATCH 44/46] refactor test utils --- cmd/info/main.go | 2 +- compiler/compiler_test.go | 2 +- encoding/ccf/ccf_test.go | 138 ++--- encoding/ccf/ccf_type_id_test.go | 6 +- encoding/json/encoding_test.go | 45 +- fuzz.go | 4 +- {tests/fuzz => fuzz}/crashers_test.go | 2 +- interpreter/account_test.go | 3 +- interpreter/arithmetic_test.go | 2 +- interpreter/attachments_test.go | 2 +- interpreter/bitwise_test.go | 2 +- interpreter/builtinfunctions_test.go | 3 +- interpreter/character_test.go | 2 +- interpreter/composite_value_test.go | 3 +- interpreter/condition_test.go | 5 +- interpreter/container_mutation_test.go | 5 +- interpreter/contract_test.go | 2 +- interpreter/conversion_test.go | 2 +- interpreter/deepcopyremove_test.go | 4 +- interpreter/dynamic_casting_test.go | 3 +- interpreter/encoding_test.go | 21 +- interpreter/entitlements_test.go | 2 +- interpreter/enum_test.go | 3 +- interpreter/equality_test.go | 3 +- interpreter/errors_test.go | 6 +- interpreter/fixedpoint_test.go | 3 +- interpreter/for_test.go | 3 +- interpreter/function_test.go | 12 +- interpreter/if_test.go | 5 +- interpreter/import_test.go | 5 +- interpreter/inspect_test.go | 2 +- interpreter/integers_test.go | 4 +- interpreter/interface_test.go | 14 +- interpreter/interpreter_tracing_test.go | 4 +- interpreter/invocation_test.go | 2 +- interpreter/member_test.go | 4 +- interpreter/memory_metering_test.go | 10 +- interpreter/metatype_test.go | 3 +- interpreter/metering_test.go | 20 +- interpreter/misc_test.go | 7 +- interpreter/path_test.go | 2 +- interpreter/range_value_test.go | 8 +- interpreter/reference_test.go | 5 +- interpreter/resources_test.go | 8 +- interpreter/runtimetype_test.go | 30 +- interpreter/statictype_test.go | 74 +-- interpreter/storage_test.go | 3 +- interpreter/string_test.go | 3 +- interpreter/switch_test.go | 5 +- interpreter/transactions_test.go | 5 +- interpreter/transfer_test.go | 2 +- interpreter/uuid_test.go | 5 +- interpreter/value_function_test.go | 7 +- interpreter/value_test.go | 68 +-- interpreter/value_uint64.go | 3 +- interpreter/values_test.go | 65 +-- interpreter/while_test.go | 3 +- old_parser/declaration_test.go | 340 ++++++------ old_parser/expression_test.go | 376 +++++++------- old_parser/lexer/lexer_test.go | 4 +- old_parser/parser_test.go | 26 +- old_parser/statement_test.go | 96 ++-- old_parser/type_test.go | 146 +++--- parser/declaration_test.go | 484 +++++++++--------- parser/expression_test.go | 400 +++++++-------- parser/lexer/lexer_test.go | 4 +- parser/parser_test.go | 26 +- parser/statement_test.go | 112 ++-- parser/type_test.go | 154 +++--- runtime/account_test.go | 12 +- runtime/attachments_test.go | 3 +- runtime/capabilities_test.go | 4 +- runtime/capabilitycontrollers_test.go | 4 +- runtime/contract_test.go | 7 +- runtime/contract_update_test.go | 4 +- runtime/contract_update_validation_test.go | 4 +- runtime/convertTypes_test.go | 10 +- runtime/convertValues_test.go | 5 +- runtime/coverage_test.go | 5 +- runtime/crypto_test.go | 2 +- runtime/debugger_test.go | 2 +- runtime/deployedcontract_test.go | 5 +- runtime/deployment_test.go | 5 +- runtime/entitlements_test.go | 5 +- runtime/error_test.go | 2 +- runtime/ft_test.go | 15 +- runtime/import_test.go | 6 +- .../imported_values_memory_metering_test.go | 6 +- runtime/inbox_test.go | 2 +- runtime/literal_test.go | 4 +- runtime/predeclaredvalues_test.go | 6 +- runtime/program_params_validation_test.go | 6 +- runtime/resource_duplicate_test.go | 4 +- runtime/resourcedictionary_test.go | 17 +- runtime/rlp_test.go | 4 +- runtime/runtime_memory_metering_test.go | 4 +- runtime/runtime_test.go | 6 +- runtime/sharedstate_test.go | 3 +- runtime/storage_test.go | 5 +- runtime/type_test.go | 2 +- runtime/validation_test.go | 4 +- sema/accesses_test.go | 2 +- sema/account_test.go | 6 +- sema/any_test.go | 2 +- sema/arrays_dictionaries_test.go | 2 +- sema/assert_test.go | 2 +- sema/assignment_test.go | 2 +- sema/attachments_test.go | 2 +- sema/boolean_test.go | 2 +- sema/builtinfunctions_test.go | 2 +- sema/capability_controller_test.go | 2 +- sema/capability_test.go | 11 +- sema/casting_test.go | 2 +- sema/character_test.go | 2 +- sema/composite_test.go | 2 +- sema/conditional_test.go | 2 +- sema/conditions_test.go | 2 +- sema/conformance_test.go | 2 +- sema/contract_test.go | 2 +- sema/crypto_test.go | 2 +- sema/declaration_test.go | 2 +- sema/dictionary_test.go | 2 +- sema/dynamic_casting_test.go | 6 +- sema/entitlements_test.go | 2 +- sema/entrypoint_test.go | 2 +- sema/enum_test.go | 2 +- sema/error_handling_test.go | 6 +- sema/events_test.go | 6 +- sema/external_mutation_test.go | 2 +- sema/fixedpoint_test.go | 2 +- sema/for_test.go | 2 +- sema/force_test.go | 2 +- sema/function_expression_test.go | 2 +- sema/function_test.go | 2 +- sema/gen/golden_test.go | 2 +- sema/genericfunction_test.go | 2 +- sema/hashable_struct_test.go | 2 +- sema/if_test.go | 2 +- sema/import_test.go | 22 +- sema/indexing_test.go | 2 +- sema/initialization_test.go | 2 +- sema/integer_test.go | 2 +- sema/interface_test.go | 2 +- sema/intersection_test.go | 2 +- sema/invalid_test.go | 2 +- sema/invocation_test.go | 12 +- sema/member_test.go | 2 +- sema/metatype_test.go | 2 +- sema/move_test.go | 2 +- sema/nesting_test.go | 2 +- sema/never_test.go | 2 +- sema/nil_coalescing_test.go | 2 +- sema/occurrences_test.go | 2 +- sema/operations_test.go | 2 +- sema/optional_test.go | 2 +- sema/overloading_test.go | 2 +- sema/path_test.go | 2 +- sema/pragma_test.go | 2 +- sema/predeclaredvalues_test.go | 2 +- sema/purity_test.go | 2 +- sema/range_test.go | 6 +- sema/range_value_test.go | 2 +- sema/reference_test.go | 10 +- sema/resource_test.go | 5 +- sema/return_test.go | 2 +- sema/rlp_test.go | 2 +- sema/runtimetype_test.go | 2 +- sema/storable_test.go | 2 +- sema/string_test.go | 2 +- sema/swap_test.go | 2 +- sema/switch_test.go | 2 +- sema/transactions_test.go | 2 +- sema/type_inference_test.go | 2 +- sema/typeargument_test.go | 2 +- sema/utils_test.go | 2 +- sema/while_test.go | 2 +- stdlib/account_test.go | 4 +- stdlib/builtin_test.go | 17 +- ..._to_v1_contract_upgrade_validation_test.go | 40 +- stdlib/rlp/rlp_test.go | 2 +- stdlib/test_test.go | 6 +- test_utils/common_utils/utils.go | 112 ++++ .../interpreter_utils}/interpreter.go | 6 +- .../interpreter_utils/values.go | 155 +----- .../runtime_utils/location.go | 0 .../runtime_utils/testinterface.go | 0 .../runtime_utils/testledger.go | 0 .../runtime_utils/testruntime.go | 0 test_utils/runtime_utils/transactions.go | 68 +++ {tests => test_utils}/sema_utils/utils.go | 9 +- tools/analysis/analysis_test.go | 2 +- .../compatibility-check/contracts_checker.go | 3 +- types_test.go | 24 +- values_test.go | 16 +- 194 files changed, 1874 insertions(+), 1817 deletions(-) rename {tests/fuzz => fuzz}/crashers_test.go (96%) create mode 100644 test_utils/common_utils/utils.go rename {tests/runtime_utils => test_utils/interpreter_utils}/interpreter.go (92%) rename tests/utils/utils.go => test_utils/interpreter_utils/values.go (56%) rename {tests => test_utils}/runtime_utils/location.go (100%) rename {tests => test_utils}/runtime_utils/testinterface.go (100%) rename {tests => test_utils}/runtime_utils/testledger.go (100%) rename {tests => test_utils}/runtime_utils/testruntime.go (100%) create mode 100644 test_utils/runtime_utils/transactions.go rename {tests => test_utils}/sema_utils/utils.go (97%) diff --git a/cmd/info/main.go b/cmd/info/main.go index 62a91f8a6c..7ca71664cc 100644 --- a/cmd/info/main.go +++ b/cmd/info/main.go @@ -31,7 +31,7 @@ import ( "github.com/onflow/cadence/parser" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - "github.com/onflow/cadence/tests/sema_utils" + "github.com/onflow/cadence/test_utils/sema_utils" ) type command struct { diff --git a/compiler/compiler_test.go b/compiler/compiler_test.go index 60c96154aa..b9a0e2d866 100644 --- a/compiler/compiler_test.go +++ b/compiler/compiler_test.go @@ -24,7 +24,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/compiler/ir" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCompilerSimple(t *testing.T) { diff --git a/encoding/ccf/ccf_test.go b/encoding/ccf/ccf_test.go index 3332bbb065..c4513037ae 100644 --- a/encoding/ccf/ccf_test.go +++ b/encoding/ccf/ccf_test.go @@ -38,9 +38,9 @@ import ( "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/runtime" "github.com/onflow/cadence/sema" - "github.com/onflow/cadence/tests/runtime_utils" - . "github.com/onflow/cadence/tests/sema_utils" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/runtime_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) var deterministicEncMode, _ = ccf.EncOptions{ @@ -100,7 +100,7 @@ func TestEncodeOptional(t *testing.T) { newStructType := func() *cadence.StructType { return cadence.NewStructType( - utils.TestLocation, + TestLocation, "Foo", []cadence.Field{ { @@ -122,7 +122,7 @@ func TestEncodeOptional(t *testing.T) { newStructTypeWithOptionalAbstractField := func() *cadence.StructType { return cadence.NewStructType( - utils.TestLocation, + TestLocation, "Foo", []cadence.Field{ { @@ -807,7 +807,7 @@ func TestEncodeOptional(t *testing.T) { val: func() cadence.Value { structTypeWithOptionalAbstractField := newStructTypeWithOptionalAbstractField() simpleStructType := cadence.NewStructType( - utils.TestLocation, + TestLocation, "FooStruct", []cadence.Field{ { @@ -3576,7 +3576,7 @@ func TestEncodeArray(t *testing.T) { name: "Resource Interface Array", val: func() cadence.Value { resourceInterfaceType := cadence.NewResourceInterfaceType( - utils.TestLocation, + TestLocation, "Bar", nil, nil, @@ -3930,13 +3930,13 @@ func TestEncodeArray(t *testing.T) { name: "Struct Interface Array", val: func() cadence.Value { structInterfaceType := cadence.NewStructInterfaceType( - utils.TestLocation, + TestLocation, "FooStructInterface", nil, nil, ) structType := cadence.NewStructType( - utils.TestLocation, + TestLocation, "FooStruct", []cadence.Field{ { @@ -4075,13 +4075,13 @@ func TestEncodeArray(t *testing.T) { name: "Contract Interface Array", val: func() cadence.Value { contractInterfaceType := cadence.NewContractInterfaceType( - utils.TestLocation, + TestLocation, "FooContractInterface", nil, nil, ) contractType := cadence.NewContractType( - utils.TestLocation, + TestLocation, "FooContract", []cadence.Field{ { @@ -5414,7 +5414,7 @@ func TestEncodeStruct(t *testing.T) { name: "no field", val: func() cadence.Value { noFieldStructType := cadence.NewStructType( - utils.TestLocation, + TestLocation, "FooStruct", []cadence.Field{}, nil, @@ -5473,7 +5473,7 @@ func TestEncodeStruct(t *testing.T) { name: "Simple", val: func() cadence.Value { simpleStructType := cadence.NewStructType( - utils.TestLocation, + TestLocation, "FooStruct", []cadence.Field{ { @@ -5824,7 +5824,7 @@ func TestEncodeEvent(t *testing.T) { name: "Simple", val: func() cadence.Value { simpleEventType := cadence.NewEventType( - utils.TestLocation, + TestLocation, "FooEvent", []cadence.Field{ { @@ -5928,7 +5928,7 @@ func TestEncodeEvent(t *testing.T) { name: "abstract event", val: func() cadence.Value { abstractEventType := cadence.NewEventType( - utils.TestLocation, + TestLocation, "FooEvent", []cadence.Field{ { @@ -5943,7 +5943,7 @@ func TestEncodeEvent(t *testing.T) { nil, ) simpleStructType := cadence.NewStructType( - utils.TestLocation, + TestLocation, "FooStruct", []cadence.Field{ { @@ -6090,7 +6090,7 @@ func TestEncodeEvent(t *testing.T) { val: func() cadence.Value { fooResourceType := newFooResourceType() resourceEventType := cadence.NewEventType( - utils.TestLocation, + TestLocation, "FooEvent", []cadence.Field{ { @@ -6238,7 +6238,7 @@ func TestEncodeEvent(t *testing.T) { t.Run(tc.name, func(t *testing.T) { actualCBOR, err := ccf.EventsEncMode.Encode(tc.val) require.NoError(t, err) - utils.AssertEqualWithDiff(t, tc.expected, actualCBOR) + AssertEqualWithDiff(t, tc.expected, actualCBOR) decodedVal, err := ccf.EventsDecMode.Decode(nil, actualCBOR) require.NoError(t, err) @@ -6259,7 +6259,7 @@ func TestEncodeContract(t *testing.T) { name: "Simple", val: func() cadence.Value { simpleContractType := cadence.NewContractType( - utils.TestLocation, + TestLocation, "FooContract", []cadence.Field{ { @@ -6363,7 +6363,7 @@ func TestEncodeContract(t *testing.T) { name: "abstract contract", val: func() cadence.Value { simpleStructType := cadence.NewStructType( - utils.TestLocation, + TestLocation, "FooStruct", []cadence.Field{ { @@ -6374,7 +6374,7 @@ func TestEncodeContract(t *testing.T) { nil, ) abstractContractType := cadence.NewContractType( - utils.TestLocation, + TestLocation, "FooContract", []cadence.Field{ { @@ -6525,7 +6525,7 @@ func TestEncodeContract(t *testing.T) { val: func() cadence.Value { fooResourceType := newFooResourceType() resourceContractType := cadence.NewContractType( - utils.TestLocation, + TestLocation, "FooContract", []cadence.Field{ { @@ -6677,7 +6677,7 @@ func TestEncodeEnum(t *testing.T) { name: "Simple", val: func() cadence.Value { simpleEnumType := cadence.NewEnumType( - utils.TestLocation, + TestLocation, "FooEnum", nil, []cadence.Field{ @@ -6764,7 +6764,7 @@ func TestEncodeAttachment(t *testing.T) { name: "no field", val: func() cadence.Value { attachmentType := cadence.NewAttachmentType( - utils.TestLocation, + TestLocation, "FooAttachment", nil, []cadence.Field{}, @@ -6825,7 +6825,7 @@ func TestEncodeAttachment(t *testing.T) { name: "simple", val: func() cadence.Value { attachmentType := cadence.NewAttachmentType( - utils.TestLocation, + TestLocation, "FooAttachment", nil, []cadence.Field{ @@ -6906,7 +6906,7 @@ func TestEncodeAttachment(t *testing.T) { name: "struct field", val: func() cadence.Value { structType := cadence.NewStructType( - utils.TestLocation, + TestLocation, "FooStruct", []cadence.Field{ { @@ -6917,7 +6917,7 @@ func TestEncodeAttachment(t *testing.T) { nil, ) attachmentType := cadence.NewAttachmentType( - utils.TestLocation, + TestLocation, "FooAttachment", nil, []cadence.Field{ @@ -7508,7 +7508,7 @@ func TestEncodeValueOfReferenceType(t *testing.T) { newSimpleStructType := func() *cadence.StructType { return cadence.NewStructType( - utils.TestLocation, + TestLocation, "Foo", []cadence.Field{ { @@ -8840,7 +8840,7 @@ func TestEncodeType(t *testing.T) { t, cadence.TypeValue{ StaticType: cadence.NewStructType( - utils.TestLocation, + TestLocation, "S", []cadence.Field{}, [][]cadence.Parameter{}, @@ -8889,7 +8889,7 @@ func TestEncodeType(t *testing.T) { val := cadence.TypeValue{ StaticType: cadence.NewStructType( - utils.TestLocation, + TestLocation, "S", []cadence.Field{ {Identifier: "foo", Type: cadence.IntType}, @@ -8993,7 +8993,7 @@ func TestEncodeType(t *testing.T) { // Encode value without sorting of composite fields. actualCBOR, err := ccf.Encode(val) require.NoError(t, err) - utils.AssertEqualWithDiff(t, expectedCBOR, actualCBOR) + AssertEqualWithDiff(t, expectedCBOR, actualCBOR) // Decode value without enforcing sorting of composite fields. decodedVal, err := ccf.Decode(nil, actualCBOR) @@ -9012,7 +9012,7 @@ func TestEncodeType(t *testing.T) { t, cadence.TypeValue{ StaticType: cadence.NewStructType( - utils.TestLocation, + TestLocation, "S", []cadence.Field{ {Identifier: "foo", Type: cadence.IntType}, @@ -9113,7 +9113,7 @@ func TestEncodeType(t *testing.T) { }, cadence.TypeValue{ StaticType: cadence.NewStructType( - utils.TestLocation, + TestLocation, "S", []cadence.Field{ {Identifier: "bar", Type: cadence.IntType}, @@ -9134,21 +9134,21 @@ func TestEncodeType(t *testing.T) { t.Parallel() fooTy := cadence.NewResourceType( - utils.TestLocation, + TestLocation, "Foo", []cadence.Field{}, [][]cadence.Parameter{}, ) fooTy2 := cadence.NewResourceType( - utils.TestLocation, + TestLocation, "Foo2", []cadence.Field{}, [][]cadence.Parameter{}, ) barTy := cadence.NewResourceType( - utils.TestLocation, + TestLocation, "Bar", []cadence.Field{ { @@ -9274,7 +9274,7 @@ func TestEncodeType(t *testing.T) { t, cadence.TypeValue{ StaticType: cadence.NewResourceType( - utils.TestLocation, + TestLocation, "R", []cadence.Field{ {Identifier: "foo", Type: cadence.IntType}, @@ -9372,7 +9372,7 @@ func TestEncodeType(t *testing.T) { t, cadence.TypeValue{ StaticType: cadence.NewContractType( - utils.TestLocation, + TestLocation, "C", []cadence.Field{ {Identifier: "foo", Type: cadence.IntType}, @@ -9470,7 +9470,7 @@ func TestEncodeType(t *testing.T) { t, cadence.TypeValue{ StaticType: cadence.NewStructInterfaceType( - utils.TestLocation, + TestLocation, "S", []cadence.Field{ {Identifier: "foo", Type: cadence.IntType}, @@ -9568,7 +9568,7 @@ func TestEncodeType(t *testing.T) { t, cadence.TypeValue{ StaticType: cadence.NewResourceInterfaceType( - utils.TestLocation, + TestLocation, "R", []cadence.Field{ {Identifier: "foo", Type: cadence.IntType}, @@ -9666,7 +9666,7 @@ func TestEncodeType(t *testing.T) { t, cadence.TypeValue{ StaticType: cadence.NewContractInterfaceType( - utils.TestLocation, + TestLocation, "C", []cadence.Field{ {Identifier: "foo", Type: cadence.IntType}, @@ -9764,7 +9764,7 @@ func TestEncodeType(t *testing.T) { t, cadence.TypeValue{ StaticType: cadence.NewEventType( - utils.TestLocation, + TestLocation, "E", []cadence.Field{ {Identifier: "foo", Type: cadence.IntType}, @@ -9860,7 +9860,7 @@ func TestEncodeType(t *testing.T) { t, cadence.TypeValue{ StaticType: cadence.NewEnumType( - utils.TestLocation, + TestLocation, "E", cadence.StringType, []cadence.Field{ @@ -9961,7 +9961,7 @@ func TestEncodeType(t *testing.T) { t, cadence.TypeValue{ StaticType: cadence.NewAttachmentType( - utils.TestLocation, + TestLocation, "A", cadence.StringType, []cadence.Field{ @@ -10059,7 +10059,7 @@ func TestEncodeType(t *testing.T) { t.Parallel() baseType := cadence.NewResourceType( - utils.TestLocation, + TestLocation, "FooBase", []cadence.Field{ {Identifier: "bar", Type: cadence.StringType}, @@ -10071,7 +10071,7 @@ func TestEncodeType(t *testing.T) { t, cadence.TypeValue{ StaticType: cadence.NewAttachmentType( - utils.TestLocation, + TestLocation, "A", baseType, []cadence.Field{ @@ -11050,7 +11050,7 @@ func TestEncodeCapability(t *testing.T) { t.Parallel() simpleStructType := cadence.NewStructType( - utils.TestLocation, + TestLocation, "FooStruct", []cadence.Field{ { @@ -11722,7 +11722,7 @@ func TestExportRecursiveType(t *testing.T) { }, } ty := cadence.NewResourceType( - utils.TestLocation, + TestLocation, "Foo", fields, nil, @@ -11815,7 +11815,7 @@ func TestExportTypeValueRecursiveType(t *testing.T) { }, } ty := cadence.NewResourceType( - utils.TestLocation, + TestLocation, "Foo", fields, [][]cadence.Parameter{}, @@ -12061,21 +12061,21 @@ func TestExportTypeValueRecursiveType(t *testing.T) { t.Parallel() fooTy := cadence.NewResourceType( - utils.TestLocation, + TestLocation, "Foo", []cadence.Field{}, [][]cadence.Parameter{}, ) fooTy2 := cadence.NewResourceType( - utils.TestLocation, + TestLocation, "Foo2", []cadence.Field{}, [][]cadence.Parameter{}, ) barTy := cadence.NewResourceType( - utils.TestLocation, + TestLocation, "Bar", []cadence.Field{ { @@ -12729,7 +12729,7 @@ func testEncode(t *testing.T, val cadence.Value, expectedCBOR []byte) (actualCBO actualCBOR, err := deterministicEncMode.Encode(val) require.NoError(t, err) - utils.AssertEqualWithDiff(t, expectedCBOR, actualCBOR) + AssertEqualWithDiff(t, expectedCBOR, actualCBOR) return actualCBOR } @@ -12748,7 +12748,7 @@ func testDecode(t *testing.T, actualCBOR []byte, expectedVal cadence.Value) { // TODO: make resource (illegal nesting) func newResourceStructType() *cadence.StructType { return cadence.NewStructType( - utils.TestLocation, + TestLocation, "FooStruct", []cadence.Field{ { @@ -12766,7 +12766,7 @@ func newResourceStructType() *cadence.StructType { func newFooResourceType() *cadence.ResourceType { return cadence.NewResourceType( - utils.TestLocation, + TestLocation, "Foo", []cadence.Field{ { @@ -12780,7 +12780,7 @@ func newFooResourceType() *cadence.ResourceType { func newFoooResourceTypeWithAbstractField() *cadence.ResourceType { return cadence.NewResourceType( - utils.TestLocation, + TestLocation, "Fooo", []cadence.Field{ { @@ -13187,7 +13187,7 @@ func TestExportFunctionValue(t *testing.T) { }, } ty := cadence.NewResourceType( - utils.TestLocation, + TestLocation, "Foo", fields, nil, @@ -14038,7 +14038,7 @@ func TestDeployedEvents(t *testing.T) { // Encode Cadence value to CCF actualCBOR, err := ccf.EventsEncMode.Encode(tc.event) require.NoError(t, err) - utils.AssertEqualWithDiff(t, tc.expectedCBOR, actualCBOR) + AssertEqualWithDiff(t, tc.expectedCBOR, actualCBOR) // Decode CCF to Cadence value decodedEvent, err := ccf.EventsDecMode.Decode(nil, actualCBOR) @@ -15912,7 +15912,7 @@ func TestSortEntitlementSet(t *testing.T) { // Encode value without sorting. actualCBOR, err := ccf.Encode(val) require.NoError(t, err) - utils.AssertEqualWithDiff(t, expectedCBOR, actualCBOR) + AssertEqualWithDiff(t, expectedCBOR, actualCBOR) // Decode value without enforcing sorting. decodedVal, err := ccf.Decode(nil, actualCBOR) @@ -16010,7 +16010,7 @@ func TestSortEntitlementSet(t *testing.T) { // Encode value with sorted entitlement types. actualCBOR, err := sortEntitlementTypesEncMode.Encode(val) require.NoError(t, err) - utils.AssertEqualWithDiff(t, expectedCBOR, actualCBOR) + AssertEqualWithDiff(t, expectedCBOR, actualCBOR) // Decode value enforcing sorting of composite fields. decodedVal, err := enforceSortedEntitlementTypesDecMode.Decode(nil, actualCBOR) @@ -16079,7 +16079,7 @@ func TestSortEntitlementSet(t *testing.T) { // Encode value without sorting. actualCBOR, err := ccf.Encode(val) require.NoError(t, err) - utils.AssertEqualWithDiff(t, expectedCBOR, actualCBOR) + AssertEqualWithDiff(t, expectedCBOR, actualCBOR) // Decode value without enforcing sorting. decodedVal, err := ccf.Decode(nil, actualCBOR) @@ -16156,7 +16156,7 @@ func TestSortEntitlementSet(t *testing.T) { // Encode value with sorting. actualCBOR, err := sortEntitlementTypesEncMode.Encode(val) require.NoError(t, err) - utils.AssertEqualWithDiff(t, expectedCBOR, actualCBOR) + AssertEqualWithDiff(t, expectedCBOR, actualCBOR) // Decode value without enforcing sorting. decodedVal, err := ccf.Decode(nil, actualCBOR) @@ -16404,7 +16404,7 @@ func TestSortOptions(t *testing.T) { // Encode value without sorting. actualCBOR, err := ccf.Encode(val) require.NoError(t, err) - utils.AssertEqualWithDiff(t, expectedCBOR, actualCBOR) + AssertEqualWithDiff(t, expectedCBOR, actualCBOR) // Decode value without enforcing sorting. decodedVal, err := ccf.Decode(nil, actualCBOR) @@ -16593,7 +16593,7 @@ func TestSortOptions(t *testing.T) { // Encode value with sorted composite fields. actualCBOR, err := sortFieldsEncMode.Encode(val) require.NoError(t, err) - utils.AssertEqualWithDiff(t, expectedCBOR, actualCBOR) + AssertEqualWithDiff(t, expectedCBOR, actualCBOR) // Decode value enforcing sorting of composite fields. decodedVal, err := enforceSortedFieldsDecMode.Decode(nil, actualCBOR) @@ -16782,7 +16782,7 @@ func TestSortOptions(t *testing.T) { // Encode value with sorted Intersection types. actualCBOR, err := sortIntersectionTypesEncMode.Encode(val) require.NoError(t, err) - utils.AssertEqualWithDiff(t, expectedCBOR, actualCBOR) + AssertEqualWithDiff(t, expectedCBOR, actualCBOR) // Decode value enforcing sorting of Intersection types. decodedVal, err := enforceSortedIntersectionTypesDecMode.Decode(nil, actualCBOR) @@ -16971,7 +16971,7 @@ func TestSortOptions(t *testing.T) { // Encode value with sorted composite fields and Intersection types. actualCBOR, err := deterministicEncMode.Encode(val) require.NoError(t, err) - utils.AssertEqualWithDiff(t, expectedCBOR, actualCBOR) + AssertEqualWithDiff(t, expectedCBOR, actualCBOR) // Decode value enforcing sorting of composite fields and Intersection types. decodedVal, err := deterministicDecMode.Decode(nil, actualCBOR) @@ -17111,7 +17111,7 @@ func TestDecodeFunctionTypeBackwardCompatibility(t *testing.T) { testDecode(t, data, val) } -func TestEncodeEventWithAttachement(t *testing.T) { +func TestEncodeEventWithAttachment(t *testing.T) { script := ` access(all) struct S { access(all) let x: Int @@ -17146,11 +17146,11 @@ func TestEncodeEventWithAttachement(t *testing.T) { } func exportEventFromScript(t *testing.T, script string) cadence.Event { - rt := runtime_utils.NewTestInterpreterRuntime() + rt := NewTestInterpreterRuntime() var events []cadence.Event - inter := &runtime_utils.TestRuntimeInterface{ + inter := &TestRuntimeInterface{ OnEmitEvent: func(event cadence.Event) error { events = append(events, event) return nil diff --git a/encoding/ccf/ccf_type_id_test.go b/encoding/ccf/ccf_type_id_test.go index 271623e4e4..2019a2bbfa 100644 --- a/encoding/ccf/ccf_type_id_test.go +++ b/encoding/ccf/ccf_type_id_test.go @@ -25,7 +25,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" ) func TestCCFTypeID(t *testing.T) { @@ -117,7 +117,7 @@ func TestCadenceTypeByCCFTypeID(t *testing.T) { func simpleStructType() *cadence.StructType { return cadence.NewStructType( - utils.TestLocation, + TestLocation, "FooStruct", []cadence.Field{ { @@ -131,7 +131,7 @@ func simpleStructType() *cadence.StructType { func simpleStructType2() *cadence.StructType { return cadence.NewStructType( - utils.TestLocation, + TestLocation, "FooStruct2", []cadence.Field{ { diff --git a/encoding/json/encoding_test.go b/encoding/json/encoding_test.go index 308c8e0e7c..da52ff3cc8 100644 --- a/encoding/json/encoding_test.go +++ b/encoding/json/encoding_test.go @@ -28,14 +28,13 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "github.com/onflow/cadence" "github.com/onflow/cadence/common" "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/runtime" - . "github.com/onflow/cadence/tests/sema_utils" - - "github.com/onflow/cadence" "github.com/onflow/cadence/sema" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) type encodeTest struct { @@ -1337,7 +1336,7 @@ func TestEncodeStruct(t *testing.T) { t.Parallel() simpleStructType := cadence.NewStructType( - utils.TestLocation, + TestLocation, "FooStruct", []cadence.Field{ { @@ -1390,7 +1389,7 @@ func TestEncodeStruct(t *testing.T) { fooResourceType := newFooResourceType() resourceStructType := cadence.NewStructType( - utils.TestLocation, + TestLocation, "FooStruct", []cadence.Field{ { @@ -1499,7 +1498,7 @@ func TestEncodeEvent(t *testing.T) { t.Parallel() simpleEventType := cadence.NewEventType( - utils.TestLocation, + TestLocation, "FooEvent", []cadence.Field{ { @@ -1552,7 +1551,7 @@ func TestEncodeEvent(t *testing.T) { fooResourceType := newFooResourceType() resourceEventType := cadence.NewEventType( - utils.TestLocation, + TestLocation, "FooEvent", []cadence.Field{ { @@ -1625,7 +1624,7 @@ func TestEncodeContract(t *testing.T) { t.Parallel() simpleContractType := cadence.NewContractType( - utils.TestLocation, + TestLocation, "FooContract", []cadence.Field{ { @@ -1678,7 +1677,7 @@ func TestEncodeContract(t *testing.T) { fooResourceType := newFooResourceType() resourceContractType := cadence.NewContractType( - utils.TestLocation, + TestLocation, "FooContract", []cadence.Field{ { @@ -1916,7 +1915,7 @@ func TestEncodeType(t *testing.T) { t, cadence.TypeValue{ StaticType: cadence.NewStructType( - utils.TestLocation, + TestLocation, "S", []cadence.Field{ {Identifier: "foo", Type: cadence.IntType}, @@ -1977,7 +1976,7 @@ func TestEncodeType(t *testing.T) { t, cadence.TypeValue{ StaticType: cadence.NewResourceType( - utils.TestLocation, + TestLocation, "R", []cadence.Field{ {Identifier: "foo", Type: cadence.IntType}, @@ -2038,7 +2037,7 @@ func TestEncodeType(t *testing.T) { t, cadence.TypeValue{ StaticType: cadence.NewContractType( - utils.TestLocation, + TestLocation, "C", []cadence.Field{ {Identifier: "foo", Type: cadence.IntType}, @@ -2099,7 +2098,7 @@ func TestEncodeType(t *testing.T) { t, cadence.TypeValue{ StaticType: cadence.NewStructInterfaceType( - utils.TestLocation, + TestLocation, "S", []cadence.Field{ {Identifier: "foo", Type: cadence.IntType}, @@ -2160,7 +2159,7 @@ func TestEncodeType(t *testing.T) { t, cadence.TypeValue{ StaticType: cadence.NewResourceInterfaceType( - utils.TestLocation, + TestLocation, "R", []cadence.Field{ {Identifier: "foo", Type: cadence.IntType}, @@ -2221,7 +2220,7 @@ func TestEncodeType(t *testing.T) { t, cadence.TypeValue{ StaticType: cadence.NewContractInterfaceType( - utils.TestLocation, + TestLocation, "C", []cadence.Field{ {Identifier: "foo", Type: cadence.IntType}, @@ -2282,7 +2281,7 @@ func TestEncodeType(t *testing.T) { t, cadence.TypeValue{ StaticType: cadence.NewEventType( - utils.TestLocation, + TestLocation, "E", []cadence.Field{ {Identifier: "foo", Type: cadence.IntType}, @@ -2341,7 +2340,7 @@ func TestEncodeType(t *testing.T) { t, cadence.TypeValue{ StaticType: cadence.NewEnumType( - utils.TestLocation, + TestLocation, "E", cadence.StringType, []cadence.Field{ @@ -3317,7 +3316,7 @@ func TestExportRecursiveType(t *testing.T) { }, } ty := cadence.NewResourceType( - utils.TestLocation, + TestLocation, "Foo", fields, nil, @@ -3368,7 +3367,7 @@ func TestExportTypeValueRecursiveType(t *testing.T) { }, } ty := cadence.NewResourceType( - utils.TestLocation, + TestLocation, "Foo", fields, [][]cadence.Parameter{}, @@ -3415,14 +3414,14 @@ func TestExportTypeValueRecursiveType(t *testing.T) { t.Parallel() fooTy := cadence.NewResourceType( - utils.TestLocation, + TestLocation, "Foo", []cadence.Field{}, [][]cadence.Parameter{}, ) barTy := cadence.NewResourceType( - utils.TestLocation, + TestLocation, "Bar", []cadence.Field{ { @@ -3638,7 +3637,7 @@ func testDecode(t *testing.T, actualJSON string, expectedVal cadence.Value, opti func newFooResourceType() *cadence.ResourceType { return cadence.NewResourceType( - utils.TestLocation, + TestLocation, "Foo", []cadence.Field{ { diff --git a/fuzz.go b/fuzz.go index 35774a3137..3b98f72655 100644 --- a/fuzz.go +++ b/fuzz.go @@ -23,7 +23,7 @@ import ( "github.com/onflow/cadence/parser" "github.com/onflow/cadence/sema" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" ) func Fuzz(data []byte) int { @@ -40,7 +40,7 @@ func Fuzz(data []byte) int { checker, err := sema.NewChecker( program, - utils.TestLocation, + TestLocation, nil, &sema.Config{ AccessCheckMode: sema.AccessCheckModeNotSpecifiedUnrestricted, diff --git a/tests/fuzz/crashers_test.go b/fuzz/crashers_test.go similarity index 96% rename from tests/fuzz/crashers_test.go rename to fuzz/crashers_test.go index b52a889d73..9ac802ac36 100644 --- a/tests/fuzz/crashers_test.go +++ b/fuzz/crashers_test.go @@ -28,7 +28,7 @@ import ( "github.com/onflow/cadence" ) -const crashersDir = "../../../crashers" +const crashersDir = "crashers" func TestCrashers(t *testing.T) { diff --git a/interpreter/account_test.go b/interpreter/account_test.go index 9ef518efb9..a003477a56 100644 --- a/interpreter/account_test.go +++ b/interpreter/account_test.go @@ -34,7 +34,8 @@ import ( "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/interpreter_utils" ) type storageKey struct { diff --git a/interpreter/arithmetic_test.go b/interpreter/arithmetic_test.go index 4c56b41345..86d966ac92 100644 --- a/interpreter/arithmetic_test.go +++ b/interpreter/arithmetic_test.go @@ -29,7 +29,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/interpreter_utils" ) var integerTestValues = map[string]interpreter.NumberValue{ diff --git a/interpreter/attachments_test.go b/interpreter/attachments_test.go index 3c61208033..384ee9f647 100644 --- a/interpreter/attachments_test.go +++ b/interpreter/attachments_test.go @@ -26,7 +26,7 @@ import ( "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/interpreter_utils" "github.com/stretchr/testify/require" ) diff --git a/interpreter/bitwise_test.go b/interpreter/bitwise_test.go index b0e9e9cd74..a288e7e667 100644 --- a/interpreter/bitwise_test.go +++ b/interpreter/bitwise_test.go @@ -24,7 +24,7 @@ import ( "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/interpreter_utils" ) var bitwiseTestValueFunctions = map[string]func(int) interpreter.NumberValue{ diff --git a/interpreter/builtinfunctions_test.go b/interpreter/builtinfunctions_test.go index b527af6900..93402c80e5 100644 --- a/interpreter/builtinfunctions_test.go +++ b/interpreter/builtinfunctions_test.go @@ -29,7 +29,8 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/interpreter_utils" ) func TestInterpretToString(t *testing.T) { diff --git a/interpreter/character_test.go b/interpreter/character_test.go index 298fb1c604..b079563f09 100644 --- a/interpreter/character_test.go +++ b/interpreter/character_test.go @@ -26,7 +26,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/interpreter" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/interpreter_utils" ) func TestInterpretCharacterUtf8Field(t *testing.T) { diff --git a/interpreter/composite_value_test.go b/interpreter/composite_value_test.go index cacf0c145d..de85e30b22 100644 --- a/interpreter/composite_value_test.go +++ b/interpreter/composite_value_test.go @@ -29,7 +29,8 @@ import ( "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/interpreter_utils" ) func TestInterpretCompositeValue(t *testing.T) { diff --git a/interpreter/condition_test.go b/interpreter/condition_test.go index 74d1deabc9..ef1df7b638 100644 --- a/interpreter/condition_test.go +++ b/interpreter/condition_test.go @@ -31,8 +31,9 @@ import ( "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - . "github.com/onflow/cadence/tests/sema_utils" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/interpreter_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestInterpretFunctionPreTestCondition(t *testing.T) { diff --git a/interpreter/container_mutation_test.go b/interpreter/container_mutation_test.go index 10a37e6a30..5f67eab2b1 100644 --- a/interpreter/container_mutation_test.go +++ b/interpreter/container_mutation_test.go @@ -29,10 +29,11 @@ import ( "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/interpreter_utils" ) -func TestInterpetArrayMutation(t *testing.T) { +func TestInterpretArrayMutation(t *testing.T) { t.Parallel() diff --git a/interpreter/contract_test.go b/interpreter/contract_test.go index e4f9e8b30f..6d437fdec1 100644 --- a/interpreter/contract_test.go +++ b/interpreter/contract_test.go @@ -24,7 +24,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/interpreter" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" ) func TestInterpretContractUseBeforeInitializationComplete(t *testing.T) { diff --git a/interpreter/conversion_test.go b/interpreter/conversion_test.go index a3eb0122a0..a798b10fb0 100644 --- a/interpreter/conversion_test.go +++ b/interpreter/conversion_test.go @@ -27,7 +27,7 @@ import ( "github.com/onflow/cadence/common" . "github.com/onflow/cadence/interpreter" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" ) func TestByteArrayValueToByteSlice(t *testing.T) { diff --git a/interpreter/deepcopyremove_test.go b/interpreter/deepcopyremove_test.go index de16e42445..0f12a4b034 100644 --- a/interpreter/deepcopyremove_test.go +++ b/interpreter/deepcopyremove_test.go @@ -27,7 +27,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/interpreter" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" ) func TestValueDeepCopyAndDeepRemove(t *testing.T) { @@ -40,7 +40,7 @@ func TestValueDeepCopyAndDeepRemove(t *testing.T) { inter, err := interpreter.NewInterpreter( nil, - utils.TestLocation, + TestLocation, &interpreter.Config{ Storage: storage, }, diff --git a/interpreter/dynamic_casting_test.go b/interpreter/dynamic_casting_test.go index 03b532b119..255a7b719e 100644 --- a/interpreter/dynamic_casting_test.go +++ b/interpreter/dynamic_casting_test.go @@ -32,7 +32,8 @@ import ( "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/interpreter_utils" ) // dynamic casting operation -> returns optional diff --git a/interpreter/encoding_test.go b/interpreter/encoding_test.go index 5bcc19bc7e..2eb4047209 100644 --- a/interpreter/encoding_test.go +++ b/interpreter/encoding_test.go @@ -30,12 +30,11 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "github.com/onflow/cadence/common" . "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" - - "github.com/onflow/cadence/common" - "github.com/onflow/cadence/tests/utils" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/interpreter_utils" ) type encodeDecodeTest struct { @@ -492,7 +491,7 @@ func TestEncodeDecodeComposite(t *testing.T) { expected := NewCompositeValue( inter, EmptyLocationRange, - utils.TestLocation, + TestLocation, "TestStruct", common.CompositeKindStructure, nil, @@ -530,7 +529,7 @@ func TestEncodeDecodeComposite(t *testing.T) { expected := NewCompositeValue( inter, EmptyLocationRange, - utils.TestLocation, + TestLocation, "TestResource", common.CompositeKindResource, fields, @@ -4256,7 +4255,7 @@ func TestEncodeDecodeStorageCapabilityControllerValue(t *testing.T) { BorrowType: &ReferenceStaticType{ ReferencedType: NewCompositeStaticTypeComputeTypeID( nil, - utils.TestLocation, + TestLocation, "SimpleStruct", ), Authorization: UnauthorizedAccess, @@ -4305,7 +4304,7 @@ func TestEncodeDecodeStorageCapabilityControllerValue(t *testing.T) { value := &StorageCapabilityControllerValue{ TargetPath: publicPathValue, BorrowType: &ReferenceStaticType{ - ReferencedType: NewInterfaceStaticTypeComputeTypeID(nil, utils.TestLocation, "SimpleInterface"), + ReferencedType: NewInterfaceStaticTypeComputeTypeID(nil, TestLocation, "SimpleInterface"), Authorization: UnauthorizedAccess, }, CapabilityID: capabilityID, @@ -4485,8 +4484,8 @@ func TestEncodeDecodeStorageCapabilityControllerValue(t *testing.T) { BorrowType: &ReferenceStaticType{ ReferencedType: &IntersectionStaticType{ Types: []*InterfaceStaticType{ - NewInterfaceStaticTypeComputeTypeID(nil, utils.TestLocation, "I1"), - NewInterfaceStaticTypeComputeTypeID(nil, utils.TestLocation, "I2"), + NewInterfaceStaticTypeComputeTypeID(nil, TestLocation, "I1"), + NewInterfaceStaticTypeComputeTypeID(nil, TestLocation, "I2"), }, }, Authorization: UnauthorizedAccess, @@ -4705,7 +4704,7 @@ func TestEncodeDecodeAccountCapabilityControllerValue(t *testing.T) { BorrowType: &ReferenceStaticType{ ReferencedType: &IntersectionStaticType{ Types: []*InterfaceStaticType{ - NewInterfaceStaticTypeComputeTypeID(nil, utils.TestLocation, "SimpleInterface"), + NewInterfaceStaticTypeComputeTypeID(nil, TestLocation, "SimpleInterface"), }, }, Authorization: UnauthorizedAccess, diff --git a/interpreter/entitlements_test.go b/interpreter/entitlements_test.go index 0475ec1191..79d368de70 100644 --- a/interpreter/entitlements_test.go +++ b/interpreter/entitlements_test.go @@ -28,7 +28,7 @@ import ( "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/interpreter_utils" ) func TestInterpretEntitledReferenceRuntimeTypes(t *testing.T) { diff --git a/interpreter/enum_test.go b/interpreter/enum_test.go index 54e563c784..fa3e9a0c05 100644 --- a/interpreter/enum_test.go +++ b/interpreter/enum_test.go @@ -24,10 +24,9 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - . "github.com/onflow/cadence/tests/utils" - "github.com/onflow/cadence/common" "github.com/onflow/cadence/interpreter" + . "github.com/onflow/cadence/test_utils/interpreter_utils" ) func TestInterpretEnum(t *testing.T) { diff --git a/interpreter/equality_test.go b/interpreter/equality_test.go index dee8dc54c9..68cfd10f04 100644 --- a/interpreter/equality_test.go +++ b/interpreter/equality_test.go @@ -31,7 +31,8 @@ import ( "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/interpreter_utils" ) func TestInterpretEquality(t *testing.T) { diff --git a/interpreter/errors_test.go b/interpreter/errors_test.go index 568158cf58..4c120a0994 100644 --- a/interpreter/errors_test.go +++ b/interpreter/errors_test.go @@ -26,7 +26,7 @@ import ( "github.com/onflow/cadence/ast" "github.com/onflow/cadence/common" . "github.com/onflow/cadence/interpreter" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" ) func TestOverwriteError_Error(t *testing.T) { @@ -47,11 +47,11 @@ func TestErrorOutputIncludesLocationRage(t *testing.T) { t.Parallel() require.Equal(t, Error{ - Location: utils.TestLocation, + Location: TestLocation, Err: DereferenceError{ Cause: "the value being referenced has been destroyed or moved", LocationRange: LocationRange{ - Location: utils.TestLocation, + Location: TestLocation, HasPosition: ast.Range{ StartPos: ast.Position{Offset: 0, Column: 0, Line: 0}, EndPos: ast.Position{Offset: 0, Column: 0, Line: 0}, diff --git a/interpreter/fixedpoint_test.go b/interpreter/fixedpoint_test.go index 0fe9d9258b..fa19591104 100644 --- a/interpreter/fixedpoint_test.go +++ b/interpreter/fixedpoint_test.go @@ -29,7 +29,8 @@ import ( "github.com/onflow/cadence/fixedpoint" "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/interpreter_utils" ) func TestInterpretNegativeZeroFixedPoint(t *testing.T) { diff --git a/interpreter/for_test.go b/interpreter/for_test.go index 370546ffdf..48246d29b0 100644 --- a/interpreter/for_test.go +++ b/interpreter/for_test.go @@ -30,7 +30,8 @@ import ( "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/interpreter_utils" ) func TestInterpretForStatement(t *testing.T) { diff --git a/interpreter/function_test.go b/interpreter/function_test.go index e4e293fa9c..b16b77c642 100644 --- a/interpreter/function_test.go +++ b/interpreter/function_test.go @@ -27,8 +27,8 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/interpreter_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestInterpretResultVariable(t *testing.T) { @@ -60,7 +60,7 @@ func TestInterpretResultVariable(t *testing.T) { require.IsType(t, &interpreter.CompositeValue{}, result) resource := result.(*interpreter.CompositeValue) assert.Equal(t, common.CompositeKindResource, resource.Kind) - utils.AssertValuesEqual( + AssertValuesEqual( t, inter, interpreter.UInt8Value(1), @@ -98,7 +98,7 @@ func TestInterpretResultVariable(t *testing.T) { resource := innerValue.(*interpreter.CompositeValue) assert.Equal(t, common.CompositeKindResource, resource.Kind) - utils.AssertValuesEqual( + AssertValuesEqual( t, inter, interpreter.UInt8Value(1), @@ -162,7 +162,7 @@ func TestInterpretResultVariable(t *testing.T) { resource := innerValue.(*interpreter.CompositeValue) assert.Equal(t, common.CompositeKindResource, resource.Kind) - utils.AssertValuesEqual( + AssertValuesEqual( t, inter, interpreter.UInt8Value(1), @@ -316,7 +316,7 @@ func TestInterpretFunctionSubtyping(t *testing.T) { result, err := inter.Invoke("main") require.NoError(t, err) - utils.AssertValuesEqual( + AssertValuesEqual( t, inter, interpreter.NewUnmeteredSomeValueNonCopying(interpreter.UInt8Value(4)), diff --git a/interpreter/if_test.go b/interpreter/if_test.go index 4242062e39..ef92e2a576 100644 --- a/interpreter/if_test.go +++ b/interpreter/if_test.go @@ -24,11 +24,10 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - . "github.com/onflow/cadence/tests/sema_utils" - . "github.com/onflow/cadence/tests/utils" - "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/test_utils/interpreter_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestInterpretIfStatement(t *testing.T) { diff --git a/interpreter/import_test.go b/interpreter/import_test.go index a5a2e808b7..b1599e2a09 100644 --- a/interpreter/import_test.go +++ b/interpreter/import_test.go @@ -29,8 +29,9 @@ import ( "github.com/onflow/cadence/common/orderedmap" "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/interpreter_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestInterpretVirtualImport(t *testing.T) { diff --git a/interpreter/inspect_test.go b/interpreter/inspect_test.go index da6e78537e..e0ea1ff19f 100644 --- a/interpreter/inspect_test.go +++ b/interpreter/inspect_test.go @@ -23,7 +23,7 @@ import ( "github.com/onflow/cadence/common" . "github.com/onflow/cadence/interpreter" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/interpreter_utils" ) func TestInspectValue(t *testing.T) { diff --git a/interpreter/integers_test.go b/interpreter/integers_test.go index 9da93b1745..86f1eb4f22 100644 --- a/interpreter/integers_test.go +++ b/interpreter/integers_test.go @@ -28,10 +28,10 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - . "github.com/onflow/cadence/tests/utils" - "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/interpreter_utils" ) var testIntegerTypesAndValues = map[string]interpreter.Value{ diff --git a/interpreter/interface_test.go b/interpreter/interface_test.go index b61c422ba5..09580c8171 100644 --- a/interpreter/interface_test.go +++ b/interpreter/interface_test.go @@ -29,7 +29,7 @@ import ( "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" ) func TestInterpretInterfaceDefaultImplementation(t *testing.T) { @@ -456,7 +456,7 @@ func TestInterpretInterfaceFunctionConditionsInheritance(t *testing.T) { // Implementation should satisfy inherited conditions _, err = inter.Invoke("main", interpreter.NewUnmeteredIntValueFromInt64(5)) - utils.RequireError(t, err) + RequireError(t, err) assert.ErrorAs(t, err, &interpreter.ConditionError{}) }) @@ -496,7 +496,7 @@ func TestInterpretInterfaceFunctionConditionsInheritance(t *testing.T) { // Implementation should satisfy inherited conditions _, err = inter.Invoke("main", interpreter.NewUnmeteredIntValueFromInt64(5)) - utils.RequireError(t, err) + RequireError(t, err) assert.ErrorAs(t, err, &interpreter.ConditionError{}) }) @@ -539,11 +539,11 @@ func TestInterpretInterfaceFunctionConditionsInheritance(t *testing.T) { // Implementation should satisfy both inherited conditions _, err = inter.Invoke("main", interpreter.NewUnmeteredIntValueFromInt64(5)) - utils.RequireError(t, err) + RequireError(t, err) assert.ErrorAs(t, err, &interpreter.ConditionError{}) _, err = inter.Invoke("main", interpreter.NewUnmeteredIntValueFromInt64(25)) - utils.RequireError(t, err) + RequireError(t, err) assert.ErrorAs(t, err, &interpreter.ConditionError{}) }) @@ -588,11 +588,11 @@ func TestInterpretInterfaceFunctionConditionsInheritance(t *testing.T) { // Implementation should satisfy both inherited conditions _, err = inter.Invoke("main", interpreter.NewUnmeteredIntValueFromInt64(5)) - utils.RequireError(t, err) + RequireError(t, err) assert.ErrorAs(t, err, &interpreter.ConditionError{}) _, err = inter.Invoke("main", interpreter.NewUnmeteredIntValueFromInt64(25)) - utils.RequireError(t, err) + RequireError(t, err) assert.ErrorAs(t, err, &interpreter.ConditionError{}) }) diff --git a/interpreter/interpreter_tracing_test.go b/interpreter/interpreter_tracing_test.go index dfcfc16521..5f2a758fbc 100644 --- a/interpreter/interpreter_tracing_test.go +++ b/interpreter/interpreter_tracing_test.go @@ -28,7 +28,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/interpreter" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" ) func setupInterpreterWithTracingCallBack( @@ -38,7 +38,7 @@ func setupInterpreterWithTracingCallBack( storage := newUnmeteredInMemoryStorage() inter, err := interpreter.NewInterpreter( nil, - utils.TestLocation, + TestLocation, &interpreter.Config{ OnRecordTrace: func(inter *interpreter.Interpreter, operationName string, diff --git a/interpreter/invocation_test.go b/interpreter/invocation_test.go index 4e9164f36f..1d08c47f14 100644 --- a/interpreter/invocation_test.go +++ b/interpreter/invocation_test.go @@ -28,7 +28,7 @@ import ( "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" ) func TestInterpretFunctionInvocationCheckArgumentTypes(t *testing.T) { diff --git a/interpreter/member_test.go b/interpreter/member_test.go index a7dd3c454a..f73b4e8be6 100644 --- a/interpreter/member_test.go +++ b/interpreter/member_test.go @@ -25,8 +25,8 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/interpreter" - . "github.com/onflow/cadence/tests/sema_utils" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestInterpretMemberAccessType(t *testing.T) { diff --git a/interpreter/memory_metering_test.go b/interpreter/memory_metering_test.go index 56fae49cb0..725ea93037 100644 --- a/interpreter/memory_metering_test.go +++ b/interpreter/memory_metering_test.go @@ -23,7 +23,7 @@ import ( "testing" "github.com/onflow/cadence/activations" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -33,7 +33,7 @@ import ( "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" ) type assumeValidPublicKeyValidator struct{} @@ -8152,7 +8152,7 @@ func TestInterpretASTMetering(t *testing.T) { let Foo = 1 `, ParseAndCheckOptions{ - Location: utils.ImportedLocation, + Location: ImportedLocation, }, ) require.NoError(t, err) @@ -8450,7 +8450,7 @@ func TestInterpretASTMetering(t *testing.T) { let B = 1 `, ParseAndCheckOptions{ - Location: utils.ImportedLocation, + Location: ImportedLocation, }, ) require.NoError(t, err) @@ -8960,7 +8960,7 @@ func TestInterpretValueStringConversion(t *testing.T) { interpreter.NewUnmeteredCapabilityValue( 4, interpreter.AddressValue{1}, - interpreter.NewCompositeStaticTypeComputeTypeID(nil, utils.TestLocation, "Bar"), + interpreter.NewCompositeStaticTypeComputeTypeID(nil, TestLocation, "Bar"), )) }) diff --git a/interpreter/metatype_test.go b/interpreter/metatype_test.go index ad96c6b1d9..edcd83a901 100644 --- a/interpreter/metatype_test.go +++ b/interpreter/metatype_test.go @@ -30,7 +30,8 @@ import ( "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/interpreter_utils" ) func TestInterpretMetaTypeEquality(t *testing.T) { diff --git a/interpreter/metering_test.go b/interpreter/metering_test.go index a7ea9882d0..267b15d985 100644 --- a/interpreter/metering_test.go +++ b/interpreter/metering_test.go @@ -28,8 +28,8 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestInterpretStatementHandler(t *testing.T) { @@ -44,7 +44,7 @@ func TestInterpretStatementHandler(t *testing.T) { } `, ParseAndCheckOptions{ - Location: utils.ImportedLocation, + Location: ImportedLocation, }, ) require.NoError(t, err) @@ -73,7 +73,7 @@ func TestInterpretStatementHandler(t *testing.T) { Config: &sema.Config{ ImportHandler: func(_ *sema.Checker, importedLocation common.Location, _ ast.Range) (sema.Import, error) { assert.Equal(t, - utils.ImportedLocation, + ImportedLocation, importedLocation, ) @@ -116,7 +116,7 @@ func TestInterpretStatementHandler(t *testing.T) { }, ImportLocationHandler: func(inter *interpreter.Interpreter, location common.Location) interpreter.Import { assert.Equal(t, - utils.ImportedLocation, + ImportedLocation, location, ) @@ -197,7 +197,7 @@ func TestInterpretLoopIterationHandler(t *testing.T) { Config: &sema.Config{ ImportHandler: func(_ *sema.Checker, importedLocation common.Location, _ ast.Range) (sema.Import, error) { assert.Equal(t, - utils.ImportedLocation, + ImportedLocation, importedLocation, ) @@ -241,7 +241,7 @@ func TestInterpretLoopIterationHandler(t *testing.T) { }, ImportLocationHandler: func(inter *interpreter.Interpreter, location common.Location) interpreter.Import { assert.Equal(t, - utils.ImportedLocation, + ImportedLocation, location, ) @@ -303,7 +303,7 @@ func TestInterpretFunctionInvocationHandler(t *testing.T) { } `, ParseAndCheckOptions{ - Location: utils.ImportedLocation, + Location: ImportedLocation, }, ) require.NoError(t, err) @@ -332,7 +332,7 @@ func TestInterpretFunctionInvocationHandler(t *testing.T) { Config: &sema.Config{ ImportHandler: func(_ *sema.Checker, importedLocation common.Location, _ ast.Range) (sema.Import, error) { assert.Equal(t, - utils.ImportedLocation, + ImportedLocation, importedLocation, ) @@ -368,7 +368,7 @@ func TestInterpretFunctionInvocationHandler(t *testing.T) { }, ImportLocationHandler: func(inter *interpreter.Interpreter, location common.Location) interpreter.Import { assert.Equal(t, - utils.ImportedLocation, + ImportedLocation, location, ) diff --git a/interpreter/misc_test.go b/interpreter/misc_test.go index d3c3138580..9c8e7c8886 100644 --- a/interpreter/misc_test.go +++ b/interpreter/misc_test.go @@ -39,8 +39,9 @@ import ( "github.com/onflow/cadence/runtime" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - . "github.com/onflow/cadence/tests/sema_utils" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/interpreter_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) type ParseCheckAndInterpretOptions struct { @@ -5257,7 +5258,7 @@ func TestInterpretReferenceFailableDowncasting(t *testing.T) { func(invocation interpreter.Invocation) interpreter.Value { authorized := bool(invocation.Arguments[0].(interpreter.BoolValue)) - var auth interpreter.Authorization = interpreter.UnauthorizedAccess + var auth = interpreter.UnauthorizedAccess if authorized { auth = interpreter.ConvertSemaAccessToStaticAuthorization( invocation.Interpreter, diff --git a/interpreter/path_test.go b/interpreter/path_test.go index 015ef66643..10ff7f32f9 100644 --- a/interpreter/path_test.go +++ b/interpreter/path_test.go @@ -27,7 +27,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/interpreter_utils" ) func TestInterpretPath(t *testing.T) { diff --git a/interpreter/range_value_test.go b/interpreter/range_value_test.go index ba3b714129..eb88cb4b50 100644 --- a/interpreter/range_value_test.go +++ b/interpreter/range_value_test.go @@ -30,8 +30,8 @@ import ( "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - "github.com/onflow/cadence/tests/utils" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/interpreter_utils" ) type containsTestCase struct { @@ -440,7 +440,7 @@ func TestInclusiveRange(t *testing.T) { ) } - utils.AssertValuesEqual( + AssertValuesEqual( t, inter, expectedRangeValue, @@ -456,7 +456,7 @@ func TestInclusiveRange(t *testing.T) { expectedValue = interpreter.AsBoolValue(tc.expectedWithoutStep) } - utils.AssertValuesEqual( + AssertValuesEqual( t, inter, expectedValue, diff --git a/interpreter/reference_test.go b/interpreter/reference_test.go index 7af848436c..273f49d74d 100644 --- a/interpreter/reference_test.go +++ b/interpreter/reference_test.go @@ -28,8 +28,9 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/interpreter_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestInterpretResourceReferenceInstanceOf(t *testing.T) { diff --git a/interpreter/resources_test.go b/interpreter/resources_test.go index fd639a5739..564c745258 100644 --- a/interpreter/resources_test.go +++ b/interpreter/resources_test.go @@ -24,11 +24,11 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" - . "github.com/onflow/cadence/tests/utils" - "github.com/onflow/cadence/interpreter" + "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/interpreter_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestInterpretOptionalResourceBindingWithSecondValue(t *testing.T) { diff --git a/interpreter/runtimetype_test.go b/interpreter/runtimetype_test.go index c1ea4ea109..526d28856d 100644 --- a/interpreter/runtimetype_test.go +++ b/interpreter/runtimetype_test.go @@ -24,7 +24,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" "github.com/stretchr/testify/assert" ) @@ -65,7 +65,7 @@ func TestInterpretOptionalType(t *testing.T) { assert.Equal(t, interpreter.TypeValue{ Type: &interpreter.OptionalStaticType{ - Type: interpreter.NewCompositeStaticTypeComputeTypeID(nil, utils.TestLocation, "R"), + Type: interpreter.NewCompositeStaticTypeComputeTypeID(nil, TestLocation, "R"), }, }, inter.Globals.Get("c").GetValue(inter), @@ -124,7 +124,7 @@ func TestInterpretVariableSizedArrayType(t *testing.T) { assert.Equal(t, interpreter.TypeValue{ Type: &interpreter.VariableSizedStaticType{ - Type: interpreter.NewCompositeStaticTypeComputeTypeID(nil, utils.TestLocation, "R"), + Type: interpreter.NewCompositeStaticTypeComputeTypeID(nil, TestLocation, "R"), }, }, inter.Globals.Get("c").GetValue(inter), @@ -184,7 +184,7 @@ func TestInterpretConstantSizedArrayType(t *testing.T) { assert.Equal(t, interpreter.TypeValue{ Type: &interpreter.ConstantSizedStaticType{ - Type: interpreter.NewCompositeStaticTypeComputeTypeID(nil, utils.TestLocation, "R"), + Type: interpreter.NewCompositeStaticTypeComputeTypeID(nil, TestLocation, "R"), Size: int64(400), }, }, @@ -250,7 +250,7 @@ func TestInterpretDictionaryType(t *testing.T) { assert.Equal(t, interpreter.TypeValue{ Type: &interpreter.DictionaryStaticType{ - ValueType: interpreter.NewCompositeStaticTypeComputeTypeID(nil, utils.TestLocation, "R"), + ValueType: interpreter.NewCompositeStaticTypeComputeTypeID(nil, TestLocation, "R"), KeyType: interpreter.PrimitiveStaticTypeInt, }, }, @@ -305,14 +305,14 @@ func TestInterpretCompositeType(t *testing.T) { assert.Equal(t, interpreter.TypeValue{ - Type: interpreter.NewCompositeStaticTypeComputeTypeID(nil, utils.TestLocation, "R"), + Type: interpreter.NewCompositeStaticTypeComputeTypeID(nil, TestLocation, "R"), }, inter.Globals.Get("a").GetValue(inter), ) assert.Equal(t, interpreter.TypeValue{ - Type: interpreter.NewCompositeStaticTypeComputeTypeID(nil, utils.TestLocation, "S"), + Type: interpreter.NewCompositeStaticTypeComputeTypeID(nil, TestLocation, "S"), }, inter.Globals.Get("b").GetValue(inter), ) @@ -334,7 +334,7 @@ func TestInterpretCompositeType(t *testing.T) { assert.Equal(t, interpreter.TypeValue{ - Type: interpreter.NewCompositeStaticTypeComputeTypeID(nil, utils.TestLocation, "F"), + Type: interpreter.NewCompositeStaticTypeComputeTypeID(nil, TestLocation, "F"), }, inter.Globals.Get("f").GetValue(inter), ) @@ -433,7 +433,7 @@ func TestInterpretReferenceType(t *testing.T) { assert.Equal(t, interpreter.TypeValue{ Type: &interpreter.ReferenceStaticType{ - ReferencedType: interpreter.NewCompositeStaticTypeComputeTypeID(nil, utils.TestLocation, "R"), + ReferencedType: interpreter.NewCompositeStaticTypeComputeTypeID(nil, TestLocation, "R"), Authorization: interpreter.NewEntitlementSetAuthorization( nil, func() []common.TypeID { return []common.TypeID{"S.test.X"} }, @@ -458,7 +458,7 @@ func TestInterpretReferenceType(t *testing.T) { assert.Equal(t, interpreter.TypeValue{ Type: &interpreter.ReferenceStaticType{ - ReferencedType: interpreter.NewCompositeStaticTypeComputeTypeID(nil, utils.TestLocation, "S"), + ReferencedType: interpreter.NewCompositeStaticTypeComputeTypeID(nil, TestLocation, "S"), Authorization: interpreter.NewEntitlementSetAuthorization( nil, func() []common.TypeID { return []common.TypeID{"S.test.X"} }, @@ -513,7 +513,7 @@ func TestInterpretIntersectionType(t *testing.T) { interpreter.TypeValue{ Type: &interpreter.IntersectionStaticType{ Types: []*interpreter.InterfaceStaticType{ - interpreter.NewInterfaceStaticTypeComputeTypeID(nil, utils.TestLocation, "R"), + interpreter.NewInterfaceStaticTypeComputeTypeID(nil, TestLocation, "R"), }, }, }, @@ -529,7 +529,7 @@ func TestInterpretIntersectionType(t *testing.T) { interpreter.TypeValue{ Type: &interpreter.IntersectionStaticType{ Types: []*interpreter.InterfaceStaticType{ - interpreter.NewInterfaceStaticTypeComputeTypeID(nil, utils.TestLocation, "S"), + interpreter.NewInterfaceStaticTypeComputeTypeID(nil, TestLocation, "S"), }, }, }, @@ -545,8 +545,8 @@ func TestInterpretIntersectionType(t *testing.T) { interpreter.TypeValue{ Type: &interpreter.IntersectionStaticType{ Types: []*interpreter.InterfaceStaticType{ - interpreter.NewInterfaceStaticTypeComputeTypeID(nil, utils.TestLocation, "S"), - interpreter.NewInterfaceStaticTypeComputeTypeID(nil, utils.TestLocation, "S2"), + interpreter.NewInterfaceStaticTypeComputeTypeID(nil, TestLocation, "S"), + interpreter.NewInterfaceStaticTypeComputeTypeID(nil, TestLocation, "S2"), }, }, }, @@ -612,7 +612,7 @@ func TestInterpretCapabilityType(t *testing.T) { interpreter.TypeValue{ Type: &interpreter.CapabilityStaticType{ BorrowType: &interpreter.ReferenceStaticType{ - ReferencedType: interpreter.NewCompositeStaticTypeComputeTypeID(nil, utils.TestLocation, "R"), + ReferencedType: interpreter.NewCompositeStaticTypeComputeTypeID(nil, TestLocation, "R"), Authorization: interpreter.UnauthorizedAccess, }, }, diff --git a/interpreter/statictype_test.go b/interpreter/statictype_test.go index 76f3570deb..145296ad56 100644 --- a/interpreter/statictype_test.go +++ b/interpreter/statictype_test.go @@ -27,7 +27,7 @@ import ( "github.com/onflow/cadence/common" . "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" ) func TestCapabilityStaticType_Equal(t *testing.T) { @@ -182,12 +182,12 @@ func TestCompositeStaticType_Equal(t *testing.T) { require.True(t, NewCompositeStaticTypeComputeTypeID( nil, - utils.TestLocation, + TestLocation, "X", ).Equal( NewCompositeStaticTypeComputeTypeID( nil, - utils.TestLocation, + TestLocation, "X", ), ), @@ -201,12 +201,12 @@ func TestCompositeStaticType_Equal(t *testing.T) { require.False(t, NewCompositeStaticTypeComputeTypeID( nil, - utils.TestLocation, + TestLocation, "X", ).Equal( NewCompositeStaticTypeComputeTypeID( nil, - utils.TestLocation, + TestLocation, "Y", ), ), @@ -333,8 +333,8 @@ func TestInterfaceStaticType_Equal(t *testing.T) { t.Parallel() require.True(t, - NewInterfaceStaticTypeComputeTypeID(nil, utils.TestLocation, "X"). - Equal(NewInterfaceStaticTypeComputeTypeID(nil, utils.TestLocation, "X")), + NewInterfaceStaticTypeComputeTypeID(nil, TestLocation, "X"). + Equal(NewInterfaceStaticTypeComputeTypeID(nil, TestLocation, "X")), ) }) @@ -343,8 +343,8 @@ func TestInterfaceStaticType_Equal(t *testing.T) { t.Parallel() require.False(t, - NewInterfaceStaticTypeComputeTypeID(nil, utils.TestLocation, "X"). - Equal(NewInterfaceStaticTypeComputeTypeID(nil, utils.TestLocation, "Y")), + NewInterfaceStaticTypeComputeTypeID(nil, TestLocation, "X"). + Equal(NewInterfaceStaticTypeComputeTypeID(nil, TestLocation, "Y")), ) }) @@ -749,14 +749,14 @@ func TestIntersectionStaticType_Equal(t *testing.T) { require.True(t, (&IntersectionStaticType{ Types: []*InterfaceStaticType{ - NewInterfaceStaticTypeComputeTypeID(nil, utils.TestLocation, "X"), - NewInterfaceStaticTypeComputeTypeID(nil, utils.TestLocation, "Y"), + NewInterfaceStaticTypeComputeTypeID(nil, TestLocation, "X"), + NewInterfaceStaticTypeComputeTypeID(nil, TestLocation, "Y"), }, }).Equal( &IntersectionStaticType{ Types: []*InterfaceStaticType{ - NewInterfaceStaticTypeComputeTypeID(nil, utils.TestLocation, "Y"), - NewInterfaceStaticTypeComputeTypeID(nil, utils.TestLocation, "X"), + NewInterfaceStaticTypeComputeTypeID(nil, TestLocation, "Y"), + NewInterfaceStaticTypeComputeTypeID(nil, TestLocation, "X"), }, }, ), @@ -785,13 +785,13 @@ func TestIntersectionStaticType_Equal(t *testing.T) { require.False(t, (&IntersectionStaticType{ Types: []*InterfaceStaticType{ - NewInterfaceStaticTypeComputeTypeID(nil, utils.TestLocation, "X"), - NewInterfaceStaticTypeComputeTypeID(nil, utils.TestLocation, "Y"), + NewInterfaceStaticTypeComputeTypeID(nil, TestLocation, "X"), + NewInterfaceStaticTypeComputeTypeID(nil, TestLocation, "Y"), }, }).Equal( &IntersectionStaticType{ Types: []*InterfaceStaticType{ - NewInterfaceStaticTypeComputeTypeID(nil, utils.TestLocation, "X"), + NewInterfaceStaticTypeComputeTypeID(nil, TestLocation, "X"), }, }, ), @@ -805,14 +805,14 @@ func TestIntersectionStaticType_Equal(t *testing.T) { require.True(t, (&IntersectionStaticType{ Types: []*InterfaceStaticType{ - NewInterfaceStaticTypeComputeTypeID(nil, utils.TestLocation, "X"), - NewInterfaceStaticTypeComputeTypeID(nil, utils.TestLocation, "Y"), + NewInterfaceStaticTypeComputeTypeID(nil, TestLocation, "X"), + NewInterfaceStaticTypeComputeTypeID(nil, TestLocation, "Y"), }, }).Equal( &IntersectionStaticType{ Types: []*InterfaceStaticType{ - NewInterfaceStaticTypeComputeTypeID(nil, utils.TestLocation, "Y"), - NewInterfaceStaticTypeComputeTypeID(nil, utils.TestLocation, "X"), + NewInterfaceStaticTypeComputeTypeID(nil, TestLocation, "Y"), + NewInterfaceStaticTypeComputeTypeID(nil, TestLocation, "X"), }, }, ), @@ -826,14 +826,14 @@ func TestIntersectionStaticType_Equal(t *testing.T) { require.True(t, (&IntersectionStaticType{ Types: []*InterfaceStaticType{ - NewInterfaceStaticTypeComputeTypeID(nil, utils.TestLocation, "X"), - NewInterfaceStaticTypeComputeTypeID(nil, utils.TestLocation, "Y"), + NewInterfaceStaticTypeComputeTypeID(nil, TestLocation, "X"), + NewInterfaceStaticTypeComputeTypeID(nil, TestLocation, "Y"), }, }).Equal( &IntersectionStaticType{ Types: []*InterfaceStaticType{ - NewInterfaceStaticTypeComputeTypeID(nil, utils.TestLocation, "X"), - NewInterfaceStaticTypeComputeTypeID(nil, utils.TestLocation, "Y"), + NewInterfaceStaticTypeComputeTypeID(nil, TestLocation, "X"), + NewInterfaceStaticTypeComputeTypeID(nil, TestLocation, "Y"), }, }, ), @@ -847,14 +847,14 @@ func TestIntersectionStaticType_Equal(t *testing.T) { require.False(t, (&IntersectionStaticType{ Types: []*InterfaceStaticType{ - NewInterfaceStaticTypeComputeTypeID(nil, utils.TestLocation, "X"), - NewInterfaceStaticTypeComputeTypeID(nil, utils.TestLocation, "Y"), + NewInterfaceStaticTypeComputeTypeID(nil, TestLocation, "X"), + NewInterfaceStaticTypeComputeTypeID(nil, TestLocation, "Y"), }, }).Equal( &IntersectionStaticType{ Types: []*InterfaceStaticType{ - NewInterfaceStaticTypeComputeTypeID(nil, utils.TestLocation, "X"), - NewInterfaceStaticTypeComputeTypeID(nil, utils.TestLocation, "Z"), + NewInterfaceStaticTypeComputeTypeID(nil, TestLocation, "X"), + NewInterfaceStaticTypeComputeTypeID(nil, TestLocation, "Z"), }, }, ), @@ -868,13 +868,13 @@ func TestIntersectionStaticType_Equal(t *testing.T) { require.False(t, (&IntersectionStaticType{ Types: []*InterfaceStaticType{ - NewInterfaceStaticTypeComputeTypeID(nil, utils.TestLocation, "X"), + NewInterfaceStaticTypeComputeTypeID(nil, TestLocation, "X"), }, }).Equal( &IntersectionStaticType{ Types: []*InterfaceStaticType{ - NewInterfaceStaticTypeComputeTypeID(nil, utils.TestLocation, "X"), - NewInterfaceStaticTypeComputeTypeID(nil, utils.TestLocation, "Y"), + NewInterfaceStaticTypeComputeTypeID(nil, TestLocation, "X"), + NewInterfaceStaticTypeComputeTypeID(nil, TestLocation, "Y"), }, }, ), @@ -888,14 +888,14 @@ func TestIntersectionStaticType_Equal(t *testing.T) { require.False(t, (&IntersectionStaticType{ Types: []*InterfaceStaticType{ - NewInterfaceStaticTypeComputeTypeID(nil, utils.TestLocation, "X"), - NewInterfaceStaticTypeComputeTypeID(nil, utils.TestLocation, "Y"), + NewInterfaceStaticTypeComputeTypeID(nil, TestLocation, "X"), + NewInterfaceStaticTypeComputeTypeID(nil, TestLocation, "Y"), }, }).Equal( &IntersectionStaticType{ Types: []*InterfaceStaticType{ - NewInterfaceStaticTypeComputeTypeID(nil, utils.TestLocation, "X"), - NewInterfaceStaticTypeComputeTypeID(nil, utils.TestLocation, "Z"), + NewInterfaceStaticTypeComputeTypeID(nil, TestLocation, "X"), + NewInterfaceStaticTypeComputeTypeID(nil, TestLocation, "Z"), }, }, ), @@ -909,8 +909,8 @@ func TestIntersectionStaticType_Equal(t *testing.T) { require.False(t, (&IntersectionStaticType{ Types: []*InterfaceStaticType{ - NewInterfaceStaticTypeComputeTypeID(nil, utils.TestLocation, "X"), - NewInterfaceStaticTypeComputeTypeID(nil, utils.TestLocation, "Y"), + NewInterfaceStaticTypeComputeTypeID(nil, TestLocation, "X"), + NewInterfaceStaticTypeComputeTypeID(nil, TestLocation, "Y"), }, }).Equal( &ReferenceStaticType{ diff --git a/interpreter/storage_test.go b/interpreter/storage_test.go index 01e9299c38..0693df2d9b 100644 --- a/interpreter/storage_test.go +++ b/interpreter/storage_test.go @@ -29,7 +29,8 @@ import ( "github.com/onflow/cadence/common" . "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/interpreter_utils" ) func TestCompositeStorage(t *testing.T) { diff --git a/interpreter/string_test.go b/interpreter/string_test.go index 410d2f478c..580608e26e 100644 --- a/interpreter/string_test.go +++ b/interpreter/string_test.go @@ -26,7 +26,8 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/interpreter" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/interpreter_utils" ) func TestInterpretRecursiveValueString(t *testing.T) { diff --git a/interpreter/switch_test.go b/interpreter/switch_test.go index 0cbe894063..2a30c6cbdb 100644 --- a/interpreter/switch_test.go +++ b/interpreter/switch_test.go @@ -24,11 +24,10 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - . "github.com/onflow/cadence/tests/sema_utils" - . "github.com/onflow/cadence/tests/utils" - "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/test_utils/interpreter_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestInterpretSwitchStatement(t *testing.T) { diff --git a/interpreter/transactions_test.go b/interpreter/transactions_test.go index 8a4167a0b1..21a1642f99 100644 --- a/interpreter/transactions_test.go +++ b/interpreter/transactions_test.go @@ -29,8 +29,9 @@ import ( "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - . "github.com/onflow/cadence/tests/sema_utils" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/interpreter_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestInterpretTransactions(t *testing.T) { diff --git a/interpreter/transfer_test.go b/interpreter/transfer_test.go index c40a4f0ee3..72447e2dd9 100644 --- a/interpreter/transfer_test.go +++ b/interpreter/transfer_test.go @@ -28,7 +28,7 @@ import ( "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" ) func TestInterpretTransferCheck(t *testing.T) { diff --git a/interpreter/uuid_test.go b/interpreter/uuid_test.go index aa4154ff19..efdc8d1010 100644 --- a/interpreter/uuid_test.go +++ b/interpreter/uuid_test.go @@ -28,8 +28,9 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/interpreter_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestInterpretResourceUUID(t *testing.T) { diff --git a/interpreter/value_function_test.go b/interpreter/value_function_test.go index 0cf1fd6464..2d25e8bc1b 100644 --- a/interpreter/value_function_test.go +++ b/interpreter/value_function_test.go @@ -24,10 +24,9 @@ import ( "github.com/stretchr/testify/assert" "github.com/onflow/cadence/common" - "github.com/onflow/cadence/tests/utils" - . "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/test_utils/common_utils" ) func TestFunctionStaticType(t *testing.T) { @@ -67,7 +66,7 @@ func TestFunctionStaticType(t *testing.T) { inter.SharedState.Config.CompositeTypeHandler = func(location common.Location, typeID TypeID) *sema.CompositeType { return &sema.CompositeType{ - Location: utils.TestLocation, + Location: TestLocation, Identifier: "foo", Kind: common.CompositeKindStructure, } @@ -92,7 +91,7 @@ func TestFunctionStaticType(t *testing.T) { var compositeValue Value = NewCompositeValue( inter, EmptyLocationRange, - utils.TestLocation, + TestLocation, "foo", common.CompositeKindStructure, []CompositeField{}, diff --git a/interpreter/value_test.go b/interpreter/value_test.go index 8f4df2bcc1..295f5a4346 100644 --- a/interpreter/value_test.go +++ b/interpreter/value_test.go @@ -36,15 +36,15 @@ import ( . "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - . "github.com/onflow/cadence/tests/sema_utils" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func newTestCompositeValue(inter *Interpreter, owner common.Address) *CompositeValue { return NewCompositeValue( inter, EmptyLocationRange, - utils.TestLocation, + TestLocation, "Test", common.CompositeKindStructure, nil, @@ -53,7 +53,7 @@ func newTestCompositeValue(inter *Interpreter, owner common.Address) *CompositeV } var testCompositeValueType = &sema.CompositeType{ - Location: utils.TestLocation, + Location: TestLocation, Identifier: "Test", Kind: common.CompositeKindStructure, Members: &sema.StringMemberOrderedMap{}, @@ -94,7 +94,7 @@ func TestOwnerNewArray(t *testing.T) { &Program{ Elaboration: elaboration, }, - utils.TestLocation, + TestLocation, &Config{Storage: storage}, ) require.NoError(t, err) @@ -137,7 +137,7 @@ func TestOwnerArrayDeepCopy(t *testing.T) { &Program{ Elaboration: elaboration, }, - utils.TestLocation, + TestLocation, &Config{ Storage: storage, OnMeterComputation: getMeterCompFuncWithExpectedKinds(t, @@ -206,7 +206,7 @@ func TestOwnerArrayElement(t *testing.T) { &Program{ Elaboration: elaboration, }, - utils.TestLocation, + TestLocation, &Config{Storage: storage}, ) require.NoError(t, err) @@ -248,7 +248,7 @@ func TestOwnerArraySetIndex(t *testing.T) { &Program{ Elaboration: elaboration, }, - utils.TestLocation, + TestLocation, &Config{Storage: storage}, ) require.NoError(t, err) @@ -300,7 +300,7 @@ func TestOwnerArrayAppend(t *testing.T) { &Program{ Elaboration: elaboration, }, - utils.TestLocation, + TestLocation, &Config{Storage: storage}, ) require.NoError(t, err) @@ -346,7 +346,7 @@ func TestOwnerArrayInsert(t *testing.T) { &Program{ Elaboration: elaboration, }, - utils.TestLocation, + TestLocation, &Config{Storage: storage}, ) require.NoError(t, err) @@ -392,7 +392,7 @@ func TestOwnerArrayRemove(t *testing.T) { &Program{ Elaboration: elaboration, }, - utils.TestLocation, + TestLocation, &Config{Storage: storage}, ) require.NoError(t, err) @@ -436,7 +436,7 @@ func TestOwnerNewDictionary(t *testing.T) { &Program{ Elaboration: elaboration, }, - utils.TestLocation, + TestLocation, &Config{Storage: storage}, ) require.NoError(t, err) @@ -483,7 +483,7 @@ func TestOwnerDictionary(t *testing.T) { &Program{ Elaboration: elaboration, }, - utils.TestLocation, + TestLocation, &Config{Storage: storage}, ) require.NoError(t, err) @@ -530,7 +530,7 @@ func TestOwnerDictionaryCopy(t *testing.T) { &Program{ Elaboration: elaboration, }, - utils.TestLocation, + TestLocation, &Config{ Storage: storage, OnMeterComputation: getMeterCompFuncWithExpectedKinds(t, @@ -603,7 +603,7 @@ func TestOwnerDictionarySetSome(t *testing.T) { &Program{ Elaboration: elaboration, }, - utils.TestLocation, + TestLocation, &Config{Storage: storage}, ) require.NoError(t, err) @@ -657,7 +657,7 @@ func TestOwnerDictionaryInsertNonExisting(t *testing.T) { &Program{ Elaboration: elaboration, }, - utils.TestLocation, + TestLocation, &Config{Storage: storage}, ) require.NoError(t, err) @@ -712,7 +712,7 @@ func TestOwnerDictionaryRemove(t *testing.T) { &Program{ Elaboration: elaboration, }, - utils.TestLocation, + TestLocation, &Config{Storage: storage}, ) require.NoError(t, err) @@ -773,7 +773,7 @@ func TestOwnerDictionaryInsertExisting(t *testing.T) { &Program{ Elaboration: elaboration, }, - utils.TestLocation, + TestLocation, &Config{Storage: storage}, ) require.NoError(t, err) @@ -1115,7 +1115,7 @@ func TestStringer(t *testing.T) { return NewCompositeValue( inter, EmptyLocationRange, - utils.TestLocation, + TestLocation, "Foo", common.CompositeKindResource, fields, @@ -1137,7 +1137,7 @@ func TestStringer(t *testing.T) { compositeValue := NewCompositeValue( inter, EmptyLocationRange, - utils.TestLocation, + TestLocation, "Foo", common.CompositeKindResource, fields, @@ -1410,7 +1410,7 @@ func TestVisitor(t *testing.T) { value = NewCompositeValue( inter, EmptyLocationRange, - utils.TestLocation, + TestLocation, "Foo", common.CompositeKindStructure, fields, @@ -1742,7 +1742,7 @@ func TestGetHashInput(t *testing.T) { return NewCompositeValue( inter, EmptyLocationRange, - utils.TestLocation, + TestLocation, "Foo", common.CompositeKindEnum, fields, @@ -1770,7 +1770,7 @@ func TestGetHashInput(t *testing.T) { return NewCompositeValue( inter, EmptyLocationRange, - utils.TestLocation, + TestLocation, strings.Repeat("a", 32), common.CompositeKindEnum, fields, @@ -2959,7 +2959,7 @@ func TestCompositeValue_Equal(t *testing.T) { NewCompositeValue( inter, EmptyLocationRange, - utils.TestLocation, + TestLocation, "X", common.CompositeKindStructure, fields1, @@ -2970,7 +2970,7 @@ func TestCompositeValue_Equal(t *testing.T) { NewCompositeValue( inter, EmptyLocationRange, - utils.TestLocation, + TestLocation, "X", common.CompositeKindStructure, fields2, @@ -3384,7 +3384,7 @@ func TestPublicKeyValue(t *testing.T) { inter, err := NewInterpreter( nil, - utils.TestLocation, + TestLocation, &Config{ Storage: storage, }, @@ -3433,7 +3433,7 @@ func TestPublicKeyValue(t *testing.T) { inter, err := NewInterpreter( nil, - utils.TestLocation, + TestLocation, &Config{ Storage: storage, }, @@ -3589,7 +3589,7 @@ func newTestInterpreter(tb testing.TB) *Interpreter { inter, err := NewInterpreter( nil, - utils.TestLocation, + TestLocation, &Config{ Storage: storage, AtreeValueValidationEnabled: true, @@ -3756,7 +3756,7 @@ func TestValue_ConformsToStaticType(t *testing.T) { return NewCompositeValue( inter, EmptyLocationRange, - utils.TestLocation, + TestLocation, "Test", common.CompositeKindStructure, fields, @@ -3775,7 +3775,7 @@ func TestValue_ConformsToStaticType(t *testing.T) { members := &sema.StringMemberOrderedMap{} compositeType := &sema.CompositeType{ - Location: utils.TestLocation, + Location: TestLocation, Identifier: "Test", Kind: common.CompositeKindStructure, Members: members, @@ -3801,7 +3801,7 @@ func TestValue_ConformsToStaticType(t *testing.T) { &Program{ Elaboration: elaboration, }, - utils.TestLocation, + TestLocation, &Config{Storage: storage}, ) require.NoError(t, err) @@ -4493,7 +4493,7 @@ func TestOverwriteDictionaryValueWhereKeyIsStoredInSeparateAtreeSlab(t *testing. return NewCompositeValue( inter, EmptyLocationRange, - utils.TestLocation, + TestLocation, "Test", common.CompositeKindEnum, []CompositeField{ @@ -4518,7 +4518,7 @@ func TestOverwriteDictionaryValueWhereKeyIsStoredInSeparateAtreeSlab(t *testing. &Program{ Elaboration: elaboration, }, - utils.TestLocation, + TestLocation, &Config{ Storage: storage, AtreeValueValidationEnabled: true, @@ -4594,7 +4594,7 @@ func TestOverwriteDictionaryValueWhereKeyIsStoredInSeparateAtreeSlab(t *testing. &Program{ Elaboration: elaboration, }, - utils.TestLocation, + TestLocation, &Config{ Storage: storage, AtreeValueValidationEnabled: true, diff --git a/interpreter/value_uint64.go b/interpreter/value_uint64.go index 5c11cca04b..f8b3cdb2ce 100644 --- a/interpreter/value_uint64.go +++ b/interpreter/value_uint64.go @@ -19,12 +19,11 @@ package interpreter import ( + "encoding/binary" "math" "math/big" "unsafe" - "encoding/binary" - "github.com/onflow/atree" "github.com/onflow/cadence/ast" diff --git a/interpreter/values_test.go b/interpreter/values_test.go index e725b5a30c..b874aa4213 100644 --- a/interpreter/values_test.go +++ b/interpreter/values_test.go @@ -36,7 +36,8 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/interpreter_utils" ) // TODO: make these program args? @@ -64,7 +65,7 @@ func TestInterpretRandomMapOperations(t *testing.T) { Program: ast.NewProgram(nil, []ast.Declaration{}), Elaboration: sema.NewElaboration(nil), }, - utils.TestLocation, + TestLocation, &interpreter.Config{ Storage: storage, ImportLocationHandler: func(inter *interpreter.Interpreter, location common.Location) interpreter.Import { @@ -119,7 +120,7 @@ func TestInterpretRandomMapOperations(t *testing.T) { value, found := testMap.Get(inter, interpreter.EmptyLocationRange, orgKey) require.True(t, found) - utils.AssertValuesEqual(t, inter, orgValue, value) + AssertValuesEqual(t, inter, orgValue, value) return false }) @@ -138,7 +139,7 @@ func TestInterpretRandomMapOperations(t *testing.T) { orgValue, ok := entries.get(inter, key) require.True(t, ok, "cannot find key: %v", key) - utils.AssertValuesEqual(t, inter, orgValue, value) + AssertValuesEqual(t, inter, orgValue, value) return true }, ) @@ -164,7 +165,7 @@ func TestInterpretRandomMapOperations(t *testing.T) { value, found := copyOfTestMap.Get(inter, interpreter.EmptyLocationRange, orgKey) require.True(t, found) - utils.AssertValuesEqual(t, inter, orgValue, value) + AssertValuesEqual(t, inter, orgValue, value) return false }) @@ -192,7 +193,7 @@ func TestInterpretRandomMapOperations(t *testing.T) { value, found := testMap.Get(inter, interpreter.EmptyLocationRange, orgKey) require.True(t, found) - utils.AssertValuesEqual(t, inter, orgValue, value) + AssertValuesEqual(t, inter, orgValue, value) return false }) @@ -233,7 +234,7 @@ func TestInterpretRandomMapOperations(t *testing.T) { value, found := dictionary.Get(inter, interpreter.EmptyLocationRange, orgKey) require.True(t, found) - utils.AssertValuesEqual(t, inter, orgValue, value) + AssertValuesEqual(t, inter, orgValue, value) return false }) @@ -284,7 +285,7 @@ func TestInterpretRandomMapOperations(t *testing.T) { // Removed value must be same as the original value innerValue := someValue.InnerValue(inter, interpreter.EmptyLocationRange) - utils.AssertValuesEqual(t, inter, orgValue, innerValue) + AssertValuesEqual(t, inter, orgValue, innerValue) return false }) @@ -344,7 +345,7 @@ func TestInterpretRandomMapOperations(t *testing.T) { // Removed value must be same as the original value innerValue := someValue.InnerValue(inter, interpreter.EmptyLocationRange) - utils.AssertValuesEqual(t, inter, orgValue, innerValue) + AssertValuesEqual(t, inter, orgValue, innerValue) return false }) @@ -412,7 +413,7 @@ func TestInterpretRandomMapOperations(t *testing.T) { // Removed value must be same as the original value innerValue := someValue.InnerValue(inter, interpreter.EmptyLocationRange) - utils.AssertValuesEqual(t, inter, value1, innerValue) + AssertValuesEqual(t, inter, value1, innerValue) } // Check the values @@ -428,7 +429,7 @@ func TestInterpretRandomMapOperations(t *testing.T) { // Read value must be updated value innerValue := someValue.InnerValue(inter, interpreter.EmptyLocationRange) - utils.AssertValuesEqual(t, inter, value2, innerValue) + AssertValuesEqual(t, inter, value2, innerValue) } }) @@ -515,7 +516,7 @@ func TestInterpretRandomMapOperations(t *testing.T) { // Removed value must be same as the original value innerValue := someValue.InnerValue(inter, interpreter.EmptyLocationRange) - utils.AssertValuesEqual(t, inter, orgValue, innerValue) + AssertValuesEqual(t, inter, orgValue, innerValue) deleteCount++ } @@ -583,7 +584,7 @@ func TestInterpretRandomMapOperations(t *testing.T) { value, found := movedDictionary.Get(inter, interpreter.EmptyLocationRange, orgKey) require.True(t, found) - utils.AssertValuesEqual(t, inter, orgValue, value) + AssertValuesEqual(t, inter, orgValue, value) return false }) @@ -607,7 +608,7 @@ func TestInterpretRandomArrayOperations(t *testing.T) { Program: ast.NewProgram(nil, []ast.Declaration{}), Elaboration: sema.NewElaboration(nil), }, - utils.TestLocation, + TestLocation, &interpreter.Config{ Storage: storage, ImportLocationHandler: func(inter *interpreter.Interpreter, location common.Location) interpreter.Import { @@ -651,7 +652,7 @@ func TestInterpretRandomArrayOperations(t *testing.T) { for index, orgElement := range elements { element := testArray.Get(inter, interpreter.EmptyLocationRange, index) - utils.AssertValuesEqual(t, inter, orgElement, element) + AssertValuesEqual(t, inter, orgElement, element) } owner := testArray.GetOwner() @@ -666,10 +667,10 @@ func TestInterpretRandomArrayOperations(t *testing.T) { inter, func(element interpreter.Value) (resume bool) { orgElement := elements[index] - utils.AssertValuesEqual(t, inter, orgElement, element) + AssertValuesEqual(t, inter, orgElement, element) elementByIndex := testArray.Get(inter, interpreter.EmptyLocationRange, index) - utils.AssertValuesEqual(t, inter, element, elementByIndex) + AssertValuesEqual(t, inter, element, elementByIndex) index++ return true @@ -695,7 +696,7 @@ func TestInterpretRandomArrayOperations(t *testing.T) { for index, orgElement := range elements { element := copyOfTestArray.Get(inter, interpreter.EmptyLocationRange, index) - utils.AssertValuesEqual(t, inter, orgElement, element) + AssertValuesEqual(t, inter, orgElement, element) } owner := copyOfTestArray.GetOwner() @@ -717,7 +718,7 @@ func TestInterpretRandomArrayOperations(t *testing.T) { // go over original elements again and check no missing data (no side effect should be found) for index, orgElement := range elements { element := testArray.Get(inter, interpreter.EmptyLocationRange, index) - utils.AssertValuesEqual(t, inter, orgElement, element) + AssertValuesEqual(t, inter, orgElement, element) } owner := testArray.GetOwner() @@ -755,7 +756,7 @@ func TestInterpretRandomArrayOperations(t *testing.T) { // Go over original values again and check no missing data (no side effect should be found) for index, element := range newElements { value := testArray.Get(inter, interpreter.EmptyLocationRange, index) - utils.AssertValuesEqual(t, inter, element, value) + AssertValuesEqual(t, inter, element, value) } }) @@ -789,7 +790,7 @@ func TestInterpretRandomArrayOperations(t *testing.T) { // Go over original values again and check no missing data (no side effect should be found) for index, element := range newElements { value := testArray.Get(inter, interpreter.EmptyLocationRange, index) - utils.AssertValuesEqual(t, inter, element, value) + AssertValuesEqual(t, inter, element, value) } }) @@ -831,7 +832,7 @@ func TestInterpretRandomArrayOperations(t *testing.T) { removedValue := testArray.Remove(inter, interpreter.EmptyLocationRange, 0) // Removed value must be same as the original value - utils.AssertValuesEqual(t, inter, element, removedValue) + AssertValuesEqual(t, inter, element, removedValue) } // Array must be empty @@ -896,7 +897,7 @@ func TestInterpretRandomArrayOperations(t *testing.T) { removedValue := testArray.RemoveFirst(inter, interpreter.EmptyLocationRange) // Removed value must be same as the original value - utils.AssertValuesEqual(t, inter, orgValue, removedValue) + AssertValuesEqual(t, inter, orgValue, removedValue) deleteCount++ } @@ -957,7 +958,7 @@ func TestInterpretRandomArrayOperations(t *testing.T) { // Check the elements for index, orgElement := range elements { element := movedArray.Get(inter, interpreter.EmptyLocationRange, index) - utils.AssertValuesEqual(t, inter, orgElement, element) + AssertValuesEqual(t, inter, orgElement, element) } owner = movedArray.GetOwner() @@ -979,7 +980,7 @@ func TestInterpretRandomCompositeValueOperations(t *testing.T) { Program: ast.NewProgram(nil, []ast.Declaration{}), Elaboration: sema.NewElaboration(nil), }, - utils.TestLocation, + TestLocation, &interpreter.Config{ Storage: storage, ImportLocationHandler: func(inter *interpreter.Interpreter, location common.Location) interpreter.Import { @@ -1005,7 +1006,7 @@ func TestInterpretRandomCompositeValueOperations(t *testing.T) { for fieldName, orgFieldValue := range orgFields { fieldValue := testComposite.GetField(inter, interpreter.EmptyLocationRange, fieldName) - utils.AssertValuesEqual(t, inter, orgFieldValue, fieldValue) + AssertValuesEqual(t, inter, orgFieldValue, fieldValue) } owner := testComposite.GetOwner() @@ -1017,7 +1018,7 @@ func TestInterpretRandomCompositeValueOperations(t *testing.T) { testComposite.ForEachField(inter, func(name string, value interpreter.Value) (resume bool) { orgValue, ok := orgFields[name] require.True(t, ok) - utils.AssertValuesEqual(t, inter, orgValue, value) + AssertValuesEqual(t, inter, orgValue, value) fieldCount++ // continue iteration @@ -1042,7 +1043,7 @@ func TestInterpretRandomCompositeValueOperations(t *testing.T) { for name, orgValue := range orgFields { value := copyOfTestComposite.GetField(inter, interpreter.EmptyLocationRange, name) - utils.AssertValuesEqual(t, inter, orgValue, value) + AssertValuesEqual(t, inter, orgValue, value) } owner := copyOfTestComposite.GetOwner() @@ -1062,7 +1063,7 @@ func TestInterpretRandomCompositeValueOperations(t *testing.T) { // go over original values again and check no missing data (no side effect should be found) for name, orgValue := range orgFields { value := testComposite.GetField(inter, interpreter.EmptyLocationRange, name) - utils.AssertValuesEqual(t, inter, orgValue, value) + AssertValuesEqual(t, inter, orgValue, value) } owner := testComposite.GetOwner() @@ -1115,7 +1116,7 @@ func TestInterpretRandomCompositeValueOperations(t *testing.T) { // Check the elements for fieldName, orgFieldValue := range fields { fieldValue := movedComposite.GetField(inter, interpreter.EmptyLocationRange, fieldName) - utils.AssertValuesEqual(t, inter, orgFieldValue, fieldValue) + AssertValuesEqual(t, inter, orgFieldValue, fieldValue) } owner = composite.GetOwner() @@ -1714,7 +1715,7 @@ func TestCheckStorageHealthInMiddleOfDeepRemove(t *testing.T) { Program: ast.NewProgram(nil, []ast.Declaration{}), Elaboration: sema.NewElaboration(nil), }, - utils.TestLocation, + TestLocation, &interpreter.Config{ Storage: storage, ImportLocationHandler: func(inter *interpreter.Interpreter, location common.Location) interpreter.Import { @@ -1792,7 +1793,7 @@ func TestCheckStorageHealthInMiddleOfTransferAndRemove(t *testing.T) { Program: ast.NewProgram(nil, []ast.Declaration{}), Elaboration: sema.NewElaboration(nil), }, - utils.TestLocation, + TestLocation, &interpreter.Config{ Storage: storage, ImportLocationHandler: func(inter *interpreter.Interpreter, location common.Location) interpreter.Import { diff --git a/interpreter/while_test.go b/interpreter/while_test.go index 10bcf69db6..c341dfdf57 100644 --- a/interpreter/while_test.go +++ b/interpreter/while_test.go @@ -23,9 +23,8 @@ import ( "github.com/stretchr/testify/require" - . "github.com/onflow/cadence/tests/utils" - "github.com/onflow/cadence/interpreter" + . "github.com/onflow/cadence/test_utils/interpreter_utils" ) func TestInterpretWhileStatement(t *testing.T) { diff --git a/old_parser/declaration_test.go b/old_parser/declaration_test.go index f41fd0c978..23463f9479 100644 --- a/old_parser/declaration_test.go +++ b/old_parser/declaration_test.go @@ -27,7 +27,7 @@ import ( "github.com/onflow/cadence/ast" "github.com/onflow/cadence/common" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" ) func TestParseVariableDeclaration(t *testing.T) { @@ -41,7 +41,7 @@ func TestParseVariableDeclaration(t *testing.T) { result, errs := testParseDeclarations("var x = 1") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -77,7 +77,7 @@ func TestParseVariableDeclaration(t *testing.T) { result, errs := testParseDeclarations(" pub var x = 1") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessAll, @@ -113,7 +113,7 @@ func TestParseVariableDeclaration(t *testing.T) { result, errs := testParseDeclarations("let x = 1") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -149,7 +149,7 @@ func TestParseVariableDeclaration(t *testing.T) { result, errs := testParseDeclarations("let x <- 1") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -185,7 +185,7 @@ func TestParseVariableDeclaration(t *testing.T) { result, errs := testParseDeclarations("let r2: @R <- r") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -228,7 +228,7 @@ func TestParseVariableDeclaration(t *testing.T) { result, errs := testParseStatements("var x <- y <- z") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -275,7 +275,7 @@ func TestParseVariableDeclaration(t *testing.T) { StaticModifierEnabled: true, }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid static modifier for variable", @@ -291,7 +291,7 @@ func TestParseVariableDeclaration(t *testing.T) { t.Parallel() _, errs := testParseDeclarations("static var x = 1") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: identifier", @@ -313,7 +313,7 @@ func TestParseVariableDeclaration(t *testing.T) { NativeModifierEnabled: true, }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid native modifier for variable", @@ -329,7 +329,7 @@ func TestParseVariableDeclaration(t *testing.T) { t.Parallel() _, errs := testParseDeclarations("native var x = 1") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: identifier", @@ -361,7 +361,7 @@ func TestParseParameterList(t *testing.T) { result, errs := parse("()") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.ParameterList{ Range: ast.Range{ StartPos: ast.Position{Line: 1, Column: 0, Offset: 0}, @@ -379,7 +379,7 @@ func TestParseParameterList(t *testing.T) { result, errs := parse(" ( )") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.ParameterList{ Range: ast.Range{ StartPos: ast.Position{Line: 1, Column: 1, Offset: 1}, @@ -397,7 +397,7 @@ func TestParseParameterList(t *testing.T) { result, errs := parse("( a : Int )") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.ParameterList{ Parameters: []*ast.Parameter{ { @@ -435,7 +435,7 @@ func TestParseParameterList(t *testing.T) { result, errs := parse("( a b : Int )") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.ParameterList{ Parameters: []*ast.Parameter{ { @@ -473,7 +473,7 @@ func TestParseParameterList(t *testing.T) { result, errs := parse("( a b : Int , c : Int )") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.ParameterList{ Parameters: []*ast.Parameter{ { @@ -527,7 +527,7 @@ func TestParseParameterList(t *testing.T) { t.Parallel() _, errs := parse("( a b : Int c : Int )") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &MissingCommaInParameterListError{ Pos: ast.Position{Offset: 14, Line: 1, Column: 14}, @@ -549,7 +549,7 @@ func TestParseFunctionDeclaration(t *testing.T) { result, errs := testParseDeclarations("fun foo () { }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -586,7 +586,7 @@ func TestParseFunctionDeclaration(t *testing.T) { result, errs := testParseDeclarations("pub fun foo () { }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessAll, @@ -623,7 +623,7 @@ func TestParseFunctionDeclaration(t *testing.T) { result, errs := testParseDeclarations("fun foo (): X { }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -682,7 +682,7 @@ func TestParseFunctionDeclaration(t *testing.T) { `) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -797,7 +797,7 @@ func TestParseFunctionDeclaration(t *testing.T) { result, errs := testParseDeclarations("/// Test\nfun foo() {}") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -835,7 +835,7 @@ func TestParseFunctionDeclaration(t *testing.T) { result, errs := testParseDeclarations("\n /// First line\n \n/// Second line\n\n\nfun foo() {}") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -873,7 +873,7 @@ func TestParseFunctionDeclaration(t *testing.T) { result, errs := testParseDeclarations("\n /** Cool dogs.\n\n Cool cats!! */\n\n\nfun foo() {}") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -916,7 +916,7 @@ func TestParseFunctionDeclaration(t *testing.T) { result, errs := testParseDeclarations("fun main(): Int{ return 1 }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -985,7 +985,7 @@ func TestParseFunctionDeclaration(t *testing.T) { ) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -1022,7 +1022,7 @@ func TestParseFunctionDeclaration(t *testing.T) { _, errs := testParseDeclarations("native fun foo() {}") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: identifier", @@ -1046,7 +1046,7 @@ func TestParseFunctionDeclaration(t *testing.T) { ) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -1083,7 +1083,7 @@ func TestParseFunctionDeclaration(t *testing.T) { _, errs := testParseDeclarations("static fun foo() {}") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: identifier", @@ -1108,7 +1108,7 @@ func TestParseFunctionDeclaration(t *testing.T) { ) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -1145,7 +1145,7 @@ func TestParseFunctionDeclaration(t *testing.T) { _, errs := testParseDeclarations("static native fun foo() {}") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: identifier", @@ -1168,7 +1168,7 @@ func TestParseFunctionDeclaration(t *testing.T) { NativeModifierEnabled: true, }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid static modifier after native modifier", @@ -1185,7 +1185,7 @@ func TestParseFunctionDeclaration(t *testing.T) { _, errs := testParseDeclarations("native static fun foo() {}") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: identifier", @@ -1210,7 +1210,7 @@ func TestParseFunctionDeclaration(t *testing.T) { ) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessAll, @@ -1247,7 +1247,7 @@ func TestParseFunctionDeclaration(t *testing.T) { _, errs := testParseDeclarations("pub static native fun foo() {}") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: identifier", @@ -1271,7 +1271,7 @@ func TestParseFunctionDeclaration(t *testing.T) { ) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -1321,7 +1321,7 @@ func TestParseFunctionDeclaration(t *testing.T) { ) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -1378,7 +1378,7 @@ func TestParseFunctionDeclaration(t *testing.T) { ) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -1443,7 +1443,7 @@ func TestParseFunctionDeclaration(t *testing.T) { _, errs := testParseDeclarations("fun foo() {}") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected '(' as start of parameter list, got '<'", @@ -1466,7 +1466,7 @@ func TestParseFunctionDeclaration(t *testing.T) { }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "missing '>' at end of type parameter list", @@ -1489,7 +1489,7 @@ func TestParseFunctionDeclaration(t *testing.T) { }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &MissingCommaInParameterListError{ Pos: ast.Position{Offset: 13, Line: 1, Column: 13}, @@ -1521,7 +1521,7 @@ func TestParseAccess(t *testing.T) { result, errs := parse("pub") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, ast.AccessAll, result, ) @@ -1534,7 +1534,7 @@ func TestParseAccess(t *testing.T) { result, errs := parse("pub ( set )") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, ast.AccessPubSettableLegacy, result, ) @@ -1545,7 +1545,7 @@ func TestParseAccess(t *testing.T) { t.Parallel() result, errs := parse("pub ( ") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected keyword \"set\", got EOF", @@ -1555,7 +1555,7 @@ func TestParseAccess(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, ast.AccessNotSpecified, result, ) @@ -1566,7 +1566,7 @@ func TestParseAccess(t *testing.T) { t.Parallel() result, errs := parse("pub ( set ") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected token ')'", @@ -1576,7 +1576,7 @@ func TestParseAccess(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, ast.AccessNotSpecified, result, ) @@ -1587,7 +1587,7 @@ func TestParseAccess(t *testing.T) { t.Parallel() result, errs := parse("pub ( foo )") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected keyword \"set\", got \"foo\"", @@ -1597,7 +1597,7 @@ func TestParseAccess(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, ast.AccessNotSpecified, result, ) @@ -1610,7 +1610,7 @@ func TestParseAccess(t *testing.T) { result, errs := parse("priv") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, ast.AccessSelf, result, ) @@ -1623,7 +1623,7 @@ func TestParseAccess(t *testing.T) { result, errs := parse("access ( all )") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, ast.AccessAll, result, ) @@ -1636,7 +1636,7 @@ func TestParseAccess(t *testing.T) { result, errs := parse("access ( account )") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, ast.AccessAccount, result, ) @@ -1649,7 +1649,7 @@ func TestParseAccess(t *testing.T) { result, errs := parse("access ( contract )") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, ast.AccessContract, result, ) @@ -1662,7 +1662,7 @@ func TestParseAccess(t *testing.T) { result, errs := parse("access ( self )") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, ast.AccessSelf, result, ) @@ -1673,7 +1673,7 @@ func TestParseAccess(t *testing.T) { t.Parallel() result, errs := parse("access ( ") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected keyword \"all\", \"account\", \"contract\", or \"self\", got EOF", @@ -1683,7 +1683,7 @@ func TestParseAccess(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, ast.AccessNotSpecified, result, ) @@ -1694,7 +1694,7 @@ func TestParseAccess(t *testing.T) { t.Parallel() result, errs := parse("access ( self ") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected token ')'", @@ -1704,7 +1704,7 @@ func TestParseAccess(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, ast.AccessNotSpecified, result, ) @@ -1715,7 +1715,7 @@ func TestParseAccess(t *testing.T) { t.Parallel() result, errs := parse("access ( foo )") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected keyword \"all\", \"account\", \"contract\", or \"self\", got \"foo\"", @@ -1725,7 +1725,7 @@ func TestParseAccess(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, ast.AccessNotSpecified, result, ) @@ -1741,7 +1741,7 @@ func TestParseImportDeclaration(t *testing.T) { t.Parallel() result, errs := testParseDeclarations(` import`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected end in import declaration: expected string, address, or identifier", @@ -1753,7 +1753,7 @@ func TestParseImportDeclaration(t *testing.T) { var expected []ast.Declaration - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, expected, result, ) @@ -1766,7 +1766,7 @@ func TestParseImportDeclaration(t *testing.T) { result, errs := testParseDeclarations(` import "foo"`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.ImportDeclaration{ Identifiers: nil, @@ -1789,7 +1789,7 @@ func TestParseImportDeclaration(t *testing.T) { result, errs := testParseDeclarations(` import 0x42`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.ImportDeclaration{ Identifiers: nil, @@ -1812,7 +1812,7 @@ func TestParseImportDeclaration(t *testing.T) { t.Parallel() result, errs := testParseDeclarations(` import 0x10000000000000001`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "address too large", @@ -1836,7 +1836,7 @@ func TestParseImportDeclaration(t *testing.T) { }, } - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, expected, result, ) @@ -1847,7 +1847,7 @@ func TestParseImportDeclaration(t *testing.T) { t.Parallel() result, errs := testParseDeclarations(` import 1`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token in import declaration: " + @@ -1860,7 +1860,7 @@ func TestParseImportDeclaration(t *testing.T) { var expected []ast.Declaration - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, expected, result, ) @@ -1874,7 +1874,7 @@ func TestParseImportDeclaration(t *testing.T) { result, errs := testParseDeclarations(` import foo from "bar"`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.ImportDeclaration{ Identifiers: []ast.Identifier{ @@ -1900,7 +1900,7 @@ func TestParseImportDeclaration(t *testing.T) { t.Parallel() result, errs := testParseDeclarations(` import foo "bar"`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token in import declaration: " + @@ -1913,7 +1913,7 @@ func TestParseImportDeclaration(t *testing.T) { var expected []ast.Declaration - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, expected, result, ) @@ -1926,7 +1926,7 @@ func TestParseImportDeclaration(t *testing.T) { result, errs := testParseDeclarations(` import foo , bar , baz from 0x42`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.ImportDeclaration{ Identifiers: []ast.Identifier{ @@ -1962,7 +1962,7 @@ func TestParseImportDeclaration(t *testing.T) { t.Parallel() result, errs := testParseDeclarations(` import foo , bar , from 0x42`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: `expected identifier, got keyword "from"`, @@ -1974,7 +1974,7 @@ func TestParseImportDeclaration(t *testing.T) { var expected []ast.Declaration - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, expected, result, ) @@ -1987,7 +1987,7 @@ func TestParseImportDeclaration(t *testing.T) { result, errs := testParseDeclarations(` import foo`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.ImportDeclaration{ Identifiers: nil, @@ -2013,7 +2013,7 @@ func TestParseImportDeclaration(t *testing.T) { `) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.ImportDeclaration{ Identifiers: []ast.Identifier{ @@ -2076,7 +2076,7 @@ func TestParseEvent(t *testing.T) { result, errs := testParseDeclarations("event E()") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.CompositeDeclaration{ Access: ast.AccessNotSpecified, @@ -2119,7 +2119,7 @@ func TestParseEvent(t *testing.T) { result, errs := testParseDeclarations(" priv event E2 ( a : Int , b : String )") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.CompositeDeclaration{ @@ -2224,7 +2224,7 @@ func TestParseFieldWithVariableKind(t *testing.T) { result, errs := parse("var x : Int") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.FieldDeclaration{ Access: ast.AccessNotSpecified, VariableKind: ast.VariableKindVariable, @@ -2258,7 +2258,7 @@ func TestParseFieldWithVariableKind(t *testing.T) { result, errs := parse("let x : Int") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.FieldDeclaration{ Access: ast.AccessNotSpecified, VariableKind: ast.VariableKindConstant, @@ -2316,7 +2316,7 @@ func TestParseField(t *testing.T) { ) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.FieldDeclaration{ Access: ast.AccessNotSpecified, Flags: ast.FieldDeclarationFlagsIsNative, @@ -2367,7 +2367,7 @@ func TestParseField(t *testing.T) { ) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.FieldDeclaration{ Access: ast.AccessNotSpecified, Flags: ast.FieldDeclarationFlagsIsStatic, @@ -2422,7 +2422,7 @@ func TestParseField(t *testing.T) { ) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.FieldDeclaration{ Access: ast.AccessNotSpecified, Flags: ast.FieldDeclarationFlagsIsStatic | ast.FieldDeclarationFlagsIsNative, @@ -2458,7 +2458,7 @@ func TestParseField(t *testing.T) { // For now, leading unknown identifiers are valid. // This will be rejected in Stable Cadence. - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected identifier", @@ -2481,7 +2481,7 @@ func TestParseField(t *testing.T) { }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid static modifier after native modifier", @@ -2505,7 +2505,7 @@ func TestParseField(t *testing.T) { ) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.FieldDeclaration{ Access: ast.AccessAll, Flags: ast.FieldDeclarationFlagsIsStatic | ast.FieldDeclarationFlagsIsNative, @@ -2541,7 +2541,7 @@ func TestParseField(t *testing.T) { // For now, leading unknown identifiers are valid. // This will be rejected in Stable Cadence. - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected identifier", @@ -2565,7 +2565,7 @@ func TestParseCompositeDeclaration(t *testing.T) { result, errs := testParseDeclarations(" pub struct S { }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.CompositeDeclaration{ Access: ast.AccessAll, @@ -2592,7 +2592,7 @@ func TestParseCompositeDeclaration(t *testing.T) { result, errs := testParseDeclarations(" pub resource R : RI { }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.CompositeDeclaration{ Access: ast.AccessAll, @@ -2640,7 +2640,7 @@ func TestParseCompositeDeclaration(t *testing.T) { require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.CompositeDeclaration{ Access: ast.AccessNotSpecified, @@ -2822,7 +2822,7 @@ func TestParseAttachmentDeclaration(t *testing.T) { result, errs := testParseDeclarations("pub attachment E for S {} ") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.AttachmentDeclaration{ Access: ast.AccessAll, @@ -2857,7 +2857,7 @@ func TestParseAttachmentDeclaration(t *testing.T) { }`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.CompositeDeclaration{ Access: ast.AccessNotSpecified, @@ -2903,7 +2903,7 @@ func TestParseAttachmentDeclaration(t *testing.T) { t.Parallel() _, errs := testParseDeclarations("attachment E {} ") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected 'for', got '{'", @@ -2921,7 +2921,7 @@ func TestParseAttachmentDeclaration(t *testing.T) { result, errs := testParseDeclarations("pub attachment E for S: I {} ") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.AttachmentDeclaration{ Access: ast.AccessAll, @@ -2963,7 +2963,7 @@ func TestParseAttachmentDeclaration(t *testing.T) { result, errs := testParseDeclarations("pub attachment E for S: I1, I2 {} ") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.AttachmentDeclaration{ Access: ast.AccessAll, @@ -3018,7 +3018,7 @@ func TestParseAttachmentDeclaration(t *testing.T) { }`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.AttachmentDeclaration{ Access: ast.AccessAll, @@ -3162,7 +3162,7 @@ func TestParseInterfaceDeclaration(t *testing.T) { result, errs := testParseDeclarations(" pub struct interface S { }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.InterfaceDeclaration{ Access: ast.AccessAll, @@ -3187,7 +3187,7 @@ func TestParseInterfaceDeclaration(t *testing.T) { t.Parallel() result, errs := testParseDeclarations(" pub struct interface interface { }") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected interface name, got keyword \"interface\"", @@ -3199,7 +3199,7 @@ func TestParseInterfaceDeclaration(t *testing.T) { var expected []ast.Declaration - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, expected, result, ) @@ -3225,7 +3225,7 @@ func TestParseInterfaceDeclaration(t *testing.T) { require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.InterfaceDeclaration{ Access: ast.AccessNotSpecified, @@ -3400,7 +3400,7 @@ func TestParseEnumDeclaration(t *testing.T) { result, errs := testParseDeclarations(" pub enum E { case c ; pub case d }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.CompositeDeclaration{ Access: ast.AccessAll, @@ -3450,7 +3450,7 @@ func TestParseEnumDeclaration(t *testing.T) { StaticModifierEnabled: true, }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid static modifier for enum case", @@ -3484,7 +3484,7 @@ func TestParseEnumDeclaration(t *testing.T) { NativeModifierEnabled: true, }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid native modifier for enum case", @@ -3519,7 +3519,7 @@ func TestParseTransactionDeclaration(t *testing.T) { result, errs := testParseDeclarations("transaction { execute {} }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.TransactionDeclaration{ Execute: &ast.SpecialFunctionDeclaration{ @@ -3559,7 +3559,7 @@ func TestParseTransactionDeclaration(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.TransactionDeclaration{ Fields: nil, @@ -3595,7 +3595,7 @@ func TestParseTransactionDeclaration(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.TransactionDeclaration{ Fields: []*ast.FieldDeclaration{ @@ -3788,7 +3788,7 @@ func TestParseTransactionDeclaration(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.TransactionDeclaration{ Fields: []*ast.FieldDeclaration{ @@ -4027,7 +4027,7 @@ func TestParseTransactionDeclaration(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.TransactionDeclaration{ Fields: []*ast.FieldDeclaration{ @@ -4250,7 +4250,7 @@ func TestParseFunctionAndBlock(t *testing.T) { `) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -4296,7 +4296,7 @@ func TestParseFunctionParameterWithoutLabel(t *testing.T) { `) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -4354,7 +4354,7 @@ func TestParseFunctionParameterWithLabel(t *testing.T) { `) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -4423,7 +4423,7 @@ func TestParseStructure(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.CompositeDeclaration{ Access: ast.AccessNotSpecified, @@ -4603,7 +4603,7 @@ func TestParseStructureWithConformances(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.CompositeDeclaration{ Access: ast.AccessNotSpecified, @@ -4674,7 +4674,7 @@ func TestParsePreAndPostConditions(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -4824,7 +4824,7 @@ func TestParseConditionMessage(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -5045,7 +5045,7 @@ func TestParseInterface(t *testing.T) { }, } - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{test}, actual.Declarations(), ) @@ -5063,7 +5063,7 @@ func TestParsePragmaNoArguments(t *testing.T) { result, errs := testParseDeclarations(`#pedantic`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.PragmaDeclaration{ Expression: &ast.IdentifierExpression{ @@ -5093,7 +5093,7 @@ func TestParsePragmaNoArguments(t *testing.T) { StaticModifierEnabled: true, }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid static modifier for pragma", @@ -5109,7 +5109,7 @@ func TestParsePragmaNoArguments(t *testing.T) { t.Parallel() _, errs := testParseDeclarations("static #foo") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: identifier", @@ -5131,7 +5131,7 @@ func TestParsePragmaNoArguments(t *testing.T) { NativeModifierEnabled: true, }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid native modifier for pragma", @@ -5147,7 +5147,7 @@ func TestParsePragmaNoArguments(t *testing.T) { t.Parallel() _, errs := testParseDeclarations("native #foo") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: identifier", @@ -5167,7 +5167,7 @@ func TestParsePragmaArguments(t *testing.T) { actual, err := testParseProgram(code) require.NoError(t, err) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.PragmaDeclaration{ Expression: &ast.InvocationExpression{ @@ -5212,7 +5212,7 @@ func TestParseImportWithString(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.ImportDeclaration{ Identifiers: nil, @@ -5238,7 +5238,7 @@ func TestParseImportWithAddress(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.ImportDeclaration{ Identifiers: nil, @@ -5266,7 +5266,7 @@ func TestParseImportWithIdentifiers(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.ImportDeclaration{ Identifiers: []ast.Identifier{ @@ -5305,7 +5305,7 @@ func TestParseFieldWithFromIdentifier(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.CompositeDeclaration{ Access: ast.AccessNotSpecified, @@ -5370,7 +5370,7 @@ func TestParseImportWithFromIdentifier(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.ImportDeclaration{ Identifiers: []ast.Identifier{ @@ -5415,7 +5415,7 @@ func TestParseResource(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.CompositeDeclaration{ Access: ast.AccessNotSpecified, @@ -5445,7 +5445,7 @@ func TestParseEventDeclaration(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.CompositeDeclaration{ Access: ast.AccessNotSpecified, @@ -5531,7 +5531,7 @@ func TestParseEventEmitStatement(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -5617,7 +5617,7 @@ func TestParseResourceReturnType(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -5666,7 +5666,7 @@ func TestParseMovingVariableDeclaration(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -5702,7 +5702,7 @@ func TestParseResourceParameterType(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -5761,7 +5761,7 @@ func TestParseMovingVariableDeclarationWithTypeAnnotation(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -5807,7 +5807,7 @@ func TestParseFieldDeclarationWithMoveTypeAnnotation(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.CompositeDeclaration{ Access: ast.AccessNotSpecified, @@ -5864,7 +5864,7 @@ func TestParseDestructor(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.CompositeDeclaration{ Access: ast.AccessNotSpecified, @@ -5922,7 +5922,7 @@ func TestParseCompositeDeclarationWithSemicolonSeparatedMembers(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.CompositeDeclaration{ Access: ast.AccessNotSpecified, @@ -6136,7 +6136,7 @@ func TestParsePreconditionWithUnaryNegation(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -6215,7 +6215,7 @@ func TestParseInvalidAccessModifiers(t *testing.T) { t.Parallel() _, errs := testParseDeclarations("pub #test") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid access modifier for pragma", @@ -6231,7 +6231,7 @@ func TestParseInvalidAccessModifiers(t *testing.T) { t.Parallel() _, errs := testParseDeclarations("pub transaction {}") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid access modifier for transaction", @@ -6247,7 +6247,7 @@ func TestParseInvalidAccessModifiers(t *testing.T) { t.Parallel() _, errs := testParseDeclarations("pub priv let x = 1") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid second access modifier", @@ -6277,7 +6277,7 @@ func TestParseInvalidImportWithModifier(t *testing.T) { }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid static modifier for import", @@ -6296,7 +6296,7 @@ func TestParseInvalidImportWithModifier(t *testing.T) { static import x from 0x1 `) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: identifier", @@ -6321,7 +6321,7 @@ func TestParseInvalidImportWithModifier(t *testing.T) { }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid native modifier for import", @@ -6340,7 +6340,7 @@ func TestParseInvalidImportWithModifier(t *testing.T) { native import x from 0x1 `) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: identifier", @@ -6370,7 +6370,7 @@ func TestParseInvalidEventWithModifier(t *testing.T) { }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid static modifier for event", @@ -6389,7 +6389,7 @@ func TestParseInvalidEventWithModifier(t *testing.T) { static event Foo() `) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: identifier", @@ -6414,7 +6414,7 @@ func TestParseInvalidEventWithModifier(t *testing.T) { }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid native modifier for event", @@ -6433,7 +6433,7 @@ func TestParseInvalidEventWithModifier(t *testing.T) { native event Foo() `) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: identifier", @@ -6464,7 +6464,7 @@ func TestParseCompositeWithModifier(t *testing.T) { }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid static modifier for structure", @@ -6483,7 +6483,7 @@ func TestParseCompositeWithModifier(t *testing.T) { static struct Foo() `) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: identifier", @@ -6508,7 +6508,7 @@ func TestParseCompositeWithModifier(t *testing.T) { }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid native modifier for structure", @@ -6527,7 +6527,7 @@ func TestParseCompositeWithModifier(t *testing.T) { native struct Foo() `) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: identifier", @@ -6557,7 +6557,7 @@ func TestParseTransactionWithModifier(t *testing.T) { }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid static modifier for transaction", @@ -6576,7 +6576,7 @@ func TestParseTransactionWithModifier(t *testing.T) { static transaction {} `) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: identifier", @@ -6601,7 +6601,7 @@ func TestParseTransactionWithModifier(t *testing.T) { }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid native modifier for transaction", @@ -6620,7 +6620,7 @@ func TestParseTransactionWithModifier(t *testing.T) { native transaction {} `) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: identifier", @@ -6661,7 +6661,7 @@ func TestParseNestedPragma(t *testing.T) { }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid native modifier for pragma", @@ -6678,7 +6678,7 @@ func TestParseNestedPragma(t *testing.T) { _, errs := parse("native #pragma", Config{}) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: identifier", @@ -6699,7 +6699,7 @@ func TestParseNestedPragma(t *testing.T) { StaticModifierEnabled: true, }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid static modifier for pragma", @@ -6719,7 +6719,7 @@ func TestParseNestedPragma(t *testing.T) { Config{}, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: identifier", @@ -6741,7 +6741,7 @@ func TestParseNestedPragma(t *testing.T) { NativeModifierEnabled: true, }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid static modifier for pragma", @@ -6761,7 +6761,7 @@ func TestParseNestedPragma(t *testing.T) { // For now, leading unknown identifiers are valid. // This will be rejected in Stable Cadence. - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected identifier", @@ -6784,7 +6784,7 @@ func TestParseNestedPragma(t *testing.T) { }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid static modifier after native modifier", @@ -6801,7 +6801,7 @@ func TestParseNestedPragma(t *testing.T) { _, errs := parse("pub #pragma", Config{}) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid access modifier for pragma", @@ -6823,7 +6823,7 @@ func TestParseNestedPragma(t *testing.T) { NativeModifierEnabled: true, }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid access modifier for pragma", @@ -6843,7 +6843,7 @@ func TestParseNestedPragma(t *testing.T) { // For now, leading unknown identifiers are valid. // This will be rejected in Stable Cadence. - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected identifier", @@ -6880,7 +6880,7 @@ func TestParseMemberDocStrings(t *testing.T) { require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.CompositeDeclaration{ Access: ast.AccessNotSpecified, @@ -6996,7 +6996,7 @@ func TestParseMemberDocStrings(t *testing.T) { require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.CompositeDeclaration{ Access: ast.AccessNotSpecified, @@ -7093,7 +7093,7 @@ func TestParseInvalidSpecialFunctionReturnTypeAnnotation(t *testing.T) { init(): Int } `) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid return type for initializer", diff --git a/old_parser/expression_test.go b/old_parser/expression_test.go index c90f4702cf..a91ad7d4dc 100644 --- a/old_parser/expression_test.go +++ b/old_parser/expression_test.go @@ -34,7 +34,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/errors" "github.com/onflow/cadence/parser/lexer" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" ) func TestParseSimpleInfixExpression(t *testing.T) { @@ -48,7 +48,7 @@ func TestParseSimpleInfixExpression(t *testing.T) { result, errs := testParseExpression("1+2*3") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BinaryExpression{ Operation: ast.OperationPlus, Left: &ast.IntegerExpression{ @@ -93,7 +93,7 @@ func TestParseSimpleInfixExpression(t *testing.T) { result, errs := testParseExpression(" 1 + 2 * 3 ") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BinaryExpression{ Operation: ast.OperationPlus, Left: &ast.IntegerExpression{ @@ -138,7 +138,7 @@ func TestParseSimpleInfixExpression(t *testing.T) { result, errs := testParseExpression("1 + 2 + 3") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BinaryExpression{ Operation: ast.OperationPlus, Left: &ast.BinaryExpression{ @@ -183,7 +183,7 @@ func TestParseSimpleInfixExpression(t *testing.T) { result, errs := testParseExpression("1 ?? 2 ?? 3") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BinaryExpression{ Operation: ast.OperationNilCoalesce, Left: &ast.IntegerExpression{ @@ -233,7 +233,7 @@ func TestParseAdvancedExpression(t *testing.T) { result, errs := testParseExpression("1 +- 2 -- 3") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BinaryExpression{ Operation: ast.OperationMinus, Left: &ast.BinaryExpression{ @@ -278,7 +278,7 @@ func TestParseAdvancedExpression(t *testing.T) { result, errs := testParseExpression("(1 + 2) * 3") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BinaryExpression{ Operation: ast.OperationMul, Left: &ast.BinaryExpression{ @@ -369,7 +369,7 @@ func TestParseAdvancedExpression(t *testing.T) { result, errs := testParseExpression("1 < 2 > 3") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BinaryExpression{ Operation: ast.OperationGreater, Left: &ast.BinaryExpression{ @@ -414,7 +414,7 @@ func TestParseAdvancedExpression(t *testing.T) { result, errs := testParseExpression("a ? b : c ? d : e") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.ConditionalExpression{ Test: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -460,7 +460,7 @@ func TestParseAdvancedExpression(t *testing.T) { result, errs := testParseExpression("true + false") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BinaryExpression{ Operation: ast.OperationPlus, Left: &ast.BoolExpression{ @@ -489,7 +489,7 @@ func TestParseAdvancedExpression(t *testing.T) { result, errs := testParseExpression("(<-x)") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.UnaryExpression{ Operation: ast.OperationMove, Expression: &ast.IdentifierExpression{ @@ -517,7 +517,7 @@ func TestParseArrayExpression(t *testing.T) { result, errs := testParseExpression("[ 1,2 + 3, 4 , 5 ]") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.ArrayExpression{ Values: []ast.Expression{ &ast.IntegerExpression{ @@ -585,7 +585,7 @@ func TestParseArrayExpression(t *testing.T) { result, errs := testParseExpression("[ 1 , \n 2 \n , \n\n 3 \n\n\n]") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.ArrayExpression{ Values: []ast.Expression{ &ast.IntegerExpression{ @@ -632,7 +632,7 @@ func TestParseArrayExpression(t *testing.T) { result, errs := testParseExpression("[\n]") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.ArrayExpression{ Range: ast.Range{ StartPos: ast.Position{Line: 1, Column: 0, Offset: 0}, @@ -656,7 +656,7 @@ func TestParseDictionaryExpression(t *testing.T) { result, errs := testParseExpression("{ 1:2 + 3, 4 : 5 }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.DictionaryExpression{ Entries: []ast.DictionaryEntry{ { @@ -728,7 +728,7 @@ func TestParseDictionaryExpression(t *testing.T) { result, errs := testParseExpression("{ 1 : 2 , \n 3 \n : \n 4 \n , \n\n 5 \n\n : \n\n 6 \n\n }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.DictionaryExpression{ Entries: []ast.DictionaryEntry{ { @@ -808,7 +808,7 @@ func TestParseDictionaryExpression(t *testing.T) { result, errs := testParseExpression("{\n}") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.DictionaryExpression{ Range: ast.Range{ StartPos: ast.Position{Line: 1, Column: 0, Offset: 0}, @@ -829,7 +829,7 @@ func TestParseIndexExpression(t *testing.T) { result, errs := testParseExpression("a[0]") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IndexExpression{ TargetExpression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -861,7 +861,7 @@ func TestParseIndexExpression(t *testing.T) { result, errs := testParseExpression("a [ 0 ]") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IndexExpression{ TargetExpression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -893,7 +893,7 @@ func TestParseIndexExpression(t *testing.T) { result, errs := testParseExpression("a [foo]") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IndexExpression{ TargetExpression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -928,7 +928,7 @@ func TestParseIdentifier(t *testing.T) { result, errs := testParseExpression("a + 3") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BinaryExpression{ Operation: ast.OperationPlus, Left: &ast.IdentifierExpression{ @@ -959,7 +959,7 @@ func TestParsePath(t *testing.T) { result, errs := testParseExpression("/foo/bar") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.PathExpression{ Domain: ast.Identifier{ Identifier: "foo", @@ -986,7 +986,7 @@ func TestParseString(t *testing.T) { result, errs := testParseExpression("\"\"") assert.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.StringExpression{ Value: "", Range: ast.Range{ @@ -1003,7 +1003,7 @@ func TestParseString(t *testing.T) { t.Parallel() result, errs := testParseExpression("\"") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid end of string literal: missing '\"'", @@ -1013,7 +1013,7 @@ func TestParseString(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.StringExpression{ Value: "", Range: ast.Range{ @@ -1030,7 +1030,7 @@ func TestParseString(t *testing.T) { t.Parallel() result, errs := testParseExpression("\"\n") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid end of string literal: missing '\"'", @@ -1040,7 +1040,7 @@ func TestParseString(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.StringExpression{ Value: "", Range: ast.Range{ @@ -1056,7 +1056,7 @@ func TestParseString(t *testing.T) { t.Parallel() result, errs := testParseExpression("\"t") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid end of string literal: missing '\"'", @@ -1066,7 +1066,7 @@ func TestParseString(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.StringExpression{ Value: "t", Range: ast.Range{ @@ -1083,7 +1083,7 @@ func TestParseString(t *testing.T) { t.Parallel() result, errs := testParseExpression("\"t\n") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid end of string literal: missing '\"'", @@ -1093,7 +1093,7 @@ func TestParseString(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.StringExpression{ Value: "t", Range: ast.Range{ @@ -1110,7 +1110,7 @@ func TestParseString(t *testing.T) { t.Parallel() result, errs := testParseExpression("\"\\") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "incomplete escape sequence: missing character after escape character", @@ -1124,7 +1124,7 @@ func TestParseString(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.StringExpression{ Value: "", Range: ast.Range{ @@ -1143,7 +1143,7 @@ func TestParseString(t *testing.T) { result, errs := testParseExpression(`"te\tst\"te\u{1F3CE}\u{FE0F}xt"`) assert.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.StringExpression{ Value: "te\tst\"te\U0001F3CE\uFE0Fxt", Range: ast.Range{ @@ -1160,7 +1160,7 @@ func TestParseString(t *testing.T) { t.Parallel() result, errs := testParseExpression(`"te\Xst"`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid escape character: 'X'", @@ -1170,7 +1170,7 @@ func TestParseString(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.StringExpression{ Value: "test", Range: ast.Range{ @@ -1187,7 +1187,7 @@ func TestParseString(t *testing.T) { t.Parallel() result, errs := testParseExpression(`"te\u`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "incomplete Unicode escape sequence: missing character '{' after escape character", @@ -1201,7 +1201,7 @@ func TestParseString(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.StringExpression{ Value: "te", Range: ast.Range{ @@ -1218,7 +1218,7 @@ func TestParseString(t *testing.T) { t.Parallel() result, errs := testParseExpression(`"te\us`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid Unicode escape sequence: expected '{', got 's'", @@ -1232,7 +1232,7 @@ func TestParseString(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.StringExpression{ Value: "te", Range: ast.Range{ @@ -1249,7 +1249,7 @@ func TestParseString(t *testing.T) { t.Parallel() result, errs := testParseExpression(`"te\u{`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "incomplete Unicode escape sequence: missing character '}' after escape character", @@ -1263,7 +1263,7 @@ func TestParseString(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.StringExpression{ Value: "te", Range: ast.Range{ @@ -1282,7 +1282,7 @@ func TestParseString(t *testing.T) { result, errs := testParseExpression(`"te\u{}"`) assert.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.StringExpression{ Value: "te", Range: ast.Range{ @@ -1309,7 +1309,7 @@ func TestParseString(t *testing.T) { ) assert.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.StringExpression{ Value: "test JJJJ KKKK LLLL MMMM NNNN OOOO", Range: ast.Range{ @@ -1326,7 +1326,7 @@ func TestParseString(t *testing.T) { t.Parallel() result, errs := testParseExpression(`"te\u{X}st"`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid Unicode escape sequence: expected hex digit, got 'X'", @@ -1336,7 +1336,7 @@ func TestParseString(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.StringExpression{ Value: "test", Range: ast.Range{ @@ -1360,7 +1360,7 @@ func TestParseInvocation(t *testing.T) { result, errs := testParseExpression("f()") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.InvocationExpression{ InvokedExpression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -1383,7 +1383,7 @@ func TestParseInvocation(t *testing.T) { result, errs := testParseExpression("f ()") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.InvocationExpression{ InvokedExpression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -1406,7 +1406,7 @@ func TestParseInvocation(t *testing.T) { result, errs := testParseExpression("f ( )") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.InvocationExpression{ InvokedExpression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -1429,7 +1429,7 @@ func TestParseInvocation(t *testing.T) { result, errs := testParseExpression("f(1)") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.InvocationExpression{ InvokedExpression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -1466,7 +1466,7 @@ func TestParseInvocation(t *testing.T) { result, errs := testParseExpression("f(label:1)") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.InvocationExpression{ InvokedExpression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -1505,7 +1505,7 @@ func TestParseInvocation(t *testing.T) { result, errs := testParseExpression("f(1,2)") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.InvocationExpression{ InvokedExpression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -1555,7 +1555,7 @@ func TestParseInvocation(t *testing.T) { result, errs := testParseExpression("f(a:1,b:2)") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.InvocationExpression{ InvokedExpression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -1607,7 +1607,7 @@ func TestParseInvocation(t *testing.T) { t.Parallel() _, errs := testParseExpression("f(,,)") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected argument or end of argument list, got ','", @@ -1623,7 +1623,7 @@ func TestParseInvocation(t *testing.T) { t.Parallel() _, errs := testParseExpression("f(1,,)") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected argument or end of argument list, got ','", @@ -1639,7 +1639,7 @@ func TestParseInvocation(t *testing.T) { t.Parallel() _, errs := testParseExpression("f(1 2)") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected argument in argument list (expecting delimiter or end of argument list)," + @@ -1658,7 +1658,7 @@ func TestParseInvocation(t *testing.T) { result, errs := testParseExpression("f(1,g(2))") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.InvocationExpression{ InvokedExpression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -1724,7 +1724,7 @@ func TestParseInvocation(t *testing.T) { result, errs := testParseExpression("f(1,g(\"test\"))") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.InvocationExpression{ InvokedExpression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -1793,7 +1793,7 @@ func TestParseMemberExpression(t *testing.T) { result, errs := testParseExpression("f.n") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.MemberExpression{ Expression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -1818,7 +1818,7 @@ func TestParseMemberExpression(t *testing.T) { result, errs := testParseExpression("f .n") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.MemberExpression{ Expression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -1841,7 +1841,7 @@ func TestParseMemberExpression(t *testing.T) { t.Parallel() result, errs := testParseExpression("f.") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected member name, got EOF", @@ -1851,7 +1851,7 @@ func TestParseMemberExpression(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.MemberExpression{ Expression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -1872,7 +1872,7 @@ func TestParseMemberExpression(t *testing.T) { result, errs := testParseExpression("f.n * 3") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BinaryExpression{ Operation: ast.OperationMul, Left: &ast.MemberExpression{ @@ -1909,7 +1909,7 @@ func TestParseMemberExpression(t *testing.T) { result, errs := testParseExpression("3 * f.n") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BinaryExpression{ Operation: ast.OperationMul, Left: &ast.IntegerExpression{ @@ -1946,7 +1946,7 @@ func TestParseMemberExpression(t *testing.T) { result, errs := testParseExpression("f?.n") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.MemberExpression{ Optional: true, Expression: &ast.IdentifierExpression{ @@ -1975,7 +1975,7 @@ func TestParseMemberExpression(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -2020,7 +2020,7 @@ func TestParseBlockComment(t *testing.T) { result, errs := testParseExpression(" /* test foo/* bar */ asd*/ true") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BoolExpression{ Value: true, Range: ast.Range{ @@ -2039,7 +2039,7 @@ func TestParseBlockComment(t *testing.T) { result, errs := testParseExpression(" /*test foo*/ /* bar */ true") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BoolExpression{ Value: true, Range: ast.Range{ @@ -2058,7 +2058,7 @@ func TestParseBlockComment(t *testing.T) { result, errs := testParseExpression(" 1/*test foo*/+/* bar */ 2 ") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BinaryExpression{ Operation: ast.OperationPlus, Left: &ast.IntegerExpression{ @@ -2089,7 +2089,7 @@ func TestParseBlockComment(t *testing.T) { t.Parallel() _, errs := testParseExpression(" /* test foo/* bar */ asd*/ true */ bar") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ // `true */ bar` is parsed as infix operation of path &SyntaxError{ @@ -2110,7 +2110,7 @@ func TestParseBlockComment(t *testing.T) { t.Parallel() _, errs := testParseExpression(" /* test foo/* bar */ asd true ") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ // `true */ bar` is parsed as infix operation of path &SyntaxError{ @@ -2185,7 +2185,7 @@ func TestParseBlockComment(t *testing.T) { }, Config{}, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token identifier in block comment", @@ -2244,7 +2244,7 @@ func TestParseReference(t *testing.T) { result, errs := testParseExpression("& t as T") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.ReferenceExpression{ Expression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -2265,7 +2265,7 @@ func TestParseReference(t *testing.T) { const code = `&y[z]` _, errs := testParseExpression(code) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected casting expression", @@ -2287,7 +2287,7 @@ func TestParseReference(t *testing.T) { const code = `&x[y]? as &Z?` _, errs := testParseExpression(code) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected casting expression", @@ -2312,7 +2312,7 @@ func TestParseNilCoelesceReference(t *testing.T) { `) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BinaryExpression{ Operation: ast.OperationNilCoalesce, Left: &ast.ReferenceExpression{ @@ -2394,7 +2394,7 @@ func TestParseCasts(t *testing.T) { result, errs := testParseExpression(" t as T") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.CastingExpression{ Operation: ast.OperationCast, Expression: &ast.IdentifierExpression{ @@ -2424,7 +2424,7 @@ func TestParseCasts(t *testing.T) { result, errs := testParseExpression(" t as? T") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.CastingExpression{ Operation: ast.OperationFailableCast, Expression: &ast.IdentifierExpression{ @@ -2455,7 +2455,7 @@ func TestParseCasts(t *testing.T) { result, errs := testParseExpression(" t as! T") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.CastingExpression{ Operation: ast.OperationForceCast, Expression: &ast.IdentifierExpression{ @@ -2490,7 +2490,7 @@ func TestParseForceExpression(t *testing.T) { result, errs := testParseExpression("t!") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.ForceExpression{ Expression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -2511,7 +2511,7 @@ func TestParseForceExpression(t *testing.T) { result, errs := testParseExpression(" t ! ") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.ForceExpression{ Expression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -2532,7 +2532,7 @@ func TestParseForceExpression(t *testing.T) { result, errs := testParseExpression("<-t!") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.UnaryExpression{ Operation: ast.OperationMove, Expression: &ast.ForceExpression{ @@ -2557,7 +2557,7 @@ func TestParseForceExpression(t *testing.T) { result, errs := testParseExpression("10 * t!") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BinaryExpression{ Operation: ast.OperationMul, Left: &ast.IntegerExpression{ @@ -2589,7 +2589,7 @@ func TestParseForceExpression(t *testing.T) { result, errs := testParseStatements("x\n!y") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.ExpressionStatement{ Expression: &ast.IdentifierExpression{ @@ -2623,7 +2623,7 @@ func TestParseForceExpression(t *testing.T) { result, errs := testParseStatements("x\n.y!") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.ExpressionStatement{ Expression: &ast.ForceExpression{ @@ -2653,7 +2653,7 @@ func TestParseForceExpression(t *testing.T) { t.Parallel() result, errs := testParseStatements("x. y") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid whitespace after '.'", @@ -2663,7 +2663,7 @@ func TestParseForceExpression(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.ExpressionStatement{ Expression: &ast.MemberExpression{ @@ -2697,7 +2697,7 @@ func TestParseCreate(t *testing.T) { result, errs := testParseExpression("create T()") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.CreateExpression{ InvocationExpression: &ast.InvocationExpression{ InvokedExpression: &ast.IdentifierExpression{ @@ -2723,7 +2723,7 @@ func TestParseNil(t *testing.T) { result, errs := testParseExpression(" nil") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.NilExpression{ Pos: ast.Position{Line: 1, Column: 1, Offset: 1}, }, @@ -2742,7 +2742,7 @@ func TestParseDestroy(t *testing.T) { result, errs := testParseExpression("destroy t") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.DestroyExpression{ Expression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -2768,7 +2768,7 @@ func TestParseAttach(t *testing.T) { result, errs := testParseExpression("attach E() to r") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.AttachExpression{ Base: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -2797,7 +2797,7 @@ func TestParseAttach(t *testing.T) { t.Parallel() _, errs := testParseExpression("attach A to E") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected token '('", @@ -2815,7 +2815,7 @@ func TestParseAttach(t *testing.T) { result, errs := testParseExpression("attach A() to attach B() to r") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.AttachExpression{ Base: &ast.AttachExpression{ Base: &ast.IdentifierExpression{ @@ -2857,7 +2857,7 @@ func TestParseAttach(t *testing.T) { t.Parallel() _, errs := testParseExpression("attach A()") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected 'to', got EOF", @@ -2873,7 +2873,7 @@ func TestParseAttach(t *testing.T) { t.Parallel() _, errs := testParseExpression("attach E() to") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected end of program", @@ -2892,7 +2892,7 @@ func TestParseLineComment(t *testing.T) { result, errs := testParseExpression(" //// // this is a comment\n 1 / 2") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BinaryExpression{ Operation: ast.OperationDiv, Left: &ast.IntegerExpression{ @@ -2929,7 +2929,7 @@ func TestParseFunctionExpression(t *testing.T) { result, errs := testParseExpression("fun () { }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.FunctionExpression{ ParameterList: &ast.ParameterList{ Parameters: nil, @@ -2959,7 +2959,7 @@ func TestParseFunctionExpression(t *testing.T) { result, errs := testParseExpression("fun (): X { }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.FunctionExpression{ ParameterList: &ast.ParameterList{ Parameters: nil, @@ -3001,7 +3001,7 @@ func TestParseIntegerLiterals(t *testing.T) { t.Parallel() result, errs := testParseExpression(`0b`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "missing digits", @@ -3020,7 +3020,7 @@ func TestParseIntegerLiterals(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("0b"), Value: new(big.Int), @@ -3041,7 +3041,7 @@ func TestParseIntegerLiterals(t *testing.T) { result, errs := testParseExpression(`0b101010`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("0b101010"), Value: big.NewInt(42), @@ -3060,7 +3060,7 @@ func TestParseIntegerLiterals(t *testing.T) { result, errs := testParseExpression(`0b001000`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("0b001000"), Value: big.NewInt(8), @@ -3081,7 +3081,7 @@ func TestParseIntegerLiterals(t *testing.T) { result, errs := testParseExpression(`0b101010_101010`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("0b101010_101010"), Value: big.NewInt(2730), @@ -3100,7 +3100,7 @@ func TestParseIntegerLiterals(t *testing.T) { t.Parallel() result, errs := testParseExpression(`0b_101010_101010`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &InvalidIntegerLiteralError{ Literal: "0b_101010_101010", @@ -3115,7 +3115,7 @@ func TestParseIntegerLiterals(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("0b_101010_101010"), Value: big.NewInt(2730), @@ -3134,7 +3134,7 @@ func TestParseIntegerLiterals(t *testing.T) { t.Parallel() result, errs := testParseExpression(`0b101010_101010_`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &InvalidIntegerLiteralError{ Literal: "0b101010_101010_", @@ -3149,7 +3149,7 @@ func TestParseIntegerLiterals(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("0b101010_101010_"), Value: big.NewInt(2730), @@ -3168,7 +3168,7 @@ func TestParseIntegerLiterals(t *testing.T) { t.Parallel() result, errs := testParseExpression(`0o`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "missing digits", @@ -3187,7 +3187,7 @@ func TestParseIntegerLiterals(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("0o"), Value: new(big.Int), @@ -3208,7 +3208,7 @@ func TestParseIntegerLiterals(t *testing.T) { result, errs := testParseExpression(`0o32`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("0o32"), Value: big.NewInt(26), @@ -3229,7 +3229,7 @@ func TestParseIntegerLiterals(t *testing.T) { result, errs := testParseExpression(`0o32_45`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("0o32_45"), Value: big.NewInt(1701), @@ -3248,7 +3248,7 @@ func TestParseIntegerLiterals(t *testing.T) { t.Parallel() result, errs := testParseExpression(`0o_32_45`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &InvalidIntegerLiteralError{ Literal: "0o_32_45", @@ -3263,7 +3263,7 @@ func TestParseIntegerLiterals(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("0o_32_45"), Value: big.NewInt(1701), @@ -3282,7 +3282,7 @@ func TestParseIntegerLiterals(t *testing.T) { t.Parallel() result, errs := testParseExpression(`0o32_45_`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &InvalidIntegerLiteralError{ Literal: "0o32_45_", @@ -3297,7 +3297,7 @@ func TestParseIntegerLiterals(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("0o32_45_"), Value: big.NewInt(1701), @@ -3318,7 +3318,7 @@ func TestParseIntegerLiterals(t *testing.T) { result, errs := testParseExpression(`1234567890`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("1234567890"), Value: big.NewInt(1234567890), @@ -3339,7 +3339,7 @@ func TestParseIntegerLiterals(t *testing.T) { result, errs := testParseExpression(`1_234_567_890`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("1_234_567_890"), Value: big.NewInt(1234567890), @@ -3358,7 +3358,7 @@ func TestParseIntegerLiterals(t *testing.T) { t.Parallel() result, errs := testParseExpression(`1_234_567_890_`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &InvalidIntegerLiteralError{ Literal: "1_234_567_890_", @@ -3373,7 +3373,7 @@ func TestParseIntegerLiterals(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("1_234_567_890_"), Value: big.NewInt(1234567890), @@ -3392,7 +3392,7 @@ func TestParseIntegerLiterals(t *testing.T) { t.Parallel() result, errs := testParseExpression(`0x`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "missing digits", @@ -3411,7 +3411,7 @@ func TestParseIntegerLiterals(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("0x"), Value: new(big.Int), @@ -3432,7 +3432,7 @@ func TestParseIntegerLiterals(t *testing.T) { result, errs := testParseExpression(`0xf2`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("0xf2"), Value: big.NewInt(242), @@ -3453,7 +3453,7 @@ func TestParseIntegerLiterals(t *testing.T) { result, errs := testParseExpression(`0xf2_09`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("0xf2_09"), Value: big.NewInt(61961), @@ -3472,7 +3472,7 @@ func TestParseIntegerLiterals(t *testing.T) { t.Parallel() result, errs := testParseExpression(`0x_f2_09`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &InvalidIntegerLiteralError{ Literal: "0x_f2_09", @@ -3487,7 +3487,7 @@ func TestParseIntegerLiterals(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("0x_f2_09"), Value: big.NewInt(61961), @@ -3506,7 +3506,7 @@ func TestParseIntegerLiterals(t *testing.T) { t.Parallel() result, errs := testParseExpression(`0xf2_09_`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &InvalidIntegerLiteralError{ Literal: `0xf2_09_`, @@ -3521,7 +3521,7 @@ func TestParseIntegerLiterals(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("0xf2_09_"), Value: big.NewInt(61961), @@ -3542,7 +3542,7 @@ func TestParseIntegerLiterals(t *testing.T) { result, errs := testParseExpression(`0`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("0"), Value: big.NewInt(0), @@ -3563,7 +3563,7 @@ func TestParseIntegerLiterals(t *testing.T) { result, errs := testParseExpression(`01`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("01"), Value: big.NewInt(1), @@ -3584,7 +3584,7 @@ func TestParseIntegerLiterals(t *testing.T) { result, errs := testParseExpression(`09`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("09"), Value: big.NewInt(9), @@ -3605,7 +3605,7 @@ func TestParseIntegerLiterals(t *testing.T) { result, errs := testParseExpression("00123") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("00123"), Value: big.NewInt(123), @@ -3624,7 +3624,7 @@ func TestParseIntegerLiterals(t *testing.T) { t.Parallel() result, errs := testParseExpression(`0z123`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid number literal prefix: 'z'", @@ -3643,7 +3643,7 @@ func TestParseIntegerLiterals(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("0z123"), Value: new(big.Int), @@ -3664,7 +3664,7 @@ func TestParseIntegerLiterals(t *testing.T) { result, errs := testParseExpression(`0_100`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("0_100"), Value: big.NewInt(100), @@ -3685,7 +3685,7 @@ func TestParseIntegerLiterals(t *testing.T) { result, errs := testParseExpression(`1_100`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("1_100"), Value: big.NewInt(1100), @@ -3708,7 +3708,7 @@ func TestParseIntegerLiterals(t *testing.T) { result, errs := testParseExpression(`_100`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IdentifierExpression{ Identifier: ast.Identifier{ Identifier: "_100", @@ -3731,7 +3731,7 @@ func TestParseFixedPoint(t *testing.T) { result, errs := testParseExpression("1234_5678_90.0009_8765_4321") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.FixedPointExpression{ PositiveLiteral: []byte("1234_5678_90.0009_8765_4321"), Negative: false, @@ -3754,7 +3754,7 @@ func TestParseFixedPoint(t *testing.T) { result, errs := testParseExpression("0.1") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.FixedPointExpression{ PositiveLiteral: []byte("0.1"), Negative: false, @@ -3775,7 +3775,7 @@ func TestParseFixedPoint(t *testing.T) { t.Parallel() result, errs := testParseExpression("0.") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "missing fractional digits", @@ -3785,7 +3785,7 @@ func TestParseFixedPoint(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.FixedPointExpression{ PositiveLiteral: []byte("0."), Negative: false, @@ -3813,7 +3813,7 @@ func TestParseLessThanOrTypeArguments(t *testing.T) { result, errs := testParseExpression("1 < 2") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BinaryExpression{ Operation: ast.OperationLess, Left: &ast.IntegerExpression{ @@ -3846,7 +3846,7 @@ func TestParseLessThanOrTypeArguments(t *testing.T) { result, errs := testParseExpression("a < > ()") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.InvocationExpression{ InvokedExpression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -3870,7 +3870,7 @@ func TestParseLessThanOrTypeArguments(t *testing.T) { result, errs := testParseExpression("a < { K : V } > ( 1 )") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.InvocationExpression{ InvokedExpression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -3930,7 +3930,7 @@ func TestParseLessThanOrTypeArguments(t *testing.T) { result, errs := testParseExpression("a < { K : V } , @R , [ S ] > ( 1 , 2 )") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.InvocationExpression{ InvokedExpression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -4028,7 +4028,7 @@ func TestParseLessThanOrTypeArguments(t *testing.T) { result, errs := testParseExpression("1 + a<>()") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BinaryExpression{ Operation: ast.OperationPlus, Left: &ast.IntegerExpression{ @@ -4064,7 +4064,7 @@ func TestParseLessThanOrTypeArguments(t *testing.T) { result, errs := testParseExpression("a>()") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.InvocationExpression{ InvokedExpression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -4114,7 +4114,7 @@ func TestParseLessThanOrTypeArguments(t *testing.T) { result, errs := testParseExpression("a >()") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.InvocationExpression{ InvokedExpression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -4164,7 +4164,7 @@ func TestParseLessThanOrTypeArguments(t *testing.T) { result, errs := testParseExpression("0 + 1 < 2") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BinaryExpression{ Operation: ast.OperationLess, Left: &ast.BinaryExpression{ @@ -4209,7 +4209,7 @@ func TestParseLessThanOrTypeArguments(t *testing.T) { result, errs := testParseExpression("0 + 1 << 2") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BinaryExpression{ Operation: ast.OperationBitwiseLeftShift, Left: &ast.BinaryExpression{ @@ -4254,7 +4254,7 @@ func TestParseLessThanOrTypeArguments(t *testing.T) { result, errs := testParseExpression("0 + 1 > 2") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BinaryExpression{ Operation: ast.OperationGreater, Left: &ast.BinaryExpression{ @@ -4299,7 +4299,7 @@ func TestParseLessThanOrTypeArguments(t *testing.T) { result, errs := testParseExpression("0 + 1 >> 2") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BinaryExpression{ Operation: ast.OperationBitwiseRightShift, Left: &ast.BinaryExpression{ @@ -4348,7 +4348,7 @@ func TestParseBoolExpression(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -4385,7 +4385,7 @@ func TestParseIdentifierExpression(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -4421,7 +4421,7 @@ func TestParseArrayExpressionInVariableDeclaration(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -4476,7 +4476,7 @@ func TestParseDictionaryExpressionInVariableDeclaration(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -4549,7 +4549,7 @@ func TestParseInvocationExpressionWithoutLabels(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -4617,7 +4617,7 @@ func TestParseInvocationExpressionWithLabels(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -4704,7 +4704,7 @@ func TestParseOptionalMemberExpression(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -4748,7 +4748,7 @@ func TestParseIndexExpressionInVariableDeclaration(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -4799,7 +4799,7 @@ func TestParseUnaryExpression(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -4839,7 +4839,7 @@ func TestParseOrExpression(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -4886,7 +4886,7 @@ func TestParseAndExpression(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -4933,7 +4933,7 @@ func TestParseEqualityExpression(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -4980,7 +4980,7 @@ func TestParseRelationalExpression(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -5031,7 +5031,7 @@ func TestParseAdditiveExpression(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -5082,7 +5082,7 @@ func TestParseMultiplicativeExpression(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -5133,7 +5133,7 @@ func TestParseFunctionExpressionAndReturn(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -5207,7 +5207,7 @@ func TestParseLeftAssociativity(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -5270,7 +5270,7 @@ func TestParseNegativeInteger(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -5309,7 +5309,7 @@ func TestParseNegativeFixedPoint(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -5352,7 +5352,7 @@ func TestParseTernaryRightAssociativity(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -5455,7 +5455,7 @@ func TestParseVoidLiteral(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -5501,7 +5501,7 @@ func TestParseMissingReturnType(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -5643,7 +5643,7 @@ func TestParseExpression(t *testing.T) { }, } - utils.AssertEqualWithDiff(t, expected, actual) + AssertEqualWithDiff(t, expected, actual) } func TestParseStringEscapes(t *testing.T) { @@ -5671,7 +5671,7 @@ func TestParseStringEscapes(t *testing.T) { }, } - utils.AssertEqualWithDiff(t, expected, actual) + AssertEqualWithDiff(t, expected, actual) } func TestParseStringWithUnicode(t *testing.T) { @@ -5699,7 +5699,7 @@ func TestParseStringWithUnicode(t *testing.T) { }, } - utils.AssertEqualWithDiff(t, expected, actual) + AssertEqualWithDiff(t, expected, actual) } func TestParseNilCoalescing(t *testing.T) { @@ -5712,7 +5712,7 @@ func TestParseNilCoalescing(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -5758,7 +5758,7 @@ func TestParseNilCoalescingRightAssociativity(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -5861,7 +5861,7 @@ func TestParseFailableCasting(t *testing.T) { failableDowncast.ParentVariableDeclaration = variableDeclaration - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ variableDeclaration, }, @@ -5879,7 +5879,7 @@ func TestParseMoveOperator(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -5937,7 +5937,7 @@ func TestParseFunctionExpressionWithResourceTypeAnnotation(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ @@ -6046,7 +6046,7 @@ func TestParseFailableCastingResourceTypeAnnotation(t *testing.T) { failableDowncast.ParentVariableDeclaration = variableDeclaration - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ variableDeclaration, }, @@ -6100,7 +6100,7 @@ func TestParseCasting(t *testing.T) { cast.ParentVariableDeclaration = variableDeclaration - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ variableDeclaration, }, @@ -6131,7 +6131,7 @@ func TestParseReferenceInVariableDeclaration(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -6189,7 +6189,7 @@ func TestParseFixedPointExpression(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -6229,7 +6229,7 @@ func TestParseFixedPointExpressionZeroInteger(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -6269,7 +6269,7 @@ func TestParsePathLiteral(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -6309,7 +6309,7 @@ func TestParseBitwiseExpression(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, diff --git a/old_parser/lexer/lexer_test.go b/old_parser/lexer/lexer_test.go index 1e48fed700..be9ee63f08 100644 --- a/old_parser/lexer/lexer_test.go +++ b/old_parser/lexer/lexer_test.go @@ -28,7 +28,7 @@ import ( "go.uber.org/goleak" "github.com/onflow/cadence/ast" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" ) func TestMain(m *testing.M) { @@ -64,7 +64,7 @@ func testLex(t *testing.T, input string, expected []token) { bytes := []byte(input) withTokens(Lex(bytes, nil), func(actualTokens []Token) { - utils.AssertEqualWithDiff(t, expectedTokens, actualTokens) + AssertEqualWithDiff(t, expectedTokens, actualTokens) require.Len(t, actualTokens, len(expectedTokens)) for i, expectedToken := range expected { diff --git a/old_parser/parser_test.go b/old_parser/parser_test.go index 156ae7c286..ecff29407f 100644 --- a/old_parser/parser_test.go +++ b/old_parser/parser_test.go @@ -33,7 +33,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/errors" "github.com/onflow/cadence/parser/lexer" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" ) func TestMain(m *testing.M) { @@ -240,7 +240,7 @@ func TestParseBuffering(t *testing.T) { Config{}, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected token identifier with string value c", @@ -483,7 +483,7 @@ func TestParseBuffering(t *testing.T) { Config{}, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected token identifier with string value d", @@ -511,7 +511,7 @@ func TestParseBuffering(t *testing.T) { } ` _, err := testParseProgram(code) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected token identifier", @@ -536,7 +536,7 @@ func TestParseBuffering(t *testing.T) { ` _, err := testParseProgram(code) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected token identifier", @@ -703,7 +703,7 @@ func TestParseArgumentList(t *testing.T) { t.Parallel() _, errs := testParseArgumentList(`xyz`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected token '('", @@ -722,7 +722,7 @@ func TestParseArgumentList(t *testing.T) { var expected ast.Arguments - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, expected, result, ) @@ -747,7 +747,7 @@ func TestParseArgumentList(t *testing.T) { result, errs := testParseArgumentList(`(1, b: true)`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, ast.Arguments{ { Label: "", @@ -832,7 +832,7 @@ func TestParseBufferedErrors(t *testing.T) { // there is another error (missing closing parenthesis after). _, errs := testParseExpression("a(") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "missing type annotation after comma", @@ -871,7 +871,7 @@ func TestParseExpressionDepthLimit(t *testing.T) { _, err := testParseProgram(code) require.Error(t, err) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ ExpressionDepthLimitReachedError{ Pos: ast.Position{ @@ -907,7 +907,7 @@ func TestParseTypeDepthLimit(t *testing.T) { _, err := testParseProgram(code) require.Error(t, err) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ TypeDepthLimitReachedError{ Pos: ast.Position{ @@ -933,7 +933,7 @@ func TestParseLocalReplayLimit(t *testing.T) { code := []byte(builder.String()) _, err := ParseProgram(nil, code, Config{}) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, Error{ Code: code, Errors: []error{ @@ -968,7 +968,7 @@ func TestParseGlobalReplayLimit(t *testing.T) { code := []byte(builder.String()) _, err := ParseProgram(nil, code, Config{}) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, Error{ Code: code, Errors: []error{ diff --git a/old_parser/statement_test.go b/old_parser/statement_test.go index e22d1c2b94..ce5d17d25d 100644 --- a/old_parser/statement_test.go +++ b/old_parser/statement_test.go @@ -26,7 +26,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/ast" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" ) func TestParseReplInput(t *testing.T) { @@ -63,7 +63,7 @@ func TestParseReturnStatement(t *testing.T) { result, errs := testParseStatements("return") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.ReturnStatement{ Range: ast.Range{ @@ -83,7 +83,7 @@ func TestParseReturnStatement(t *testing.T) { result, errs := testParseStatements("return 1") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.ReturnStatement{ Expression: &ast.IntegerExpression{ @@ -112,7 +112,7 @@ func TestParseReturnStatement(t *testing.T) { result, errs := testParseStatements("return \n1") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.ReturnStatement{ Range: ast.Range{ @@ -143,7 +143,7 @@ func TestParseReturnStatement(t *testing.T) { result, errs := testParseStatements("return ;\n1") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.ReturnStatement{ Range: ast.Range{ @@ -179,7 +179,7 @@ func TestParseIfStatement(t *testing.T) { result, errs := testParseStatements("if true { }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.IfStatement{ Test: &ast.BoolExpression{ @@ -210,7 +210,7 @@ func TestParseIfStatement(t *testing.T) { result, errs := testParseStatements("if true { 1 ; 2 }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.IfStatement{ Test: &ast.BoolExpression{ @@ -264,7 +264,7 @@ func TestParseIfStatement(t *testing.T) { result, errs := testParseStatements("if true { 1 \n 2 }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.IfStatement{ Test: &ast.BoolExpression{ @@ -318,7 +318,7 @@ func TestParseIfStatement(t *testing.T) { result, errs := testParseStatements("if true { 1 } else { 2 }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.IfStatement{ Test: &ast.BoolExpression{ @@ -380,7 +380,7 @@ func TestParseIfStatement(t *testing.T) { result, errs := testParseStatements("if true{1}else if true {2} else{3}") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.IfStatement{ Test: &ast.BoolExpression{ @@ -514,7 +514,7 @@ func TestParseIfStatement(t *testing.T) { expected.Test.(*ast.VariableDeclaration).ParentIfStatement = expected - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ expected, }, @@ -564,7 +564,7 @@ func TestParseIfStatement(t *testing.T) { expected.Test.(*ast.VariableDeclaration).ParentIfStatement = expected - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ expected, }, @@ -585,7 +585,7 @@ func TestParseWhileStatement(t *testing.T) { result, errs := testParseStatements("while true { }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.WhileStatement{ Test: &ast.BoolExpression{ @@ -621,7 +621,7 @@ func TestParseAssignmentStatement(t *testing.T) { result, errs := testParseStatements("x=1") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.AssignmentStatement{ Target: &ast.IdentifierExpression{ @@ -656,7 +656,7 @@ func TestParseAssignmentStatement(t *testing.T) { result, errs := testParseStatements(" x = 1") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.AssignmentStatement{ Target: &ast.IdentifierExpression{ @@ -691,7 +691,7 @@ func TestParseAssignmentStatement(t *testing.T) { result, errs := testParseStatements(" x <- 1") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.AssignmentStatement{ Target: &ast.IdentifierExpression{ @@ -726,7 +726,7 @@ func TestParseAssignmentStatement(t *testing.T) { result, errs := testParseStatements(" x <-! 1") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.AssignmentStatement{ Target: &ast.IdentifierExpression{ @@ -766,7 +766,7 @@ func TestParseSwapStatement(t *testing.T) { result, errs := testParseStatements(" x <-> y") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.SwapStatement{ Left: &ast.IdentifierExpression{ @@ -799,7 +799,7 @@ func TestParseForStatement(t *testing.T) { result, errs := testParseStatements("for x in y { }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.ForStatement{ Identifier: ast.Identifier{ @@ -838,7 +838,7 @@ func TestParseForStatementIndexBinding(t *testing.T) { result, errs := testParseStatements("for i, x in y { }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.ForStatement{ Identifier: ast.Identifier{ @@ -874,7 +874,7 @@ func TestParseForStatementIndexBinding(t *testing.T) { t.Parallel() _, errs := testParseStatements("for i x in y { }") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected keyword \"in\", got identifier", @@ -894,7 +894,7 @@ func TestParseForStatementIndexBinding(t *testing.T) { t.Parallel() _, errs := testParseStatements("for in y { }") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected identifier, got keyword \"in\"", @@ -921,7 +921,7 @@ func TestParseEmit(t *testing.T) { result, errs := testParseStatements("emit T()") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.EmitStatement{ InvocationExpression: &ast.InvocationExpression{ @@ -953,7 +953,7 @@ func TestParseFunctionStatementOrExpression(t *testing.T) { result, errs := testParseStatements("fun foo() {}") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -989,7 +989,7 @@ func TestParseFunctionStatementOrExpression(t *testing.T) { result, errs := testParseStatements("fun () {}") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.ExpressionStatement{ Expression: &ast.FunctionExpression{ @@ -1027,7 +1027,7 @@ func TestParseStatements(t *testing.T) { result, errs := testParseStatements("a + b < c\nd") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.ExpressionStatement{ Expression: &ast.BinaryExpression{ @@ -1073,7 +1073,7 @@ func TestParseStatements(t *testing.T) { t.Parallel() result, errs := testParseStatements(`assert true`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "statements on the same line must be separated with a semicolon", @@ -1083,7 +1083,7 @@ func TestParseStatements(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.ExpressionStatement{ Expression: &ast.IdentifierExpression{ @@ -1119,7 +1119,7 @@ func TestParseRemoveAttachmentStatement(t *testing.T) { result, errs := testParseStatements("remove A from b") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.RemoveStatement{ Attachment: &ast.NominalType{ @@ -1148,7 +1148,7 @@ func TestParseRemoveAttachmentStatement(t *testing.T) { result, errs := testParseStatements("remove Foo.E from b") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.RemoveStatement{ Attachment: &ast.NominalType{ @@ -1182,7 +1182,7 @@ func TestParseRemoveAttachmentStatement(t *testing.T) { _, errs := testParseStatements("remove A") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected from keyword, got EOF", @@ -1203,7 +1203,7 @@ func TestParseRemoveAttachmentStatement(t *testing.T) { _, errs := testParseStatements("remove A from") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected end of program", @@ -1220,7 +1220,7 @@ func TestParseRemoveAttachmentStatement(t *testing.T) { _, errs := testParseStatements("remove [A] from e") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected attachment nominal type, got [A]", @@ -1238,7 +1238,7 @@ func TestParseRemoveAttachmentStatement(t *testing.T) { result, errs := testParseStatements("remove A from foo()") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.RemoveStatement{ Attachment: &ast.NominalType{ @@ -1276,7 +1276,7 @@ func TestParseSwitchStatement(t *testing.T) { result, errs := testParseStatements("switch true { }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.SwitchStatement{ Expression: &ast.BoolExpression{ @@ -1304,7 +1304,7 @@ func TestParseSwitchStatement(t *testing.T) { result, errs := testParseStatements("switch x { case 1 :\n a\nb default : c\nd }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.SwitchStatement{ Expression: &ast.IdentifierExpression{ @@ -1402,7 +1402,7 @@ func TestParseIfStatementInFunctionDeclaration(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -1604,7 +1604,7 @@ func TestParseIfStatementWithVariableDeclaration(t *testing.T) { ifStatement.Test = ifTestVariableDeclaration - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -1650,7 +1650,7 @@ func TestParseIfStatementNoElse(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -1722,7 +1722,7 @@ func TestParseWhileStatementInFunctionDeclaration(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -1802,7 +1802,7 @@ func TestParseForStatementInFunctionDeclaration(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -1864,7 +1864,7 @@ func TestParseAssignment(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -1928,7 +1928,7 @@ func TestParseAccessAssignment(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -2041,7 +2041,7 @@ func TestParseExpressionStatementWithAccess(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -2143,7 +2143,7 @@ func TestParseMoveStatement(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -2205,7 +2205,7 @@ func TestParseFunctionExpressionStatementAfterVariableDeclarationWithCreateExpre result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -2308,7 +2308,7 @@ func TestParseExpressionStatementAfterReturnStatement(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -2369,7 +2369,7 @@ func TestParseSwapStatementInFunctionDeclaration(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, diff --git a/old_parser/type_test.go b/old_parser/type_test.go index 814a51b813..7e9bcdf1dc 100644 --- a/old_parser/type_test.go +++ b/old_parser/type_test.go @@ -27,7 +27,7 @@ import ( "github.com/onflow/cadence/ast" "github.com/onflow/cadence/common" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" ) func TestParseNominalType(t *testing.T) { @@ -41,7 +41,7 @@ func TestParseNominalType(t *testing.T) { result, errs := testParseType("Int") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.NominalType{ Identifier: ast.Identifier{ Identifier: "Int", @@ -59,7 +59,7 @@ func TestParseNominalType(t *testing.T) { result, errs := testParseType("Foo.Bar") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.NominalType{ Identifier: ast.Identifier{ Identifier: "Foo", @@ -88,7 +88,7 @@ func TestParseArrayType(t *testing.T) { result, errs := testParseType("[Int]") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.VariableSizedType{ Type: &ast.NominalType{ Identifier: ast.Identifier{ @@ -112,7 +112,7 @@ func TestParseArrayType(t *testing.T) { result, errs := testParseType("[Int ; 2 ]") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.ConstantSizedType{ Type: &ast.NominalType{ Identifier: ast.Identifier{ @@ -143,7 +143,7 @@ func TestParseArrayType(t *testing.T) { t.Parallel() result, errs := testParseType("[Int ; -2 ]") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: `expected positive integer size for constant sized type`, @@ -166,7 +166,7 @@ func TestParseArrayType(t *testing.T) { t.Parallel() result, errs := testParseType("[Int ; X ]") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: `expected positive integer size for constant sized type`, @@ -176,7 +176,7 @@ func TestParseArrayType(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.VariableSizedType{ Type: &ast.NominalType{ Identifier: ast.Identifier{ @@ -206,7 +206,7 @@ func TestParseOptionalType(t *testing.T) { result, errs := testParseType("Int?") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.OptionalType{ Type: &ast.NominalType{ Identifier: ast.Identifier{ @@ -227,7 +227,7 @@ func TestParseOptionalType(t *testing.T) { result, errs := testParseType("Int??") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.OptionalType{ Type: &ast.OptionalType{ Type: &ast.NominalType{ @@ -251,7 +251,7 @@ func TestParseOptionalType(t *testing.T) { result, errs := testParseType("Int???") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.OptionalType{ Type: &ast.OptionalType{ Type: &ast.OptionalType{ @@ -283,7 +283,7 @@ func TestParseReferenceType(t *testing.T) { result, errs := testParseType("&Int") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.ReferenceType{ Authorization: nil, Type: &ast.NominalType{ @@ -305,7 +305,7 @@ func TestParseReferenceType(t *testing.T) { result, errs := testParseType("auth &Int") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.ReferenceType{ Authorization: nil, LegacyAuthorized: true, @@ -333,7 +333,7 @@ func TestParseOptionalReferenceType(t *testing.T) { result, errs := testParseType("&Int?") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.OptionalType{ Type: &ast.ReferenceType{ Authorization: nil, @@ -363,7 +363,7 @@ func TestParseRestrictedType(t *testing.T) { result, errs := testParseType("T{}") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntersectionType{ LegacyRestrictedType: &ast.NominalType{ NestedIdentifiers: nil, @@ -388,7 +388,7 @@ func TestParseRestrictedType(t *testing.T) { result, errs := testParseType("T{U}") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntersectionType{ LegacyRestrictedType: &ast.NominalType{ NestedIdentifiers: nil, @@ -421,7 +421,7 @@ func TestParseRestrictedType(t *testing.T) { result, errs := testParseType("T{U , V }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntersectionType{ LegacyRestrictedType: &ast.NominalType{ NestedIdentifiers: nil, @@ -460,7 +460,7 @@ func TestParseRestrictedType(t *testing.T) { result, errs := testParseType("{}") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntersectionType{ Range: ast.Range{ StartPos: ast.Position{Line: 1, Column: 0, Offset: 0}, @@ -478,7 +478,7 @@ func TestParseRestrictedType(t *testing.T) { result, errs := testParseType("{ T }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntersectionType{ Types: []*ast.NominalType{ { @@ -502,7 +502,7 @@ func TestParseRestrictedType(t *testing.T) { t.Parallel() result, errs := testParseType("{ T , }") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "missing type after comma", @@ -512,7 +512,7 @@ func TestParseRestrictedType(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntersectionType{ Types: []*ast.NominalType{ { @@ -536,7 +536,7 @@ func TestParseRestrictedType(t *testing.T) { t.Parallel() result, errs := testParseType("{ T U }") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected type", @@ -555,7 +555,7 @@ func TestParseRestrictedType(t *testing.T) { t.Parallel() result, errs := testParseType("{ T , U : V }") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected colon in restricted type", @@ -574,7 +574,7 @@ func TestParseRestrictedType(t *testing.T) { t.Parallel() result, errs := testParseType("T{U , V : W }") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: `unexpected token: got ':', expected ',' or '}'`, @@ -593,7 +593,7 @@ func TestParseRestrictedType(t *testing.T) { t.Parallel() result, errs := testParseType("{[T]}") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "non-nominal type in restriction list: [T]", @@ -612,7 +612,7 @@ func TestParseRestrictedType(t *testing.T) { t.Parallel() result, errs := testParseType("T{[U]}") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected non-nominal type: [U]", @@ -631,7 +631,7 @@ func TestParseRestrictedType(t *testing.T) { t.Parallel() result, errs := testParseType("{T, [U]}") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "non-nominal type in restriction list: [U]", @@ -650,7 +650,7 @@ func TestParseRestrictedType(t *testing.T) { t.Parallel() result, errs := testParseType("T{U, [V]}") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected non-nominal type: [V]", @@ -669,7 +669,7 @@ func TestParseRestrictedType(t *testing.T) { t.Parallel() result, errs := testParseType("{") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid end of input, expected type", @@ -687,7 +687,7 @@ func TestParseRestrictedType(t *testing.T) { t.Parallel() result, errs := testParseType("T{") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid end of input, expected type", @@ -705,7 +705,7 @@ func TestParseRestrictedType(t *testing.T) { t.Parallel() result, errs := testParseType("{U") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid end of input, expected '}'", @@ -723,7 +723,7 @@ func TestParseRestrictedType(t *testing.T) { t.Parallel() result, errs := testParseType("T{U") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid end of input, expected '}'", @@ -741,7 +741,7 @@ func TestParseRestrictedType(t *testing.T) { t.Parallel() result, errs := testParseType("{U,") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid end of input, expected type", @@ -759,7 +759,7 @@ func TestParseRestrictedType(t *testing.T) { t.Parallel() result, errs := testParseType("T{U,") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid end of input, expected type", @@ -777,7 +777,7 @@ func TestParseRestrictedType(t *testing.T) { t.Parallel() result, errs := testParseType("{,}") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected comma in restricted type", @@ -795,7 +795,7 @@ func TestParseRestrictedType(t *testing.T) { t.Parallel() result, errs := testParseType("T{,}") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected comma", @@ -820,7 +820,7 @@ func TestParseDictionaryType(t *testing.T) { result, errs := testParseType("{T: U}") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.DictionaryType{ KeyType: &ast.NominalType{ Identifier: ast.Identifier{ @@ -848,7 +848,7 @@ func TestParseDictionaryType(t *testing.T) { t.Parallel() result, errs := testParseType("{T:}") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "missing dictionary value type", @@ -858,7 +858,7 @@ func TestParseDictionaryType(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.DictionaryType{ KeyType: &ast.NominalType{ Identifier: ast.Identifier{ @@ -881,7 +881,7 @@ func TestParseDictionaryType(t *testing.T) { t.Parallel() result, errs := testParseType("{:}") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected colon in dictionary type", @@ -899,7 +899,7 @@ func TestParseDictionaryType(t *testing.T) { t.Parallel() result, errs := testParseType("{:U}") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected colon in dictionary type", @@ -918,7 +918,7 @@ func TestParseDictionaryType(t *testing.T) { t.Parallel() result, errs := testParseType("{T:U,}") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected comma in dictionary type", @@ -937,7 +937,7 @@ func TestParseDictionaryType(t *testing.T) { t.Parallel() result, errs := testParseType("{T:U:}") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected colon in dictionary type", @@ -956,7 +956,7 @@ func TestParseDictionaryType(t *testing.T) { t.Parallel() result, errs := testParseType("{T::U}") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected colon in dictionary type", @@ -975,7 +975,7 @@ func TestParseDictionaryType(t *testing.T) { t.Parallel() result, errs := testParseType("{T:") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid end of input, expected type", @@ -993,7 +993,7 @@ func TestParseDictionaryType(t *testing.T) { t.Parallel() result, errs := testParseType("{T:U") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid end of input, expected '}'", @@ -1018,7 +1018,7 @@ func TestParseFunctionType(t *testing.T) { result, errs := testParseType("(():Void)") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.FunctionType{ ParameterTypeAnnotations: nil, ReturnTypeAnnotation: &ast.TypeAnnotation{ @@ -1047,7 +1047,7 @@ func TestParseFunctionType(t *testing.T) { result, errs := testParseType("( ( String , Bool , @R ) : Int)") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.FunctionType{ ParameterTypeAnnotations: []*ast.TypeAnnotation{ { @@ -1112,7 +1112,7 @@ func TestParseInstantiationType(t *testing.T) { result, errs := testParseType("T<>") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.InstantiationType{ Type: &ast.NominalType{ Identifier: ast.Identifier{ @@ -1134,7 +1134,7 @@ func TestParseInstantiationType(t *testing.T) { result, errs := testParseType("T") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.InstantiationType{ Type: &ast.NominalType{ Identifier: ast.Identifier{ @@ -1168,7 +1168,7 @@ func TestParseInstantiationType(t *testing.T) { result, errs := testParseType("T< U >") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.InstantiationType{ Type: &ast.NominalType{ Identifier: ast.Identifier{ @@ -1202,7 +1202,7 @@ func TestParseInstantiationType(t *testing.T) { result, errs := testParseType("T< U , @V >") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.InstantiationType{ Type: &ast.NominalType{ Identifier: ast.Identifier{ @@ -1246,7 +1246,7 @@ func TestParseInstantiationType(t *testing.T) { result, errs := testParseType("T") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.InstantiationType{ Type: &ast.NominalType{ Identifier: ast.Identifier{ @@ -1280,7 +1280,7 @@ func TestParseInstantiationType(t *testing.T) { result, errs := testParseType("T< U< V > >") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.InstantiationType{ Type: &ast.NominalType{ Identifier: ast.Identifier{ @@ -1334,7 +1334,7 @@ func TestParseParametersAndArrayTypes(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessAll, @@ -1483,7 +1483,7 @@ func TestParseDictionaryTypeInVariableDeclaration(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -1805,7 +1805,7 @@ func TestParseIntegerTypes(t *testing.T) { StartPos: ast.Position{Offset: 137, Line: 9, Column: 2}, } - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{a, b, c, d, e, f, g, h}, result.Declarations(), ) @@ -1821,7 +1821,7 @@ func TestParseFunctionTypeInVariableDeclaration(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -1899,7 +1899,7 @@ func TestParseFunctionArrayType(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -1983,7 +1983,7 @@ func TestParseFunctionTypeWithArrayReturnType(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -2066,7 +2066,7 @@ func TestParseFunctionTypeWithFunctionReturnTypeInParentheses(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -2156,7 +2156,7 @@ func TestParseFunctionTypeWithFunctionReturnType(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -2246,7 +2246,7 @@ func TestParseOptionalTypeDouble(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -2301,7 +2301,7 @@ func TestParseFunctionTypeWithResourceTypeAnnotation(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -2358,7 +2358,7 @@ func TestParseReferenceTypeInVariableDeclaration(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -2419,7 +2419,7 @@ func TestParseOptionalReference(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -2474,7 +2474,7 @@ func TestParseRestrictedReferenceTypeWithBaseType(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -2541,7 +2541,7 @@ func TestParseRestrictedReferenceTypeWithoutBaseType(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -2601,7 +2601,7 @@ func TestParseOptionalRestrictedType(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -2668,7 +2668,7 @@ func TestParseOptionalRestrictedTypeOnlyRestrictions(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -2728,7 +2728,7 @@ func TestParseAuthorizedReferenceType(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -2783,7 +2783,7 @@ func TestParseInstantiationTypeInVariableDeclaration(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -2859,7 +2859,7 @@ func TestParseConstantSizedSizedArrayWithTrailingUnderscoreSize(t *testing.T) { let T:[d;0_]=0 `) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &InvalidIntegerLiteralError{ Literal: "0_", diff --git a/parser/declaration_test.go b/parser/declaration_test.go index 2f27396cbd..681d5cb593 100644 --- a/parser/declaration_test.go +++ b/parser/declaration_test.go @@ -29,7 +29,7 @@ import ( "github.com/onflow/cadence/ast" "github.com/onflow/cadence/common" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" ) func TestParseVariableDeclaration(t *testing.T) { @@ -43,7 +43,7 @@ func TestParseVariableDeclaration(t *testing.T) { result, errs := testParseDeclarations("var x = 1") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -79,7 +79,7 @@ func TestParseVariableDeclaration(t *testing.T) { result, errs := testParseDeclarations(" access(all) var x = 1") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Value: &ast.IntegerExpression{ @@ -136,7 +136,7 @@ func TestParseVariableDeclaration(t *testing.T) { result, errs := testParseDeclarations("let x = 1") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -172,7 +172,7 @@ func TestParseVariableDeclaration(t *testing.T) { result, errs := testParseDeclarations("let x <- 1") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -208,7 +208,7 @@ func TestParseVariableDeclaration(t *testing.T) { result, errs := testParseDeclarations("let r2: @R <- r") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -251,7 +251,7 @@ func TestParseVariableDeclaration(t *testing.T) { result, errs := testParseStatements("var x <- y <- z") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -292,7 +292,7 @@ func TestParseVariableDeclaration(t *testing.T) { t.Parallel() _, errs := testParseDeclarations("view var x = 1") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid view modifier for variable", @@ -314,7 +314,7 @@ func TestParseVariableDeclaration(t *testing.T) { StaticModifierEnabled: true, }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid static modifier for variable", @@ -330,7 +330,7 @@ func TestParseVariableDeclaration(t *testing.T) { t.Parallel() _, errs := testParseDeclarations("static var x = 1") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: identifier", @@ -352,7 +352,7 @@ func TestParseVariableDeclaration(t *testing.T) { NativeModifierEnabled: true, }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid native modifier for variable", @@ -368,7 +368,7 @@ func TestParseVariableDeclaration(t *testing.T) { t.Parallel() _, errs := testParseDeclarations("native var x = 1") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: identifier", @@ -402,7 +402,7 @@ func TestParseParameterList(t *testing.T) { result, errs := parse("()") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.ParameterList{ Range: ast.Range{ StartPos: ast.Position{Line: 1, Column: 0, Offset: 0}, @@ -420,7 +420,7 @@ func TestParseParameterList(t *testing.T) { result, errs := parse(" ( )") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.ParameterList{ Range: ast.Range{ StartPos: ast.Position{Line: 1, Column: 1, Offset: 1}, @@ -438,7 +438,7 @@ func TestParseParameterList(t *testing.T) { result, errs := parse("( a : Int )") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.ParameterList{ Parameters: []*ast.Parameter{ { @@ -476,7 +476,7 @@ func TestParseParameterList(t *testing.T) { result, errs := parse("( a b : Int )") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.ParameterList{ Parameters: []*ast.Parameter{ { @@ -514,7 +514,7 @@ func TestParseParameterList(t *testing.T) { result, errs := parse("( a b : Int , c : Int )") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.ParameterList{ Parameters: []*ast.Parameter{ { @@ -568,7 +568,7 @@ func TestParseParameterList(t *testing.T) { t.Parallel() _, errs := parse("( a b : Int c : Int )") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &MissingCommaInParameterListError{ Pos: ast.Position{Offset: 14, Line: 1, Column: 14}, @@ -590,7 +590,7 @@ func TestParseFunctionDeclaration(t *testing.T) { result, errs := testParseDeclarations("fun foo () { }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -628,7 +628,7 @@ func TestParseFunctionDeclaration(t *testing.T) { result, errs := testParseDeclarations("access(all) fun foo () { }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ ParameterList: &ast.ParameterList{ @@ -688,7 +688,7 @@ func TestParseFunctionDeclaration(t *testing.T) { result, errs := testParseDeclarations("fun foo (): X { }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -747,7 +747,7 @@ func TestParseFunctionDeclaration(t *testing.T) { `) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -870,7 +870,7 @@ func TestParseFunctionDeclaration(t *testing.T) { result, errs := testParseDeclarations("/// Test\nfun foo() {}") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -908,7 +908,7 @@ func TestParseFunctionDeclaration(t *testing.T) { result, errs := testParseDeclarations("\n /// First line\n \n/// Second line\n\n\nfun foo() {}") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -946,7 +946,7 @@ func TestParseFunctionDeclaration(t *testing.T) { result, errs := testParseDeclarations("\n /** Cool dogs.\n\n Cool cats!! */\n\n\nfun foo() {}") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -989,7 +989,7 @@ func TestParseFunctionDeclaration(t *testing.T) { result, errs := testParseDeclarations("fun main(): Int{ return 1 }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -1052,7 +1052,7 @@ func TestParseFunctionDeclaration(t *testing.T) { result, errs := testParseDeclarations("view fun foo (): X { }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -1105,7 +1105,7 @@ func TestParseFunctionDeclaration(t *testing.T) { ) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -1154,7 +1154,7 @@ func TestParseFunctionDeclaration(t *testing.T) { _, errs := testParseDeclarations("native fun foo() {}") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: identifier", @@ -1178,7 +1178,7 @@ func TestParseFunctionDeclaration(t *testing.T) { ) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -1215,7 +1215,7 @@ func TestParseFunctionDeclaration(t *testing.T) { _, errs := testParseDeclarations("static fun foo() {}") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: identifier", @@ -1240,7 +1240,7 @@ func TestParseFunctionDeclaration(t *testing.T) { ) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -1277,7 +1277,7 @@ func TestParseFunctionDeclaration(t *testing.T) { _, errs := testParseDeclarations("static native fun foo() {}") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: identifier", @@ -1300,7 +1300,7 @@ func TestParseFunctionDeclaration(t *testing.T) { NativeModifierEnabled: true, }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid static modifier after native modifier", @@ -1317,7 +1317,7 @@ func TestParseFunctionDeclaration(t *testing.T) { _, errs := testParseDeclarations("native static fun foo() {}") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: identifier", @@ -1342,7 +1342,7 @@ func TestParseFunctionDeclaration(t *testing.T) { ) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Purity: 0, @@ -1408,7 +1408,7 @@ func TestParseFunctionDeclaration(t *testing.T) { _, errs := testParseDeclarations("access(all) static native fun foo() {}") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: identifier", @@ -1436,7 +1436,7 @@ func TestParseFunctionDeclaration(t *testing.T) { ) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -1486,7 +1486,7 @@ func TestParseFunctionDeclaration(t *testing.T) { ) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -1543,7 +1543,7 @@ func TestParseFunctionDeclaration(t *testing.T) { ) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -1608,7 +1608,7 @@ func TestParseFunctionDeclaration(t *testing.T) { _, errs := testParseDeclarations("fun foo() {}") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected '(' as start of parameter list, got '<'", @@ -1631,7 +1631,7 @@ func TestParseFunctionDeclaration(t *testing.T) { }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "missing '>' at end of type parameter list", @@ -1654,7 +1654,7 @@ func TestParseFunctionDeclaration(t *testing.T) { }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &MissingCommaInParameterListError{ Pos: ast.Position{Offset: 13, Line: 1, Column: 13}, @@ -1686,7 +1686,7 @@ func TestParseAccess(t *testing.T) { result, errs := parse("access ( all )") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, ast.AccessAll, result, ) @@ -1699,7 +1699,7 @@ func TestParseAccess(t *testing.T) { result, errs := parse("access ( account )") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, ast.AccessAccount, result, ) @@ -1712,7 +1712,7 @@ func TestParseAccess(t *testing.T) { result, errs := parse("access ( contract )") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, ast.AccessContract, result, ) @@ -1725,7 +1725,7 @@ func TestParseAccess(t *testing.T) { result, errs := parse("access ( self )") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, ast.AccessSelf, result, ) @@ -1736,7 +1736,7 @@ func TestParseAccess(t *testing.T) { t.Parallel() result, errs := parse("access ( ") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected keyword \"all\", \"account\", \"contract\", or \"self\", got EOF", @@ -1746,7 +1746,7 @@ func TestParseAccess(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, ast.AccessNotSpecified, result, ) @@ -1757,7 +1757,7 @@ func TestParseAccess(t *testing.T) { t.Parallel() result, errs := parse("access ( self ") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected token ')'", @@ -1767,7 +1767,7 @@ func TestParseAccess(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, ast.AccessNotSpecified, result, ) @@ -1780,7 +1780,7 @@ func TestParseAccess(t *testing.T) { result, errs := parse("access ( foo )") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, ast.EntitlementAccess{ EntitlementSet: &ast.ConjunctiveEntitlementSet{ Elements: []*ast.NominalType{ @@ -1804,7 +1804,7 @@ func TestParseAccess(t *testing.T) { result, errs := parse("access ( foo , bar )") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, ast.EntitlementAccess{ EntitlementSet: &ast.ConjunctiveEntitlementSet{ Elements: []*ast.NominalType{ @@ -1834,7 +1834,7 @@ func TestParseAccess(t *testing.T) { result, errs := parse("access ( foo | bar )") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, ast.EntitlementAccess{ EntitlementSet: &ast.DisjunctiveEntitlementSet{ Elements: []*ast.NominalType{ @@ -1862,7 +1862,7 @@ func TestParseAccess(t *testing.T) { t.Parallel() result, errs := parse("access ( foo | bar , baz )") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: got ',', expected '|' or ')'", @@ -1872,7 +1872,7 @@ func TestParseAccess(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, ast.AccessNotSpecified, result, ) @@ -1883,7 +1883,7 @@ func TestParseAccess(t *testing.T) { t.Parallel() result, errs := parse("access ( foo , bar | baz )") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: got '|', expected ',' or ')'", @@ -1893,7 +1893,7 @@ func TestParseAccess(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, ast.AccessNotSpecified, result, ) @@ -1904,7 +1904,7 @@ func TestParseAccess(t *testing.T) { t.Parallel() result, errs := parse("access ( self , bar )") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected token ')'", @@ -1914,7 +1914,7 @@ func TestParseAccess(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, ast.AccessNotSpecified, result, ) @@ -1925,7 +1925,7 @@ func TestParseAccess(t *testing.T) { t.Parallel() result, errs := parse("access ( self | bar )") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected token ')'", @@ -1935,7 +1935,7 @@ func TestParseAccess(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, ast.AccessNotSpecified, result, ) @@ -1946,7 +1946,7 @@ func TestParseAccess(t *testing.T) { t.Parallel() result, errs := parse("access ( foo , self )") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected non-nominal type: self", @@ -1956,7 +1956,7 @@ func TestParseAccess(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, ast.AccessNotSpecified, result, ) @@ -1967,7 +1967,7 @@ func TestParseAccess(t *testing.T) { t.Parallel() result, errs := parse("access ( foo | self )") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected non-nominal type: self", @@ -1977,7 +1977,7 @@ func TestParseAccess(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, ast.AccessNotSpecified, result, ) @@ -1988,7 +1988,7 @@ func TestParseAccess(t *testing.T) { t.Parallel() result, errs := parse("access ( foo bar )") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected entitlement separator identifier", @@ -1998,7 +1998,7 @@ func TestParseAccess(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, ast.AccessNotSpecified, result, ) @@ -2009,7 +2009,7 @@ func TestParseAccess(t *testing.T) { t.Parallel() result, errs := parse("access ( foo & bar )") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected entitlement separator '&'", @@ -2019,7 +2019,7 @@ func TestParseAccess(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, ast.AccessNotSpecified, result, ) @@ -2032,7 +2032,7 @@ func TestParseAccess(t *testing.T) { result, errs := parse("access ( mapping foo )") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.MappedAccess{ EntitlementMap: &ast.NominalType{ Identifier: ast.Identifier{ @@ -2051,7 +2051,7 @@ func TestParseAccess(t *testing.T) { t.Parallel() result, errs := parse("access ( mapping )") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token in type: ')'", @@ -2061,7 +2061,7 @@ func TestParseAccess(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, ast.AccessNotSpecified, result, ) @@ -2078,7 +2078,7 @@ func TestParseImportDeclaration(t *testing.T) { t.Parallel() result, errs := testParseDeclarations(` import`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected end in import declaration: expected string, address, or identifier", @@ -2090,7 +2090,7 @@ func TestParseImportDeclaration(t *testing.T) { var expected []ast.Declaration - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, expected, result, ) @@ -2103,7 +2103,7 @@ func TestParseImportDeclaration(t *testing.T) { result, errs := testParseDeclarations(` import "foo"`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.ImportDeclaration{ Identifiers: nil, @@ -2126,7 +2126,7 @@ func TestParseImportDeclaration(t *testing.T) { result, errs := testParseDeclarations(` import 0x42`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.ImportDeclaration{ Identifiers: nil, @@ -2149,7 +2149,7 @@ func TestParseImportDeclaration(t *testing.T) { t.Parallel() result, errs := testParseDeclarations(` import 0x10000000000000001`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "address too large", @@ -2173,7 +2173,7 @@ func TestParseImportDeclaration(t *testing.T) { }, } - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, expected, result, ) @@ -2184,7 +2184,7 @@ func TestParseImportDeclaration(t *testing.T) { t.Parallel() result, errs := testParseDeclarations(` import 1`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token in import declaration: " + @@ -2197,7 +2197,7 @@ func TestParseImportDeclaration(t *testing.T) { var expected []ast.Declaration - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, expected, result, ) @@ -2211,7 +2211,7 @@ func TestParseImportDeclaration(t *testing.T) { result, errs := testParseDeclarations(` import foo from "bar"`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.ImportDeclaration{ Identifiers: []ast.Identifier{ @@ -2237,7 +2237,7 @@ func TestParseImportDeclaration(t *testing.T) { t.Parallel() result, errs := testParseDeclarations(` import foo "bar"`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token in import declaration: " + @@ -2250,7 +2250,7 @@ func TestParseImportDeclaration(t *testing.T) { var expected []ast.Declaration - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, expected, result, ) @@ -2263,7 +2263,7 @@ func TestParseImportDeclaration(t *testing.T) { result, errs := testParseDeclarations(` import foo , bar , baz from 0x42`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.ImportDeclaration{ Identifiers: []ast.Identifier{ @@ -2299,7 +2299,7 @@ func TestParseImportDeclaration(t *testing.T) { t.Parallel() result, errs := testParseDeclarations(` import foo , bar , from 0x42`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: `expected identifier, got keyword "from"`, @@ -2311,7 +2311,7 @@ func TestParseImportDeclaration(t *testing.T) { var expected []ast.Declaration - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, expected, result, ) @@ -2321,7 +2321,7 @@ func TestParseImportDeclaration(t *testing.T) { t.Parallel() result, errs := testParseDeclarations(`import foo, , bar from 0xaaaa`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Pos: ast.Position{Line: 1, Column: 12, Offset: 12}, @@ -2332,7 +2332,7 @@ func TestParseImportDeclaration(t *testing.T) { ) var expected []ast.Declaration - utils.AssertEqualWithDiff(t, expected, result) + AssertEqualWithDiff(t, expected, result) }) t.Run("no identifiers, identifier location", func(t *testing.T) { @@ -2342,7 +2342,7 @@ func TestParseImportDeclaration(t *testing.T) { result, errs := testParseDeclarations(` import foo`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.ImportDeclaration{ Identifiers: nil, @@ -2363,7 +2363,7 @@ func TestParseImportDeclaration(t *testing.T) { _, errs := testParseDeclarations(`import foo, bar, baz, @ from 0x42`) - utils.AssertEqualWithDiff(t, []error{ + AssertEqualWithDiff(t, []error{ &SyntaxError{ Pos: ast.Position{Line: 1, Column: 22, Offset: 22}, Message: `unexpected token in import declaration: got '@', expected keyword "from" or ','`, @@ -2381,7 +2381,7 @@ func TestParseImportDeclaration(t *testing.T) { `) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.ImportDeclaration{ Identifiers: []ast.Identifier{ @@ -2444,7 +2444,7 @@ func TestParseEvent(t *testing.T) { result, errs := testParseDeclarations("event E()") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.CompositeDeclaration{ Access: ast.AccessNotSpecified, @@ -2487,7 +2487,7 @@ func TestParseEvent(t *testing.T) { result, errs := testParseDeclarations(" access(self) event E2 ( a : Int , b : String )") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.CompositeDeclaration{ Members: ast.NewUnmeteredMembers( @@ -2620,7 +2620,7 @@ func TestParseEvent(t *testing.T) { result, errs := testParseDeclarations(` access(all) event ResourceDestroyed ( a : String = "foo")`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.CompositeDeclaration{ Members: ast.NewUnmeteredMembers( @@ -2735,7 +2735,7 @@ func TestParseEvent(t *testing.T) { _, errs := testParseDeclarations(" access(all) event ResourceDestroyed ( a : Int )") - utils.AssertEqualWithDiff(t, []error{ + AssertEqualWithDiff(t, []error{ &SyntaxError{ Pos: ast.Position{Line: 1, Column: 47, Offset: 47}, Message: "expected a default argument after type annotation, got ')'", @@ -2749,7 +2749,7 @@ func TestParseEvent(t *testing.T) { _, errs := testParseDeclarations(" access(all) event Foo ( a : Int = 3)") - utils.AssertEqualWithDiff(t, []error{ + AssertEqualWithDiff(t, []error{ &SyntaxError{ Pos: ast.Position{Line: 1, Column: 33, Offset: 33}, Message: "cannot use a default argument for this function", @@ -2760,7 +2760,7 @@ func TestParseEvent(t *testing.T) { t.Run("invalid event name", func(t *testing.T) { _, errs := testParseDeclarations(`event continue {}`) - utils.AssertEqualWithDiff(t, []error{ + AssertEqualWithDiff(t, []error{ &SyntaxError{ Pos: ast.Position{Line: 1, Column: 6, Offset: 6}, Message: "expected identifier after start of event declaration, got keyword continue", @@ -2798,7 +2798,7 @@ func TestParseFieldWithVariableKind(t *testing.T) { result, errs := parse("var x : Int") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.FieldDeclaration{ Access: ast.AccessNotSpecified, VariableKind: ast.VariableKindVariable, @@ -2832,7 +2832,7 @@ func TestParseFieldWithVariableKind(t *testing.T) { result, errs := parse("let x : Int") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.FieldDeclaration{ Access: ast.AccessNotSpecified, VariableKind: ast.VariableKindConstant, @@ -2890,7 +2890,7 @@ func TestParseField(t *testing.T) { ) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.FieldDeclaration{ Access: ast.AccessNotSpecified, Flags: ast.FieldDeclarationFlagsIsNative, @@ -2923,7 +2923,7 @@ func TestParseField(t *testing.T) { _, errs := parse("native let foo: Int", Config{}) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected identifier", @@ -2946,7 +2946,7 @@ func TestParseField(t *testing.T) { ) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.FieldDeclaration{ Access: ast.AccessNotSpecified, Flags: ast.FieldDeclarationFlagsIsStatic, @@ -2982,7 +2982,7 @@ func TestParseField(t *testing.T) { Config{}, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected identifier", @@ -3006,7 +3006,7 @@ func TestParseField(t *testing.T) { ) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.FieldDeclaration{ Access: ast.AccessNotSpecified, Flags: ast.FieldDeclarationFlagsIsStatic | ast.FieldDeclarationFlagsIsNative, @@ -3039,7 +3039,7 @@ func TestParseField(t *testing.T) { _, errs := parse("static native let foo: Int", Config{}) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected identifier", @@ -3062,7 +3062,7 @@ func TestParseField(t *testing.T) { }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid static modifier after native modifier", @@ -3086,7 +3086,7 @@ func TestParseField(t *testing.T) { ) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.FieldDeclaration{ TypeAnnotation: &ast.TypeAnnotation{ Type: &ast.NominalType{ @@ -3140,7 +3140,7 @@ func TestParseField(t *testing.T) { _, errs := parse("access(all) static native let foo: Int", Config{}) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected identifier", @@ -3164,7 +3164,7 @@ func TestParseCompositeDeclaration(t *testing.T) { result, errs := testParseDeclarations(" access(all) struct S { }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.CompositeDeclaration{ Members: ast.NewUnmeteredMembers(nil), @@ -3203,7 +3203,7 @@ func TestParseCompositeDeclaration(t *testing.T) { result, errs := testParseDeclarations(" access(all) resource R : RI { }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.CompositeDeclaration{ Access: ast.AccessAll, @@ -3251,7 +3251,7 @@ func TestParseCompositeDeclaration(t *testing.T) { require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.CompositeDeclaration{ Members: ast.NewUnmeteredMembers( @@ -3579,7 +3579,7 @@ func TestParseCompositeDeclaration(t *testing.T) { }`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.CompositeDeclaration{ Access: ast.AccessNotSpecified, @@ -3632,7 +3632,7 @@ func TestParseCompositeDeclaration(t *testing.T) { }`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.CompositeDeclaration{ Access: ast.AccessNotSpecified, @@ -3687,7 +3687,7 @@ func TestParseCompositeDeclaration(t *testing.T) { view foo: Int }`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid view modifier for variable", @@ -3720,7 +3720,7 @@ func TestParseInvalidCompositeFunctionWithSelfParameter(t *testing.T) { _, err := testParseDeclarations(code) - utils.AssertEqualWithDiff( + AssertEqualWithDiff( t, []error{ &SyntaxError{ @@ -3739,7 +3739,7 @@ func TestParseInvalidParameterWithoutLabel(t *testing.T) { _, errs := testParseDeclarations(`access(all) fun foo(continue: Int) {}`) - utils.AssertEqualWithDiff(t, []error{ + AssertEqualWithDiff(t, []error{ &SyntaxError{ Pos: ast.Position{Line: 1, Column: 20, Offset: 20}, Message: "expected identifier for argument label or parameter name, got keyword continue", @@ -3752,7 +3752,7 @@ func TestParseParametersWithExtraLabels(t *testing.T) { _, errs := testParseDeclarations(`access(all) fun foo(_ foo: String, label fable table: Int) {}`) - utils.AssertEqualWithDiff(t, []error{ + AssertEqualWithDiff(t, []error{ &SyntaxError{ Pos: ast.Position{Line: 1, Column: 47, Offset: 47}, Message: "expected ':' after parameter name, got identifier", @@ -3771,7 +3771,7 @@ func TestParseAttachmentDeclaration(t *testing.T) { result, errs := testParseDeclarations("access(all) attachment E for S {} ") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.AttachmentDeclaration{ Access: ast.AccessAll, @@ -3806,7 +3806,7 @@ func TestParseAttachmentDeclaration(t *testing.T) { }`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.CompositeDeclaration{ Access: ast.AccessNotSpecified, @@ -3852,7 +3852,7 @@ func TestParseAttachmentDeclaration(t *testing.T) { t.Parallel() _, errs := testParseDeclarations("attachment E {} ") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected 'for', got '{'", @@ -3870,7 +3870,7 @@ func TestParseAttachmentDeclaration(t *testing.T) { result, errs := testParseDeclarations("access(all) attachment E for S: I {} ") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.AttachmentDeclaration{ Access: ast.AccessAll, @@ -3912,7 +3912,7 @@ func TestParseAttachmentDeclaration(t *testing.T) { result, errs := testParseDeclarations("access(all) attachment E for S: I1, I2 {} ") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.AttachmentDeclaration{ Access: ast.AccessAll, @@ -3986,7 +3986,7 @@ func TestParseAttachmentDeclaration(t *testing.T) { }`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.AttachmentDeclaration{ Access: ast.AccessAll, @@ -4193,7 +4193,7 @@ func TestParseAttachmentDeclaration(t *testing.T) { _, errs := testParseDeclarations(`access(all) attachment E for S { require entitlement X }`) - utils.AssertEqualWithDiff(t, []error{ + AssertEqualWithDiff(t, []error{ &SyntaxError{ Pos: ast.Position{Line: 2, Column: 3, Offset: 36}, Message: "unexpected identifier", @@ -4210,7 +4210,7 @@ func TestParseAttachmentDeclaration(t *testing.T) { }`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.AttachmentDeclaration{ Access: ast.AccessAll, @@ -4323,7 +4323,7 @@ func TestParseInterfaceDeclaration(t *testing.T) { result, errs := testParseDeclarations(" access(all) struct interface S { }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.InterfaceDeclaration{ Access: ast.AccessAll, @@ -4348,7 +4348,7 @@ func TestParseInterfaceDeclaration(t *testing.T) { t.Parallel() result, errs := testParseDeclarations(" access(all) struct interface interface { }") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected interface name, got keyword \"interface\"", @@ -4360,7 +4360,7 @@ func TestParseInterfaceDeclaration(t *testing.T) { var expected []ast.Declaration - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, expected, result, ) @@ -4384,7 +4384,7 @@ func TestParseInterfaceDeclaration(t *testing.T) { require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.InterfaceDeclaration{ Members: ast.NewUnmeteredMembers( @@ -4647,7 +4647,7 @@ func TestParseInterfaceDeclaration(t *testing.T) { t.Run("invalid interface name", func(t *testing.T) { _, errs := testParseDeclarations(`access(all) struct interface continue {}`) - utils.AssertEqualWithDiff(t, []error{ + AssertEqualWithDiff(t, []error{ &SyntaxError{ Pos: ast.Position{Line: 1, Column: 29, Offset: 29}, Message: "expected identifier following struct declaration, got keyword continue", @@ -4664,7 +4664,7 @@ func TestParseInterfaceDeclaration(t *testing.T) { }`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.InterfaceDeclaration{ Access: ast.AccessNotSpecified, @@ -4720,7 +4720,7 @@ func TestParseEnumDeclaration(t *testing.T) { result, errs := testParseDeclarations(" access(all) enum E { case c ; access(all) case d }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.CompositeDeclaration{ Access: ast.AccessAll, @@ -4764,7 +4764,7 @@ func TestParseEnumDeclaration(t *testing.T) { t.Parallel() _, errs := testParseDeclarations(" enum E { view case e }") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid view modifier for enum case", @@ -4786,7 +4786,7 @@ func TestParseEnumDeclaration(t *testing.T) { StaticModifierEnabled: true, }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid static modifier for enum case", @@ -4803,7 +4803,7 @@ func TestParseEnumDeclaration(t *testing.T) { _, errs := testParseDeclarations(" enum E { static case e }") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected identifier", @@ -4825,7 +4825,7 @@ func TestParseEnumDeclaration(t *testing.T) { NativeModifierEnabled: true, }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid native modifier for enum case", @@ -4842,7 +4842,7 @@ func TestParseEnumDeclaration(t *testing.T) { _, errs := testParseDeclarations(" enum E { native case e }") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected identifier", @@ -4865,7 +4865,7 @@ func TestParseTransactionDeclaration(t *testing.T) { result, errs := testParseDeclarations("transaction { execute {} }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.TransactionDeclaration{ Execute: &ast.SpecialFunctionDeclaration{ @@ -4905,7 +4905,7 @@ func TestParseTransactionDeclaration(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.TransactionDeclaration{ Fields: nil, @@ -4941,7 +4941,7 @@ func TestParseTransactionDeclaration(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.TransactionDeclaration{ Fields: []*ast.FieldDeclaration{ @@ -5141,7 +5141,7 @@ func TestParseTransactionDeclaration(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.TransactionDeclaration{ Fields: []*ast.FieldDeclaration{ @@ -5388,7 +5388,7 @@ func TestParseTransactionDeclaration(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.TransactionDeclaration{ Fields: []*ast.FieldDeclaration{ @@ -5628,7 +5628,7 @@ func TestParseTransactionDeclaration(t *testing.T) { _, errs := testParseDeclarations(code) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, `unexpected identifier, expected keyword "prepare" or "execute", got "uwu"`, errs[0].Error(), ) @@ -5644,7 +5644,7 @@ func TestParseFunctionAndBlock(t *testing.T) { `) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -5690,7 +5690,7 @@ func TestParseFunctionParameterWithoutLabel(t *testing.T) { `) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -5748,7 +5748,7 @@ func TestParseFunctionParameterWithLabel(t *testing.T) { `) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -5817,7 +5817,7 @@ func TestParseStructure(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.CompositeDeclaration{ Members: ast.NewUnmeteredMembers( @@ -6144,7 +6144,7 @@ func TestParseStructureWithConformances(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.CompositeDeclaration{ Access: ast.AccessNotSpecified, @@ -6205,7 +6205,7 @@ func TestParseInvalidMember(t *testing.T) { IgnoreLeadingIdentifierEnabled: false, }) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected identifier", @@ -6236,7 +6236,7 @@ func TestParsePreAndPostConditions(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -6393,7 +6393,7 @@ func TestParseConditionMessage(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -6507,7 +6507,7 @@ func TestParseInvalidEmitConditionNonInvocation(t *testing.T) { } `) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected token '('", @@ -6530,7 +6530,7 @@ func TestParseInvalidEmitConditionNonInvocation(t *testing.T) { } `) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected token '('", @@ -6562,7 +6562,7 @@ func TestParseEmitAndTestCondition(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -6833,7 +6833,7 @@ func TestParseInterface(t *testing.T) { }, } - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{test}, actual.Declarations(), ) @@ -6851,7 +6851,7 @@ func TestParsePragmaNoArguments(t *testing.T) { result, errs := testParseDeclarations(`#pedantic`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.PragmaDeclaration{ Expression: &ast.IdentifierExpression{ @@ -6875,7 +6875,7 @@ func TestParsePragmaNoArguments(t *testing.T) { t.Parallel() _, errs := testParseDeclarations("view #foo") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid view modifier for pragma", @@ -6897,7 +6897,7 @@ func TestParsePragmaNoArguments(t *testing.T) { StaticModifierEnabled: true, }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid static modifier for pragma", @@ -6913,7 +6913,7 @@ func TestParsePragmaNoArguments(t *testing.T) { t.Parallel() _, errs := testParseDeclarations("static #foo") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: identifier", @@ -6935,7 +6935,7 @@ func TestParsePragmaNoArguments(t *testing.T) { NativeModifierEnabled: true, }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid native modifier for pragma", @@ -6951,7 +6951,7 @@ func TestParsePragmaNoArguments(t *testing.T) { t.Parallel() _, errs := testParseDeclarations("native #foo") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: identifier", @@ -6971,7 +6971,7 @@ func TestParsePragmaArguments(t *testing.T) { actual, err := testParseProgram(code) require.NoError(t, err) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.PragmaDeclaration{ Expression: &ast.InvocationExpression{ @@ -7016,7 +7016,7 @@ func TestParseImportWithString(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.ImportDeclaration{ Identifiers: nil, @@ -7042,7 +7042,7 @@ func TestParseImportWithAddress(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.ImportDeclaration{ Identifiers: nil, @@ -7070,7 +7070,7 @@ func TestParseImportWithIdentifiers(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.ImportDeclaration{ Identifiers: []ast.Identifier{ @@ -7109,7 +7109,7 @@ func TestParseFieldWithFromIdentifier(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.CompositeDeclaration{ Access: ast.AccessNotSpecified, @@ -7174,7 +7174,7 @@ func TestParseImportWithFromIdentifier(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.ImportDeclaration{ Identifiers: []ast.Identifier{ @@ -7206,7 +7206,7 @@ func TestParseInvalidImportWithPurity(t *testing.T) { ` _, errs := testParseDeclarations(code) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid view modifier for import", @@ -7227,7 +7227,7 @@ func TestParseInvalidDefaultArgument(t *testing.T) { _, errs := testParseDeclarations(" access(all) fun foo ( a : Int = 3) { } ") - utils.AssertEqualWithDiff(t, []error{ + AssertEqualWithDiff(t, []error{ &SyntaxError{ Pos: ast.Position{Line: 1, Column: 31, Offset: 31}, Message: "cannot use a default argument for this function", @@ -7241,7 +7241,7 @@ func TestParseInvalidDefaultArgument(t *testing.T) { _, errs := testParseDeclarations(" let foo = fun ( a : Int = 3) { } ") - utils.AssertEqualWithDiff(t, []error{ + AssertEqualWithDiff(t, []error{ &SyntaxError{ Pos: ast.Position{Line: 1, Column: 25, Offset: 25}, Message: "cannot use a default argument for this function", @@ -7259,7 +7259,7 @@ func TestParseInvalidEventWithPurity(t *testing.T) { ` _, errs := testParseDeclarations(code) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid view modifier for event", @@ -7279,7 +7279,7 @@ func TestParseInvalidCompositeWithPurity(t *testing.T) { ` _, errs := testParseDeclarations(code) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid view modifier for struct", @@ -7299,7 +7299,7 @@ func TestParseInvalidTransactionWithPurity(t *testing.T) { ` _, errs := testParseDeclarations(code) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid view modifier for transaction", @@ -7332,7 +7332,7 @@ func TestParseResource(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.CompositeDeclaration{ Access: ast.AccessNotSpecified, @@ -7362,7 +7362,7 @@ func TestParseEventDeclaration(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.CompositeDeclaration{ Access: ast.AccessNotSpecified, @@ -7448,7 +7448,7 @@ func TestParseEventEmitStatement(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -7534,7 +7534,7 @@ func TestParseResourceReturnType(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -7583,7 +7583,7 @@ func TestParseMovingVariableDeclaration(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -7619,7 +7619,7 @@ func TestParseResourceParameterType(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -7678,7 +7678,7 @@ func TestParseMovingVariableDeclarationWithTypeAnnotation(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -7724,7 +7724,7 @@ func TestParseFieldDeclarationWithMoveTypeAnnotation(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.CompositeDeclaration{ Access: ast.AccessNotSpecified, @@ -7779,7 +7779,7 @@ func TestParseDestructor(t *testing.T) { } ` _, errs := testParseDeclarations(code) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &CustomDestructorError{ Pos: ast.Position{Offset: 37, Line: 3, Column: 12}, @@ -7799,7 +7799,7 @@ func TestParseCompositeDeclarationWithSemicolonSeparatedMembers(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.CompositeDeclaration{ Access: ast.AccessNotSpecified, @@ -7965,7 +7965,7 @@ func TestParseInvalidCompositeFunctionNames(t *testing.T) { assert.True(t, ok, "Parser error does not conform to parser.Error") syntaxErr := errs.Errors[0].(*SyntaxError) - utils.AssertEqualWithDiff( + AssertEqualWithDiff( t, "expected identifier after start of function declaration, got keyword init", syntaxErr.Message, @@ -8075,7 +8075,7 @@ func TestParsePreconditionWithUnaryNegation(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -8157,7 +8157,7 @@ func TestParseInvalidAccessModifiers(t *testing.T) { t.Parallel() _, errs := testParseDeclarations("access(all) #test") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid access modifier for pragma", @@ -8173,7 +8173,7 @@ func TestParseInvalidAccessModifiers(t *testing.T) { t.Parallel() _, errs := testParseDeclarations("access(all) transaction {}") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid access modifier for transaction", @@ -8189,7 +8189,7 @@ func TestParseInvalidAccessModifiers(t *testing.T) { t.Parallel() _, errs := testParseDeclarations("access(all) access(self) let x = 1") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid second access modifier", @@ -8219,7 +8219,7 @@ func TestParseInvalidImportWithModifier(t *testing.T) { }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid static modifier for import", @@ -8238,7 +8238,7 @@ func TestParseInvalidImportWithModifier(t *testing.T) { static import x from 0x1 `) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: identifier", @@ -8263,7 +8263,7 @@ func TestParseInvalidImportWithModifier(t *testing.T) { }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid native modifier for import", @@ -8282,7 +8282,7 @@ func TestParseInvalidImportWithModifier(t *testing.T) { native import x from 0x1 `) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: identifier", @@ -8312,7 +8312,7 @@ func TestParseInvalidEventWithModifier(t *testing.T) { }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid static modifier for event", @@ -8331,7 +8331,7 @@ func TestParseInvalidEventWithModifier(t *testing.T) { static event Foo() `) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: identifier", @@ -8356,7 +8356,7 @@ func TestParseInvalidEventWithModifier(t *testing.T) { }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid native modifier for event", @@ -8375,7 +8375,7 @@ func TestParseInvalidEventWithModifier(t *testing.T) { native event Foo() `) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: identifier", @@ -8406,7 +8406,7 @@ func TestParseCompositeWithModifier(t *testing.T) { }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid static modifier for structure", @@ -8425,7 +8425,7 @@ func TestParseCompositeWithModifier(t *testing.T) { static struct Foo() `) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: identifier", @@ -8450,7 +8450,7 @@ func TestParseCompositeWithModifier(t *testing.T) { }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid native modifier for structure", @@ -8469,7 +8469,7 @@ func TestParseCompositeWithModifier(t *testing.T) { native struct Foo() `) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: identifier", @@ -8499,7 +8499,7 @@ func TestParseTransactionWithModifier(t *testing.T) { }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid static modifier for transaction", @@ -8518,7 +8518,7 @@ func TestParseTransactionWithModifier(t *testing.T) { static transaction {} `) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: identifier", @@ -8543,7 +8543,7 @@ func TestParseTransactionWithModifier(t *testing.T) { }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid native modifier for transaction", @@ -8562,7 +8562,7 @@ func TestParseTransactionWithModifier(t *testing.T) { native transaction {} `) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: identifier", @@ -8603,7 +8603,7 @@ func TestParseNestedPragma(t *testing.T) { }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid native modifier for pragma", @@ -8620,7 +8620,7 @@ func TestParseNestedPragma(t *testing.T) { _, errs := parse("native #pragma", Config{}) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: identifier", @@ -8641,7 +8641,7 @@ func TestParseNestedPragma(t *testing.T) { StaticModifierEnabled: true, }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid static modifier for pragma", @@ -8661,7 +8661,7 @@ func TestParseNestedPragma(t *testing.T) { Config{}, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: identifier", @@ -8683,7 +8683,7 @@ func TestParseNestedPragma(t *testing.T) { NativeModifierEnabled: true, }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid static modifier for pragma", @@ -8700,7 +8700,7 @@ func TestParseNestedPragma(t *testing.T) { _, errs := parse("static native #pragma", Config{}) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected identifier", @@ -8723,7 +8723,7 @@ func TestParseNestedPragma(t *testing.T) { }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid static modifier after native modifier", @@ -8740,7 +8740,7 @@ func TestParseNestedPragma(t *testing.T) { _, errs := parse("access(all) #pragma", Config{}) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid access modifier for pragma", @@ -8762,7 +8762,7 @@ func TestParseNestedPragma(t *testing.T) { NativeModifierEnabled: true, }, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid access modifier for pragma", @@ -8779,7 +8779,7 @@ func TestParseNestedPragma(t *testing.T) { _, errs := parse("access(all) static native #pragma", Config{}) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected identifier", @@ -8803,7 +8803,7 @@ func TestParseEntitlementDeclaration(t *testing.T) { result, errs := testParseDeclarations(" access(all) entitlement ABC ") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.EntitlementDeclaration{ Access: ast.AccessAll, @@ -8834,7 +8834,7 @@ func TestParseEntitlementDeclaration(t *testing.T) { `) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.CompositeDeclaration{ Members: ast.NewUnmeteredMembers( @@ -8897,7 +8897,7 @@ func TestParseEntitlementDeclaration(t *testing.T) { t.Parallel() _, errs := testParseDeclarations(" access(all) entitlement") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected identifier, got EOF", @@ -8913,7 +8913,7 @@ func TestParseEntitlementDeclaration(t *testing.T) { t.Parallel() _, errs := testParseDeclarations(" access(all) view entitlement E") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid view modifier for entitlement", @@ -8949,7 +8949,7 @@ func TestParseMemberDocStrings(t *testing.T) { require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.CompositeDeclaration{ Access: ast.AccessNotSpecified, @@ -9062,7 +9062,7 @@ func TestParseMemberDocStrings(t *testing.T) { require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.CompositeDeclaration{ Access: ast.AccessNotSpecified, @@ -9134,7 +9134,7 @@ func TestParseEntitlementMappingDeclaration(t *testing.T) { result, errs := testParseDeclarations(" access(all) entitlement mapping M { } ") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.EntitlementMappingDeclaration{ Access: ast.AccessAll, @@ -9162,7 +9162,7 @@ func TestParseEntitlementMappingDeclaration(t *testing.T) { } `) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.EntitlementMappingDeclaration{ Access: ast.AccessAll, @@ -9251,7 +9251,7 @@ func TestParseEntitlementMappingDeclaration(t *testing.T) { } `) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.EntitlementMappingDeclaration{ Access: ast.AccessAll, @@ -9356,7 +9356,7 @@ func TestParseEntitlementMappingDeclaration(t *testing.T) { } `) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.EntitlementMappingDeclaration{ Access: ast.AccessAll, @@ -9437,7 +9437,7 @@ func TestParseEntitlementMappingDeclaration(t *testing.T) { t.Parallel() _, errs := testParseDeclarations(" access(all) mapping M {} ") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: identifier", @@ -9453,7 +9453,7 @@ func TestParseEntitlementMappingDeclaration(t *testing.T) { t.Parallel() _, errs := testParseDeclarations(" access(all) entitlement M {} ") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: '{'", @@ -9469,7 +9469,7 @@ func TestParseEntitlementMappingDeclaration(t *testing.T) { t.Parallel() _, errs := testParseDeclarations(" access(all) entitlement mapping M ") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected token '{'", @@ -9485,7 +9485,7 @@ func TestParseEntitlementMappingDeclaration(t *testing.T) { t.Parallel() _, errs := testParseDeclarations(" access(all) entitlement mapping M {") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected token '}'", @@ -9501,7 +9501,7 @@ func TestParseEntitlementMappingDeclaration(t *testing.T) { t.Parallel() _, errs := testParseDeclarations(" access(all) entitlement mapping M }") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected token '{'", @@ -9517,7 +9517,7 @@ func TestParseEntitlementMappingDeclaration(t *testing.T) { t.Parallel() _, errs := testParseDeclarations(" access(all) entitlement mapping {}") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected identifier following entitlement mapping declaration, got '{'", @@ -9536,7 +9536,7 @@ func TestParseEntitlementMappingDeclaration(t *testing.T) { &A -> B } `) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected nominal type, got &A", @@ -9555,7 +9555,7 @@ func TestParseEntitlementMappingDeclaration(t *testing.T) { A -> [B] } `) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected nominal type, got [B]", @@ -9574,7 +9574,7 @@ func TestParseEntitlementMappingDeclaration(t *testing.T) { A B } `) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected token '->'", @@ -9593,7 +9593,7 @@ func TestParseEntitlementMappingDeclaration(t *testing.T) { A - B } `) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected token '->'", @@ -9612,7 +9612,7 @@ func TestParseEntitlementMappingDeclaration(t *testing.T) { include &A } `) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected nominal type, got &A", @@ -9631,7 +9631,7 @@ func TestParseEntitlementMappingDeclaration(t *testing.T) { include -> B } `) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token in type: '->'", @@ -9653,7 +9653,7 @@ func TestParseInvalidSpecialFunctionReturnTypeAnnotation(t *testing.T) { init(): Int } `) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid return type for initializer", @@ -9709,7 +9709,7 @@ func TestSoftKeywordsInFunctionDeclaration(t *testing.T) { }, }, } - utils.AssertEqualWithDiff(t, expected, result) + AssertEqualWithDiff(t, expected, result) }) } @@ -9728,7 +9728,7 @@ func TestParseDeprecatedAccessModifiers(t *testing.T) { t.Parallel() _, errs := testParseDeclarations(" pub fun foo ( ) { }") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxErrorWithSuggestedReplacement{ Message: "`pub` is no longer a valid access keyword", @@ -9749,7 +9749,7 @@ func TestParseDeprecatedAccessModifiers(t *testing.T) { t.Parallel() _, errs := testParseDeclarations(" priv fun foo ( ) { }") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxErrorWithSuggestedReplacement{ Message: "`priv` is no longer a valid access keyword", @@ -9770,7 +9770,7 @@ func TestParseDeprecatedAccessModifiers(t *testing.T) { t.Parallel() _, errs := testParseDeclarations(" pub(set) fun foo ( ) { }") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "`pub(set)` is no longer a valid access keyword", diff --git a/parser/expression_test.go b/parser/expression_test.go index 7acb0ac4eb..28e92f6404 100644 --- a/parser/expression_test.go +++ b/parser/expression_test.go @@ -34,7 +34,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/errors" "github.com/onflow/cadence/parser/lexer" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" ) func TestParseSimpleInfixExpression(t *testing.T) { @@ -48,7 +48,7 @@ func TestParseSimpleInfixExpression(t *testing.T) { result, errs := testParseExpression("1+2*3") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BinaryExpression{ Operation: ast.OperationPlus, Left: &ast.IntegerExpression{ @@ -93,7 +93,7 @@ func TestParseSimpleInfixExpression(t *testing.T) { result, errs := testParseExpression(" 1 + 2 * 3 ") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BinaryExpression{ Operation: ast.OperationPlus, Left: &ast.IntegerExpression{ @@ -138,7 +138,7 @@ func TestParseSimpleInfixExpression(t *testing.T) { result, errs := testParseExpression("1 + 2 + 3") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BinaryExpression{ Operation: ast.OperationPlus, Left: &ast.BinaryExpression{ @@ -183,7 +183,7 @@ func TestParseSimpleInfixExpression(t *testing.T) { result, errs := testParseExpression("1 ?? 2 ?? 3") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BinaryExpression{ Operation: ast.OperationNilCoalesce, Left: &ast.IntegerExpression{ @@ -233,7 +233,7 @@ func TestParseAdvancedExpression(t *testing.T) { result, errs := testParseExpression("1 +- 2 -- 3") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BinaryExpression{ Operation: ast.OperationMinus, Left: &ast.BinaryExpression{ @@ -278,7 +278,7 @@ func TestParseAdvancedExpression(t *testing.T) { result, errs := testParseExpression("(1 + 2) * 3") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BinaryExpression{ Operation: ast.OperationMul, Left: &ast.BinaryExpression{ @@ -356,7 +356,7 @@ func TestParseAdvancedExpression(t *testing.T) { result, errs := testParseExpression("1 < 2 > 3") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BinaryExpression{ Operation: ast.OperationGreater, Left: &ast.BinaryExpression{ @@ -401,7 +401,7 @@ func TestParseAdvancedExpression(t *testing.T) { result, errs := testParseExpression("a ? b : c ? d : e") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.ConditionalExpression{ Test: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -447,7 +447,7 @@ func TestParseAdvancedExpression(t *testing.T) { result, errs := testParseExpression("true + false") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BinaryExpression{ Operation: ast.OperationPlus, Left: &ast.BoolExpression{ @@ -476,7 +476,7 @@ func TestParseAdvancedExpression(t *testing.T) { result, errs := testParseExpression("(<-x)") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.UnaryExpression{ Operation: ast.OperationMove, Expression: &ast.IdentifierExpression{ @@ -498,7 +498,7 @@ func TestParseAdvancedExpression(t *testing.T) { result, errs := testParseExpression("<-x as! @T") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.UnaryExpression{ Operation: ast.OperationMove, Expression: &ast.CastingExpression{ @@ -533,7 +533,7 @@ func TestParseAdvancedExpression(t *testing.T) { result, errs := testParseExpression("<-x as? @T") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.UnaryExpression{ Operation: ast.OperationMove, Expression: &ast.CastingExpression{ @@ -568,7 +568,7 @@ func TestParseAdvancedExpression(t *testing.T) { result, errs := testParseExpression("<-x as @T") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.UnaryExpression{ Operation: ast.OperationMove, Expression: &ast.CastingExpression{ @@ -609,7 +609,7 @@ func TestParseArrayExpression(t *testing.T) { result, errs := testParseExpression("[ 1,2 + 3, 4 , 5 ]") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.ArrayExpression{ Values: []ast.Expression{ &ast.IntegerExpression{ @@ -677,7 +677,7 @@ func TestParseArrayExpression(t *testing.T) { result, errs := testParseExpression("[ 1 , \n 2 \n , \n\n 3 \n\n\n]") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.ArrayExpression{ Values: []ast.Expression{ &ast.IntegerExpression{ @@ -724,7 +724,7 @@ func TestParseArrayExpression(t *testing.T) { result, errs := testParseExpression("[\n]") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.ArrayExpression{ Range: ast.Range{ StartPos: ast.Position{Line: 1, Column: 0, Offset: 0}, @@ -748,7 +748,7 @@ func TestParseDictionaryExpression(t *testing.T) { result, errs := testParseExpression("{ 1:2 + 3, 4 : 5 }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.DictionaryExpression{ Entries: []ast.DictionaryEntry{ { @@ -820,7 +820,7 @@ func TestParseDictionaryExpression(t *testing.T) { result, errs := testParseExpression("{ 1 : 2 , \n 3 \n : \n 4 \n , \n\n 5 \n\n : \n\n 6 \n\n }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.DictionaryExpression{ Entries: []ast.DictionaryEntry{ { @@ -900,7 +900,7 @@ func TestParseDictionaryExpression(t *testing.T) { result, errs := testParseExpression("{\n}") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.DictionaryExpression{ Range: ast.Range{ StartPos: ast.Position{Line: 1, Column: 0, Offset: 0}, @@ -921,7 +921,7 @@ func TestParseIndexExpression(t *testing.T) { result, errs := testParseExpression("a[0]") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IndexExpression{ TargetExpression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -953,7 +953,7 @@ func TestParseIndexExpression(t *testing.T) { result, errs := testParseExpression("a [ 0 ]") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IndexExpression{ TargetExpression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -985,7 +985,7 @@ func TestParseIndexExpression(t *testing.T) { result, errs := testParseExpression("a [foo]") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IndexExpression{ TargetExpression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -1020,7 +1020,7 @@ func TestParseIdentifier(t *testing.T) { result, errs := testParseExpression("a + 3") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BinaryExpression{ Operation: ast.OperationPlus, Left: &ast.IdentifierExpression{ @@ -1051,7 +1051,7 @@ func TestParsePath(t *testing.T) { result, errs := testParseExpression("/foo/bar") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.PathExpression{ Domain: ast.Identifier{ Identifier: "foo", @@ -1078,7 +1078,7 @@ func TestParseString(t *testing.T) { result, errs := testParseExpression("\"\"") assert.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.StringExpression{ Value: "", Range: ast.Range{ @@ -1095,7 +1095,7 @@ func TestParseString(t *testing.T) { t.Parallel() result, errs := testParseExpression("\"") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid end of string literal: missing '\"'", @@ -1105,7 +1105,7 @@ func TestParseString(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.StringExpression{ Value: "", Range: ast.Range{ @@ -1122,7 +1122,7 @@ func TestParseString(t *testing.T) { t.Parallel() result, errs := testParseExpression("\"\n") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid end of string literal: missing '\"'", @@ -1132,7 +1132,7 @@ func TestParseString(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.StringExpression{ Value: "", Range: ast.Range{ @@ -1148,7 +1148,7 @@ func TestParseString(t *testing.T) { t.Parallel() result, errs := testParseExpression("\"t") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid end of string literal: missing '\"'", @@ -1158,7 +1158,7 @@ func TestParseString(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.StringExpression{ Value: "t", Range: ast.Range{ @@ -1175,7 +1175,7 @@ func TestParseString(t *testing.T) { t.Parallel() result, errs := testParseExpression("\"t\n") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid end of string literal: missing '\"'", @@ -1185,7 +1185,7 @@ func TestParseString(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.StringExpression{ Value: "t", Range: ast.Range{ @@ -1202,7 +1202,7 @@ func TestParseString(t *testing.T) { t.Parallel() result, errs := testParseExpression("\"\\") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "incomplete escape sequence: missing character after escape character", @@ -1216,7 +1216,7 @@ func TestParseString(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.StringExpression{ Value: "", Range: ast.Range{ @@ -1235,7 +1235,7 @@ func TestParseString(t *testing.T) { result, errs := testParseExpression(`"te\tst\"te\u{1F3CE}\u{FE0F}xt"`) assert.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.StringExpression{ Value: "te\tst\"te\U0001F3CE\uFE0Fxt", Range: ast.Range{ @@ -1252,7 +1252,7 @@ func TestParseString(t *testing.T) { t.Parallel() result, errs := testParseExpression(`"te\Xst"`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid escape character: 'X'", @@ -1262,7 +1262,7 @@ func TestParseString(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.StringExpression{ Value: "test", Range: ast.Range{ @@ -1279,7 +1279,7 @@ func TestParseString(t *testing.T) { t.Parallel() result, errs := testParseExpression(`"te\u`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "incomplete Unicode escape sequence: missing character '{' after escape character", @@ -1293,7 +1293,7 @@ func TestParseString(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.StringExpression{ Value: "te", Range: ast.Range{ @@ -1310,7 +1310,7 @@ func TestParseString(t *testing.T) { t.Parallel() result, errs := testParseExpression(`"te\us`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid Unicode escape sequence: expected '{', got 's'", @@ -1324,7 +1324,7 @@ func TestParseString(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.StringExpression{ Value: "te", Range: ast.Range{ @@ -1341,7 +1341,7 @@ func TestParseString(t *testing.T) { t.Parallel() result, errs := testParseExpression(`"te\u{`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "incomplete Unicode escape sequence: missing character '}' after escape character", @@ -1355,7 +1355,7 @@ func TestParseString(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.StringExpression{ Value: "te", Range: ast.Range{ @@ -1374,7 +1374,7 @@ func TestParseString(t *testing.T) { result, errs := testParseExpression(`"te\u{}"`) assert.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.StringExpression{ Value: "te", Range: ast.Range{ @@ -1401,7 +1401,7 @@ func TestParseString(t *testing.T) { ) assert.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.StringExpression{ Value: "test JJJJ KKKK LLLL MMMM NNNN OOOO", Range: ast.Range{ @@ -1418,7 +1418,7 @@ func TestParseString(t *testing.T) { t.Parallel() result, errs := testParseExpression(`"te\u{X}st"`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid Unicode escape sequence: expected hex digit, got 'X'", @@ -1428,7 +1428,7 @@ func TestParseString(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.StringExpression{ Value: "test", Range: ast.Range{ @@ -1452,7 +1452,7 @@ func TestParseInvocation(t *testing.T) { result, errs := testParseExpression("f()") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.InvocationExpression{ InvokedExpression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -1475,7 +1475,7 @@ func TestParseInvocation(t *testing.T) { result, errs := testParseExpression("f ()") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.InvocationExpression{ InvokedExpression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -1498,7 +1498,7 @@ func TestParseInvocation(t *testing.T) { result, errs := testParseExpression("f ( )") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.InvocationExpression{ InvokedExpression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -1521,7 +1521,7 @@ func TestParseInvocation(t *testing.T) { result, errs := testParseExpression("f(1)") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.InvocationExpression{ InvokedExpression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -1558,7 +1558,7 @@ func TestParseInvocation(t *testing.T) { result, errs := testParseExpression("f(label:1)") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.InvocationExpression{ InvokedExpression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -1597,7 +1597,7 @@ func TestParseInvocation(t *testing.T) { result, errs := testParseExpression("f(1,2)") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.InvocationExpression{ InvokedExpression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -1647,7 +1647,7 @@ func TestParseInvocation(t *testing.T) { result, errs := testParseExpression("f(a:1,b:2)") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.InvocationExpression{ InvokedExpression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -1699,7 +1699,7 @@ func TestParseInvocation(t *testing.T) { t.Parallel() _, errs := testParseExpression("f(,,)") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected argument or end of argument list, got ','", @@ -1715,7 +1715,7 @@ func TestParseInvocation(t *testing.T) { t.Parallel() _, errs := testParseExpression("f(1,,)") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected argument or end of argument list, got ','", @@ -1731,7 +1731,7 @@ func TestParseInvocation(t *testing.T) { t.Parallel() _, errs := testParseExpression("f(1 2)") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected argument in argument list (expecting delimiter or end of argument list)," + @@ -1750,7 +1750,7 @@ func TestParseInvocation(t *testing.T) { result, errs := testParseExpression("f(1,g(2))") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.InvocationExpression{ InvokedExpression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -1816,7 +1816,7 @@ func TestParseInvocation(t *testing.T) { result, errs := testParseExpression("f(1,g(\"test\"))") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.InvocationExpression{ InvokedExpression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -1885,7 +1885,7 @@ func TestParseMemberExpression(t *testing.T) { result, errs := testParseExpression("f.n") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.MemberExpression{ Expression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -1910,7 +1910,7 @@ func TestParseMemberExpression(t *testing.T) { result, errs := testParseExpression("f .n") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.MemberExpression{ Expression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -1933,7 +1933,7 @@ func TestParseMemberExpression(t *testing.T) { t.Parallel() result, errs := testParseExpression("f.") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected member name, got EOF", @@ -1943,7 +1943,7 @@ func TestParseMemberExpression(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.MemberExpression{ Expression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -1964,7 +1964,7 @@ func TestParseMemberExpression(t *testing.T) { result, errs := testParseExpression("f.n * 3") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BinaryExpression{ Operation: ast.OperationMul, Left: &ast.MemberExpression{ @@ -2001,7 +2001,7 @@ func TestParseMemberExpression(t *testing.T) { result, errs := testParseExpression("3 * f.n") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BinaryExpression{ Operation: ast.OperationMul, Left: &ast.IntegerExpression{ @@ -2038,7 +2038,7 @@ func TestParseMemberExpression(t *testing.T) { result, errs := testParseExpression("f?.n") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.MemberExpression{ Optional: true, Expression: &ast.IdentifierExpression{ @@ -2067,7 +2067,7 @@ func TestParseMemberExpression(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -2112,7 +2112,7 @@ func TestParseBlockComment(t *testing.T) { result, errs := testParseExpression(" /* test foo/* bar */ asd*/ true") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BoolExpression{ Value: true, Range: ast.Range{ @@ -2131,7 +2131,7 @@ func TestParseBlockComment(t *testing.T) { result, errs := testParseExpression(" /*test foo*/ /* bar */ true") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BoolExpression{ Value: true, Range: ast.Range{ @@ -2150,7 +2150,7 @@ func TestParseBlockComment(t *testing.T) { result, errs := testParseExpression(" 1/*test foo*/+/* bar */ 2 ") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BinaryExpression{ Operation: ast.OperationPlus, Left: &ast.IntegerExpression{ @@ -2181,7 +2181,7 @@ func TestParseBlockComment(t *testing.T) { t.Parallel() _, errs := testParseExpression(" /* test foo/* bar */ asd*/ true */ bar") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ // `true */ bar` is parsed as infix operation of path &SyntaxError{ @@ -2202,7 +2202,7 @@ func TestParseBlockComment(t *testing.T) { t.Parallel() _, errs := testParseExpression(" /* test foo/* bar */ asd true ") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ // `true */ bar` is parsed as infix operation of path &SyntaxError{ @@ -2277,7 +2277,7 @@ func TestParseBlockComment(t *testing.T) { }, Config{}, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token identifier in block comment", @@ -2300,7 +2300,7 @@ func TestParseMulInfixExpression(t *testing.T) { result, errs := testParseExpression(" 1 ** 2") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BinaryExpression{ Operation: ast.OperationMul, Left: &ast.IntegerExpression{ @@ -2373,7 +2373,7 @@ func TestParseReference(t *testing.T) { result, errs := testParseExpression("& t") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.ReferenceExpression{ Expression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -2396,7 +2396,7 @@ func TestParseReference(t *testing.T) { result, errs := testParseExpression(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.ReferenceExpression{ Expression: &ast.IndexExpression{ TargetExpression: &ast.IdentifierExpression{ @@ -2429,7 +2429,7 @@ func TestParseReference(t *testing.T) { const code = `&x[y]? as &Z?` _, errs := testParseExpression(code) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected end of program", @@ -2454,7 +2454,7 @@ func TestParseNilCoelesceReference(t *testing.T) { `) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BinaryExpression{ Operation: ast.OperationNilCoalesce, Left: &ast.CastingExpression{ @@ -2570,7 +2570,7 @@ func TestParseCasts(t *testing.T) { result, errs := testParseExpression(" t as T") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.CastingExpression{ Operation: ast.OperationCast, Expression: &ast.IdentifierExpression{ @@ -2600,7 +2600,7 @@ func TestParseCasts(t *testing.T) { result, errs := testParseExpression(" t as? T") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.CastingExpression{ Operation: ast.OperationFailableCast, Expression: &ast.IdentifierExpression{ @@ -2631,7 +2631,7 @@ func TestParseCasts(t *testing.T) { result, errs := testParseExpression(" t as! T") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.CastingExpression{ Operation: ast.OperationForceCast, Expression: &ast.IdentifierExpression{ @@ -2666,7 +2666,7 @@ func TestParseForceExpression(t *testing.T) { result, errs := testParseExpression("t!") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.ForceExpression{ Expression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -2687,7 +2687,7 @@ func TestParseForceExpression(t *testing.T) { result, errs := testParseExpression(" t ! ") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.ForceExpression{ Expression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -2708,7 +2708,7 @@ func TestParseForceExpression(t *testing.T) { result, errs := testParseExpression("<-t!") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.UnaryExpression{ Operation: ast.OperationMove, Expression: &ast.ForceExpression{ @@ -2733,7 +2733,7 @@ func TestParseForceExpression(t *testing.T) { result, errs := testParseExpression("10 * t!") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BinaryExpression{ Operation: ast.OperationMul, Left: &ast.IntegerExpression{ @@ -2765,7 +2765,7 @@ func TestParseForceExpression(t *testing.T) { result, errs := testParseStatements("x\n!y") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.ExpressionStatement{ Expression: &ast.IdentifierExpression{ @@ -2799,7 +2799,7 @@ func TestParseForceExpression(t *testing.T) { result, errs := testParseStatements("x\n.y!") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.ExpressionStatement{ Expression: &ast.ForceExpression{ @@ -2829,7 +2829,7 @@ func TestParseForceExpression(t *testing.T) { t.Parallel() result, errs := testParseStatements("x. y") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid whitespace after '.'", @@ -2839,7 +2839,7 @@ func TestParseForceExpression(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.ExpressionStatement{ Expression: &ast.MemberExpression{ @@ -2873,7 +2873,7 @@ func TestParseCreate(t *testing.T) { result, errs := testParseExpression("create T()") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.CreateExpression{ InvocationExpression: &ast.InvocationExpression{ InvokedExpression: &ast.IdentifierExpression{ @@ -2899,7 +2899,7 @@ func TestParseNil(t *testing.T) { result, errs := testParseExpression(" nil") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.NilExpression{ Pos: ast.Position{Line: 1, Column: 1, Offset: 1}, }, @@ -2918,7 +2918,7 @@ func TestParseDestroy(t *testing.T) { result, errs := testParseExpression("destroy t") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.DestroyExpression{ Expression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -2944,7 +2944,7 @@ func TestParseAttach(t *testing.T) { result, errs := testParseExpression("attach E() to r") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.AttachExpression{ Base: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -2973,7 +2973,7 @@ func TestParseAttach(t *testing.T) { t.Parallel() _, errs := testParseExpression("attach E() to r with (X)") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: identifier", @@ -2991,7 +2991,7 @@ func TestParseAttach(t *testing.T) { result, errs := testParseExpression("attach A() to attach B() to r") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.AttachExpression{ Base: &ast.AttachExpression{ Base: &ast.IdentifierExpression{ @@ -3033,7 +3033,7 @@ func TestParseAttach(t *testing.T) { t.Parallel() _, errs := testParseExpression("attach A()") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected 'to', got EOF", @@ -3049,7 +3049,7 @@ func TestParseAttach(t *testing.T) { t.Parallel() _, errs := testParseExpression("attach E() to") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected end of program", @@ -3068,7 +3068,7 @@ func TestParseLineComment(t *testing.T) { result, errs := testParseExpression(" //// // this is a comment\n 1 / 2") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BinaryExpression{ Operation: ast.OperationDiv, Left: &ast.IntegerExpression{ @@ -3105,7 +3105,7 @@ func TestParseFunctionExpression(t *testing.T) { result, errs := testParseExpression("fun () { }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.FunctionExpression{ ParameterList: &ast.ParameterList{ Parameters: nil, @@ -3135,7 +3135,7 @@ func TestParseFunctionExpression(t *testing.T) { result, errs := testParseExpression("fun (): X { }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.FunctionExpression{ ParameterList: &ast.ParameterList{ Parameters: nil, @@ -3174,7 +3174,7 @@ func TestParseFunctionExpression(t *testing.T) { result, errs := testParseExpression("view fun (): X { }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.FunctionExpression{ Purity: 1, ParameterList: &ast.ParameterList{ @@ -3212,7 +3212,7 @@ func TestParseFunctionExpression(t *testing.T) { t.Parallel() _, errs := testParseExpression("view for (): X { }") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: identifier", @@ -3255,7 +3255,7 @@ func TestParseAdjacentViewKeyword(t *testing.T) { }, StartPos: ast.Position{Line: 2, Column: 2, Offset: 3}, } - utils.AssertEqualWithDiff(t, expected, result) + AssertEqualWithDiff(t, expected, result) } @@ -3268,7 +3268,7 @@ func TestParseIntegerLiterals(t *testing.T) { t.Parallel() result, errs := testParseExpression(`0b`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "missing digits", @@ -3287,7 +3287,7 @@ func TestParseIntegerLiterals(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("0b"), Value: new(big.Int), @@ -3308,7 +3308,7 @@ func TestParseIntegerLiterals(t *testing.T) { result, errs := testParseExpression(`0b101010`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("0b101010"), Value: big.NewInt(42), @@ -3327,7 +3327,7 @@ func TestParseIntegerLiterals(t *testing.T) { result, errs := testParseExpression(`0b001000`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("0b001000"), Value: big.NewInt(8), @@ -3348,7 +3348,7 @@ func TestParseIntegerLiterals(t *testing.T) { result, errs := testParseExpression(`0b101010_101010`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("0b101010_101010"), Value: big.NewInt(2730), @@ -3367,7 +3367,7 @@ func TestParseIntegerLiterals(t *testing.T) { t.Parallel() result, errs := testParseExpression(`0b_101010_101010`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &InvalidIntegerLiteralError{ Literal: "0b_101010_101010", @@ -3382,7 +3382,7 @@ func TestParseIntegerLiterals(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("0b_101010_101010"), Value: big.NewInt(2730), @@ -3401,7 +3401,7 @@ func TestParseIntegerLiterals(t *testing.T) { t.Parallel() result, errs := testParseExpression(`0b101010_101010_`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &InvalidIntegerLiteralError{ Literal: "0b101010_101010_", @@ -3416,7 +3416,7 @@ func TestParseIntegerLiterals(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("0b101010_101010_"), Value: big.NewInt(2730), @@ -3435,7 +3435,7 @@ func TestParseIntegerLiterals(t *testing.T) { t.Parallel() result, errs := testParseExpression(`0o`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "missing digits", @@ -3454,7 +3454,7 @@ func TestParseIntegerLiterals(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("0o"), Value: new(big.Int), @@ -3475,7 +3475,7 @@ func TestParseIntegerLiterals(t *testing.T) { result, errs := testParseExpression(`0o32`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("0o32"), Value: big.NewInt(26), @@ -3496,7 +3496,7 @@ func TestParseIntegerLiterals(t *testing.T) { result, errs := testParseExpression(`0o32_45`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("0o32_45"), Value: big.NewInt(1701), @@ -3515,7 +3515,7 @@ func TestParseIntegerLiterals(t *testing.T) { t.Parallel() result, errs := testParseExpression(`0o_32_45`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &InvalidIntegerLiteralError{ Literal: "0o_32_45", @@ -3530,7 +3530,7 @@ func TestParseIntegerLiterals(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("0o_32_45"), Value: big.NewInt(1701), @@ -3549,7 +3549,7 @@ func TestParseIntegerLiterals(t *testing.T) { t.Parallel() result, errs := testParseExpression(`0o32_45_`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &InvalidIntegerLiteralError{ Literal: "0o32_45_", @@ -3564,7 +3564,7 @@ func TestParseIntegerLiterals(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("0o32_45_"), Value: big.NewInt(1701), @@ -3585,7 +3585,7 @@ func TestParseIntegerLiterals(t *testing.T) { result, errs := testParseExpression(`1234567890`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("1234567890"), Value: big.NewInt(1234567890), @@ -3606,7 +3606,7 @@ func TestParseIntegerLiterals(t *testing.T) { result, errs := testParseExpression(`1_234_567_890`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("1_234_567_890"), Value: big.NewInt(1234567890), @@ -3625,7 +3625,7 @@ func TestParseIntegerLiterals(t *testing.T) { t.Parallel() result, errs := testParseExpression(`1_234_567_890_`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &InvalidIntegerLiteralError{ Literal: "1_234_567_890_", @@ -3640,7 +3640,7 @@ func TestParseIntegerLiterals(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("1_234_567_890_"), Value: big.NewInt(1234567890), @@ -3659,7 +3659,7 @@ func TestParseIntegerLiterals(t *testing.T) { t.Parallel() result, errs := testParseExpression(`0x`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "missing digits", @@ -3678,7 +3678,7 @@ func TestParseIntegerLiterals(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("0x"), Value: new(big.Int), @@ -3699,7 +3699,7 @@ func TestParseIntegerLiterals(t *testing.T) { result, errs := testParseExpression(`0xf2`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("0xf2"), Value: big.NewInt(242), @@ -3720,7 +3720,7 @@ func TestParseIntegerLiterals(t *testing.T) { result, errs := testParseExpression(`0xf2_09`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("0xf2_09"), Value: big.NewInt(61961), @@ -3739,7 +3739,7 @@ func TestParseIntegerLiterals(t *testing.T) { t.Parallel() result, errs := testParseExpression(`0x_f2_09`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &InvalidIntegerLiteralError{ Literal: "0x_f2_09", @@ -3754,7 +3754,7 @@ func TestParseIntegerLiterals(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("0x_f2_09"), Value: big.NewInt(61961), @@ -3773,7 +3773,7 @@ func TestParseIntegerLiterals(t *testing.T) { t.Parallel() result, errs := testParseExpression(`0xf2_09_`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &InvalidIntegerLiteralError{ Literal: `0xf2_09_`, @@ -3788,7 +3788,7 @@ func TestParseIntegerLiterals(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("0xf2_09_"), Value: big.NewInt(61961), @@ -3809,7 +3809,7 @@ func TestParseIntegerLiterals(t *testing.T) { result, errs := testParseExpression(`0`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("0"), Value: big.NewInt(0), @@ -3830,7 +3830,7 @@ func TestParseIntegerLiterals(t *testing.T) { result, errs := testParseExpression(`01`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("01"), Value: big.NewInt(1), @@ -3851,7 +3851,7 @@ func TestParseIntegerLiterals(t *testing.T) { result, errs := testParseExpression(`09`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("09"), Value: big.NewInt(9), @@ -3872,7 +3872,7 @@ func TestParseIntegerLiterals(t *testing.T) { result, errs := testParseExpression("00123") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("00123"), Value: big.NewInt(123), @@ -3891,7 +3891,7 @@ func TestParseIntegerLiterals(t *testing.T) { t.Parallel() result, errs := testParseExpression(`0z123`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid number literal prefix: 'z'", @@ -3910,7 +3910,7 @@ func TestParseIntegerLiterals(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("0z123"), Value: new(big.Int), @@ -3931,7 +3931,7 @@ func TestParseIntegerLiterals(t *testing.T) { result, errs := testParseExpression(`0_100`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("0_100"), Value: big.NewInt(100), @@ -3952,7 +3952,7 @@ func TestParseIntegerLiterals(t *testing.T) { result, errs := testParseExpression(`1_100`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntegerExpression{ PositiveLiteral: []byte("1_100"), Value: big.NewInt(1100), @@ -3975,7 +3975,7 @@ func TestParseIntegerLiterals(t *testing.T) { result, errs := testParseExpression(`_100`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IdentifierExpression{ Identifier: ast.Identifier{ Identifier: "_100", @@ -3998,7 +3998,7 @@ func TestParseFixedPoint(t *testing.T) { result, errs := testParseExpression("1234_5678_90.0009_8765_4321") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.FixedPointExpression{ PositiveLiteral: []byte("1234_5678_90.0009_8765_4321"), Negative: false, @@ -4021,7 +4021,7 @@ func TestParseFixedPoint(t *testing.T) { result, errs := testParseExpression("0.1") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.FixedPointExpression{ PositiveLiteral: []byte("0.1"), Negative: false, @@ -4042,7 +4042,7 @@ func TestParseFixedPoint(t *testing.T) { t.Parallel() result, errs := testParseExpression("0.") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "missing fractional digits", @@ -4052,7 +4052,7 @@ func TestParseFixedPoint(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.FixedPointExpression{ PositiveLiteral: []byte("0."), Negative: false, @@ -4080,7 +4080,7 @@ func TestParseLessThanOrTypeArguments(t *testing.T) { result, errs := testParseExpression("1 < 2") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BinaryExpression{ Operation: ast.OperationLess, Left: &ast.IntegerExpression{ @@ -4113,7 +4113,7 @@ func TestParseLessThanOrTypeArguments(t *testing.T) { result, errs := testParseExpression("a < > ()") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.InvocationExpression{ InvokedExpression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -4137,7 +4137,7 @@ func TestParseLessThanOrTypeArguments(t *testing.T) { result, errs := testParseExpression("a < { K : V } > ( 1 )") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.InvocationExpression{ InvokedExpression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -4197,7 +4197,7 @@ func TestParseLessThanOrTypeArguments(t *testing.T) { result, errs := testParseExpression("a < { K : V } , @R , [ S ] > ( 1 , 2 )") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.InvocationExpression{ InvokedExpression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -4295,7 +4295,7 @@ func TestParseLessThanOrTypeArguments(t *testing.T) { result, errs := testParseExpression("1 + a<>()") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BinaryExpression{ Operation: ast.OperationPlus, Left: &ast.IntegerExpression{ @@ -4331,7 +4331,7 @@ func TestParseLessThanOrTypeArguments(t *testing.T) { result, errs := testParseExpression("a>()") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.InvocationExpression{ InvokedExpression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -4381,7 +4381,7 @@ func TestParseLessThanOrTypeArguments(t *testing.T) { result, errs := testParseExpression("a >()") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.InvocationExpression{ InvokedExpression: &ast.IdentifierExpression{ Identifier: ast.Identifier{ @@ -4431,7 +4431,7 @@ func TestParseLessThanOrTypeArguments(t *testing.T) { result, errs := testParseExpression("0 + 1 < 2") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BinaryExpression{ Operation: ast.OperationLess, Left: &ast.BinaryExpression{ @@ -4476,7 +4476,7 @@ func TestParseLessThanOrTypeArguments(t *testing.T) { result, errs := testParseExpression("0 + 1 << 2") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BinaryExpression{ Operation: ast.OperationBitwiseLeftShift, Left: &ast.BinaryExpression{ @@ -4521,7 +4521,7 @@ func TestParseLessThanOrTypeArguments(t *testing.T) { result, errs := testParseExpression("0 + 1 > 2") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BinaryExpression{ Operation: ast.OperationGreater, Left: &ast.BinaryExpression{ @@ -4566,7 +4566,7 @@ func TestParseLessThanOrTypeArguments(t *testing.T) { result, errs := testParseExpression("0 + 1 >> 2") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.BinaryExpression{ Operation: ast.OperationBitwiseRightShift, Left: &ast.BinaryExpression{ @@ -4609,7 +4609,7 @@ func TestParseLessThanOrTypeArguments(t *testing.T) { t.Parallel() _, errs := testParseExpression("foo") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &RestrictedTypeError{ Range: ast.Range{ @@ -4633,7 +4633,7 @@ func TestParseBoolExpression(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -4670,7 +4670,7 @@ func TestParseIdentifierExpression(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -4706,7 +4706,7 @@ func TestParseArrayExpressionInVariableDeclaration(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -4761,7 +4761,7 @@ func TestParseDictionaryExpressionInVariableDeclaration(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -4834,7 +4834,7 @@ func TestParseInvocationExpressionWithoutLabels(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -4902,7 +4902,7 @@ func TestParseInvocationExpressionWithLabels(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -4989,7 +4989,7 @@ func TestParseOptionalMemberExpression(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -5033,7 +5033,7 @@ func TestParseIndexExpressionInVariableDeclaration(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -5087,7 +5087,7 @@ func TestParseUnaryExpression(t *testing.T) { result, errs := testParseExpression(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.UnaryExpression{ Operation: ast.OperationMinus, Expression: &ast.IdentifierExpression{ @@ -5111,7 +5111,7 @@ func TestParseUnaryExpression(t *testing.T) { result, errs := testParseExpression(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.UnaryExpression{ Operation: ast.OperationNegate, Expression: &ast.IdentifierExpression{ @@ -5135,7 +5135,7 @@ func TestParseUnaryExpression(t *testing.T) { result, errs := testParseExpression(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.UnaryExpression{ Operation: ast.OperationMul, Expression: &ast.IdentifierExpression{ @@ -5157,7 +5157,7 @@ func TestParseUnaryExpression(t *testing.T) { const code = ` % boo` _, errs := testParseExpression(code) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token in expression: '%'", @@ -5179,7 +5179,7 @@ func TestParseOrExpression(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -5226,7 +5226,7 @@ func TestParseAndExpression(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -5273,7 +5273,7 @@ func TestParseEqualityExpression(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -5320,7 +5320,7 @@ func TestParseRelationalExpression(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -5371,7 +5371,7 @@ func TestParseAdditiveExpression(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -5422,7 +5422,7 @@ func TestParseMultiplicativeExpression(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -5473,7 +5473,7 @@ func TestParseFunctionExpressionAndReturn(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -5547,7 +5547,7 @@ func TestParseLeftAssociativity(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -5610,7 +5610,7 @@ func TestParseNegativeInteger(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -5649,7 +5649,7 @@ func TestParseNegativeFixedPoint(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -5692,7 +5692,7 @@ func TestParseTernaryRightAssociativity(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -5795,7 +5795,7 @@ func TestParseVoidLiteral(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -5841,7 +5841,7 @@ func TestParseMissingReturnType(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -5983,7 +5983,7 @@ func TestParseExpression(t *testing.T) { }, } - utils.AssertEqualWithDiff(t, expected, actual) + AssertEqualWithDiff(t, expected, actual) } func TestParseStringEscapes(t *testing.T) { @@ -6011,7 +6011,7 @@ func TestParseStringEscapes(t *testing.T) { }, } - utils.AssertEqualWithDiff(t, expected, actual) + AssertEqualWithDiff(t, expected, actual) } func TestParseStringWithUnicode(t *testing.T) { @@ -6039,7 +6039,7 @@ func TestParseStringWithUnicode(t *testing.T) { }, } - utils.AssertEqualWithDiff(t, expected, actual) + AssertEqualWithDiff(t, expected, actual) } func TestParseNilCoalescing(t *testing.T) { @@ -6052,7 +6052,7 @@ func TestParseNilCoalescing(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -6098,7 +6098,7 @@ func TestParseNilCoalescingRightAssociativity(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -6201,7 +6201,7 @@ func TestParseFailableCasting(t *testing.T) { failableDowncast.ParentVariableDeclaration = variableDeclaration - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ variableDeclaration, }, @@ -6219,7 +6219,7 @@ func TestParseMoveOperator(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -6277,7 +6277,7 @@ func TestParseFunctionExpressionWithResourceTypeAnnotation(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ @@ -6386,7 +6386,7 @@ func TestParseFailableCastingResourceTypeAnnotation(t *testing.T) { failableDowncast.ParentVariableDeclaration = variableDeclaration - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ variableDeclaration, }, @@ -6440,7 +6440,7 @@ func TestParseCasting(t *testing.T) { cast.ParentVariableDeclaration = variableDeclaration - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ variableDeclaration, }, @@ -6484,7 +6484,7 @@ func TestParseHardKeywords(t *testing.T) { t.Parallel() testParseIdentifiersWith(t, HardKeywords, func(t *testing.T, keyword string, err error) { - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Pos: ast.Position{Line: 1, Column: 4, Offset: 4}, @@ -6573,7 +6573,7 @@ func TestParseReferenceInVariableDeclaration(t *testing.T) { expected.Value.(*ast.CastingExpression).ParentVariableDeclaration = expected - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ expected, }, @@ -6591,7 +6591,7 @@ func TestParseFixedPointExpression(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -6631,7 +6631,7 @@ func TestParseFixedPointExpressionZeroInteger(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -6671,7 +6671,7 @@ func TestParsePathLiteral(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -6711,7 +6711,7 @@ func TestParseBitwiseExpression(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, diff --git a/parser/lexer/lexer_test.go b/parser/lexer/lexer_test.go index d6562fdebd..c529b750ce 100644 --- a/parser/lexer/lexer_test.go +++ b/parser/lexer/lexer_test.go @@ -28,7 +28,7 @@ import ( "go.uber.org/goleak" "github.com/onflow/cadence/ast" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" ) func TestMain(m *testing.M) { @@ -67,7 +67,7 @@ func testLex(t *testing.T, input string, expected []token) { require.NoError(t, err) withTokens(tokenStream, func(actualTokens []Token) { - utils.AssertEqualWithDiff(t, expectedTokens, actualTokens) + AssertEqualWithDiff(t, expectedTokens, actualTokens) require.Len(t, actualTokens, len(expectedTokens)) for i, expectedToken := range expected { diff --git a/parser/parser_test.go b/parser/parser_test.go index 93bc5f4918..3629ac6b43 100644 --- a/parser/parser_test.go +++ b/parser/parser_test.go @@ -33,7 +33,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/errors" "github.com/onflow/cadence/parser/lexer" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" ) func TestMain(m *testing.M) { @@ -240,7 +240,7 @@ func TestParseBuffering(t *testing.T) { Config{}, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected token identifier with string value c", @@ -483,7 +483,7 @@ func TestParseBuffering(t *testing.T) { Config{}, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected token identifier with string value d", @@ -511,7 +511,7 @@ func TestParseBuffering(t *testing.T) { } ` _, err := testParseProgram(code) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected token identifier", @@ -536,7 +536,7 @@ func TestParseBuffering(t *testing.T) { ` _, err := testParseProgram(code) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &RestrictedTypeError{ Range: ast.Range{ @@ -705,7 +705,7 @@ func TestParseArgumentList(t *testing.T) { t.Parallel() _, errs := testParseArgumentList(`xyz`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected token '('", @@ -724,7 +724,7 @@ func TestParseArgumentList(t *testing.T) { var expected ast.Arguments - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, expected, result, ) @@ -750,7 +750,7 @@ func TestParseArgumentList(t *testing.T) { result, errs := testParseArgumentList(`(1, b: true)`) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, ast.Arguments{ { Label: "", @@ -835,7 +835,7 @@ func TestParseBufferedErrors(t *testing.T) { // there is another error (missing closing parenthesis after). _, errs := testParseExpression("a(") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "missing type annotation after comma", @@ -874,7 +874,7 @@ func TestParseExpressionDepthLimit(t *testing.T) { _, err := testParseProgram(code) require.Error(t, err) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ ExpressionDepthLimitReachedError{ Pos: ast.Position{ @@ -910,7 +910,7 @@ func TestParseTypeDepthLimit(t *testing.T) { _, err := testParseProgram(code) require.Error(t, err) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ TypeDepthLimitReachedError{ Pos: ast.Position{ @@ -936,7 +936,7 @@ func TestParseLocalReplayLimit(t *testing.T) { code := []byte(builder.String()) _, err := ParseProgram(nil, code, Config{}) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, Error{ Code: code, Errors: []error{ @@ -971,7 +971,7 @@ func TestParseGlobalReplayLimit(t *testing.T) { code := []byte(builder.String()) _, err := ParseProgram(nil, code, Config{}) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, Error{ Code: code, Errors: []error{ diff --git a/parser/statement_test.go b/parser/statement_test.go index 8e3b6762cb..397fd3c19d 100644 --- a/parser/statement_test.go +++ b/parser/statement_test.go @@ -27,7 +27,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/ast" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" ) func TestParseReplInput(t *testing.T) { @@ -65,7 +65,7 @@ func TestParseReturnStatement(t *testing.T) { result, errs := testParseStatements("return") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.ReturnStatement{ Range: ast.Range{ @@ -85,7 +85,7 @@ func TestParseReturnStatement(t *testing.T) { result, errs := testParseStatements("return 1") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.ReturnStatement{ Expression: &ast.IntegerExpression{ @@ -114,7 +114,7 @@ func TestParseReturnStatement(t *testing.T) { result, errs := testParseStatements("return \n1") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.ReturnStatement{ Range: ast.Range{ @@ -145,7 +145,7 @@ func TestParseReturnStatement(t *testing.T) { result, errs := testParseStatements("return ;\n1") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.ReturnStatement{ Range: ast.Range{ @@ -181,7 +181,7 @@ func TestParseIfStatement(t *testing.T) { result, errs := testParseStatements("if true { }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.IfStatement{ Test: &ast.BoolExpression{ @@ -212,7 +212,7 @@ func TestParseIfStatement(t *testing.T) { result, errs := testParseStatements("if true { 1 ; 2 }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.IfStatement{ Test: &ast.BoolExpression{ @@ -266,7 +266,7 @@ func TestParseIfStatement(t *testing.T) { result, errs := testParseStatements("if true { 1 \n 2 }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.IfStatement{ Test: &ast.BoolExpression{ @@ -320,7 +320,7 @@ func TestParseIfStatement(t *testing.T) { result, errs := testParseStatements("if true { 1 } else { 2 }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.IfStatement{ Test: &ast.BoolExpression{ @@ -382,7 +382,7 @@ func TestParseIfStatement(t *testing.T) { result, errs := testParseStatements("if true{1}else if true {2} else{3}") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.IfStatement{ Test: &ast.BoolExpression{ @@ -516,7 +516,7 @@ func TestParseIfStatement(t *testing.T) { expected.Test.(*ast.VariableDeclaration).ParentIfStatement = expected - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ expected, }, @@ -566,7 +566,7 @@ func TestParseIfStatement(t *testing.T) { expected.Test.(*ast.VariableDeclaration).ParentIfStatement = expected - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ expected, }, @@ -587,7 +587,7 @@ func TestParseWhileStatement(t *testing.T) { result, errs := testParseStatements("while true { }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.WhileStatement{ Test: &ast.BoolExpression{ @@ -623,7 +623,7 @@ func TestParseAssignmentStatement(t *testing.T) { result, errs := testParseStatements("x=1") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.AssignmentStatement{ Target: &ast.IdentifierExpression{ @@ -658,7 +658,7 @@ func TestParseAssignmentStatement(t *testing.T) { result, errs := testParseStatements(" x = 1") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.AssignmentStatement{ Target: &ast.IdentifierExpression{ @@ -693,7 +693,7 @@ func TestParseAssignmentStatement(t *testing.T) { result, errs := testParseStatements(" x <- 1") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.AssignmentStatement{ Target: &ast.IdentifierExpression{ @@ -728,7 +728,7 @@ func TestParseAssignmentStatement(t *testing.T) { result, errs := testParseStatements(" x <-! 1") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.AssignmentStatement{ Target: &ast.IdentifierExpression{ @@ -768,7 +768,7 @@ func TestParseSwapStatement(t *testing.T) { result, errs := testParseStatements(" x <-> y") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.SwapStatement{ Left: &ast.IdentifierExpression{ @@ -801,7 +801,7 @@ func TestParseForStatement(t *testing.T) { result, errs := testParseStatements("for x in y { }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.ForStatement{ Identifier: ast.Identifier{ @@ -840,7 +840,7 @@ func TestParseForStatementIndexBinding(t *testing.T) { result, errs := testParseStatements("for i, x in y { }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.ForStatement{ Identifier: ast.Identifier{ @@ -876,7 +876,7 @@ func TestParseForStatementIndexBinding(t *testing.T) { t.Parallel() _, errs := testParseStatements("for i x in y { }") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected keyword \"in\", got identifier", @@ -896,7 +896,7 @@ func TestParseForStatementIndexBinding(t *testing.T) { t.Parallel() _, errs := testParseStatements("for in y { }") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected identifier, got keyword \"in\"", @@ -923,7 +923,7 @@ func TestParseEmit(t *testing.T) { result, errs := testParseStatements("emit T()") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.EmitStatement{ InvocationExpression: &ast.InvocationExpression{ @@ -955,7 +955,7 @@ func TestParseFunctionStatementOrExpression(t *testing.T) { result, errs := testParseStatements("fun foo() {}") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -991,7 +991,7 @@ func TestParseFunctionStatementOrExpression(t *testing.T) { result, errs := testParseStatements("view fun () {}") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.ExpressionStatement{ Expression: &ast.FunctionExpression{ @@ -1025,7 +1025,7 @@ func TestParseFunctionStatementOrExpression(t *testing.T) { result, errs := testParseStatements("view fun foo() {}") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.FunctionDeclaration{ Purity: ast.FunctionPurityView, @@ -1062,7 +1062,7 @@ func TestParseFunctionStatementOrExpression(t *testing.T) { result, errs := testParseStatements("fun () {}") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.ExpressionStatement{ Expression: &ast.FunctionExpression{ @@ -1095,7 +1095,7 @@ func TestParseFunctionStatementOrExpression(t *testing.T) { require.Empty(t, result) - utils.AssertEqualWithDiff(t, []error{ + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected identifier after start of function declaration, got keyword continue", Pos: ast.Position{Line: 1, Column: 4, Offset: 4}, @@ -1110,7 +1110,7 @@ func TestParseFunctionStatementOrExpression(t *testing.T) { require.Empty(t, result) - utils.AssertEqualWithDiff(t, []error{ + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected identifier after start of function declaration, got keyword break", Pos: ast.Position{Line: 1, Column: 9, Offset: 9}, @@ -1123,7 +1123,7 @@ func TestParseViewNonFunction(t *testing.T) { t.Parallel() _, errs := testParseStatements("view return 3") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "statements on the same line must be separated with a semicolon", @@ -1145,7 +1145,7 @@ func TestParseStatements(t *testing.T) { result, errs := testParseStatements("a + b < c\nd") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.ExpressionStatement{ Expression: &ast.BinaryExpression{ @@ -1191,7 +1191,7 @@ func TestParseStatements(t *testing.T) { t.Parallel() result, errs := testParseStatements(`assert true`) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "statements on the same line must be separated with a semicolon", @@ -1201,7 +1201,7 @@ func TestParseStatements(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.ExpressionStatement{ Expression: &ast.IdentifierExpression{ @@ -1237,7 +1237,7 @@ func TestParseRemoveAttachmentStatement(t *testing.T) { result, errs := testParseStatements("remove A from b") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.RemoveStatement{ Attachment: &ast.NominalType{ @@ -1266,7 +1266,7 @@ func TestParseRemoveAttachmentStatement(t *testing.T) { result, errs := testParseStatements("remove Foo.E from b") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.RemoveStatement{ Attachment: &ast.NominalType{ @@ -1300,7 +1300,7 @@ func TestParseRemoveAttachmentStatement(t *testing.T) { _, errs := testParseStatements("remove A") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected from keyword, got EOF", @@ -1321,7 +1321,7 @@ func TestParseRemoveAttachmentStatement(t *testing.T) { _, errs := testParseStatements("remove A from") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected end of program", @@ -1338,7 +1338,7 @@ func TestParseRemoveAttachmentStatement(t *testing.T) { _, errs := testParseStatements("remove [A] from e") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected attachment nominal type, got [A]", @@ -1356,7 +1356,7 @@ func TestParseRemoveAttachmentStatement(t *testing.T) { result, errs := testParseStatements("remove A from foo()") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.RemoveStatement{ Attachment: &ast.NominalType{ @@ -1394,7 +1394,7 @@ func TestParseSwitchStatement(t *testing.T) { result, errs := testParseStatements("switch true { }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.SwitchStatement{ Expression: &ast.BoolExpression{ @@ -1422,7 +1422,7 @@ func TestParseSwitchStatement(t *testing.T) { result, errs := testParseStatements("switch x { case 1 :\n a\nb default : c\nd }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ &ast.SwitchStatement{ Expression: &ast.IdentifierExpression{ @@ -1503,7 +1503,7 @@ func TestParseSwitchStatement(t *testing.T) { t.Run("Invalid identifiers in switch cases", func(t *testing.T) { code := "switch 1 {AAAAA: break; case 3: break; default: break}" _, errs := testParseStatements(code) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, `unexpected token: got identifier, expected "case" or "default"`, errs[0].Error(), ) @@ -1529,7 +1529,7 @@ func TestParseIfStatementInFunctionDeclaration(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -1731,7 +1731,7 @@ func TestParseIfStatementWithVariableDeclaration(t *testing.T) { ifStatement.Test = ifTestVariableDeclaration - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -1777,7 +1777,7 @@ func TestParseIfStatementNoElse(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -1849,7 +1849,7 @@ func TestParseWhileStatementInFunctionDeclaration(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -1929,7 +1929,7 @@ func TestParseForStatementInFunctionDeclaration(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -1991,7 +1991,7 @@ func TestParseAssignment(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -2055,7 +2055,7 @@ func TestParseAccessAssignment(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -2168,7 +2168,7 @@ func TestParseExpressionStatementWithAccess(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -2270,7 +2270,7 @@ func TestParseMoveStatement(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -2332,7 +2332,7 @@ func TestParseFunctionExpressionStatementAfterVariableDeclarationWithCreateExpre result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -2435,7 +2435,7 @@ func TestParseExpressionStatementAfterReturnStatement(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -2496,7 +2496,7 @@ func TestParseSwapStatementInFunctionDeclaration(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ Access: ast.AccessNotSpecified, @@ -2622,7 +2622,7 @@ func TestParseReferenceExpressionStatement(t *testing.T) { castingExpression.ParentVariableDeclaration = expectedVariableDeclaration - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Statement{ expectedVariableDeclaration, &ast.ExpressionStatement{ @@ -2685,7 +2685,7 @@ func TestSoftKeywordsInStatement(t *testing.T) { }, }, } - utils.AssertEqualWithDiff(t, expected, result) + AssertEqualWithDiff(t, expected, result) }) } diff --git a/parser/type_test.go b/parser/type_test.go index 5a741dc03d..e5efe9d92d 100644 --- a/parser/type_test.go +++ b/parser/type_test.go @@ -27,7 +27,7 @@ import ( "github.com/onflow/cadence/ast" "github.com/onflow/cadence/common" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" ) func TestParseNominalType(t *testing.T) { @@ -41,7 +41,7 @@ func TestParseNominalType(t *testing.T) { result, errs := testParseType("Int") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.NominalType{ Identifier: ast.Identifier{ Identifier: "Int", @@ -59,7 +59,7 @@ func TestParseNominalType(t *testing.T) { result, errs := testParseType("Foo.Bar") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.NominalType{ Identifier: ast.Identifier{ Identifier: "Foo", @@ -88,7 +88,7 @@ func TestParseArrayType(t *testing.T) { result, errs := testParseType("[Int]") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.VariableSizedType{ Type: &ast.NominalType{ Identifier: ast.Identifier{ @@ -112,7 +112,7 @@ func TestParseArrayType(t *testing.T) { result, errs := testParseType("[Int ; 2 ]") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.ConstantSizedType{ Type: &ast.NominalType{ Identifier: ast.Identifier{ @@ -143,7 +143,7 @@ func TestParseArrayType(t *testing.T) { t.Parallel() result, errs := testParseType("[Int ; -2 ]") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: `expected positive integer size for constant sized type`, @@ -166,7 +166,7 @@ func TestParseArrayType(t *testing.T) { t.Parallel() result, errs := testParseType("[Int ; X ]") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: `expected positive integer size for constant sized type`, @@ -176,7 +176,7 @@ func TestParseArrayType(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.VariableSizedType{ Type: &ast.NominalType{ Identifier: ast.Identifier{ @@ -206,7 +206,7 @@ func TestParseOptionalType(t *testing.T) { result, errs := testParseType("Int?") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.OptionalType{ Type: &ast.NominalType{ Identifier: ast.Identifier{ @@ -227,7 +227,7 @@ func TestParseOptionalType(t *testing.T) { result, errs := testParseType("Int??") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.OptionalType{ Type: &ast.OptionalType{ Type: &ast.NominalType{ @@ -251,7 +251,7 @@ func TestParseOptionalType(t *testing.T) { result, errs := testParseType("Int???") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.OptionalType{ Type: &ast.OptionalType{ Type: &ast.OptionalType{ @@ -283,7 +283,7 @@ func TestParseReferenceType(t *testing.T) { result, errs := testParseType("&Int") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.ReferenceType{ Type: &ast.NominalType{ Identifier: ast.Identifier{ @@ -302,7 +302,7 @@ func TestParseReferenceType(t *testing.T) { t.Parallel() _, errs := testParseType("auth &Int") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected authorization (entitlement list)", @@ -320,7 +320,7 @@ func TestParseReferenceType(t *testing.T) { result, errs := testParseType("auth(X) &Int") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.ReferenceType{ Authorization: &ast.ConjunctiveEntitlementSet{ Elements: []*ast.NominalType{ @@ -351,7 +351,7 @@ func TestParseReferenceType(t *testing.T) { result, errs := testParseType("auth(X, Y) &Int") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.ReferenceType{ Authorization: &ast.ConjunctiveEntitlementSet{ Elements: []*ast.NominalType{ @@ -388,7 +388,7 @@ func TestParseReferenceType(t *testing.T) { result, errs := testParseType("auth(X| Y) &Int") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.ReferenceType{ Authorization: &ast.DisjunctiveEntitlementSet{ Elements: []*ast.NominalType{ @@ -424,7 +424,7 @@ func TestParseReferenceType(t *testing.T) { _, errs := testParseType("auth() &Int") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token in type: ')'", @@ -440,7 +440,7 @@ func TestParseReferenceType(t *testing.T) { t.Parallel() _, errs := testParseType("auth(X, Y | Z) &Int") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: got '|', expected ',' or ')'", @@ -456,7 +456,7 @@ func TestParseReferenceType(t *testing.T) { t.Parallel() _, errs := testParseType("auth(X | Y, Z) &Int") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token: got ',', expected '|' or ')'", @@ -474,7 +474,7 @@ func TestParseReferenceType(t *testing.T) { result, errs := testParseType("auth ( mapping X ) & Int") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.ReferenceType{ Authorization: &ast.MappedAccess{ EntitlementMap: &ast.NominalType{ @@ -502,7 +502,7 @@ func TestParseReferenceType(t *testing.T) { t.Parallel() _, errs := testParseType("auth( mapping ) &Int") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token in type: ')'", @@ -525,7 +525,7 @@ func TestParseOptionalReferenceType(t *testing.T) { result, errs := testParseType("&Int?") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.OptionalType{ Type: &ast.ReferenceType{ Type: &ast.NominalType{ @@ -553,7 +553,7 @@ func TestParseIntersectionType(t *testing.T) { _, errs := testParseType("T{}") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &RestrictedTypeError{ Range: ast.Range{ @@ -571,7 +571,7 @@ func TestParseIntersectionType(t *testing.T) { t.Parallel() _, errs := testParseType("T{U}") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &RestrictedTypeError{ Range: ast.Range{ @@ -589,7 +589,7 @@ func TestParseIntersectionType(t *testing.T) { t.Parallel() _, errs := testParseType("T{U , V }") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &RestrictedTypeError{ Range: ast.Range{ @@ -609,7 +609,7 @@ func TestParseIntersectionType(t *testing.T) { result, errs := testParseType("{}") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntersectionType{ Range: ast.Range{ StartPos: ast.Position{Line: 1, Column: 0, Offset: 0}, @@ -627,7 +627,7 @@ func TestParseIntersectionType(t *testing.T) { result, errs := testParseType("{ T }") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntersectionType{ Types: []*ast.NominalType{ { @@ -651,7 +651,7 @@ func TestParseIntersectionType(t *testing.T) { t.Parallel() result, errs := testParseType("{ T , }") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "missing type after comma", @@ -661,7 +661,7 @@ func TestParseIntersectionType(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.IntersectionType{ Types: []*ast.NominalType{ { @@ -685,7 +685,7 @@ func TestParseIntersectionType(t *testing.T) { t.Parallel() result, errs := testParseType("{ T U }") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected type", @@ -704,7 +704,7 @@ func TestParseIntersectionType(t *testing.T) { t.Parallel() result, errs := testParseType("{ T , U : V }") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected colon in intersection type", @@ -723,7 +723,7 @@ func TestParseIntersectionType(t *testing.T) { t.Parallel() result, errs := testParseType("{U , V : W }") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: `unexpected colon in intersection type`, @@ -742,7 +742,7 @@ func TestParseIntersectionType(t *testing.T) { t.Parallel() result, errs := testParseType("{[T]}") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "non-nominal type in intersection list: [T]", @@ -761,7 +761,7 @@ func TestParseIntersectionType(t *testing.T) { t.Parallel() result, errs := testParseType("{T, [U]}") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "non-nominal type in intersection list: [U]", @@ -780,7 +780,7 @@ func TestParseIntersectionType(t *testing.T) { t.Parallel() result, errs := testParseType("{") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid end of input, expected type", @@ -798,7 +798,7 @@ func TestParseIntersectionType(t *testing.T) { t.Parallel() result, errs := testParseType("{U") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid end of input, expected '}'", @@ -816,7 +816,7 @@ func TestParseIntersectionType(t *testing.T) { t.Parallel() result, errs := testParseType("{U,") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid end of input, expected type", @@ -834,7 +834,7 @@ func TestParseIntersectionType(t *testing.T) { t.Parallel() result, errs := testParseType("{,}") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected comma in intersection type", @@ -859,7 +859,7 @@ func TestParseDictionaryType(t *testing.T) { result, errs := testParseType("{T: U}") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.DictionaryType{ KeyType: &ast.NominalType{ Identifier: ast.Identifier{ @@ -887,7 +887,7 @@ func TestParseDictionaryType(t *testing.T) { t.Parallel() result, errs := testParseType("{T:}") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "missing dictionary value type", @@ -897,7 +897,7 @@ func TestParseDictionaryType(t *testing.T) { errs, ) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.DictionaryType{ KeyType: &ast.NominalType{ Identifier: ast.Identifier{ @@ -920,7 +920,7 @@ func TestParseDictionaryType(t *testing.T) { t.Parallel() result, errs := testParseType("{:}") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected colon in dictionary type", @@ -938,7 +938,7 @@ func TestParseDictionaryType(t *testing.T) { t.Parallel() result, errs := testParseType("{:U}") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected colon in dictionary type", @@ -957,7 +957,7 @@ func TestParseDictionaryType(t *testing.T) { t.Parallel() result, errs := testParseType("{T:U,}") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected comma in dictionary type", @@ -976,7 +976,7 @@ func TestParseDictionaryType(t *testing.T) { t.Parallel() result, errs := testParseType("{T:U:}") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected colon in dictionary type", @@ -995,7 +995,7 @@ func TestParseDictionaryType(t *testing.T) { t.Parallel() result, errs := testParseType("{T::U}") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected colon in dictionary type", @@ -1014,7 +1014,7 @@ func TestParseDictionaryType(t *testing.T) { t.Parallel() result, errs := testParseType("{T:") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid end of input, expected type", @@ -1032,7 +1032,7 @@ func TestParseDictionaryType(t *testing.T) { t.Parallel() result, errs := testParseType("{T:U") - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid end of input, expected '}'", @@ -1057,7 +1057,7 @@ func TestParseFunctionType(t *testing.T) { result, errs := testParseType("fun():Void") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.FunctionType{ PurityAnnotation: ast.FunctionPurityUnspecified, ParameterTypeAnnotations: nil, @@ -1087,7 +1087,7 @@ func TestParseFunctionType(t *testing.T) { result, errs := testParseType("view fun ():Void") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.FunctionType{ PurityAnnotation: ast.FunctionPurityView, ParameterTypeAnnotations: nil, @@ -1117,7 +1117,7 @@ func TestParseFunctionType(t *testing.T) { result, errs := testParseType("fun( String , Bool , @R ) : Int") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.FunctionType{ ParameterTypeAnnotations: []*ast.TypeAnnotation{ { @@ -1182,7 +1182,7 @@ func TestParseInstantiationType(t *testing.T) { result, errs := testParseType("T<>") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.InstantiationType{ Type: &ast.NominalType{ Identifier: ast.Identifier{ @@ -1204,7 +1204,7 @@ func TestParseInstantiationType(t *testing.T) { result, errs := testParseType("T") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.InstantiationType{ Type: &ast.NominalType{ Identifier: ast.Identifier{ @@ -1238,7 +1238,7 @@ func TestParseInstantiationType(t *testing.T) { result, errs := testParseType("T< U >") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.InstantiationType{ Type: &ast.NominalType{ Identifier: ast.Identifier{ @@ -1272,7 +1272,7 @@ func TestParseInstantiationType(t *testing.T) { result, errs := testParseType("T< U , @V >") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.InstantiationType{ Type: &ast.NominalType{ Identifier: ast.Identifier{ @@ -1316,7 +1316,7 @@ func TestParseInstantiationType(t *testing.T) { result, errs := testParseType("T") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.InstantiationType{ Type: &ast.NominalType{ Identifier: ast.Identifier{ @@ -1350,7 +1350,7 @@ func TestParseInstantiationType(t *testing.T) { result, errs := testParseType("T< U< V > >") require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, &ast.InstantiationType{ Type: &ast.NominalType{ Identifier: ast.Identifier{ @@ -1404,7 +1404,7 @@ func TestParseParametersAndArrayTypes(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.FunctionDeclaration{ ParameterList: &ast.ParameterList{ @@ -1696,7 +1696,7 @@ func TestParseDictionaryTypeInVariableDeclaration(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -2018,7 +2018,7 @@ func TestParseIntegerTypes(t *testing.T) { StartPos: ast.Position{Offset: 137, Line: 9, Column: 2}, } - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{a, b, c, d, e, f, g, h}, result.Declarations(), ) @@ -2034,7 +2034,7 @@ func TestParseFunctionTypeInVariableDeclaration(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -2112,7 +2112,7 @@ func TestParseFunctionArrayType(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -2196,7 +2196,7 @@ func TestParseFunctionTypeWithArrayReturnType(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -2291,7 +2291,7 @@ func TestParseFunctionTypeWithFunctionReturnType(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -2451,7 +2451,7 @@ func TestParseViewFunctionTypeWithNewSyntax(t *testing.T) { StartPos: ast.Position{Offset: 3, Line: 2, Column: 2}, }, } - utils.AssertEqualWithDiff(t, expected, result.Declarations()) + AssertEqualWithDiff(t, expected, result.Declarations()) } func TestParseNewSyntaxFunctionType(t *testing.T) { @@ -2534,7 +2534,7 @@ func TestParseNewSyntaxFunctionType(t *testing.T) { StartPos: ast.Position{Offset: 3, Line: 2, Column: 2}, }, } - utils.AssertEqualWithDiff(t, expected, result.Declarations()) + AssertEqualWithDiff(t, expected, result.Declarations()) } func TestParseOptionalTypeDouble(t *testing.T) { @@ -2547,7 +2547,7 @@ func TestParseOptionalTypeDouble(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -2602,7 +2602,7 @@ func TestParseFunctionTypeWithResourceTypeAnnotation(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -2659,7 +2659,7 @@ func TestParseReferenceTypeInVariableDeclaration(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -2720,7 +2720,7 @@ func TestParseOptionalReference(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -2775,7 +2775,7 @@ func TestParseIntersectionReferenceType(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -2835,7 +2835,7 @@ func TestParseOptionalIntersectionType(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -2894,7 +2894,7 @@ func TestParseAuthorizedReferenceTypeWithNoEntitlements(t *testing.T) { ` _, errs := testParseProgram(code) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected authorization (entitlement list)", @@ -2915,7 +2915,7 @@ func TestParseInstantiationTypeInVariableDeclaration(t *testing.T) { result, errs := testParseProgram(code) require.Empty(t, errs) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []ast.Declaration{ &ast.VariableDeclaration{ Access: ast.AccessNotSpecified, @@ -2991,7 +2991,7 @@ func TestParseConstantSizedSizedArrayWithTrailingUnderscoreSize(t *testing.T) { let T:[d;0_]=0 `) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &InvalidIntegerLiteralError{ Literal: "0_", @@ -3044,7 +3044,7 @@ func TestParseParenthesizedTypes(t *testing.T) { }, } - utils.AssertEqualWithDiff(t, expected, prog.Declarations()) + AssertEqualWithDiff(t, expected, prog.Declarations()) } func TestParseNestedParenthesizedTypes(t *testing.T) { @@ -3084,5 +3084,5 @@ func TestParseNestedParenthesizedTypes(t *testing.T) { }, } - utils.AssertEqualWithDiff(t, expected, prog.Declarations()) + AssertEqualWithDiff(t, expected, prog.Declarations()) } diff --git a/runtime/account_test.go b/runtime/account_test.go index 371cbba4cb..0d65fa3ecd 100644 --- a/runtime/account_test.go +++ b/runtime/account_test.go @@ -35,10 +35,10 @@ import ( . "github.com/onflow/cadence/runtime" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - . "github.com/onflow/cadence/tests/runtime_utils" - . "github.com/onflow/cadence/tests/sema_utils" - "github.com/onflow/cadence/tests/utils" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/interpreter_utils" + . "github.com/onflow/cadence/test_utils/runtime_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestRuntimeAccountKeyConstructor(t *testing.T) { @@ -998,7 +998,7 @@ func TestRuntimePublicAccountKeys(t *testing.T) { value, err := test.executeScript(testEnv.runtime, testEnv.runtimeInterface) require.NoError(t, err) - utils.AssertEqualWithDiff(t, cadence.Void{}, value) + AssertEqualWithDiff(t, cadence.Void{}, value) keys := make(map[int]*AccountKey, len(testEnv.storage.keys)) for _, key := range testEnv.storage.keys { @@ -1043,7 +1043,7 @@ func TestRuntimePublicAccountKeys(t *testing.T) { value, err := test.executeScript(testEnv.runtime, testEnv.runtimeInterface) require.NoError(t, err) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, cadence.NewOptional(cadence.String("Optional.map")), value, ) diff --git a/runtime/attachments_test.go b/runtime/attachments_test.go index e03c72dc22..4d3d400d1b 100644 --- a/runtime/attachments_test.go +++ b/runtime/attachments_test.go @@ -28,8 +28,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/interpreter" . "github.com/onflow/cadence/runtime" - . "github.com/onflow/cadence/tests/runtime_utils" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/runtime_utils" ) func TestRuntimeAccountAttachmentSaveAndLoad(t *testing.T) { diff --git a/runtime/capabilities_test.go b/runtime/capabilities_test.go index ade86c8d24..3e76980213 100644 --- a/runtime/capabilities_test.go +++ b/runtime/capabilities_test.go @@ -27,8 +27,8 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/interpreter" . "github.com/onflow/cadence/runtime" - . "github.com/onflow/cadence/tests/runtime_utils" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/runtime_utils" ) func TestRuntimeCapability_borrowAndCheck(t *testing.T) { diff --git a/runtime/capabilitycontrollers_test.go b/runtime/capabilitycontrollers_test.go index fbb0d924cc..fc6f692fe4 100644 --- a/runtime/capabilitycontrollers_test.go +++ b/runtime/capabilitycontrollers_test.go @@ -32,8 +32,8 @@ import ( . "github.com/onflow/cadence/runtime" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - . "github.com/onflow/cadence/tests/runtime_utils" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/runtime_utils" ) func TestRuntimeCapabilityControllers(t *testing.T) { diff --git a/runtime/contract_test.go b/runtime/contract_test.go index 6cd2b4caaa..2bb89a2cb5 100644 --- a/runtime/contract_test.go +++ b/runtime/contract_test.go @@ -33,9 +33,10 @@ import ( . "github.com/onflow/cadence/runtime" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - . "github.com/onflow/cadence/tests/runtime_utils" - . "github.com/onflow/cadence/tests/sema_utils" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/interpreter_utils" + . "github.com/onflow/cadence/test_utils/runtime_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestRuntimeContract(t *testing.T) { diff --git a/runtime/contract_update_test.go b/runtime/contract_update_test.go index c032eb7124..48a0ec8e48 100644 --- a/runtime/contract_update_test.go +++ b/runtime/contract_update_test.go @@ -29,8 +29,8 @@ import ( "github.com/onflow/cadence/interpreter" . "github.com/onflow/cadence/runtime" "github.com/onflow/cadence/stdlib" - . "github.com/onflow/cadence/tests/runtime_utils" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/runtime_utils" ) func TestRuntimeContractUpdateWithDependencies(t *testing.T) { diff --git a/runtime/contract_update_validation_test.go b/runtime/contract_update_validation_test.go index f4e77b8c85..74afc1c447 100644 --- a/runtime/contract_update_validation_test.go +++ b/runtime/contract_update_validation_test.go @@ -33,8 +33,8 @@ import ( . "github.com/onflow/cadence/runtime" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - . "github.com/onflow/cadence/tests/runtime_utils" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/runtime_utils" ) func newContractDeployTransaction(function, name, code string) string { diff --git a/runtime/convertTypes_test.go b/runtime/convertTypes_test.go index fea1f8a697..3e50371edd 100644 --- a/runtime/convertTypes_test.go +++ b/runtime/convertTypes_test.go @@ -28,7 +28,7 @@ import ( "github.com/onflow/cadence/common" . "github.com/onflow/cadence/runtime" "github.com/onflow/cadence/sema" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" ) func TestRuntimeExportRecursiveType(t *testing.T) { @@ -36,7 +36,7 @@ func TestRuntimeExportRecursiveType(t *testing.T) { t.Parallel() ty := &sema.CompositeType{ - Location: utils.TestLocation, + Location: TestLocation, Identifier: "Foo", Kind: common.CompositeKindResource, Members: &sema.StringMemberOrderedMap{}, @@ -60,7 +60,7 @@ func TestRuntimeExportRecursiveType(t *testing.T) { } expected := cadence.NewResourceType( - utils.TestLocation, + TestLocation, "Foo", fields, nil, @@ -94,7 +94,7 @@ func BenchmarkExportType(b *testing.B) { b.Run("composite type", func(b *testing.B) { ty := &sema.CompositeType{ - Location: utils.TestLocation, + Location: TestLocation, Identifier: "Foo", Kind: common.CompositeKindResource, Members: &sema.StringMemberOrderedMap{}, @@ -118,7 +118,7 @@ func BenchmarkExportType(b *testing.B) { } expected := cadence.NewResourceType( - utils.TestLocation, + TestLocation, "Foo", fields, nil, diff --git a/runtime/convertValues_test.go b/runtime/convertValues_test.go index bebbf750ca..f6cf51fcb2 100644 --- a/runtime/convertValues_test.go +++ b/runtime/convertValues_test.go @@ -37,8 +37,9 @@ import ( . "github.com/onflow/cadence/runtime" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - . "github.com/onflow/cadence/tests/runtime_utils" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/interpreter_utils" + . "github.com/onflow/cadence/test_utils/runtime_utils" ) func TestRuntimeExportValue(t *testing.T) { diff --git a/runtime/coverage_test.go b/runtime/coverage_test.go index 2c244b4c4d..5f5f746113 100644 --- a/runtime/coverage_test.go +++ b/runtime/coverage_test.go @@ -31,8 +31,7 @@ import ( "github.com/onflow/cadence/parser" . "github.com/onflow/cadence/runtime" "github.com/onflow/cadence/stdlib" - . "github.com/onflow/cadence/tests/runtime_utils" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/runtime_utils" ) func TestRuntimeNewLocationCoverage(t *testing.T) { @@ -1816,7 +1815,7 @@ func TestRuntimeCoverageWithNoStatements(t *testing.T) { } coverageReport.ExcludeLocation(txLocation) - deploy := utils.DeploymentTransaction("FooContract", contract) + deploy := DeploymentTransaction("FooContract", contract) err := runtime.ExecuteTransaction( Script{ Source: deploy, diff --git a/runtime/crypto_test.go b/runtime/crypto_test.go index 71da0b283a..fcce37cf8b 100644 --- a/runtime/crypto_test.go +++ b/runtime/crypto_test.go @@ -33,7 +33,7 @@ import ( . "github.com/onflow/cadence/runtime" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - . "github.com/onflow/cadence/tests/runtime_utils" + . "github.com/onflow/cadence/test_utils/runtime_utils" ) func TestRuntimeHashAlgorithm_hash(t *testing.T) { diff --git a/runtime/debugger_test.go b/runtime/debugger_test.go index 7d5d5f8907..b9d060775e 100644 --- a/runtime/debugger_test.go +++ b/runtime/debugger_test.go @@ -28,7 +28,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/interpreter" . "github.com/onflow/cadence/runtime" - . "github.com/onflow/cadence/tests/runtime_utils" + . "github.com/onflow/cadence/test_utils/runtime_utils" ) func TestRuntimeDebugger(t *testing.T) { diff --git a/runtime/deployedcontract_test.go b/runtime/deployedcontract_test.go index b73b16f71d..bae773da2e 100644 --- a/runtime/deployedcontract_test.go +++ b/runtime/deployedcontract_test.go @@ -26,8 +26,7 @@ import ( "github.com/onflow/cadence" "github.com/onflow/cadence/common" . "github.com/onflow/cadence/runtime" - . "github.com/onflow/cadence/tests/runtime_utils" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/runtime_utils" ) func TestRuntimeDeployedContracts(t *testing.T) { @@ -104,7 +103,7 @@ func TestRuntimeDeployedContracts(t *testing.T) { // deploy the contract err := rt.ExecuteTransaction( Script{ - Source: utils.DeploymentTransaction("Test", []byte(contractCode)), + Source: DeploymentTransaction("Test", []byte(contractCode)), }, newContext(), ) diff --git a/runtime/deployment_test.go b/runtime/deployment_test.go index 6b6cbe83bd..4d1ab95280 100644 --- a/runtime/deployment_test.go +++ b/runtime/deployment_test.go @@ -34,8 +34,9 @@ import ( . "github.com/onflow/cadence/runtime" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - . "github.com/onflow/cadence/tests/runtime_utils" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/interpreter_utils" + . "github.com/onflow/cadence/test_utils/runtime_utils" ) func TestRuntimeTransactionWithContractDeployment(t *testing.T) { diff --git a/runtime/entitlements_test.go b/runtime/entitlements_test.go index d241cb6c4d..428e56615d 100644 --- a/runtime/entitlements_test.go +++ b/runtime/entitlements_test.go @@ -28,9 +28,8 @@ import ( "github.com/onflow/cadence/interpreter" . "github.com/onflow/cadence/runtime" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/runtime_utils" - . "github.com/onflow/cadence/tests/sema_utils" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/runtime_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestRuntimeAccountEntitlementSaveAndLoadSuccess(t *testing.T) { diff --git a/runtime/error_test.go b/runtime/error_test.go index a27aecbcf2..4d74c390c1 100644 --- a/runtime/error_test.go +++ b/runtime/error_test.go @@ -31,7 +31,7 @@ import ( . "github.com/onflow/cadence/runtime" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - . "github.com/onflow/cadence/tests/runtime_utils" + . "github.com/onflow/cadence/test_utils/runtime_utils" ) func TestRuntimeError(t *testing.T) { diff --git a/runtime/ft_test.go b/runtime/ft_test.go index 5d7d78b5e6..b9374d986e 100644 --- a/runtime/ft_test.go +++ b/runtime/ft_test.go @@ -31,8 +31,9 @@ import ( "github.com/onflow/cadence/interpreter" . "github.com/onflow/cadence/runtime" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/runtime_utils" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/interpreter_utils" + . "github.com/onflow/cadence/test_utils/runtime_utils" ) const modifiedFungibleTokenContractInterface = ` @@ -627,7 +628,7 @@ func BenchmarkRuntimeFungibleTokenTransfer(b *testing.B) { err := runtime.ExecuteTransaction( Script{ - Source: utils.DeploymentTransaction( + Source: DeploymentTransaction( "FungibleToken", []byte(modifiedFungibleTokenContractInterface), ), @@ -644,7 +645,7 @@ func BenchmarkRuntimeFungibleTokenTransfer(b *testing.B) { err = runtime.ExecuteTransaction( Script{ - Source: utils.DeploymentTransaction("FlowToken", []byte(modifiedFlowContract)), + Source: DeploymentTransaction("FlowToken", []byte(modifiedFlowContract)), }, Context{ Interface: runtimeInterface, @@ -767,7 +768,7 @@ func BenchmarkRuntimeFungibleTokenTransfer(b *testing.B) { sum = sum.Plus(inter, value, interpreter.EmptyLocationRange).(interpreter.UFix64Value) } - utils.RequireValuesEqual(b, nil, mintAmountValue, sum) + RequireValuesEqual(b, nil, mintAmountValue, sum) } const oldExampleToken = ` @@ -1043,7 +1044,7 @@ func TestRuntimeBrokenFungibleTokenRecovery(t *testing.T) { err := runtime.ExecuteTransaction( Script{ - Source: utils.DeploymentTransaction( + Source: DeploymentTransaction( "FungibleToken", []byte(modifiedFungibleTokenContractInterface), ), @@ -1222,7 +1223,7 @@ func TestRuntimeBrokenFungibleTokenRecovery(t *testing.T) { Environment: environment, }, ) - utils.RequireError(t, err) + RequireError(t, err) require.ErrorContains(t, err, "Vault.withdraw is not available in recovered program") t.Log(err.Error()) diff --git a/runtime/import_test.go b/runtime/import_test.go index 295353b5f6..cbc92d7401 100644 --- a/runtime/import_test.go +++ b/runtime/import_test.go @@ -30,9 +30,9 @@ import ( "github.com/onflow/cadence/encoding/json" . "github.com/onflow/cadence/runtime" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/runtime_utils" - . "github.com/onflow/cadence/tests/sema_utils" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/runtime_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestRuntimeCyclicImport(t *testing.T) { diff --git a/runtime/imported_values_memory_metering_test.go b/runtime/imported_values_memory_metering_test.go index c3e7a882a8..d7620f27e9 100644 --- a/runtime/imported_values_memory_metering_test.go +++ b/runtime/imported_values_memory_metering_test.go @@ -29,8 +29,8 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/encoding/json" . "github.com/onflow/cadence/runtime" - . "github.com/onflow/cadence/tests/runtime_utils" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/runtime_utils" ) func testUseMemory(meter map[common.MemoryKind]uint64) func(common.MemoryUsage) error { @@ -628,7 +628,7 @@ func TestRuntimeScriptDecodedLocationMetering(t *testing.T) { }, ) - utils.RequireError(t, err) + RequireError(t, err) var entryPointErr *InvalidEntryPointArgumentError require.ErrorAs(t, err, &entryPointErr) diff --git a/runtime/inbox_test.go b/runtime/inbox_test.go index 00380e23e4..7017e4a5d9 100644 --- a/runtime/inbox_test.go +++ b/runtime/inbox_test.go @@ -30,7 +30,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/encoding/json" . "github.com/onflow/cadence/runtime" - . "github.com/onflow/cadence/tests/runtime_utils" + . "github.com/onflow/cadence/test_utils/runtime_utils" ) func TestRuntimeAccountInboxPublishUnpublish(t *testing.T) { diff --git a/runtime/literal_test.go b/runtime/literal_test.go index e35033b250..6109662007 100644 --- a/runtime/literal_test.go +++ b/runtime/literal_test.go @@ -29,8 +29,8 @@ import ( "github.com/onflow/cadence/common" . "github.com/onflow/cadence/runtime" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/runtime_utils" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/interpreter_utils" ) func TestRuntimeParseLiteral(t *testing.T) { diff --git a/runtime/predeclaredvalues_test.go b/runtime/predeclaredvalues_test.go index c60d3efb5b..9b916a3c0f 100644 --- a/runtime/predeclaredvalues_test.go +++ b/runtime/predeclaredvalues_test.go @@ -33,9 +33,9 @@ import ( . "github.com/onflow/cadence/runtime" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - . "github.com/onflow/cadence/tests/runtime_utils" - . "github.com/onflow/cadence/tests/sema_utils" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/runtime_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestRuntimePredeclaredValues(t *testing.T) { diff --git a/runtime/program_params_validation_test.go b/runtime/program_params_validation_test.go index 2e1a7f3ec1..5cc5485f9d 100644 --- a/runtime/program_params_validation_test.go +++ b/runtime/program_params_validation_test.go @@ -30,9 +30,9 @@ import ( "github.com/onflow/cadence/encoding/json" . "github.com/onflow/cadence/runtime" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/runtime_utils" - . "github.com/onflow/cadence/tests/sema_utils" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/runtime_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestRuntimeScriptParameterTypeValidation(t *testing.T) { diff --git a/runtime/resource_duplicate_test.go b/runtime/resource_duplicate_test.go index 5f5f12c666..9304dfb07a 100644 --- a/runtime/resource_duplicate_test.go +++ b/runtime/resource_duplicate_test.go @@ -29,8 +29,8 @@ import ( "github.com/onflow/cadence/interpreter" . "github.com/onflow/cadence/runtime" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/runtime_utils" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/runtime_utils" ) func TestRuntimeResourceDuplicationWithContractTransferInTransaction(t *testing.T) { diff --git a/runtime/resourcedictionary_test.go b/runtime/resourcedictionary_test.go index 088d4e977f..a1a5100423 100644 --- a/runtime/resourcedictionary_test.go +++ b/runtime/resourcedictionary_test.go @@ -29,8 +29,7 @@ import ( "github.com/onflow/cadence" "github.com/onflow/cadence/common" . "github.com/onflow/cadence/runtime" - . "github.com/onflow/cadence/tests/runtime_utils" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/runtime_utils" ) const resourceDictionaryContract = ` @@ -94,7 +93,7 @@ func TestRuntimeResourceDictionaryValues(t *testing.T) { contract := []byte(resourceDictionaryContract) - deploy := utils.DeploymentTransaction("Test", contract) + deploy := DeploymentTransaction("Test", contract) setupTx := []byte(` import Test from 0xCADE @@ -450,7 +449,7 @@ func TestRuntimeResourceDictionaryValues_Nested(t *testing.T) { } `) - deploy := utils.DeploymentTransaction("Test", contract) + deploy := DeploymentTransaction("Test", contract) setupTx := []byte(` import Test from 0xCADE @@ -754,7 +753,7 @@ func TestRuntimeResourceDictionaryValues_Removal(t *testing.T) { contract := []byte(resourceDictionaryContract) - deployTx := utils.DeploymentTransaction("Test", contract) + deployTx := DeploymentTransaction("Test", contract) setupTx := []byte(` import Test from 0x1 @@ -883,7 +882,7 @@ func TestRuntimeResourceDictionaryValues_Destruction(t *testing.T) { contract := []byte(resourceDictionaryContract) - deployTx := utils.DeploymentTransaction("Test", contract) + deployTx := DeploymentTransaction("Test", contract) setupTx := []byte(` import Test from 0x1 @@ -996,7 +995,7 @@ func TestRuntimeResourceDictionaryValues_Insertion(t *testing.T) { contract := []byte(resourceDictionaryContract) - deployTx := utils.DeploymentTransaction("Test", contract) + deployTx := DeploymentTransaction("Test", contract) setupTx := []byte(` import Test from 0x1 @@ -1137,7 +1136,7 @@ func TestRuntimeResourceDictionaryValues_ValueTransferAndDestroy(t *testing.T) { contract := []byte(resourceDictionaryContract) - deployTx := utils.DeploymentTransaction("Test", contract) + deployTx := DeploymentTransaction("Test", contract) setupTx := []byte(` import Test from 0x1 @@ -1330,7 +1329,7 @@ func BenchmarkRuntimeResourceDictionaryValues(b *testing.B) { } `) - deploy := utils.DeploymentTransaction("Test", contract) + deploy := DeploymentTransaction("Test", contract) setupTx := []byte(` import Test from 0xCADE diff --git a/runtime/rlp_test.go b/runtime/rlp_test.go index 17582dceee..93cfaa1ed6 100644 --- a/runtime/rlp_test.go +++ b/runtime/rlp_test.go @@ -28,8 +28,8 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/encoding/json" . "github.com/onflow/cadence/runtime" - . "github.com/onflow/cadence/tests/runtime_utils" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/runtime_utils" ) func TestRuntimeRLPDecodeString(t *testing.T) { diff --git a/runtime/runtime_memory_metering_test.go b/runtime/runtime_memory_metering_test.go index f7e91fd7bf..d6d389ff73 100644 --- a/runtime/runtime_memory_metering_test.go +++ b/runtime/runtime_memory_metering_test.go @@ -31,8 +31,8 @@ import ( "github.com/onflow/cadence/encoding/json" "github.com/onflow/cadence/errors" . "github.com/onflow/cadence/runtime" - . "github.com/onflow/cadence/tests/runtime_utils" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/runtime_utils" ) type testMemoryGauge struct { diff --git a/runtime/runtime_test.go b/runtime/runtime_test.go index 07e76ce395..91b7bcdc86 100644 --- a/runtime/runtime_test.go +++ b/runtime/runtime_test.go @@ -43,9 +43,9 @@ import ( . "github.com/onflow/cadence/runtime" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - . "github.com/onflow/cadence/tests/runtime_utils" - . "github.com/onflow/cadence/tests/sema_utils" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/runtime_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestRuntimeImport(t *testing.T) { diff --git a/runtime/sharedstate_test.go b/runtime/sharedstate_test.go index 660c439b1c..3008c85fff 100644 --- a/runtime/sharedstate_test.go +++ b/runtime/sharedstate_test.go @@ -28,8 +28,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/interpreter" . "github.com/onflow/cadence/runtime" - . "github.com/onflow/cadence/tests/runtime_utils" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/runtime_utils" ) func TestRuntimeSharedState(t *testing.T) { diff --git a/runtime/storage_test.go b/runtime/storage_test.go index b82b77a2cb..5a7bb60bc9 100644 --- a/runtime/storage_test.go +++ b/runtime/storage_test.go @@ -36,8 +36,9 @@ import ( "github.com/onflow/cadence/encoding/json" "github.com/onflow/cadence/interpreter" . "github.com/onflow/cadence/runtime" - . "github.com/onflow/cadence/tests/runtime_utils" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/interpreter_utils" + . "github.com/onflow/cadence/test_utils/runtime_utils" ) func withWritesToStorage( diff --git a/runtime/type_test.go b/runtime/type_test.go index 2ae870e408..c96a705675 100644 --- a/runtime/type_test.go +++ b/runtime/type_test.go @@ -27,7 +27,7 @@ import ( "github.com/onflow/cadence" "github.com/onflow/cadence/common" . "github.com/onflow/cadence/runtime" - . "github.com/onflow/cadence/tests/runtime_utils" + . "github.com/onflow/cadence/test_utils/runtime_utils" ) func TestRuntimeTypeStorage(t *testing.T) { diff --git a/runtime/validation_test.go b/runtime/validation_test.go index 980654b941..db212f8547 100644 --- a/runtime/validation_test.go +++ b/runtime/validation_test.go @@ -28,8 +28,8 @@ import ( "github.com/onflow/cadence/encoding/json" "github.com/onflow/cadence/interpreter" . "github.com/onflow/cadence/runtime" - . "github.com/onflow/cadence/tests/runtime_utils" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/runtime_utils" ) // TestRuntimeArgumentImportMissingType tests if errors produced while validating diff --git a/sema/accesses_test.go b/sema/accesses_test.go index eaa4dc16a9..976e30811e 100644 --- a/sema/accesses_test.go +++ b/sema/accesses_test.go @@ -28,7 +28,7 @@ import ( "github.com/onflow/cadence/ast" "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func expectSuccess(t *testing.T, err error) { diff --git a/sema/account_test.go b/sema/account_test.go index e993ed7303..6084a5042b 100644 --- a/sema/account_test.go +++ b/sema/account_test.go @@ -27,8 +27,8 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckAccountStorageSave(t *testing.T) { @@ -888,7 +888,7 @@ func TestCheckAccountStorageBorrow(t *testing.T) { sema.NewEntitlementSetAccess( []*sema.EntitlementType{ { - Location: utils.TestLocation, + Location: TestLocation, Identifier: "X", }, }, diff --git a/sema/any_test.go b/sema/any_test.go index 6e35846d12..c9c0c76222 100644 --- a/sema/any_test.go +++ b/sema/any_test.go @@ -24,7 +24,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckAnyStruct(t *testing.T) { diff --git a/sema/arrays_dictionaries_test.go b/sema/arrays_dictionaries_test.go index 20a306fe04..6e5a512d05 100644 --- a/sema/arrays_dictionaries_test.go +++ b/sema/arrays_dictionaries_test.go @@ -30,7 +30,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckDictionary(t *testing.T) { diff --git a/sema/assert_test.go b/sema/assert_test.go index 2912bf380b..0c19bdc57e 100644 --- a/sema/assert_test.go +++ b/sema/assert_test.go @@ -26,7 +26,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckAssertWithoutMessage(t *testing.T) { diff --git a/sema/assignment_test.go b/sema/assignment_test.go index 3d415c16ee..96494ccde0 100644 --- a/sema/assignment_test.go +++ b/sema/assignment_test.go @@ -25,7 +25,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckInvalidUnknownDeclarationAssignment(t *testing.T) { diff --git a/sema/attachments_test.go b/sema/attachments_test.go index c1609e8e0b..d7d5e62447 100644 --- a/sema/attachments_test.go +++ b/sema/attachments_test.go @@ -26,7 +26,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckAttachmentBasic(t *testing.T) { diff --git a/sema/boolean_test.go b/sema/boolean_test.go index 6d4e0cde0d..7c6202a5c2 100644 --- a/sema/boolean_test.go +++ b/sema/boolean_test.go @@ -25,7 +25,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckBoolean(t *testing.T) { diff --git a/sema/builtinfunctions_test.go b/sema/builtinfunctions_test.go index 41a956d1d1..07ca190593 100644 --- a/sema/builtinfunctions_test.go +++ b/sema/builtinfunctions_test.go @@ -28,7 +28,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckToString(t *testing.T) { diff --git a/sema/capability_controller_test.go b/sema/capability_controller_test.go index d2ab30eda3..994f600999 100644 --- a/sema/capability_controller_test.go +++ b/sema/capability_controller_test.go @@ -26,7 +26,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckStorageCapabilityController(t *testing.T) { diff --git a/sema/capability_test.go b/sema/capability_test.go index 155442dc12..cb430f7b82 100644 --- a/sema/capability_test.go +++ b/sema/capability_test.go @@ -22,13 +22,12 @@ import ( "fmt" "testing" - "github.com/onflow/cadence/sema" - "github.com/onflow/cadence/tests/utils" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - . "github.com/onflow/cadence/tests/sema_utils" + "github.com/onflow/cadence/sema" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckCapability(t *testing.T) { @@ -94,7 +93,7 @@ func TestCheckCapability_borrow(t *testing.T) { for _, auth := range []sema.Access{sema.UnauthorizedAccess, sema.NewEntitlementSetAccess([]*sema.EntitlementType{{ - Location: utils.TestLocation, + Location: TestLocation, Identifier: "X", }}, sema.Conjunction), } { @@ -321,7 +320,7 @@ func TestCheckCapability_check(t *testing.T) { for _, auth := range []sema.Access{sema.UnauthorizedAccess, sema.NewEntitlementSetAccess([]*sema.EntitlementType{{ - Location: utils.TestLocation, + Location: TestLocation, Identifier: "X", }}, sema.Conjunction), } { diff --git a/sema/casting_test.go b/sema/casting_test.go index e107a4615b..b77dbdc466 100644 --- a/sema/casting_test.go +++ b/sema/casting_test.go @@ -26,7 +26,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckCastingIntLiteralToIntegerType(t *testing.T) { diff --git a/sema/character_test.go b/sema/character_test.go index 318b101dbc..7b7c664e95 100644 --- a/sema/character_test.go +++ b/sema/character_test.go @@ -25,7 +25,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckCharacterLiteral(t *testing.T) { diff --git a/sema/composite_test.go b/sema/composite_test.go index 6598505d98..dc6c8dc927 100644 --- a/sema/composite_test.go +++ b/sema/composite_test.go @@ -29,7 +29,7 @@ import ( "github.com/onflow/cadence/errors" "github.com/onflow/cadence/parser" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckInvalidCompositeRedeclaringType(t *testing.T) { diff --git a/sema/conditional_test.go b/sema/conditional_test.go index 98ec1a75a7..c4db51acd5 100644 --- a/sema/conditional_test.go +++ b/sema/conditional_test.go @@ -25,7 +25,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckConditionalExpressionTest(t *testing.T) { diff --git a/sema/conditions_test.go b/sema/conditions_test.go index d845c52c1d..afcc7762fc 100644 --- a/sema/conditions_test.go +++ b/sema/conditions_test.go @@ -26,7 +26,7 @@ import ( "github.com/onflow/cadence/ast" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckFunctionTestConditions(t *testing.T) { diff --git a/sema/conformance_test.go b/sema/conformance_test.go index 6109516c58..d2f873cab5 100644 --- a/sema/conformance_test.go +++ b/sema/conformance_test.go @@ -27,7 +27,7 @@ import ( "github.com/onflow/cadence/ast" "github.com/onflow/cadence/errors" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckEventNonTypeRequirementConformance(t *testing.T) { diff --git a/sema/contract_test.go b/sema/contract_test.go index 2de30e7d68..e21b6d7873 100644 --- a/sema/contract_test.go +++ b/sema/contract_test.go @@ -27,7 +27,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckInvalidContractAccountField(t *testing.T) { diff --git a/sema/crypto_test.go b/sema/crypto_test.go index 91397e95ea..e6f751395d 100644 --- a/sema/crypto_test.go +++ b/sema/crypto_test.go @@ -27,7 +27,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckHashAlgorithmCases(t *testing.T) { diff --git a/sema/declaration_test.go b/sema/declaration_test.go index 738c4c6d34..139ae9e332 100644 --- a/sema/declaration_test.go +++ b/sema/declaration_test.go @@ -27,7 +27,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckConstantAndVariableDeclarations(t *testing.T) { diff --git a/sema/dictionary_test.go b/sema/dictionary_test.go index 900c53860e..edd9dd83cb 100644 --- a/sema/dictionary_test.go +++ b/sema/dictionary_test.go @@ -25,7 +25,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckIncompleteDictionaryType(t *testing.T) { diff --git a/sema/dynamic_casting_test.go b/sema/dynamic_casting_test.go index 15861bc8e7..da02975b35 100644 --- a/sema/dynamic_casting_test.go +++ b/sema/dynamic_casting_test.go @@ -28,8 +28,8 @@ import ( "github.com/onflow/cadence/ast" "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) var dynamicCastingOperations = []ast.Operation{ @@ -1207,7 +1207,7 @@ func TestCheckDynamicCastingCapability(t *testing.T) { t.Parallel() structType := &sema.CompositeType{ - Location: utils.TestLocation, + Location: TestLocation, Identifier: "S", Kind: common.CompositeKindStructure, } diff --git a/sema/entitlements_test.go b/sema/entitlements_test.go index caa5dd36e4..3b47df81b3 100644 --- a/sema/entitlements_test.go +++ b/sema/entitlements_test.go @@ -27,7 +27,7 @@ import ( "github.com/onflow/cadence/ast" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckBasicEntitlementDeclaration(t *testing.T) { diff --git a/sema/entrypoint_test.go b/sema/entrypoint_test.go index ac76190b26..e3bc9ab1a1 100644 --- a/sema/entrypoint_test.go +++ b/sema/entrypoint_test.go @@ -24,7 +24,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckEntryPointParameters(t *testing.T) { diff --git a/sema/enum_test.go b/sema/enum_test.go index 2fc3233336..96d092297c 100644 --- a/sema/enum_test.go +++ b/sema/enum_test.go @@ -27,7 +27,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckInvalidNonEnumCompositeEnumCases(t *testing.T) { diff --git a/sema/error_handling_test.go b/sema/error_handling_test.go index cc84b43316..a7cb4923c2 100644 --- a/sema/error_handling_test.go +++ b/sema/error_handling_test.go @@ -27,8 +27,8 @@ import ( "github.com/onflow/cadence/ast" "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckErrorShortCircuiting(t *testing.T) { @@ -82,7 +82,7 @@ func TestCheckErrorShortCircuiting(t *testing.T) { access(all) let y = Y `, ParseAndCheckOptions{ - Location: utils.ImportedLocation, + Location: ImportedLocation, Config: &sema.Config{ ErrorShortCircuitingEnabled: true, }, diff --git a/sema/events_test.go b/sema/events_test.go index d1c588392f..e3d6cdbbea 100644 --- a/sema/events_test.go +++ b/sema/events_test.go @@ -29,8 +29,8 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/errors" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckEventDeclaration(t *testing.T) { @@ -295,7 +295,7 @@ func TestCheckEmitEvent(t *testing.T) { access(all) event Transfer(to: Int, from: Int) `, ParseAndCheckOptions{ - Location: utils.ImportedLocation, + Location: ImportedLocation, }, ) require.NoError(t, err) diff --git a/sema/external_mutation_test.go b/sema/external_mutation_test.go index 3eabd29a5a..96936fa073 100644 --- a/sema/external_mutation_test.go +++ b/sema/external_mutation_test.go @@ -28,7 +28,7 @@ import ( "github.com/onflow/cadence/ast" "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckArrayUpdateIndexAccess(t *testing.T) { diff --git a/sema/fixedpoint_test.go b/sema/fixedpoint_test.go index a1f0eb15e5..bb537432b8 100644 --- a/sema/fixedpoint_test.go +++ b/sema/fixedpoint_test.go @@ -29,7 +29,7 @@ import ( "github.com/onflow/cadence/format" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckFixedPointLiteralTypeConversionInVariableDeclaration(t *testing.T) { diff --git a/sema/for_test.go b/sema/for_test.go index 8e2f68dcb8..7a92fc90a8 100644 --- a/sema/for_test.go +++ b/sema/for_test.go @@ -28,7 +28,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckForVariableSized(t *testing.T) { diff --git a/sema/force_test.go b/sema/force_test.go index c3d0f41f5c..63b93013d8 100644 --- a/sema/force_test.go +++ b/sema/force_test.go @@ -25,7 +25,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckForce(t *testing.T) { diff --git a/sema/function_expression_test.go b/sema/function_expression_test.go index 5bb0467941..3ba5f2e6b4 100644 --- a/sema/function_expression_test.go +++ b/sema/function_expression_test.go @@ -25,7 +25,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckInvalidFunctionExpressionReturnValue(t *testing.T) { diff --git a/sema/function_test.go b/sema/function_test.go index 334f1ee2c7..1f823f9a23 100644 --- a/sema/function_test.go +++ b/sema/function_test.go @@ -28,7 +28,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/parser" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckReferenceInFunction(t *testing.T) { diff --git a/sema/gen/golden_test.go b/sema/gen/golden_test.go index 0053427d45..62555c9176 100644 --- a/sema/gen/golden_test.go +++ b/sema/gen/golden_test.go @@ -43,7 +43,7 @@ import ( _ "github.com/onflow/cadence/sema/gen/testdata/simple_struct" _ "github.com/onflow/cadence/sema/gen/testdata/storable" "github.com/onflow/cadence/stdlib" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestConstructor(t *testing.T) { diff --git a/sema/genericfunction_test.go b/sema/genericfunction_test.go index 6b3e443db1..f88e9ac00a 100644 --- a/sema/genericfunction_test.go +++ b/sema/genericfunction_test.go @@ -30,7 +30,7 @@ import ( "github.com/onflow/cadence/parser" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func parseAndCheckWithTestValue(t *testing.T, code string, ty sema.Type) (*sema.Checker, error) { diff --git a/sema/hashable_struct_test.go b/sema/hashable_struct_test.go index 51f432bf25..82875b9f95 100644 --- a/sema/hashable_struct_test.go +++ b/sema/hashable_struct_test.go @@ -24,7 +24,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckHashableStruct(t *testing.T) { diff --git a/sema/if_test.go b/sema/if_test.go index 0674d66d97..6fd1e517c7 100644 --- a/sema/if_test.go +++ b/sema/if_test.go @@ -25,7 +25,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckIfStatementTest(t *testing.T) { diff --git a/sema/import_test.go b/sema/import_test.go index 9e92714fa9..c5bf92d36e 100644 --- a/sema/import_test.go +++ b/sema/import_test.go @@ -30,8 +30,8 @@ import ( "github.com/onflow/cadence/errors" "github.com/onflow/cadence/parser" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckInvalidImport(t *testing.T) { @@ -57,7 +57,7 @@ func TestCheckRepeatedImport(t *testing.T) { access(all) let y = 2 `, ParseAndCheckOptions{ - Location: utils.ImportedLocation, + Location: ImportedLocation, }, ) require.NoError(t, err) @@ -170,7 +170,7 @@ func TestCheckInvalidRepeatedImport(t *testing.T) { access(all) let x = 1 `, ParseAndCheckOptions{ - Location: utils.ImportedLocation, + Location: ImportedLocation, }, ) @@ -288,7 +288,7 @@ func TestCheckImportAll(t *testing.T) { } `, ParseAndCheckOptions{ - Location: utils.ImportedLocation, + Location: ImportedLocation, }, ) @@ -323,7 +323,7 @@ func TestCheckInvalidImportUnexported(t *testing.T) { access(all) let x = 1 `, ParseAndCheckOptions{ - Location: utils.ImportedLocation, + Location: ImportedLocation, }, ) @@ -364,7 +364,7 @@ func TestCheckImportSome(t *testing.T) { access(all) let x = 1 `, ParseAndCheckOptions{ - Location: utils.ImportedLocation, + Location: ImportedLocation, }, ) @@ -447,7 +447,7 @@ func TestCheckImportTypes(t *testing.T) { body, ), ParseAndCheckOptions{ - Location: utils.ImportedLocation, + Location: ImportedLocation, }, ) @@ -553,7 +553,7 @@ func TestCheckInvalidImportCycleSelf(t *testing.T) { return err } - err = check(code, utils.TestLocation) + err = check(code, TestLocation) errs := RequireCheckerErrors(t, err, 1) @@ -740,7 +740,7 @@ func TestCheckImportContract(t *testing.T) { } }`, ParseAndCheckOptions{ - Location: utils.ImportedLocation, + Location: ImportedLocation, }, ) @@ -788,7 +788,7 @@ func TestCheckImportContract(t *testing.T) { } }`, ParseAndCheckOptions{ - Location: utils.ImportedLocation, + Location: ImportedLocation, }, ) diff --git a/sema/indexing_test.go b/sema/indexing_test.go index 5eabac65ff..1979e67610 100644 --- a/sema/indexing_test.go +++ b/sema/indexing_test.go @@ -25,7 +25,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckArrayIndexingWithInteger(t *testing.T) { diff --git a/sema/initialization_test.go b/sema/initialization_test.go index 832bb2724e..a4656a2e3c 100644 --- a/sema/initialization_test.go +++ b/sema/initialization_test.go @@ -25,7 +25,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) // TODO: test multiple initializers once overloading is supported diff --git a/sema/integer_test.go b/sema/integer_test.go index 1fdcf5963f..5f53f7b0ed 100644 --- a/sema/integer_test.go +++ b/sema/integer_test.go @@ -28,7 +28,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) var allIntegerTypesAndAddressType = common.Concat( diff --git a/sema/interface_test.go b/sema/interface_test.go index b43b4f7573..48fc511f4a 100644 --- a/sema/interface_test.go +++ b/sema/interface_test.go @@ -28,7 +28,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/errors" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func constructorArguments(compositeKind common.CompositeKind) string { diff --git a/sema/intersection_test.go b/sema/intersection_test.go index 763d16f1b4..e0965d843a 100644 --- a/sema/intersection_test.go +++ b/sema/intersection_test.go @@ -26,7 +26,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckIntersectionType(t *testing.T) { diff --git a/sema/invalid_test.go b/sema/invalid_test.go index 87e85d7a28..51ea254984 100644 --- a/sema/invalid_test.go +++ b/sema/invalid_test.go @@ -24,7 +24,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckSpuriousIdentifierAssignmentInvalidValueTypeMismatch(t *testing.T) { diff --git a/sema/invocation_test.go b/sema/invocation_test.go index 11abdd4073..1d0543b2cb 100644 --- a/sema/invocation_test.go +++ b/sema/invocation_test.go @@ -28,8 +28,8 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - . "github.com/onflow/cadence/tests/sema_utils" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckInvalidFunctionCallWithTooFewArguments(t *testing.T) { @@ -375,7 +375,7 @@ func TestCheckArgumentLabels(t *testing.T) { fun test(foo bar: Int, baz: String) {} `, ParseAndCheckOptions{ - Location: utils.ImportedLocation, + Location: ImportedLocation, }, ) @@ -436,7 +436,7 @@ func TestCheckArgumentLabels(t *testing.T) { } `, ParseAndCheckOptions{ - Location: utils.ImportedLocation, + Location: ImportedLocation, }, ) @@ -497,7 +497,7 @@ func TestCheckArgumentLabels(t *testing.T) { } `, ParseAndCheckOptions{ - Location: utils.ImportedLocation, + Location: ImportedLocation, }, ) @@ -562,7 +562,7 @@ func TestCheckArgumentLabels(t *testing.T) { } `, ParseAndCheckOptions{ - Location: utils.ImportedLocation, + Location: ImportedLocation, }, ) diff --git a/sema/member_test.go b/sema/member_test.go index 94fd50858b..9d8706dbbe 100644 --- a/sema/member_test.go +++ b/sema/member_test.go @@ -27,7 +27,7 @@ import ( "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckOptionalChainingNonOptionalFieldRead(t *testing.T) { diff --git a/sema/metatype_test.go b/sema/metatype_test.go index fcf185510f..3f5455b0a0 100644 --- a/sema/metatype_test.go +++ b/sema/metatype_test.go @@ -25,7 +25,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckMetaType(t *testing.T) { diff --git a/sema/move_test.go b/sema/move_test.go index 0791f6f744..d772f2f293 100644 --- a/sema/move_test.go +++ b/sema/move_test.go @@ -24,7 +24,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckInvalidMoves(t *testing.T) { diff --git a/sema/nesting_test.go b/sema/nesting_test.go index 184e566224..cd0cd659cf 100644 --- a/sema/nesting_test.go +++ b/sema/nesting_test.go @@ -29,7 +29,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckCompositeDeclarationNesting(t *testing.T) { diff --git a/sema/never_test.go b/sema/never_test.go index 5195786007..ee3ba85b1c 100644 --- a/sema/never_test.go +++ b/sema/never_test.go @@ -25,7 +25,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckNever(t *testing.T) { diff --git a/sema/nil_coalescing_test.go b/sema/nil_coalescing_test.go index 0f7c0364fd..2e6d505cfb 100644 --- a/sema/nil_coalescing_test.go +++ b/sema/nil_coalescing_test.go @@ -25,7 +25,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckNilCoalescingNilIntToOptional(t *testing.T) { diff --git a/sema/occurrences_test.go b/sema/occurrences_test.go index a1854e5cef..cb4454e170 100644 --- a/sema/occurrences_test.go +++ b/sema/occurrences_test.go @@ -26,7 +26,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) // TODO: implement occurrences for type references diff --git a/sema/operations_test.go b/sema/operations_test.go index c5f460bc28..319e3ee5f3 100644 --- a/sema/operations_test.go +++ b/sema/operations_test.go @@ -30,7 +30,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckInvalidUnaryBooleanNegationOfInteger(t *testing.T) { diff --git a/sema/optional_test.go b/sema/optional_test.go index ea92b679e3..98e797855e 100644 --- a/sema/optional_test.go +++ b/sema/optional_test.go @@ -27,7 +27,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckOptional(t *testing.T) { diff --git a/sema/overloading_test.go b/sema/overloading_test.go index 77cdea966b..dfe464e1b9 100644 --- a/sema/overloading_test.go +++ b/sema/overloading_test.go @@ -26,7 +26,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckInvalidCompositeInitializerOverloading(t *testing.T) { diff --git a/sema/path_test.go b/sema/path_test.go index 0b3fcd1215..5aceafd85e 100644 --- a/sema/path_test.go +++ b/sema/path_test.go @@ -27,7 +27,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckPath(t *testing.T) { diff --git a/sema/pragma_test.go b/sema/pragma_test.go index 1795e86df7..1ee6e070bb 100644 --- a/sema/pragma_test.go +++ b/sema/pragma_test.go @@ -26,7 +26,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckPragmaExpression(t *testing.T) { diff --git a/sema/predeclaredvalues_test.go b/sema/predeclaredvalues_test.go index b402b49c80..046ea7435a 100644 --- a/sema/predeclaredvalues_test.go +++ b/sema/predeclaredvalues_test.go @@ -26,7 +26,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckPredeclaredValues(t *testing.T) { diff --git a/sema/purity_test.go b/sema/purity_test.go index 2df908b4cd..76a79255d9 100644 --- a/sema/purity_test.go +++ b/sema/purity_test.go @@ -26,7 +26,7 @@ import ( "github.com/onflow/cadence/ast" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckPuritySubtyping(t *testing.T) { diff --git a/sema/range_test.go b/sema/range_test.go index 752cb93f64..94919757fd 100644 --- a/sema/range_test.go +++ b/sema/range_test.go @@ -27,8 +27,8 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckRange(t *testing.T) { @@ -96,7 +96,7 @@ func TestCheckRange(t *testing.T) { // assert that the unordered repr of expected matches that of ranges assertSetsEqual := func(t *testing.T, expected []sema.Range, ranges map[sema.Range]int) { bag := getCounts(expected) - utils.AssertEqualWithDiff(t, bag, ranges) + AssertEqualWithDiff(t, bag, ranges) } barTypeVariable, ok := checker.Elaboration.GetGlobalType("_TEST_Bar") diff --git a/sema/range_value_test.go b/sema/range_value_test.go index 1598aee163..12929896b5 100644 --- a/sema/range_value_test.go +++ b/sema/range_value_test.go @@ -28,7 +28,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) type inclusiveRangeConstructionTest struct { diff --git a/sema/reference_test.go b/sema/reference_test.go index b05629424f..0914180f30 100644 --- a/sema/reference_test.go +++ b/sema/reference_test.go @@ -28,8 +28,8 @@ import ( "github.com/onflow/cadence/ast" "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckReference(t *testing.T) { @@ -1067,7 +1067,7 @@ func TestCheckReferenceExpressionReferenceType(t *testing.T) { refValueType := RequireGlobalValue(t, checker.Elaboration, "ref") xType := RequireGlobalType(t, checker.Elaboration, "X").(*sema.EntitlementType) - var access sema.Access = sema.UnauthorizedAccess + var access = sema.UnauthorizedAccess if !auth.Equal(sema.UnauthorizedAccess) { access = sema.NewEntitlementSetAccess([]*sema.EntitlementType{xType}, sema.Conjunction) } @@ -1089,7 +1089,7 @@ func TestCheckReferenceExpressionReferenceType(t *testing.T) { for _, auth := range []sema.Access{ sema.UnauthorizedAccess, sema.NewEntitlementSetAccess([]*sema.EntitlementType{{ - Location: utils.TestLocation, + Location: TestLocation, Identifier: "X", }}, sema.Conjunction), } { @@ -1930,7 +1930,7 @@ func TestCheckInvalidatedReferenceUse(t *testing.T) { } `, ParseAndCheckOptions{ - Location: utils.ImportedLocation, + Location: ImportedLocation, }, ) diff --git a/sema/resource_test.go b/sema/resource_test.go index 1bfe40da3b..f46d1d08a7 100644 --- a/sema/resource_test.go +++ b/sema/resource_test.go @@ -25,12 +25,13 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + . "github.com/onflow/cadence/test_utils/sema_utils" + "github.com/onflow/cadence/ast" "github.com/onflow/cadence/common" "github.com/onflow/cadence/errors" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" ) func TestCheckFailableCastingWithResourceAnnotation(t *testing.T) { diff --git a/sema/return_test.go b/sema/return_test.go index 5f9b20ed5b..61f7f54835 100644 --- a/sema/return_test.go +++ b/sema/return_test.go @@ -28,7 +28,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckInvalidReturnValue(t *testing.T) { diff --git a/sema/rlp_test.go b/sema/rlp_test.go index b079b03c33..216c1829fb 100644 --- a/sema/rlp_test.go +++ b/sema/rlp_test.go @@ -26,7 +26,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckRLPDecodeString(t *testing.T) { diff --git a/sema/runtimetype_test.go b/sema/runtimetype_test.go index 8d8b444c70..22a46b6248 100644 --- a/sema/runtimetype_test.go +++ b/sema/runtimetype_test.go @@ -25,7 +25,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckOptionalTypeConstructor(t *testing.T) { diff --git a/sema/storable_test.go b/sema/storable_test.go index 3720107e70..23c0b96722 100644 --- a/sema/storable_test.go +++ b/sema/storable_test.go @@ -29,7 +29,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckStorable(t *testing.T) { diff --git a/sema/string_test.go b/sema/string_test.go index 23c0ff8001..5faa94b3d9 100644 --- a/sema/string_test.go +++ b/sema/string_test.go @@ -25,7 +25,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckCharacter(t *testing.T) { diff --git a/sema/swap_test.go b/sema/swap_test.go index 63fb658906..9f39ffdff5 100644 --- a/sema/swap_test.go +++ b/sema/swap_test.go @@ -26,7 +26,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckInvalidUnknownDeclarationSwap(t *testing.T) { diff --git a/sema/switch_test.go b/sema/switch_test.go index 38328f1645..197e1dd5d5 100644 --- a/sema/switch_test.go +++ b/sema/switch_test.go @@ -25,7 +25,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckSwitchStatementTest(t *testing.T) { diff --git a/sema/transactions_test.go b/sema/transactions_test.go index 79b362d918..dd80079ecd 100644 --- a/sema/transactions_test.go +++ b/sema/transactions_test.go @@ -25,7 +25,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckTransactions(t *testing.T) { diff --git a/sema/type_inference_test.go b/sema/type_inference_test.go index 85a338eaf3..db3dcb247d 100644 --- a/sema/type_inference_test.go +++ b/sema/type_inference_test.go @@ -26,7 +26,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckArrayElementTypeInference(t *testing.T) { diff --git a/sema/typeargument_test.go b/sema/typeargument_test.go index 66895844d4..cbb85a5ff5 100644 --- a/sema/typeargument_test.go +++ b/sema/typeargument_test.go @@ -27,7 +27,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckTypeArguments(t *testing.T) { diff --git a/sema/utils_test.go b/sema/utils_test.go index d65f31264d..f19512f82b 100644 --- a/sema/utils_test.go +++ b/sema/utils_test.go @@ -24,7 +24,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func ParseAndCheckWithPanic(t *testing.T, code string) (*sema.Checker, error) { diff --git a/sema/while_test.go b/sema/while_test.go index 9d40353678..3922b94315 100644 --- a/sema/while_test.go +++ b/sema/while_test.go @@ -24,7 +24,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func TestCheckInvalidWhileTest(t *testing.T) { diff --git a/stdlib/account_test.go b/stdlib/account_test.go index 0fbd4f1164..2429663cc2 100644 --- a/stdlib/account_test.go +++ b/stdlib/account_test.go @@ -25,7 +25,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/sema" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" ) func TestSemaCheckPathLiteralForInternalStorageDomains(t *testing.T) { @@ -75,7 +75,7 @@ func TestCanBorrow(t *testing.T) { `) typeID := func(qualifiedIdentifier string) sema.TypeID { - return utils.TestLocation.TypeID(nil, qualifiedIdentifier) + return TestLocation.TypeID(nil, qualifiedIdentifier) } entitlementE := inter.Program.Elaboration.EntitlementType(typeID("E")) diff --git a/stdlib/builtin_test.go b/stdlib/builtin_test.go index 46bbed8071..9ac63b1ff5 100644 --- a/stdlib/builtin_test.go +++ b/stdlib/builtin_test.go @@ -21,17 +21,16 @@ package stdlib import ( "testing" - "github.com/onflow/cadence/activations" - "github.com/onflow/cadence/common" - . "github.com/onflow/cadence/tests/sema_utils" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "github.com/onflow/cadence/activations" + "github.com/onflow/cadence/common" "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/parser" "github.com/onflow/cadence/sema" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func newUnmeteredInMemoryStorage() interpreter.InMemoryStorage { @@ -53,7 +52,7 @@ func newInterpreter(t *testing.T, code string, valueDeclarations ...StandardLibr checker, err := sema.NewChecker( program, - utils.TestLocation, + TestLocation, nil, &sema.Config{ BaseValueActivationHandler: func(_ common.Location) *sema.VariableActivation { @@ -184,7 +183,7 @@ func TestInterpretAssert(t *testing.T) { Err: AssertionError{ Message: "oops", }, - Location: utils.TestLocation, + Location: TestLocation, }, err, ) @@ -195,7 +194,7 @@ func TestInterpretAssert(t *testing.T) { Err: AssertionError{ Message: "", }, - Location: utils.TestLocation, + Location: TestLocation, }, err) @@ -278,7 +277,7 @@ func TestInterpretPanic(t *testing.T) { Err: PanicError{ Message: "oops", }, - Location: utils.TestLocation, + Location: TestLocation, }, err, ) 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 365f0eeaf8..3aa074687b 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 @@ -33,8 +33,8 @@ import ( "github.com/onflow/cadence/runtime" "github.com/onflow/cadence/sema" "github.com/onflow/cadence/stdlib" - "github.com/onflow/cadence/tests/runtime_utils" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/runtime_utils" ) func testContractUpdate(t *testing.T, oldCode string, newCode string) error { @@ -46,7 +46,7 @@ func testContractUpdate(t *testing.T, oldCode string, newCode string) error { checker, err := sema.NewChecker( newProgram, - utils.TestLocation, + TestLocation, nil, &sema.Config{ AccessCheckMode: sema.AccessCheckModeStrict, @@ -59,13 +59,13 @@ func testContractUpdate(t *testing.T, oldCode string, newCode string) error { program := interpreter.ProgramFromChecker(checker) upgradeValidator := stdlib.NewCadenceV042ToV1ContractUpdateValidator( - utils.TestLocation, + TestLocation, "Test", - &runtime_utils.TestRuntimeInterface{}, + &TestRuntimeInterface{}, oldProgram, program, map[common.Location]*sema.Elaboration{ - utils.TestLocation: checker.Elaboration, + TestLocation: checker.Elaboration, }) return upgradeValidator.Validate() } @@ -87,7 +87,7 @@ func testContractUpdateWithImports( upgradeValidator := stdlib.NewCadenceV042ToV1ContractUpdateValidator( location, contractName, - &runtime_utils.TestRuntimeInterface{ + &TestRuntimeInterface{ OnGetAccountContractNames: func(address runtime.Address) ([]string, error) { return []string{"TestImport"}, nil }, @@ -744,7 +744,7 @@ func TestContractUpgradeFieldType(t *testing.T) { upgradeValidator := stdlib.NewCadenceV042ToV1ContractUpdateValidator( location, contractName, - &runtime_utils.TestRuntimeInterface{ + &TestRuntimeInterface{ OnGetAccountContractNames: func(address runtime.Address) ([]string, error) { return []string{"TestImport"}, nil }, @@ -818,7 +818,7 @@ func TestContractUpgradeFieldType(t *testing.T) { upgradeValidator := stdlib.NewCadenceV042ToV1ContractUpdateValidator( location, contractName, - &runtime_utils.TestRuntimeInterface{ + &TestRuntimeInterface{ OnGetAccountContractNames: func(address runtime.Address) ([]string, error) { return []string{"TestImport"}, nil }, @@ -896,7 +896,7 @@ func TestContractUpgradeFieldType(t *testing.T) { upgradeValidator := stdlib.NewCadenceV042ToV1ContractUpdateValidator( location, contractName, - &runtime_utils.TestRuntimeInterface{ + &TestRuntimeInterface{ OnGetAccountContractNames: func(address runtime.Address) ([]string, error) { return []string{"TestImport"}, nil }, @@ -919,7 +919,7 @@ func TestContractUpgradeFieldType(t *testing.T) { // This should be an error. // If there are custom rules, they MUST be followed. - utils.RequireError(t, err) + RequireError(t, err) cause := getSingleContractUpdateErrorCause(t, err, "Test") var fieldMismatchError *stdlib.FieldMismatchError @@ -1031,7 +1031,7 @@ func TestContractUpgradeFieldType(t *testing.T) { upgradeValidator := stdlib.NewCadenceV042ToV1ContractUpdateValidator( location, contractName, - &runtime_utils.TestRuntimeInterface{ + &TestRuntimeInterface{ OnGetAccountContractNames: func(address runtime.Address) ([]string, error) { return []string{"TestImport"}, nil }, @@ -1161,7 +1161,7 @@ func TestContractUpgradeFieldType(t *testing.T) { upgradeValidator := stdlib.NewCadenceV042ToV1ContractUpdateValidator( location, contractName, - &runtime_utils.TestRuntimeInterface{ + &TestRuntimeInterface{ OnGetAccountContractNames: func(address runtime.Address) ([]string, error) { return []string{"TestImport"}, nil }, @@ -1257,7 +1257,7 @@ func TestContractUpgradeFieldType(t *testing.T) { upgradeValidator := stdlib.NewCadenceV042ToV1ContractUpdateValidator( location, contractName, - &runtime_utils.TestRuntimeInterface{ + &TestRuntimeInterface{ OnGetAccountContractNames: func(address runtime.Address) ([]string, error) { return []string{"TestImport"}, nil }, @@ -2443,7 +2443,7 @@ func TestInterfaceConformanceChange(t *testing.T) { upgradeValidator := stdlib.NewCadenceV042ToV1ContractUpdateValidator( location, contractName, - &runtime_utils.TestRuntimeInterface{ + &TestRuntimeInterface{ OnGetAccountContractNames: func(address runtime.Address) ([]string, error) { return []string{"TestImport"}, nil }, @@ -2528,7 +2528,7 @@ func TestInterfaceConformanceChange(t *testing.T) { upgradeValidator := stdlib.NewCadenceV042ToV1ContractUpdateValidator( location, contractName, - &runtime_utils.TestRuntimeInterface{ + &TestRuntimeInterface{ OnGetAccountContractNames: func(address runtime.Address) ([]string, error) { return []string{"TestImport"}, nil }, @@ -2602,7 +2602,7 @@ func TestInterfaceConformanceChange(t *testing.T) { upgradeValidator := stdlib.NewCadenceV042ToV1ContractUpdateValidator( location, contractName, - &runtime_utils.TestRuntimeInterface{ + &TestRuntimeInterface{ OnGetAccountContractNames: func(address runtime.Address) ([]string, error) { return []string{"TestImport"}, nil }, @@ -2626,7 +2626,7 @@ func TestInterfaceConformanceChange(t *testing.T) { // This should be an error. // If there are custom rules, they MUST be followed. - utils.RequireError(t, err) + RequireError(t, err) cause := getSingleContractUpdateErrorCause(t, err, "Test") var conformanceMismatchError *stdlib.ConformanceMismatchError @@ -2742,7 +2742,7 @@ func TestEnumUpdates(t *testing.T) { ` err := testContractUpdate(t, oldCode, newCode) - utils.RequireError(t, err) + RequireError(t, err) cause := getSingleContractUpdateErrorCause(t, err, "Test") var conformanceMismatchError *stdlib.ConformanceMismatchError @@ -2773,7 +2773,7 @@ func TestEnumUpdates(t *testing.T) { ` err := testContractUpdate(t, oldCode, newCode) - utils.RequireError(t, err) + RequireError(t, err) cause := getSingleContractUpdateErrorCause(t, err, "Test") var missingEnumCasesError *stdlib.MissingEnumCasesError diff --git a/stdlib/rlp/rlp_test.go b/stdlib/rlp/rlp_test.go index f707026356..ce07309d82 100644 --- a/stdlib/rlp/rlp_test.go +++ b/stdlib/rlp/rlp_test.go @@ -24,7 +24,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/stdlib/rlp" - . "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" ) func TestRLPReadSize(t *testing.T) { diff --git a/stdlib/test_test.go b/stdlib/test_test.go index 47592a0de2..9e602af451 100644 --- a/stdlib/test_test.go +++ b/stdlib/test_test.go @@ -34,8 +34,8 @@ import ( "github.com/onflow/cadence/interpreter" "github.com/onflow/cadence/parser" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" ) func newTestContractInterpreter(t *testing.T, code string) (*interpreter.Interpreter, error) { @@ -65,7 +65,7 @@ func newTestContractInterpreterWithTestFramework( checker, err := sema.NewChecker( program, - utils.TestLocation, + TestLocation, nil, &sema.Config{ BaseValueActivationHandler: func(_ common.Location) *sema.VariableActivation { diff --git a/test_utils/common_utils/utils.go b/test_utils/common_utils/utils.go new file mode 100644 index 0000000000..009494e373 --- /dev/null +++ b/test_utils/common_utils/utils.go @@ -0,0 +1,112 @@ +/* + * Cadence - The resource-oriented smart contract programming language + * + * Copyright Flow Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package common_utils + +import ( + "strings" + "testing" + + "github.com/k0kubun/pp" + "github.com/kr/pretty" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + "github.com/onflow/cadence/ast" + "github.com/onflow/cadence/errors" + + "github.com/onflow/cadence/common" +) + +func init() { + pp.ColoringEnabled = false +} + +// TestLocation is used as the default location for programs in tests. +const TestLocation = common.StringLocation("test") + +// ImportedLocation is used as the default location for imported programs in tests. +const ImportedLocation = common.StringLocation("imported") + +// AssertEqualWithDiff asserts that two objects are equal. +// +// If the objects are not equal, this function prints a human-readable diff. +func AssertEqualWithDiff(t *testing.T, expected, actual any) { + + // the maximum levels of a struct to recurse into + // this prevents infinite recursion from circular references + diff := pretty.Diff(expected, actual) + + if len(diff) != 0 { + s := strings.Builder{} + + for i, d := range diff { + if i == 0 { + s.WriteString("diff : ") + } else { + s.WriteString(" ") + } + + s.WriteString(d) + s.WriteString("\n") + } + + t.Errorf( + "Not equal: \n"+ + "expected: %s\n"+ + "actual : %s\n\n"+ + "%s", + pp.Sprint(expected), + pp.Sprint(actual), + s.String(), + ) + } +} + +// RequireError is a wrapper around require.Error which also ensures +// that the error message, the secondary message (if any), +// and the error notes' (if any) messages can be successfully produced +func RequireError(t *testing.T, err error) { + require.Error(t, err) + + _ = err.Error() + + if hasImportLocation, ok := err.(common.HasLocation); ok { + location := hasImportLocation.ImportLocation() + assert.NotNil(t, location) + } + + if hasPosition, ok := err.(ast.HasPosition); ok { + _ = hasPosition.StartPosition() + _ = hasPosition.EndPosition(nil) + } + + if hasErrorNotes, ok := err.(errors.ErrorNotes); ok { + for _, note := range hasErrorNotes.ErrorNotes() { + _ = note.Message() + } + } + + if hasSecondaryError, ok := err.(errors.SecondaryError); ok { + _ = hasSecondaryError.SecondaryError() + } + + if hasSuggestedFixes, ok := err.(errors.HasSuggestedFixes[ast.TextEdit]); ok { + _ = hasSuggestedFixes.SuggestFixes("") + } +} diff --git a/tests/runtime_utils/interpreter.go b/test_utils/interpreter_utils/interpreter.go similarity index 92% rename from tests/runtime_utils/interpreter.go rename to test_utils/interpreter_utils/interpreter.go index e7458be09b..46a8182023 100644 --- a/tests/runtime_utils/interpreter.go +++ b/test_utils/interpreter_utils/interpreter.go @@ -16,7 +16,7 @@ * limitations under the License. */ -package runtime_utils +package interpreter_utils import ( "testing" @@ -24,7 +24,7 @@ import ( "github.com/stretchr/testify/require" "github.com/onflow/cadence/interpreter" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" ) func NewTestInterpreter(tb testing.TB) *interpreter.Interpreter { @@ -32,7 +32,7 @@ func NewTestInterpreter(tb testing.TB) *interpreter.Interpreter { inter, err := interpreter.NewInterpreter( nil, - utils.TestLocation, + TestLocation, &interpreter.Config{ Storage: storage, AtreeValueValidationEnabled: true, diff --git a/tests/utils/utils.go b/test_utils/interpreter_utils/values.go similarity index 56% rename from tests/utils/utils.go rename to test_utils/interpreter_utils/values.go index 1c6d840712..f271ba944b 100644 --- a/tests/utils/utils.go +++ b/test_utils/interpreter_utils/values.go @@ -16,113 +16,37 @@ * limitations under the License. */ -package utils +package interpreter_utils import ( - "encoding/hex" "fmt" "strings" "testing" - "github.com/k0kubun/pp" "github.com/kr/pretty" "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - "github.com/onflow/cadence/ast" - "github.com/onflow/cadence/errors" "github.com/onflow/cadence/interpreter" - - "github.com/onflow/cadence/common" ) -func init() { - pp.ColoringEnabled = false +func RequireValuesEqual(t testing.TB, inter *interpreter.Interpreter, expected, actual interpreter.Value) { + if !AssertValuesEqual(t, inter, expected, actual) { + t.FailNow() + } } -// TestLocation is used as the default location for programs in tests. -const TestLocation = common.StringLocation("test") - -// ImportedLocation is used as the default location for imported programs in tests. -const ImportedLocation = common.StringLocation("imported") - -// AssertEqualWithDiff asserts that two objects are equal. -// -// If the objects are not equal, this function prints a human-readable diff. -func AssertEqualWithDiff(t *testing.T, expected, actual any) { - - // the maximum levels of a struct to recurse into - // this prevents infinite recursion from circular references - diff := pretty.Diff(expected, actual) - - if len(diff) != 0 { - s := strings.Builder{} - - for i, d := range diff { - if i == 0 { - s.WriteString("diff : ") - } else { - s.WriteString(" ") - } +func AssertValueSlicesEqual(t testing.TB, inter *interpreter.Interpreter, expected, actual []interpreter.Value) bool { + if !assert.Equal(t, len(expected), len(actual)) { + return false + } - s.WriteString(d) - s.WriteString("\n") + for i, value := range expected { + if !AssertValuesEqual(t, inter, value, actual[i]) { + return false } - - t.Errorf( - "Not equal: \n"+ - "expected: %s\n"+ - "actual : %s\n\n"+ - "%s", - pp.Sprint(expected), - pp.Sprint(actual), - s.String(), - ) } -} - -func DeploymentTransaction(name string, contract []byte) []byte { - return []byte(fmt.Sprintf( - ` - transaction { - - prepare(signer: auth(Contracts) &Account) { - signer.contracts.add(name: "%s", code: "%s".decodeHex()) - } - } - `, - name, - hex.EncodeToString(contract), - )) -} - -func RemovalTransaction(name string) []byte { - return []byte(fmt.Sprintf( - ` - transaction { - prepare(signer: auth(Contracts) &Account) { - signer.contracts.remove(name: "%s") - } - } - `, - name, - )) -} - -func UpdateTransaction(name string, contract []byte) []byte { - return []byte(fmt.Sprintf( - ` - transaction { - - prepare(signer: auth(Contracts) &Account) { - signer.contracts.update(name: "%s", code: "%s".decodeHex()) - } - } - `, - name, - hex.EncodeToString(contract), - )) + return true } func ValuesAreEqual(inter *interpreter.Interpreter, expected, actual interpreter.Value) bool { @@ -173,59 +97,6 @@ func AssertValuesEqual(t testing.TB, interpreter *interpreter.Interpreter, expec return true } -func RequireValuesEqual(t testing.TB, inter *interpreter.Interpreter, expected, actual interpreter.Value) { - if !AssertValuesEqual(t, inter, expected, actual) { - t.FailNow() - } -} - -func AssertValueSlicesEqual(t testing.TB, inter *interpreter.Interpreter, expected, actual []interpreter.Value) bool { - if !assert.Equal(t, len(expected), len(actual)) { - return false - } - - for i, value := range expected { - if !AssertValuesEqual(t, inter, value, actual[i]) { - return false - } - } - - return true -} - -// RequireError is a wrapper around require.Error which also ensures -// that the error message, the secondary message (if any), -// and the error notes' (if any) messages can be successfully produced -func RequireError(t *testing.T, err error) { - require.Error(t, err) - - _ = err.Error() - - if hasImportLocation, ok := err.(common.HasLocation); ok { - location := hasImportLocation.ImportLocation() - assert.NotNil(t, location) - } - - if hasPosition, ok := err.(ast.HasPosition); ok { - _ = hasPosition.StartPosition() - _ = hasPosition.EndPosition(nil) - } - - if hasErrorNotes, ok := err.(errors.ErrorNotes); ok { - for _, note := range hasErrorNotes.ErrorNotes() { - _ = note.Message() - } - } - - if hasSecondaryError, ok := err.(errors.SecondaryError); ok { - _ = hasSecondaryError.SecondaryError() - } - - if hasSuggestedFixes, ok := err.(errors.HasSuggestedFixes[ast.TextEdit]); ok { - _ = hasSuggestedFixes.SuggestFixes("") - } -} - func ArrayElements(inter *interpreter.Interpreter, array *interpreter.ArrayValue) []interpreter.Value { count := array.Count() result := make([]interpreter.Value, count) diff --git a/tests/runtime_utils/location.go b/test_utils/runtime_utils/location.go similarity index 100% rename from tests/runtime_utils/location.go rename to test_utils/runtime_utils/location.go diff --git a/tests/runtime_utils/testinterface.go b/test_utils/runtime_utils/testinterface.go similarity index 100% rename from tests/runtime_utils/testinterface.go rename to test_utils/runtime_utils/testinterface.go diff --git a/tests/runtime_utils/testledger.go b/test_utils/runtime_utils/testledger.go similarity index 100% rename from tests/runtime_utils/testledger.go rename to test_utils/runtime_utils/testledger.go diff --git a/tests/runtime_utils/testruntime.go b/test_utils/runtime_utils/testruntime.go similarity index 100% rename from tests/runtime_utils/testruntime.go rename to test_utils/runtime_utils/testruntime.go diff --git a/test_utils/runtime_utils/transactions.go b/test_utils/runtime_utils/transactions.go new file mode 100644 index 0000000000..72f8af976c --- /dev/null +++ b/test_utils/runtime_utils/transactions.go @@ -0,0 +1,68 @@ +/* + * Cadence - The resource-oriented smart contract programming language + * + * Copyright Flow Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package runtime_utils + +import ( + "encoding/hex" + "fmt" +) + +func DeploymentTransaction(name string, contract []byte) []byte { + return []byte(fmt.Sprintf( + ` + transaction { + + prepare(signer: auth(Contracts) &Account) { + signer.contracts.add(name: "%s", code: "%s".decodeHex()) + } + } + `, + name, + hex.EncodeToString(contract), + )) +} + +func RemovalTransaction(name string) []byte { + return []byte(fmt.Sprintf( + ` + transaction { + + prepare(signer: auth(Contracts) &Account) { + signer.contracts.remove(name: "%s") + } + } + `, + name, + )) +} + +func UpdateTransaction(name string, contract []byte) []byte { + return []byte(fmt.Sprintf( + ` + transaction { + + prepare(signer: auth(Contracts) &Account) { + signer.contracts.update(name: "%s", code: "%s".decodeHex()) + } + } + `, + name, + hex.EncodeToString(contract), + )) +} diff --git a/tests/sema_utils/utils.go b/test_utils/sema_utils/utils.go similarity index 97% rename from tests/sema_utils/utils.go rename to test_utils/sema_utils/utils.go index 23d1e7756e..220d0e653f 100644 --- a/tests/sema_utils/utils.go +++ b/test_utils/sema_utils/utils.go @@ -25,7 +25,6 @@ import ( "testing" gopretty "github.com/kr/pretty" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -33,7 +32,7 @@ import ( "github.com/onflow/cadence/parser" "github.com/onflow/cadence/pretty" "github.com/onflow/cadence/sema" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" ) func ParseAndCheck(t testing.TB, code string) (*sema.Checker, error) { @@ -69,7 +68,7 @@ func ParseAndCheckWithOptionsAndMemoryMetering( ) (*sema.Checker, error) { if options.Location == nil { - options.Location = utils.TestLocation + options.Location = TestLocation } program, err := parser.ParseProgram(memoryGauge, []byte(code), options.ParseOptions) @@ -170,7 +169,7 @@ func RequireCheckerErrors(t *testing.T, err error, count int) []error { return nil } - utils.RequireError(t, err) + RequireError(t, err) var checkerErr *sema.CheckerError require.ErrorAs(t, err, &checkerErr) @@ -182,7 +181,7 @@ func RequireCheckerErrors(t *testing.T, err error, count int) []error { // Get the error message, to check that it can be successfully generated for _, checkerErr := range errs { - utils.RequireError(t, checkerErr) + RequireError(t, checkerErr) } return errs diff --git a/tools/analysis/analysis_test.go b/tools/analysis/analysis_test.go index 0baebceefa..da09e6dd74 100644 --- a/tools/analysis/analysis_test.go +++ b/tools/analysis/analysis_test.go @@ -29,7 +29,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/parser" "github.com/onflow/cadence/sema" - . "github.com/onflow/cadence/tests/sema_utils" + . "github.com/onflow/cadence/test_utils/sema_utils" "github.com/onflow/cadence/tools/analysis" ) diff --git a/tools/compatibility-check/contracts_checker.go b/tools/compatibility-check/contracts_checker.go index 887cb02a0c..99bd2149c4 100644 --- a/tools/compatibility-check/contracts_checker.go +++ b/tools/compatibility-check/contracts_checker.go @@ -19,14 +19,13 @@ package compatibility_check import ( + "encoding/csv" "fmt" "io" "log" "reflect" "strings" - "encoding/csv" - "github.com/onflow/cadence/ast" "github.com/onflow/cadence/common" "github.com/onflow/cadence/parser" diff --git a/types_test.go b/types_test.go index 27f0edd4c9..45412ae7c5 100644 --- a/types_test.go +++ b/types_test.go @@ -26,7 +26,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" ) func TestType_ID(t *testing.T) { @@ -85,7 +85,7 @@ func TestType_ID(t *testing.T) { }, { &StructType{ - Location: utils.TestLocation, + Location: TestLocation, QualifiedIdentifier: "Foo", }, "S.test.Foo", @@ -98,7 +98,7 @@ func TestType_ID(t *testing.T) { }, { &StructInterfaceType{ - Location: utils.TestLocation, + Location: TestLocation, QualifiedIdentifier: "FooI", }, "S.test.FooI", @@ -111,7 +111,7 @@ func TestType_ID(t *testing.T) { }, { &ResourceType{ - Location: utils.TestLocation, + Location: TestLocation, QualifiedIdentifier: "Bar", }, "S.test.Bar", @@ -124,7 +124,7 @@ func TestType_ID(t *testing.T) { }, { &ResourceInterfaceType{ - Location: utils.TestLocation, + Location: TestLocation, QualifiedIdentifier: "BarI", }, "S.test.BarI", @@ -133,7 +133,7 @@ func TestType_ID(t *testing.T) { &IntersectionType{ Types: []Type{ &ResourceInterfaceType{ - Location: utils.TestLocation, + Location: TestLocation, QualifiedIdentifier: "FooI", }, }, @@ -167,7 +167,7 @@ func TestType_ID(t *testing.T) { }, { &EventType{ - Location: utils.TestLocation, + Location: TestLocation, QualifiedIdentifier: "Event", }, "S.test.Event", @@ -180,7 +180,7 @@ func TestType_ID(t *testing.T) { }, { &EnumType{ - Location: utils.TestLocation, + Location: TestLocation, QualifiedIdentifier: "Enum", }, "S.test.Enum", @@ -193,7 +193,7 @@ func TestType_ID(t *testing.T) { }, { &ContractType{ - Location: utils.TestLocation, + Location: TestLocation, QualifiedIdentifier: "Contract", }, "S.test.Contract", @@ -206,7 +206,7 @@ func TestType_ID(t *testing.T) { }, { &ContractInterfaceType{ - Location: utils.TestLocation, + Location: TestLocation, QualifiedIdentifier: "ContractI", }, "S.test.ContractI", @@ -2287,7 +2287,7 @@ func TestDecodeFields(t *testing.T) { NewStruct([]Value{ NewInt(42), }).WithType(NewStructType( - utils.TestLocation, + TestLocation, "NestedStruct", []Field{ { @@ -2299,7 +2299,7 @@ func TestDecodeFields(t *testing.T) { )), }, ).WithType(NewEventType( - utils.TestLocation, + TestLocation, "SimpleEvent", []Field{ { diff --git a/values_test.go b/values_test.go index d70200a911..ac5ea3b067 100644 --- a/values_test.go +++ b/values_test.go @@ -29,7 +29,7 @@ import ( "github.com/onflow/cadence/common" "github.com/onflow/cadence/sema" - "github.com/onflow/cadence/tests/utils" + . "github.com/onflow/cadence/test_utils/common_utils" ) type valueTestCase struct { @@ -242,7 +242,7 @@ func newValueTestCases() map[string]valueTestCase { "struct": { value: NewStruct([]Value{String("bar")}), exampleType: NewStructType( - utils.TestLocation, + TestLocation, "FooStruct", []Field{ { @@ -260,7 +260,7 @@ func newValueTestCases() map[string]valueTestCase { "resource": { value: NewResource([]Value{NewInt(1)}), exampleType: NewResourceType( - utils.TestLocation, + TestLocation, "FooResource", []Field{ { @@ -283,7 +283,7 @@ func newValueTestCases() map[string]valueTestCase { }, ), exampleType: NewEventType( - utils.TestLocation, + TestLocation, "FooEvent", []Field{ { @@ -305,7 +305,7 @@ func newValueTestCases() map[string]valueTestCase { "contract": { value: NewContract([]Value{String("bar")}), exampleType: NewContractType( - utils.TestLocation, + TestLocation, "FooContract", []Field{ { @@ -323,7 +323,7 @@ func newValueTestCases() map[string]valueTestCase { "enum": { value: NewEnum([]Value{UInt8(1)}), exampleType: NewEnumType( - utils.TestLocation, + TestLocation, "FooEnum", nil, []Field{ @@ -342,7 +342,7 @@ func newValueTestCases() map[string]valueTestCase { "attachment": { value: NewAttachment([]Value{NewInt(1)}), exampleType: NewAttachmentType( - utils.TestLocation, + TestLocation, "FooAttachment", nil, []Field{ @@ -960,7 +960,7 @@ func TestEvent_GetFieldByName(t *testing.T) { assert.Nil(t, SearchFieldByName(simpleEvent, "a")) simpleEventWithType := simpleEvent.WithType(NewEventType( - utils.TestLocation, + TestLocation, "SimpleEvent", []Field{ { From ff8d29d984d0389782929bfd7be31d38153997c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20M=C3=BCller?= Date: Mon, 28 Oct 2024 18:17:45 -0700 Subject: [PATCH 45/46] adjust paths --- Makefile | 2 +- docs/development.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index c14880b9f5..16b7bd328f 100644 --- a/Makefile +++ b/Makefile @@ -64,7 +64,7 @@ ci: # test all packages go test -coverprofile=coverage.txt -covermode=atomic -parallel 8 -race -coverpkg $(COVERPKGS) ./... # run interpreter smoke tests. results from run above are reused, so no tests runs are duplicated - go test -count=5 ./tests/interpreter/... -runSmokeTests=true -validateAtree=false + go test -count=5 ./interpreter/... -runSmokeTests=true -validateAtree=false # remove coverage of empty functions from report sed -i -e 's/^.* 0 0$$//' coverage.txt diff --git a/docs/development.md b/docs/development.md index 4a166bba19..477bcf6222 100644 --- a/docs/development.md +++ b/docs/development.md @@ -83,7 +83,7 @@ contains command-line tools that are useful when working on the implementation f Run the checker tests with the `cadence.checkConcurrently` flag, e.g. ```shell -go test -race -v ./tests/checker -cadence.checkConcurrently=10 +go test -race -v ./sema/... -cadence.checkConcurrently=10 ``` This runs each check of a checker test 10 times, concurrently, From f642b8e24632eea3ac6cc94815cc1c4ce4122221 Mon Sep 17 00:00:00 2001 From: Supun Setunga Date: Wed, 30 Oct 2024 12:03:54 -0700 Subject: [PATCH 46/46] Fix tests --- parser/expression_test.go | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/parser/expression_test.go b/parser/expression_test.go index 92006a1914..172884de18 100644 --- a/parser/expression_test.go +++ b/parser/expression_test.go @@ -6082,7 +6082,7 @@ func TestParseStringTemplate(t *testing.T) { }, } - utils.AssertEqualWithDiff(t, expected, actual) + AssertEqualWithDiff(t, expected, actual) }) t.Run("multi", func(t *testing.T) { @@ -6128,7 +6128,7 @@ func TestParseStringTemplate(t *testing.T) { }, } - utils.AssertEqualWithDiff(t, expected, actual) + AssertEqualWithDiff(t, expected, actual) }) t.Run("missing end", func(t *testing.T) { @@ -6147,7 +6147,7 @@ func TestParseStringTemplate(t *testing.T) { } require.Error(t, err) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "invalid end of string literal: missing '\"'", @@ -6174,7 +6174,7 @@ func TestParseStringTemplate(t *testing.T) { } require.Error(t, err) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token in expression: '.'", @@ -6201,7 +6201,7 @@ func TestParseStringTemplate(t *testing.T) { } require.Error(t, err) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected identifier got: 2 + 2", @@ -6248,7 +6248,7 @@ func TestParseStringTemplate(t *testing.T) { }, } - utils.AssertEqualWithDiff(t, expected, actual) + AssertEqualWithDiff(t, expected, actual) }) t.Run("invalid, empty", func(t *testing.T) { @@ -6267,7 +6267,7 @@ func TestParseStringTemplate(t *testing.T) { } require.Error(t, err) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "unexpected token in expression: ')'", @@ -6294,7 +6294,7 @@ func TestParseStringTemplate(t *testing.T) { } require.Error(t, err) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected identifier got: add()", @@ -6321,7 +6321,7 @@ func TestParseStringTemplate(t *testing.T) { } require.Error(t, err) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected token ')'", @@ -6348,7 +6348,7 @@ func TestParseStringTemplate(t *testing.T) { } require.Error(t, err) - utils.AssertEqualWithDiff(t, + AssertEqualWithDiff(t, []error{ &SyntaxError{ Message: "expected token ')'", @@ -6395,7 +6395,7 @@ func TestParseStringTemplate(t *testing.T) { }, } - utils.AssertEqualWithDiff(t, expected, actual) + AssertEqualWithDiff(t, expected, actual) }) t.Run("valid, surrounded", func(t *testing.T) { @@ -6441,7 +6441,7 @@ func TestParseStringTemplate(t *testing.T) { }, } - utils.AssertEqualWithDiff(t, expected, actual) + AssertEqualWithDiff(t, expected, actual) }) t.Run("valid, adjacent", func(t *testing.T) { @@ -6494,7 +6494,7 @@ func TestParseStringTemplate(t *testing.T) { }, } - utils.AssertEqualWithDiff(t, expected, actual) + AssertEqualWithDiff(t, expected, actual) }) }