mirror of https://github.com/status-im/nim-eth.git
Fix nim v1.0.2 compile issues
This commit is contained in:
parent
aa1f7f2c06
commit
44400ee549
|
@ -230,7 +230,7 @@ proc kdfParams(kdfkind: KdfKind, salt: string, workfactor: int,
|
|||
proc decodeHex(m: string): seq[byte] =
|
||||
if len(m) > 0:
|
||||
try:
|
||||
result = fromHex(m)
|
||||
result = utils.fromHex(m)
|
||||
except:
|
||||
result = newSeq[byte]()
|
||||
else:
|
||||
|
@ -240,7 +240,7 @@ proc decodeSalt(m: string): string =
|
|||
var sarr: seq[byte]
|
||||
if len(m) > 0:
|
||||
try:
|
||||
sarr = fromHex(m)
|
||||
sarr = utils.fromHex(m)
|
||||
result = newString(len(sarr))
|
||||
copyMem(addr result[0], addr sarr[0], len(sarr))
|
||||
except:
|
||||
|
|
|
@ -130,8 +130,6 @@ proc setAux(self: BinaryTrie, nodeHash: TrieNodeKey, keyPath: TrieBitRange,
|
|||
of BRANCH_TYPE: # node is a branch node
|
||||
checkBadKeyPath()
|
||||
return self.setBranchNode(keyPath, node, value, deleteSubtrie)
|
||||
else:
|
||||
raise newException(Exception, "Invariant: This shouldn't ever happen")
|
||||
|
||||
proc set*(self: var BinaryTrie, key, value: distinct BytesContainer) {.inline.} =
|
||||
## Sets the value at the given keyPath from the given node
|
||||
|
|
|
@ -34,8 +34,6 @@ proc checkIfBranchExistImpl(db: DB; nodeHash: TrieNodeKey; keyPrefix: TrieBitRan
|
|||
return checkIfBranchExistImpl(db, node.leftChild, keyPrefix.sliceToEnd(1))
|
||||
else:
|
||||
return checkIfBranchExistImpl(db, node.rightChild, keyPrefix.sliceToEnd(1))
|
||||
else:
|
||||
raise newException(Exception, "Invariant: unreachable code path")
|
||||
|
||||
proc checkIfBranchExist*(db: DB; rootHash: BytesContainer | KeccakHash, keyPrefix: BytesContainer): bool =
|
||||
## Given a key prefix, return whether this prefix is
|
||||
|
@ -76,9 +74,6 @@ proc getBranchImpl(db: DB; nodeHash: TrieNodeKey, keyPath: TrieBitRange, output:
|
|||
else:
|
||||
getBranchImpl(db, node.rightChild, keyPath.sliceToEnd(1), output)
|
||||
|
||||
else:
|
||||
raise newException(Exception, "Invariant: unreachable code path")
|
||||
|
||||
proc getBranch*(db: DB; rootHash: BytesContainer | KeccakHash; key: BytesContainer): seq[BytesRange] =
|
||||
## Get a long-format Merkle branch
|
||||
checkValidHashZ(rootHash)
|
||||
|
@ -123,8 +118,6 @@ proc getTrieNodesImpl(db: DB; nodeHash: TrieNodeKey, output: var seq[BytesRange]
|
|||
result = getTrieNodesImpl(db, node.rightChild, output)
|
||||
of LEAF_TYPE:
|
||||
output.add nodeVal
|
||||
else:
|
||||
raise newException(Exception, "Invariant: unreachable code path")
|
||||
|
||||
proc getTrieNodes*(db: DB; nodeHash: BytesContainer | KeccakHash): seq[BytesRange] =
|
||||
checkValidHashZ(nodeHash)
|
||||
|
@ -161,8 +154,6 @@ proc getWitnessImpl*(db: DB; nodeHash: TrieNodeKey; keyPath: TrieBitRange; outpu
|
|||
getWitnessImpl(db, node.leftChild, keyPath.sliceToEnd(1), output)
|
||||
else:
|
||||
getWitnessImpl(db, node.rightChild, keyPath.sliceToEnd(1), output)
|
||||
else:
|
||||
raise newException(Exception, "Invariant: unreachable code path")
|
||||
|
||||
proc getWitness*(db: DB; nodeHash: BytesContainer | KeccakHash; key: BytesContainer): seq[BytesRange] =
|
||||
## Get all witness given a keyPath prefix.
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
--threads:on
|
||||
--path:"$projectDir/.."
|
||||
|
||||
# rocksdb_backend newChainDB fails compiling without nimOldCaseObjects as
|
||||
# rocksdb init does this type of assignment
|
||||
--define:nimOldCaseObjects
|
||||
|
|
|
@ -7,9 +7,10 @@
|
|||
# distribution, for details about the copyright.
|
||||
#
|
||||
|
||||
import unittest, strutils
|
||||
import unittest
|
||||
import eth/keys
|
||||
import nimcrypto/hash, nimcrypto/keccak, nimcrypto/utils
|
||||
from strutils import toLowerAscii
|
||||
|
||||
proc compare(x: openarray[byte], y: openarray[byte]): bool =
|
||||
result = len(x) == len(y)
|
||||
|
|
|
@ -90,7 +90,8 @@ suite "ENode":
|
|||
test "isCorrect() tests":
|
||||
var node: ENode
|
||||
check isCorrect(node) == false
|
||||
node.address.ip.family = IpAddressFamily.IPv4
|
||||
let ip = IpAddress(family:IpAddressFamily.IPv4)
|
||||
node = Enode(address: Address(ip: ip))
|
||||
check isCorrect(node) == false
|
||||
node.address.tcpPort = Port(25)
|
||||
check isCorrect(node) == false
|
||||
|
|
|
@ -1,3 +1,2 @@
|
|||
--threads:on
|
||||
--path:"$projectDir/../.."
|
||||
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
import
|
||||
unittest, strutils, sequtils, os,
|
||||
unittest, sequtils, os,
|
||||
stew/ranges/typedranges, eth/trie/[hexary, db, trie_defs], nimcrypto/utils,
|
||||
./testutils, algorithm, eth/rlp/types as rlpTypes, random
|
||||
|
||||
from strutils import split
|
||||
|
||||
template put(t: HexaryTrie|SecureHexaryTrie, key, val: string) =
|
||||
t.put(key.toBytesRange, val.toBytesRange)
|
||||
|
||||
|
|
Loading…
Reference in New Issue