Reset EVM in between tests
This commit is contained in:
parent
6bd3e27e38
commit
b639e367c0
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue