Update to latest version of questionable

This commit is contained in:
Mark Spanbroek 2021-03-15 11:23:02 +01:00
parent 5837a655e0
commit c824a3edd1
6 changed files with 9 additions and 7 deletions

View File

@ -5,7 +5,7 @@ description = "Nitro state channels"
requires "nim >= 1.2.6 & < 2.0.0"
requires "nimcrypto >= 0.5.4 & < 0.6.0"
requires "questionable >= 0.2.0 & < 0.3.0"
requires "questionable >= 0.4.0 & < 0.5.0"
requires "secp256k1"
requires "stint"
requires "stew"

View File

@ -14,7 +14,7 @@ proc `$`*(destination: Destination): string =
destination.toArray().toHex()
proc parse*(_: type Destination, s: string): ?Destination =
Destination(array[32, byte].fromHex(s)).catch.toOption()
Destination(array[32, byte].fromHex(s)).catch.option
proc `==`*(a, b: Destination): bool {.borrow.}

View File

@ -1,4 +1,5 @@
import pkg/questionable
import pkg/questionable/results
import pkg/stew/byteutils
export questionable
@ -15,6 +16,6 @@ proc `$`*(a: EthAddress): string =
a.toArray().toHex()
proc parse*(_: type EthAddress, hex: string): ?EthAddress =
EthAddress(array[20, byte].fromHex(hex)).catch.toOption
EthAddress(array[20, byte].fromHex(hex)).catch.option
proc `==`*(a, b: EthAddress): bool {.borrow.}

View File

@ -21,7 +21,7 @@ proc `$`*(key: PrivateKey): string =
key.toHex()
proc parse*(_: type PrivateKey, s: string): ?PrivateKey =
SkSecretKey.fromHex(s).toOption()
SkSecretKey.fromHex(s).option
proc toAddress*(key: PublicKey): EthAddress =
let hash = keccak256.digest(key.toRaw())

View File

@ -37,4 +37,4 @@ proc parse*(_: type Signature, s: string): ?Signature =
var bytes = array[65, byte].fromHex(s)
bytes[64] = bytes[64] - 27
SkRecoverableSignature.fromRaw(bytes).get()
signature.toOption()
signature.option

View File

@ -18,5 +18,6 @@ suite "nitro wallet":
let expectedState = State(outcome: expectedOutcome)
let expectedSignatures = @{wallet.address: key.sign(expectedState)}
check channel.latest.isNone
check channel.upcoming.?state == expectedState.some
check channel.upcoming.?signatures == expectedSignatures.some
check channel.upcoming?.state == expectedState.some
check channel.upcoming?.signatures == expectedSignatures.some