From da46dc4a8e0dc7b95601d4b8c40338a5520344da Mon Sep 17 00:00:00 2001 From: Jensen Yap Date: Tue, 29 Apr 2025 10:42:24 +0900 Subject: [PATCH] Add additional UDF tests for live API endpoints in live.yml (#121) - Introduced multiple test cases for GET and POST methods, including batch JSON-RPC requests for Solana and Ethereum. - Ensured assertions validate response status codes and data structure integrity. - Enhanced coverage for API interactions to improve reliability and robustness of the deployment core. --- models/deploy/core/live.yml | 94 ++++++++++++++++++++++++++++++++++++- 1 file changed, 93 insertions(+), 1 deletion(-) diff --git a/models/deploy/core/live.yml b/models/deploy/core/live.yml index cb4bbf1..7e0a4d8 100644 --- a/models/deploy/core/live.yml +++ b/models/deploy/core/live.yml @@ -24,4 +24,96 @@ models: 'https://httpbin.org/post', 'foo'::VARIANT assertions: - result:data.json is not null - - result:data.json = 'foo' \ No newline at end of file + - result:data.json = 'foo' + - test_udf: + name: test__live_udf_api_get_method + args: | + 'https://httpbin.org/get' + assertions: + - result:status_code = 200 + - result:data.url = 'https://httpbin.org/get' + - test_udf: + name: test__live_udf_api_get_with_params + args: | + 'GET', 'https://httpbin.org/get', {'Content-Type': 'application/json'}, {'param1': 'value1', 'param2': 'value2'} + assertions: + - result:status_code = 200 + - result:data.args is not null + - result:data.args:param1 = 'value1' + - result:data.args:param2 = 'value2' + - test_udf: + name: test__live_udf_api_post_batch_jsonrpc + args: | + 'https://httpbin.org/post', { + 'jsonrpc': '2.0', + 'id': 1, + 'method': 'batch', + 'params': [ + {'id': 1, 'method': 'method1', 'params': {'param1': 'value1'}}, + {'id': 2, 'method': 'method2', 'params': {'param2': 'value2'}} + ] + } + assertions: + - result:status_code = 200 + - result:data.json:jsonrpc = '2.0' + - result:data.json:id = 1 + - result:data.json:method = 'batch' + - result:data.json:params is not null + - result:data.json:params[0]:id = 1 + - result:data.json:params[1]:id = 2 + - test_udf: + name: test__live_udf_api_post_jsonrpc_solana + args: | + 'POST', + 'https://api.mainnet-beta.solana.com', + {'Content-Type': 'application/json'}, + { + 'jsonrpc': '2.0', + 'id': 1, + 'method': 'getVersion' + }, + '' + assertions: + - result:status_code = 200 + - result:data.jsonrpc = '2.0' + - result:data.id = 1 + - result:data.result is not null + - test_udf: + name: test__live_udf_api_post_jsonrpc_solana_batch + args: | + 'POST', + 'https://api.mainnet-beta.solana.com', + {'Content-Type': 'application/json'}, + [ + {'jsonrpc': '2.0', 'id': 1, 'method': 'getVersion'}, + {'jsonrpc': '2.0', 'id': 2, 'method': 'getVersion'} + ], + '' + assertions: + - result:status_code = 200 + - result:data[0]:jsonrpc = '2.0' + - result:data[0]:id = 1 + - result:data[0]:result is not null + - result:data[1]:jsonrpc = '2.0' + - result:data[1]:id = 2 + - result:data[1]:result is not null + + - test_udf: + name: test__live_udf_api_post_jsonrpc_ethereum_batch + args: | + 'POST', + 'https://ethereum-rpc.publicnode.com', + {'Content-Type': 'application/json'}, + [ + {'jsonrpc': '2.0', 'id': 1, 'method': 'eth_blockNumber', 'params': []}, + {'jsonrpc': '2.0', 'id': 2, 'method': 'eth_chainId', 'params': []} + ], + '' + assertions: + - result:status_code = 200 + - result:data[0]:jsonrpc = '2.0' + - result:data[0]:id = 1 + - result:data[0]:result is not null + - result:data[1]:jsonrpc = '2.0' + - result:data[1]:id = 2 + - result:data[1]:result = '0x1'