Skip to content

Commit

Permalink
Add test case of eth_getBlockReceipts usage
Browse files Browse the repository at this point in the history
  • Loading branch information
jangko committed Feb 14, 2024
1 parent 442fd64 commit e26c183
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
24 changes: 23 additions & 1 deletion tests/test_execution_api.nim
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import
json_rpc/[rpcclient, rpcserver],
json_rpc/private/jrpc_sys,
../web3/conversions,
./helpers/handlers
./helpers/handlers,
../web3/eth_api,
results

type
TestData = tuple
Expand Down Expand Up @@ -109,3 +111,23 @@ suite "Ethereum execution api":

waitFor srv.stop()
waitFor srv.closeWait()

proc setupMethods(server: RpcServer) =
server.rpc("eth_getBlockReceipts") do(blockId: RtBlockIdentifier) -> Opt[seq[ReceiptObject]]:
var res: seq[ReceiptObject]
return Opt.some(res)

suite "Test eth api":
var srv = newRpcHttpServer(["127.0.0.1:0"])
srv.setupMethods()
srv.start()

test "eth_getBlockReceipts generic functions":
let client = newRpcHttpClient()
waitFor client.connect("http://" & $srv.localAddress()[0])
let res = waitFor client.eth_getBlockReceipts(blockId("latest"))
check res.isSome
waitFor client.close()

waitFor srv.stop()
waitFor srv.closeWait()
3 changes: 3 additions & 0 deletions web3/eth_api.nim
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ createRpcSigsFromNim(RpcClient):
# TODO: Investigate why nim v2 cannot instantiate generic functions
# with oneof params `blockId: BlockIdentifier` and and return type
# Opt[seq[ReceiptObject]], this is a regression after all
when false:
proc eth_getBlockReceipts(blockId: BlockIdentifier): Opt[seq[ReceiptObject]]

proc eth_getBlockReceipts(blockId: string): Opt[seq[ReceiptObject]]
proc eth_getBlockReceipts(blockId: BlockNumber): Opt[seq[ReceiptObject]]
proc eth_getBlockReceipts(blockId: RtBlockIdentifier): Opt[seq[ReceiptObject]]
Expand Down

0 comments on commit e26c183

Please sign in to comment.