diff --git a/tests/execution-apis b/tests/execution-apis index cea7eeb..7907424 160000 --- a/tests/execution-apis +++ b/tests/execution-apis @@ -1 +1 @@ -Subproject commit cea7eeb642052f4c2e03449dc48296def4aafc24 +Subproject commit 7907424db935b93c2fe6a3c0faab943adebe8557 diff --git a/tests/helpers/handlers.nim b/tests/helpers/handlers.nim index def3078..32b12e8 100644 --- a/tests/helpers/handlers.nim +++ b/tests/helpers/handlers.nim @@ -153,3 +153,11 @@ proc installHandlers*(server: RpcServer) = if x != "-1".JsonString: res = decodeFromString(x, seq[byte]) return res.RlpEncodedBytes + + server.rpc("eth_blobBaseFee") do(x: JsonString) -> Quantity: + if x != "-1".JsonString: + return decodeFromString(x, Quantity) + + server.rpc("eth_getLogs") do(x: JsonString, filterOptions: FilterOptions) -> seq[LogObject]: + if x != "-1".JsonString: + return decodeFromString(x, seq[LogObject]) diff --git a/tests/test_execution_api.nim b/tests/test_execution_api.nim index 4fd84bd..3f7a295 100644 --- a/tests/test_execution_api.nim +++ b/tests/test_execution_api.nim @@ -12,6 +12,7 @@ import type TestData = tuple file: string + description: string input: RequestTx output: ResponseRx @@ -82,13 +83,37 @@ func toTx(req: RequestRx): RequestTx = ) proc extractTest(fileName: string): TestData {.raises: [IOError, SerializationError].} = - let - lines = readFile(fileName).split("\n") - input = lines[0].strip() - output = lines[1].strip() + let lines = readFile(fileName).split("\n") + var + description = "" + input = "" + output = "" + for line in lines: + if line == "": + continue + if line.startsWith("// "): + if description == "": + description = line.strip() + else: + description = description & " " & line.strip() + elif line.startsWith(">> "): + if input != "": + raise (ref IOError)(msg: "Test contains multiple inputs: " & fileName) + input = line + elif line.startsWith("<< "): + if output != "": + raise (ref IOError)(msg: "Test contains multiple outputs: " & fileName) + output = line + if input == "": + raise (ref IOError)(msg: "Test contains no input: " & fileName) + if output == "": + raise (ref IOError)(msg: "Test contains no output: " & fileName) + input = input.strip() + output = output.strip() return ( file: fileName, + description: description, input: JrpcSys.decode(input, RequestRx).toTx, output: JrpcSys.decode(output, ResponseRx), ) @@ -117,6 +142,7 @@ proc callWithParams(client: RpcClient, data: TestData): Future[bool] {.async.} = if not compareValue(wantVal, getVal): debugEcho data.file + debugEcho data.description debugEcho "EXPECT: ", res.result debugEcho "GET: ", resJson.string return false @@ -147,6 +173,7 @@ suite "Ethereum execution api": srv.start() for idx, item in testCases: + checkpoint item.file & ": " & item.description let input = item.input let methodName = input.`method`