Reset EVM in between tests

This commit is contained in:
Mark Spanbroek 2022-01-25 15:05:54 +01:00
parent 6bd3e27e38
commit b639e367c0
2 changed files with 8 additions and 2 deletions

View File

@ -41,9 +41,9 @@ proc new*(_: type JsonRpcProvider, url=defaultUrl): JsonRpcProvider =
proc send*(provider: JsonRpcProvider,
call: string,
arguments = %(@[])): Future[JsonNode] {.async.} =
arguments: seq[JsonNode] = @[]): Future[JsonNode] {.async.} =
let client = await provider.client
return await client.call(call, arguments)
return await client.call(call, %arguments)
proc listAccounts*(provider: JsonRpcProvider): Future[seq[Address]] {.async.} =
let client = await provider.client

View File

@ -1,3 +1,4 @@
import std/json
import pkg/asynctest
import pkg/stint
import pkg/ethers
@ -15,12 +16,17 @@ suite "Contracts":
var token: TestToken
var provider: JsonRpcProvider
var snapshot: JsonNode
setup:
provider = JsonRpcProvider.new()
snapshot = await provider.send("evm_snapshot")
let deployment = readDeployment()
token = TestToken.new(!deployment.address(TestToken), provider)
teardown:
discard await provider.send("evm_revert", @[snapshot])
test "can call view methods":
let accounts = await provider.listAccounts()
check (await token.totalSupply()) == 0.u256