Skip to content

Commit

Permalink
fixes signature of <<getBlock>> method in mockProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
marcinczenko committed Nov 25, 2024
1 parent a91c76f commit b0248b3
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions tests/contracts/helpers/mockprovider.nim
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,24 @@ type MockProvider* = ref object of Provider
method getBlock*(
provider: MockProvider,
tag: BlockTag
): Future[?Block] {.async.} =
if $tag == "latest":
if latestBlock =? provider.latest:
if provider.blocks.hasKey(latestBlock):
return provider.blocks[latestBlock].some
elif $tag == "earliest":
if earliestBlock =? provider.earliest:
if provider.blocks.hasKey(earliestBlock):
return provider.blocks[earliestBlock].some
else:
let blockNumber = parseHexInt($tag)
if provider.blocks.hasKey(blockNumber):
return provider.blocks[blockNumber].some
return Block.none
): Future[?Block] {.async: (raises:[ProviderError]).} =
try:
if $tag == "latest":
if latestBlock =? provider.latest:
if provider.blocks.hasKey(latestBlock):
return provider.blocks[latestBlock].some
elif $tag == "earliest":
if earliestBlock =? provider.earliest:
if provider.blocks.hasKey(earliestBlock):
return provider.blocks[earliestBlock].some
else:
let blockNumber = parseHexInt($tag)
if provider.blocks.hasKey(blockNumber):
return provider.blocks[blockNumber].some
return Block.none
except:
return Block.none


proc updateEarliestAndLatest(provider: MockProvider, blockNumber: int) =
if provider.earliest.isNone:
Expand Down

0 comments on commit b0248b3

Please sign in to comment.