mirror of
https://github.com/status-im/nim-dagger.git
synced 2025-01-11 23:24:43 +00:00
5e02b0c1b8
To work around this issue when subscriptions are inactive for more than 5 minutes: https://github.com/NomicFoundation/hardhat/issues/2053
30 lines
828 B
Nim
30 lines
828 B
Nim
import std/json
|
|
import pkg/ethers
|
|
|
|
import ./asynctest
|
|
import ./checktest
|
|
|
|
## Unit testing suite that sets up an Ethereum testing environment.
|
|
## Injects a `ethProvider` instance, and a list of `accounts`.
|
|
## Calls the `evm_snapshot` and `evm_revert` methods to ensure that any
|
|
## changes to the blockchain do not persist.
|
|
template ethersuite*(name, body) =
|
|
asyncchecksuite name:
|
|
|
|
var ethProvider {.inject, used.}: JsonRpcProvider
|
|
var accounts {.inject, used.}: seq[Address]
|
|
var snapshot: JsonNode
|
|
|
|
setup:
|
|
ethProvider = JsonRpcProvider.new("http://localhost:8545")
|
|
snapshot = await send(ethProvider, "evm_snapshot")
|
|
accounts = await ethProvider.listAccounts()
|
|
|
|
teardown:
|
|
discard await send(ethProvider, "evm_revert", @[snapshot])
|
|
|
|
body
|
|
|
|
export asynctest
|
|
export ethers except `%`
|