mirror of
https://github.com/status-im/nim-ethers.git
synced 2025-02-11 14:46:42 +00:00
* chore: export subscriptions This has a knock-on effect of nim-serde not being imported into subscriptions when JsonRpcProvider.new is called from a consumer that does not export nim-serde. * import/export serde * Replace all instances of std/json with pkg/serde
28 lines
832 B
Nim
28 lines
832 B
Nim
import std/unittest
|
|
import pkg/serde
|
|
import pkg/questionable
|
|
import pkg/ethers/providers/jsonrpc/errors
|
|
|
|
suite "JSON RPC errors":
|
|
|
|
test "converts JSON RPC error to Nim error":
|
|
let error = %*{ "message": "some error" }
|
|
check JsonRpcProviderError.new(error).msg == "some error"
|
|
|
|
test "converts error data to bytes":
|
|
let error = %*{
|
|
"message": "VM Exception: reverted with 'some error'",
|
|
"data": "0xabcd"
|
|
}
|
|
check JsonRpcProviderError.new(error).data == some @[0xab'u8, 0xcd'u8]
|
|
|
|
test "converts nested error data to bytes":
|
|
let error = %*{
|
|
"message": "VM Exception: reverted with 'some error'",
|
|
"data": {
|
|
"message": "VM Exception: reverted with 'some error'",
|
|
"data": "0xabcd"
|
|
}
|
|
}
|
|
check JsonRpcProviderError.new(error).data == some @[0xab'u8, 0xcd'u8]
|