mirror of
https://github.com/status-im/nim-ethers.git
synced 2025-01-12 08:34:43 +00:00
Test JSON-RPC Provider with polling
This commit is contained in:
parent
0322ae1451
commit
88d60b14b0
@ -7,22 +7,18 @@ import pkg/stew/byteutils
|
||||
import ../../examples
|
||||
import ../../miner
|
||||
|
||||
suite "JsonRpcProvider":
|
||||
for url in ["ws://localhost:8545", "http://localhost:8545"]:
|
||||
|
||||
suite "JsonRpcProvider (" & url & ")":
|
||||
|
||||
var provider: JsonRpcProvider
|
||||
|
||||
setup:
|
||||
provider = JsonRpcProvider.new("ws://localhost:8545")
|
||||
provider = JsonRpcProvider.new(url)
|
||||
|
||||
test "can be instantiated with a default URL":
|
||||
discard JsonRpcProvider.new()
|
||||
|
||||
test "can be instantiated with an HTTP URL":
|
||||
discard JsonRpcProvider.new("http://localhost:8545")
|
||||
|
||||
test "can be instantiated with a websocket URL":
|
||||
discard JsonRpcProvider.new("ws://localhost:8545")
|
||||
|
||||
test "lists all accounts":
|
||||
let accounts = await provider.listAccounts()
|
||||
check accounts.len > 0
|
||||
@ -50,6 +46,7 @@ suite "JsonRpcProvider":
|
||||
let blockHandler = proc(blck: Block) {.async.} = newBlock = blck
|
||||
let subscription = await provider.subscribe(blockHandler)
|
||||
discard await provider.send("evm_mine")
|
||||
check eventually newBlock.number.isSome
|
||||
check !newBlock.number > !oldBlock.number
|
||||
check newBlock.timestamp > oldBlock.timestamp
|
||||
check newBlock.hash != oldBlock.hash
|
||||
|
Loading…
x
Reference in New Issue
Block a user