diff --git a/tests/consensus_spec/altair/test_fixture_ssz_consensus_objects.nim b/tests/consensus_spec/altair/test_fixture_ssz_consensus_objects.nim index de2ccecd7..53a5643ce 100644 --- a/tests/consensus_spec/altair/test_fixture_ssz_consensus_objects.nim +++ b/tests/consensus_spec/altair/test_fixture_ssz_consensus_objects.nim @@ -5,6 +5,7 @@ # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). # at your option. This file may not be copied, modified, or distributed except according to those terms. +{.push raises: [].} {.used.} import @@ -40,7 +41,11 @@ type # Note this only tracks HashTreeRoot # Checking the values against the yaml file is TODO (require more flexible Yaml parser) -proc checkSSZ(T: type altair.SignedBeaconBlock, dir: string, expectedHash: SSZHashTreeRoot) = +proc checkSSZ( + T: type altair.SignedBeaconBlock, + dir: string, + expectedHash: SSZHashTreeRoot +) {.raises: [IOError, SerializationError, UnconsumedInput].} = # Deserialize into a ref object to not fill Nim stack let encoded = snappy.decode( readFileBytes(dir/"serialized.ssz_snappy"), MaxObjectSize) @@ -58,7 +63,11 @@ proc checkSSZ(T: type altair.SignedBeaconBlock, dir: string, expectedHash: SSZHa # TODO check the value (requires YAML loader) -proc checkSSZ(T: type, dir: string, expectedHash: SSZHashTreeRoot) = +proc checkSSZ( + T: type, + dir: string, + expectedHash: SSZHashTreeRoot +) {.raises: [IOError, SerializationError, UnconsumedInput].} = # Deserialize into a ref object to not fill Nim stack let encoded = snappy.decode( readFileBytes(dir/"serialized.ssz_snappy"), MaxObjectSize) @@ -71,7 +80,10 @@ proc checkSSZ(T: type, dir: string, expectedHash: SSZHashTreeRoot) = # TODO check the value (requires YAML loader) -proc loadExpectedHashTreeRoot(dir: string): SSZHashTreeRoot = +proc loadExpectedHashTreeRoot( + dir: string +): SSZHashTreeRoot {.raises: [ + Exception, IOError, OSError, YamlConstructionError, YamlParserError].} = let s = openFileStream(dir/"roots.yaml") yaml.load(s, result) s.close() diff --git a/tests/consensus_spec/bellatrix/test_fixture_ssz_consensus_objects.nim b/tests/consensus_spec/bellatrix/test_fixture_ssz_consensus_objects.nim index 3a7eb3564..6d097b75d 100644 --- a/tests/consensus_spec/bellatrix/test_fixture_ssz_consensus_objects.nim +++ b/tests/consensus_spec/bellatrix/test_fixture_ssz_consensus_objects.nim @@ -5,6 +5,7 @@ # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). # at your option. This file may not be copied, modified, or distributed except according to those terms. +{.push raises: [].} {.used.} import @@ -40,7 +41,11 @@ type # Note this only tracks HashTreeRoot # Checking the values against the yaml file is TODO (require more flexible Yaml parser) -proc checkSSZ(T: type bellatrix.SignedBeaconBlock, dir: string, expectedHash: SSZHashTreeRoot) = +proc checkSSZ( + T: type bellatrix.SignedBeaconBlock, + dir: string, + expectedHash: SSZHashTreeRoot +) {.raises: [IOError, SerializationError, UnconsumedInput].} = # Deserialize into a ref object to not fill Nim stack let encoded = snappy.decode( readFileBytes(dir/"serialized.ssz_snappy"), MaxObjectSize) @@ -58,7 +63,11 @@ proc checkSSZ(T: type bellatrix.SignedBeaconBlock, dir: string, expectedHash: SS # TODO check the value (requires YAML loader) -proc checkSSZ(T: type, dir: string, expectedHash: SSZHashTreeRoot) = +proc checkSSZ( + T: type, + dir: string, + expectedHash: SSZHashTreeRoot +) {.raises: [IOError, SerializationError, UnconsumedInput].} = # Deserialize into a ref object to not fill Nim stack let encoded = snappy.decode( readFileBytes(dir/"serialized.ssz_snappy"), MaxObjectSize) @@ -71,7 +80,10 @@ proc checkSSZ(T: type, dir: string, expectedHash: SSZHashTreeRoot) = # TODO check the value (requires YAML loader) -proc loadExpectedHashTreeRoot(dir: string): SSZHashTreeRoot = +proc loadExpectedHashTreeRoot( + dir: string +): SSZHashTreeRoot {.raises: [ + Exception, IOError, OSError, YamlConstructionError, YamlParserError].} = let s = openFileStream(dir/"roots.yaml") yaml.load(s, result) s.close() diff --git a/tests/consensus_spec/capella/test_fixture_ssz_consensus_objects.nim b/tests/consensus_spec/capella/test_fixture_ssz_consensus_objects.nim index f48b04729..271fca416 100644 --- a/tests/consensus_spec/capella/test_fixture_ssz_consensus_objects.nim +++ b/tests/consensus_spec/capella/test_fixture_ssz_consensus_objects.nim @@ -5,6 +5,7 @@ # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). # at your option. This file may not be copied, modified, or distributed except according to those terms. +{.push raises: [].} {.used.} import @@ -42,7 +43,11 @@ type # Note this only tracks HashTreeRoot # Checking the values against the yaml file is TODO (require more flexible Yaml parser) -proc checkSSZ(T: type capella.SignedBeaconBlock, dir: string, expectedHash: SSZHashTreeRoot) = +proc checkSSZ( + T: type capella.SignedBeaconBlock, + dir: string, + expectedHash: SSZHashTreeRoot +) {.raises: [IOError, SerializationError, UnconsumedInput].} = # Deserialize into a ref object to not fill Nim stack let encoded = snappy.decode( readFileBytes(dir/"serialized.ssz_snappy"), MaxObjectSize) @@ -60,7 +65,11 @@ proc checkSSZ(T: type capella.SignedBeaconBlock, dir: string, expectedHash: SSZH # TODO check the value (requires YAML loader) -proc checkSSZ(T: type, dir: string, expectedHash: SSZHashTreeRoot) = +proc checkSSZ( + T: type, + dir: string, + expectedHash: SSZHashTreeRoot +) {.raises: [IOError, SerializationError, UnconsumedInput].} = # Deserialize into a ref object to not fill Nim stack let encoded = snappy.decode( readFileBytes(dir/"serialized.ssz_snappy"), MaxObjectSize) @@ -73,7 +82,10 @@ proc checkSSZ(T: type, dir: string, expectedHash: SSZHashTreeRoot) = # TODO check the value (requires YAML loader) -proc loadExpectedHashTreeRoot(dir: string): SSZHashTreeRoot = +proc loadExpectedHashTreeRoot( + dir: string +): SSZHashTreeRoot {.raises: [ + Exception, IOError, OSError, YamlConstructionError, YamlParserError].} = let s = openFileStream(dir/"roots.yaml") yaml.load(s, result) s.close() diff --git a/tests/consensus_spec/deneb/test_fixture_ssz_consensus_objects.nim b/tests/consensus_spec/deneb/test_fixture_ssz_consensus_objects.nim index 2503c88bc..db561d215 100644 --- a/tests/consensus_spec/deneb/test_fixture_ssz_consensus_objects.nim +++ b/tests/consensus_spec/deneb/test_fixture_ssz_consensus_objects.nim @@ -5,6 +5,7 @@ # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). # at your option. This file may not be copied, modified, or distributed except according to those terms. +{.push raises: [].} {.used.} import @@ -45,7 +46,11 @@ type # Note this only tracks HashTreeRoot # Checking the values against the yaml file is TODO (require more flexible Yaml parser) -proc checkSSZ(T: type deneb.SignedBeaconBlock, dir: string, expectedHash: SSZHashTreeRoot) = +proc checkSSZ( + T: type deneb.SignedBeaconBlock, + dir: string, + expectedHash: SSZHashTreeRoot +) {.raises: [IOError, SerializationError, UnconsumedInput].} = # Deserialize into a ref object to not fill Nim stack let encoded = snappy.decode( readFileBytes(dir/"serialized.ssz_snappy"), MaxObjectSize) @@ -63,7 +68,11 @@ proc checkSSZ(T: type deneb.SignedBeaconBlock, dir: string, expectedHash: SSZHas # TODO check the value (requires YAML loader) -proc checkSSZ(T: type, dir: string, expectedHash: SSZHashTreeRoot) = +proc checkSSZ( + T: type, + dir: string, + expectedHash: SSZHashTreeRoot +) {.raises: [IOError, SerializationError, UnconsumedInput].} = # Deserialize into a ref object to not fill Nim stack let encoded = snappy.decode( readFileBytes(dir/"serialized.ssz_snappy"), MaxObjectSize) @@ -76,7 +85,10 @@ proc checkSSZ(T: type, dir: string, expectedHash: SSZHashTreeRoot) = # TODO check the value (requires YAML loader) -proc loadExpectedHashTreeRoot(dir: string): SSZHashTreeRoot = +proc loadExpectedHashTreeRoot( + dir: string +): SSZHashTreeRoot {.raises: [ + Exception, IOError, OSError, YamlConstructionError, YamlParserError].} = let s = openFileStream(dir/"roots.yaml") yaml.load(s, result) s.close() diff --git a/tests/consensus_spec/phase0/test_fixture_ssz_consensus_objects.nim b/tests/consensus_spec/phase0/test_fixture_ssz_consensus_objects.nim index 16083b85d..b2282e0ea 100644 --- a/tests/consensus_spec/phase0/test_fixture_ssz_consensus_objects.nim +++ b/tests/consensus_spec/phase0/test_fixture_ssz_consensus_objects.nim @@ -5,6 +5,7 @@ # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). # at your option. This file may not be copied, modified, or distributed except according to those terms. +{.push raises: [].} {.used.} import @@ -40,7 +41,11 @@ type # Note this only tracks HashTreeRoot # Checking the values against the yaml file is TODO (require more flexible Yaml parser) -proc checkSSZ(T: type phase0.SignedBeaconBlock, dir: string, expectedHash: SSZHashTreeRoot) = +proc checkSSZ( + T: type phase0.SignedBeaconBlock, + dir: string, + expectedHash: SSZHashTreeRoot +) {.raises: [IOError, SerializationError, UnconsumedInput].} = # Deserialize into a ref object to not fill Nim stack let encoded = snappy.decode( readFileBytes(dir/"serialized.ssz_snappy"), MaxObjectSize) @@ -58,7 +63,11 @@ proc checkSSZ(T: type phase0.SignedBeaconBlock, dir: string, expectedHash: SSZHa # TODO check the value (requires YAML loader) -proc checkSSZ(T: type, dir: string, expectedHash: SSZHashTreeRoot) = +proc checkSSZ( + T: type, + dir: string, + expectedHash: SSZHashTreeRoot +) {.raises: [IOError, SerializationError, UnconsumedInput].} = # Deserialize into a ref object to not fill Nim stack let encoded = snappy.decode( readFileBytes(dir/"serialized.ssz_snappy"), MaxObjectSize) @@ -71,7 +80,10 @@ proc checkSSZ(T: type, dir: string, expectedHash: SSZHashTreeRoot) = # TODO check the value (requires YAML loader) -proc loadExpectedHashTreeRoot(dir: string): SSZHashTreeRoot = +proc loadExpectedHashTreeRoot( + dir: string +): SSZHashTreeRoot {.raises: [ + Exception, IOError, OSError, YamlConstructionError, YamlParserError].} = let s = openFileStream(dir/"roots.yaml") yaml.load(s, result) s.close() diff --git a/tests/consensus_spec/test_fixture_fork_choice.nim b/tests/consensus_spec/test_fixture_fork_choice.nim index 4c997aed2..631c59154 100644 --- a/tests/consensus_spec/test_fixture_fork_choice.nim +++ b/tests/consensus_spec/test_fixture_fork_choice.nim @@ -96,10 +96,11 @@ proc initialLoad( (dag, fkChoice) proc loadOps( - path: string, fork: ConsensusFork + path: string, + fork: ConsensusFork ): seq[Operation] {.raises: [ IOError, KeyError, UnconsumedInput, ValueError, - YamlParserError, YamlConstructionError].} = + YamlConstructionError, YamlParserError].} = let stepsYAML = os_ops.readFile(path/"steps.yaml") let steps = yaml.loadToJson(stepsYAML) @@ -290,10 +291,11 @@ proc stepChecks( raiseAssert "Unsupported check '" & $check & "'" proc doRunTest( - path: string, fork: ConsensusFork + path: string, + fork: ConsensusFork ) {.raises: [ IOError, KeyError, UnconsumedInput, ValueError, - YamlParserError, YamlConstructionError].} = + YamlConstructionError, YamlParserError].} = let db = BeaconChainDB.new("", inMemory = true) defer: db.close() diff --git a/tests/consensus_spec/test_fixture_light_client_single_merkle_proof.nim b/tests/consensus_spec/test_fixture_light_client_single_merkle_proof.nim index 13ca2f579..15d7295da 100644 --- a/tests/consensus_spec/test_fixture_light_client_single_merkle_proof.nim +++ b/tests/consensus_spec/test_fixture_light_client_single_merkle_proof.nim @@ -5,6 +5,7 @@ # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). # at your option. This file may not be copied, modified, or distributed except according to those terms. +{.push raises: [].} {.used.} import @@ -21,7 +22,8 @@ import ./fixtures_utils, ./os_ops proc runTest[T](suiteName, path: string, objType: typedesc[T]) = - test "Light client - Single merkle proof - " & path.relativePath(SszTestsDir): + let relativePathComponent = path.relativeTestPathComponent() + test "Light client - Single merkle proof - " & relativePathComponent: type TestProof = object leaf: string diff --git a/tests/consensus_spec/test_fixture_light_client_sync.nim b/tests/consensus_spec/test_fixture_light_client_sync.nim index d6d94112c..6338bf08a 100644 --- a/tests/consensus_spec/test_fixture_light_client_sync.nim +++ b/tests/consensus_spec/test_fixture_light_client_sync.nim @@ -5,6 +5,7 @@ # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). # at your option. This file may not be copied, modified, or distributed except according to those terms. +{.push raises: [].} {.used.} import @@ -52,13 +53,17 @@ type current_slot: Slot checks: TestChecks -proc loadSteps(path: string, fork_digests: ForkDigests): seq[TestStep] = +proc loadSteps( + path: string, + fork_digests: ForkDigests +): seq[TestStep] {.raises: [ + KeyError, ValueError, YamlConstructionError, YamlParserError].} = let stepsYAML = os_ops.readFile(path/"steps.yaml") let steps = yaml.loadToJson(stepsYAML) result = @[] for step in steps[0]: - func getChecks(c: JsonNode): TestChecks = + func getChecks(c: JsonNode): TestChecks {.raises: [KeyError].} = TestChecks( finalized_slot: c["finalized_header"]["slot"].getInt().Slot, @@ -122,9 +127,11 @@ proc loadSteps(path: string, fork_digests: ForkDigests): seq[TestStep] = doAssert false, "Unknown test step: " & $step proc runTest(suiteName, path: string) = - test "Light client - Sync - " & path.relativePath(SszTestsDir): + let relativePathComponent = path.relativeTestPathComponent() + test "Light client - Sync - " & relativePathComponent: # Reduce stack size by making this a `proc` - proc loadTestMeta(): (RuntimeConfig, TestMeta) = + proc loadTestMeta(): (RuntimeConfig, TestMeta) {.raises: [ + Exception, IOError, PresetFileError, PresetIncompatibleError].} = let (cfg, _) = readRuntimeConfig(path/"config.yaml") when false: diff --git a/tests/consensus_spec/test_fixture_light_client_update_ranking.nim b/tests/consensus_spec/test_fixture_light_client_update_ranking.nim index 41a461d55..0cac0a6ad 100644 --- a/tests/consensus_spec/test_fixture_light_client_update_ranking.nim +++ b/tests/consensus_spec/test_fixture_light_client_update_ranking.nim @@ -5,6 +5,7 @@ # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). # at your option. This file may not be copied, modified, or distributed except according to those terms. +{.push raises: [].} {.used.} import @@ -25,7 +26,8 @@ type updates_count: uint64 proc runTest(suiteName, path: string, lcDataFork: static LightClientDataFork) = - test "Light client - Update ranking - " & path.relativePath(SszTestsDir): + let relativePathComponent = path.relativeTestPathComponent() + test "Light client - Update ranking - " & relativePathComponent: let meta = block: var s = openFileStream(path/"meta.yaml") defer: close(s) diff --git a/tests/consensus_spec/test_fixture_merkle_proof.nim b/tests/consensus_spec/test_fixture_merkle_proof.nim index 828a4e048..d19010469 100644 --- a/tests/consensus_spec/test_fixture_merkle_proof.nim +++ b/tests/consensus_spec/test_fixture_merkle_proof.nim @@ -1,10 +1,11 @@ # beacon_chain -# Copyright (c) 2023 Status Research & Development GmbH +# Copyright (c) 2023-2024 Status Research & Development GmbH # Licensed and distributed under either of # * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). # at your option. This file may not be copied, modified, or distributed except according to those terms. +{.push raises: [].} {.used.} import @@ -21,7 +22,8 @@ import ./fixtures_utils, ./os_ops proc runTest[T](suiteName, path: string, objType: typedesc[T]) = - test "Merkle proof - Single merkle proof - " & path.relativePath(SszTestsDir): + let relativePathComponent = path.relativeTestPathComponent() + test "Merkle proof - Single merkle proof - " & relativePathComponent: type TestProof = object leaf: string diff --git a/tests/consensus_spec/test_fixture_sanity_slots.nim b/tests/consensus_spec/test_fixture_sanity_slots.nim index 111ca978f..74c640240 100644 --- a/tests/consensus_spec/test_fixture_sanity_slots.nim +++ b/tests/consensus_spec/test_fixture_sanity_slots.nim @@ -5,6 +5,7 @@ # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). # at your option. This file may not be copied, modified, or distributed except according to those terms. +{.push raises: [].} {.used.} import ../../beacon_chain/spec/forks @@ -15,7 +16,10 @@ from ../testutil import check, preset, suite, test from ../../beacon_chain/spec/state_transition import process_slots from ../helpers/debug_state import reportDiff -proc runTest(T: type, testDir, forkName: static[string], suiteName, identifier: string) = +proc runTest( + T: type, + testDir, forkName: static[string], + suiteName, identifier: string) {.raises: [IOError, ValueError].} = let testDir = testDir / identifier num_slots = readLines(testDir / "slots.yaml", 2)[0].parseInt.uint64 diff --git a/tests/consensus_spec/test_fixture_transition.nim b/tests/consensus_spec/test_fixture_transition.nim index 1db945831..53cbb6652 100644 --- a/tests/consensus_spec/test_fixture_transition.nim +++ b/tests/consensus_spec/test_fixture_transition.nim @@ -5,6 +5,7 @@ # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). # at your option. This file may not be copied, modified, or distributed except according to those terms. +{.push raises: [].} {.used.} import @@ -25,7 +26,8 @@ type fork_block {.defaultVal: -1.}: int bls_setting {.defaultVal: 1.}: int -proc getTransitionInfo(testPath: string): TransitionInfo = +proc getTransitionInfo( + testPath: string): TransitionInfo {.raises: [Exception, IOError].} = var transitionInfo: TransitionInfo let s = openFileStream(testPath/"meta.yaml") defer: close(s) diff --git a/tests/test_el_conf.nim b/tests/test_el_conf.nim index f5bc1b59d..fc8e948e6 100644 --- a/tests/test_el_conf.nim +++ b/tests/test_el_conf.nim @@ -5,6 +5,7 @@ # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). # at your option. This file may not be copied, modified, or distributed except according to those terms. +{.push raises: [].} {.used.} import @@ -18,12 +19,15 @@ type dataDir* {.name: "data-dir".}: string el* {.name: "el".}: seq[EngineApiUrlConfigValue] -proc loadExampleConfig(content: string, cmdLine = newSeq[string]()): ExampleConfigFile = +proc loadExampleConfig( + content: string, + cmdLine = newSeq[string]() +): ExampleConfigFile {.raises: [ConfigurationError, OSError].} = ExampleConfigFile.load( cmdLine = cmdLine, secondarySources = proc ( - config: ExampleConfigFile, sources: ref SecondarySources - ) {.raises: [ConfigurationError].} = + config: ExampleConfigFile, + sources: ref SecondarySources) {.raises: [ConfigurationError].} = sources.addConfigFileContent(Toml, content)) const