exists{Dir,File} -> {dir,file}Exists; rm unused imports (#3543)
This commit is contained in:
parent
bc4d4e1741
commit
50f5754e3c
|
@ -31,7 +31,7 @@
|
|||
import
|
||||
std/[typetraits, sets, hashes],
|
||||
chronicles,
|
||||
stew/[assign2, bitops2, objects],
|
||||
stew/[bitops2, objects],
|
||||
"."/[base, phase0]
|
||||
|
||||
export base, sets
|
||||
|
@ -547,7 +547,7 @@ chronicles.formatIt SyncSubcommitteeIndex: uint8(it)
|
|||
template `[]`*(a: auto; i: SyncSubcommitteeIndex): auto =
|
||||
a[i.asInt]
|
||||
|
||||
template `[]`*(arr: array[SYNC_COMMITTEE_SIZE, any] | seq;
|
||||
template `[]`*(arr: array[SYNC_COMMITTEE_SIZE, auto] | seq;
|
||||
idx: IndexInSyncCommittee): auto =
|
||||
arr[int idx]
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
{.push raises: [Defect].}
|
||||
|
||||
import
|
||||
stew/[assign2, byteutils],
|
||||
stew/byteutils,
|
||||
json_serialization,
|
||||
ssz_serialization/types as sszTypes,
|
||||
../digest,
|
||||
|
|
|
@ -482,10 +482,10 @@ proc removeValidatorFiles*(validatorsDir, secretsDir, keyName: string,
|
|||
keystoreDir / RemoteKeystoreFileName
|
||||
secretFile = secretsDir / keyName
|
||||
|
||||
if not(existsDir(keystoreDir)):
|
||||
if not(dirExists(keystoreDir)):
|
||||
return ok(RemoveValidatorStatus.notFound)
|
||||
|
||||
if not(existsFile(keystoreFile)):
|
||||
if not(fileExists(keystoreFile)):
|
||||
return ok(RemoveValidatorStatus.notFound)
|
||||
|
||||
case kind
|
||||
|
@ -496,7 +496,7 @@ proc removeValidatorFiles*(validatorsDir, secretsDir, keyName: string,
|
|||
return err("Could not remove keystore file")
|
||||
block:
|
||||
let res = io2.removeFile(secretFile)
|
||||
if res.isErr() and existsFile(secretFile):
|
||||
if res.isErr() and fileExists(secretFile):
|
||||
return err("Could not remove password file")
|
||||
# We remove folder with all subfolders and files inside.
|
||||
try:
|
||||
|
@ -553,9 +553,9 @@ proc existsKeystore*(keystoreDir: string, keyKind: KeystoreKind): bool {.
|
|||
raises: [Defect].} =
|
||||
case keyKind
|
||||
of KeystoreKind.Local:
|
||||
existsFile(keystoreDir / KeystoreFileName)
|
||||
fileExists(keystoreDir / KeystoreFileName)
|
||||
of KeystoreKind.Remote:
|
||||
existsFile(keystoreDir / RemoteKeystoreFileName)
|
||||
fileExists(keystoreDir / RemoteKeystoreFileName)
|
||||
|
||||
proc existsKeystore*(keystoreDir: string,
|
||||
keysMask: set[KeystoreKind]): bool {.raises: [Defect].} =
|
||||
|
@ -794,10 +794,10 @@ proc saveKeystore*(rng: var BrHmacDrbgContext,
|
|||
keystoreDir = validatorsDir / keyName
|
||||
keystoreFile = keystoreDir / KeystoreFileName
|
||||
|
||||
if existsDir(keystoreDir):
|
||||
if dirExists(keystoreDir):
|
||||
return err(KeystoreGenerationError(kind: DuplicateKeystoreDir,
|
||||
error: "Keystore directory already exists"))
|
||||
if existsFile(keystoreFile):
|
||||
if fileExists(keystoreFile):
|
||||
return err(KeystoreGenerationError(kind: DuplicateKeystoreFile,
|
||||
error: "Keystore file already exists"))
|
||||
|
||||
|
@ -837,10 +837,10 @@ proc saveKeystore*(validatorsDir: string,
|
|||
pubkey: publicKey, remote: url, flags: flags
|
||||
)
|
||||
|
||||
if existsDir(keystoreDir):
|
||||
if dirExists(keystoreDir):
|
||||
return err(KeystoreGenerationError(kind: DuplicateKeystoreDir,
|
||||
error: "Keystore directory already exists"))
|
||||
if existsFile(keystoreFile):
|
||||
if fileExists(keystoreFile):
|
||||
return err(KeystoreGenerationError(kind: DuplicateKeystoreFile,
|
||||
error: "Keystore file already exists"))
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ proc runTest[T, U](
|
|||
|
||||
proc testImpl() =
|
||||
let prefix =
|
||||
if existsFile(testDir/"post.ssz_snappy"):
|
||||
if fileExists(testDir/"post.ssz_snappy"):
|
||||
"[Valid] "
|
||||
else:
|
||||
"[Invalid] "
|
||||
|
@ -57,7 +57,7 @@ proc runTest[T, U](
|
|||
let done = applyProc(
|
||||
preState[], parseTest(testDir/(applyFile & ".ssz_snappy"), SSZ, T))
|
||||
|
||||
if existsFile(testDir/"post.ssz_snappy"):
|
||||
if fileExists(testDir/"post.ssz_snappy"):
|
||||
let postState =
|
||||
newClone(parseTest(testDir/"post.ssz_snappy", SSZ, altair.BeaconState))
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ proc runTest(testName, testDir, unitTestName: string) =
|
|||
|
||||
proc `testImpl _ blck _ testName`() =
|
||||
let
|
||||
hasPostState = existsFile(testPath/"post.ssz_snappy")
|
||||
hasPostState = fileExists(testPath/"post.ssz_snappy")
|
||||
prefix = if hasPostState: "[Valid] " else: "[Invalid] "
|
||||
|
||||
test prefix & testName & " - " & unitTestName & preset():
|
||||
|
|
|
@ -79,7 +79,7 @@ proc loadExpectedHashTreeRoot(dir: string): SSZHashTreeRoot =
|
|||
# ----------------------------------------------------------------
|
||||
|
||||
suite "EF - Altair - SSZ consensus objects " & preset():
|
||||
doAssert existsDir(SSZDir), "You need to run the \"download_test_vectors.sh\" script to retrieve the consensus spec test vectors."
|
||||
doAssert dirExists(SSZDir), "You need to run the \"download_test_vectors.sh\" script to retrieve the consensus spec test vectors."
|
||||
for pathKind, sszType in walkDir(SSZDir, relative = true, checkDir = true):
|
||||
doAssert pathKind == pcDir
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ proc runTest[T, U](
|
|||
|
||||
proc testImpl() =
|
||||
let prefix =
|
||||
if existsFile(testDir/"post.ssz_snappy"):
|
||||
if fileExists(testDir/"post.ssz_snappy"):
|
||||
"[Valid] "
|
||||
else:
|
||||
"[Invalid] "
|
||||
|
@ -58,7 +58,7 @@ proc runTest[T, U](
|
|||
let done = applyProc(
|
||||
preState[], parseTest(testDir/(applyFile & ".ssz_snappy"), SSZ, T))
|
||||
|
||||
if existsFile(testDir/"post.ssz_snappy"):
|
||||
if fileExists(testDir/"post.ssz_snappy"):
|
||||
let postState =
|
||||
newClone(parseTest(
|
||||
testDir/"post.ssz_snappy", SSZ, bellatrix.BeaconState))
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
import
|
||||
# Standard library
|
||||
std/[os, sequtils, strutils],
|
||||
std/[os, sequtils],
|
||||
# Nimble
|
||||
chronicles,
|
||||
# Beacon chain internals
|
||||
|
@ -30,7 +30,7 @@ proc runTest(testName, testDir, unitTestName: string) =
|
|||
|
||||
proc `testImpl _ blck _ testName`() =
|
||||
let
|
||||
hasPostState = existsFile(testPath/"post.ssz_snappy")
|
||||
hasPostState = fileExists(testPath/"post.ssz_snappy")
|
||||
prefix = if hasPostState: "[Valid] " else: "[Invalid] "
|
||||
|
||||
test prefix & testName & " - " & unitTestName & preset():
|
||||
|
|
|
@ -79,7 +79,7 @@ proc loadExpectedHashTreeRoot(dir: string): SSZHashTreeRoot =
|
|||
# ----------------------------------------------------------------
|
||||
|
||||
suite "EF - Bellatrix - SSZ consensus objects " & preset():
|
||||
doAssert existsDir(SSZDir), "You need to run the \"download_test_vectors.sh\" script to retrieve the consensus spec test vectors."
|
||||
doAssert dirExists(SSZDir), "You need to run the \"download_test_vectors.sh\" script to retrieve the consensus spec test vectors."
|
||||
for pathKind, sszType in walkDir(SSZDir, relative = true, checkDir = true):
|
||||
doAssert pathKind == pcDir
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
||||
|
||||
import
|
||||
chronicles,
|
||||
../testutil
|
||||
|
||||
# Tests that depend on `mainnet` vs `minimal` compile-time configuration
|
||||
|
|
|
@ -44,7 +44,7 @@ proc runTest[T, U](
|
|||
|
||||
proc testImpl() =
|
||||
let prefix =
|
||||
if existsFile(testDir/"post.ssz_snappy"):
|
||||
if fileExists(testDir/"post.ssz_snappy"):
|
||||
"[Valid] "
|
||||
else:
|
||||
"[Invalid] "
|
||||
|
@ -55,7 +55,7 @@ proc runTest[T, U](
|
|||
let done = applyProc(
|
||||
preState[], parseTest(testDir/(applyFile & ".ssz_snappy"), SSZ, T))
|
||||
|
||||
if existsFile(testDir/"post.ssz_snappy"):
|
||||
if fileExists(testDir/"post.ssz_snappy"):
|
||||
let postState =
|
||||
newClone(parseTest(testDir/"post.ssz_snappy", SSZ, phase0.BeaconState))
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ proc runTest(testName, testDir, unitTestName: string) =
|
|||
|
||||
proc `testImpl _ blck _ testName`() =
|
||||
let
|
||||
hasPostState = existsFile(testPath/"post.ssz_snappy")
|
||||
hasPostState = fileExists(testPath/"post.ssz_snappy")
|
||||
prefix = if hasPostState: "[Valid] " else: "[Invalid] "
|
||||
|
||||
test prefix & testName & " - " & unitTestName & preset():
|
||||
|
|
|
@ -79,7 +79,7 @@ proc loadExpectedHashTreeRoot(dir: string): SSZHashTreeRoot =
|
|||
# ----------------------------------------------------------------
|
||||
|
||||
suite "EF - Phase 0 - SSZ consensus objects " & preset():
|
||||
doAssert existsDir(SSZDir), "You need to run the \"download_test_vectors.sh\" script to retrieve the consensus spec test vectors."
|
||||
doAssert dirExists(SSZDir), "You need to run the \"download_test_vectors.sh\" script to retrieve the consensus spec test vectors."
|
||||
for pathKind, sszType in walkDir(SSZDir, relative = true, checkDir = true):
|
||||
doAssert pathKind == pcDir
|
||||
|
||||
|
|
|
@ -246,7 +246,7 @@ proc sszCheck(baseDir, sszType, sszSubType: string) =
|
|||
# ------------------------------------------------------------------------
|
||||
|
||||
suite "EF - SSZ generic types":
|
||||
doAssert existsDir(SSZDir), "You need to run the \"download_test_vectors.sh\" script to retrieve the consensus spec test vectors."
|
||||
doAssert dirExists(SSZDir), "You need to run the \"download_test_vectors.sh\" script to retrieve the consensus spec test vectors."
|
||||
for pathKind, sszType in walkDir(SSZDir, relative = true, checkDir = true):
|
||||
doAssert pathKind == pcDir
|
||||
|
||||
|
|
Loading…
Reference in New Issue