Test that subscription stops after call to unsubscribe()
This commit is contained in:
parent
ceedf03c82
commit
f8cac08cde
|
@ -24,11 +24,24 @@ template subscriptionTests(subscriptions, client) =
|
|||
latestBlock = blck
|
||||
let subscription = await subscriptions.subscribeBlocks(callback)
|
||||
discard await client.call("evm_mine", newJArray())
|
||||
check eventually(latestBlock.number.isSome)
|
||||
check eventually latestBlock.number.isSome
|
||||
check latestBlock.hash.isSome
|
||||
check latestBlock.timestamp > 0.u256
|
||||
await subscription.unsubscribe()
|
||||
|
||||
test "stops listening to new blocks when unsubscribed":
|
||||
var count = 0
|
||||
proc callback(blck: Block) {.async.} =
|
||||
inc count
|
||||
let subscription = await subscriptions.subscribeBlocks(callback)
|
||||
discard await client.call("evm_mine", newJArray())
|
||||
check eventually count > 0
|
||||
await subscription.unsubscribe()
|
||||
let endcount = count
|
||||
discard await client.call("evm_mine", newJArray())
|
||||
await sleepAsync(100.millis)
|
||||
check count == endcount
|
||||
|
||||
suite "Web socket subscriptions":
|
||||
|
||||
var subscriptions: JsonRpcSubscriptions
|
||||
|
|
Loading…
Reference in New Issue