Skip to content

Commit

Permalink
Reduce compiler warnings in testethcalls
Browse files Browse the repository at this point in the history
  • Loading branch information
jangko committed Jan 21, 2024
1 parent c31850e commit 40fa454
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions tests/testethcalls.nim
Original file line number Diff line number Diff line change
Expand Up @@ -43,27 +43,42 @@ server.rpc(rpcDynamicName "testReturnUint256") do() -> UInt256:
let r: UInt256 = "0x1234567890abcdef".parse(UInt256, 16)
return r

proc testLocalCalls: Future[seq[JsonString]] =
proc testLocalCalls: Future[seq[JsonString]] {.async.} =
## Call RPCs created with `rpc` locally.
## This simply demonstrates async calls of the procs generated by the `rpc` macro.
let
uint256Param = server.executeMethod("rpc.uint256Param", %[%"0x1234567890"])
returnUint256 = server.executeMethod("rpc.testReturnUint256", %[])
return all(uint256Param, returnUint256)

proc testRemoteUInt256: Future[seq[JsonString]] =
await noCancel(allFutures(uint256Param, returnUint256))
var pending: seq[JsonString]
pending.add uint256Param.read()
pending.add returnUint256.read()
return pending

proc testRemoteUInt256: Future[seq[JsonString]] {.async.} =
## Call function remotely on server, testing `stint` types
let
uint256Param = client.call("rpc.uint256Param", %[%"0x1234567890"])
returnUint256 = client.call("rpc.testReturnUint256", %[])
return all(uint256Param, returnUint256)

proc testSigCalls: Future[seq[string]] =
await noCancel(allFutures(uint256Param, returnUint256))
var pending: seq[JsonString]
pending.add uint256Param.read()
pending.add returnUint256.read()
return pending

proc testSigCalls: Future[seq[string]] {.async.} =
## Remote call using proc generated from signatures in `ethcallsigs.nim`
let
version = client.web3_clientVersion()
sha3 = client.web3_sha3("0x68656c6c6f20776f726c64")
return all(version, sha3)

await noCancel(allFutures(version, sha3))
var pending: seq[string]
pending.add version.read()
pending.add sha3.read()
return pending

server.start()
waitFor client.connect(server.localAddress()[0])
Expand Down

0 comments on commit 40fa454

Please sign in to comment.