fix: pending blocks may not contains block hash
Pending blocks may not contain a block hash and therefore Block.hash should be optional.
This commit is contained in:
parent
0321e6d7bd
commit
34b7a82565
|
@ -46,7 +46,7 @@ type
|
||||||
Block* = object
|
Block* = object
|
||||||
number*: ?UInt256
|
number*: ?UInt256
|
||||||
timestamp*: UInt256
|
timestamp*: UInt256
|
||||||
hash*: array[32, byte]
|
hash*: ?array[32, byte]
|
||||||
|
|
||||||
const EthersDefaultConfirmations* {.intdefine.} = 12
|
const EthersDefaultConfirmations* {.intdefine.} = 12
|
||||||
const EthersReceiptTimeoutBlks* {.intdefine.} = 50 # in blocks
|
const EthersReceiptTimeoutBlks* {.intdefine.} = 50 # in blocks
|
||||||
|
|
|
@ -128,6 +128,20 @@ suite "JsonRpcProvider":
|
||||||
check blk.number.isSome
|
check blk.number.isSome
|
||||||
check blk.number.get.isZero
|
check blk.number.get.isZero
|
||||||
|
|
||||||
|
test "Conversion: missing block hash in Block isNone":
|
||||||
|
|
||||||
|
var blkJson = %*{
|
||||||
|
"subscription": "0x20",
|
||||||
|
"result":{
|
||||||
|
"number": "0x1",
|
||||||
|
"hash": newJNull(),
|
||||||
|
"timestamp": "0x6285c293"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var blk = Block.fromJson(blkJson["result"])
|
||||||
|
check blk.hash.isNone
|
||||||
|
|
||||||
test "Conversion: missing block number in TransactionReceipt isNone":
|
test "Conversion: missing block number in TransactionReceipt isNone":
|
||||||
|
|
||||||
var txReceiptJson = %*{
|
var txReceiptJson = %*{
|
||||||
|
|
Loading…
Reference in New Issue