mirror of
https://github.com/skot/ESP-Miner.git
synced 2025-03-17 13:22:53 +01:00
test: add boundary check for implicit response method (#548)
Test the boundary of STRATUM_RESULT and STRATUM_RESULT_SETUP more completely
This commit is contained in:
parent
5e56bcdccc
commit
3bf8997a72
@ -117,10 +117,17 @@ TEST_CASE("Parse stratum mining.set_version_mask params", "[stratum]")
|
||||
|
||||
TEST_CASE("Parse stratum result success", "[stratum]")
|
||||
{
|
||||
StratumApiV1Message stratum_api_v1_setup_message = {};
|
||||
const char* resp1 = "{\"id\":4,\"error\":null,\"result\":true}";
|
||||
STRATUM_V1_parse(&stratum_api_v1_setup_message, resp1);
|
||||
TEST_ASSERT_EQUAL(4, stratum_api_v1_setup_message.message_id);
|
||||
TEST_ASSERT_EQUAL(STRATUM_RESULT_SETUP, stratum_api_v1_setup_message.method);
|
||||
TEST_ASSERT_TRUE(stratum_api_v1_setup_message.response_success);
|
||||
|
||||
StratumApiV1Message stratum_api_v1_message = {};
|
||||
const char *json_string = "{\"id\":1,\"error\":null,\"result\":true}";
|
||||
const char* json_string = "{\"id\":5,\"error\":null,\"result\":true}";
|
||||
STRATUM_V1_parse(&stratum_api_v1_message, json_string);
|
||||
TEST_ASSERT_EQUAL(1, stratum_api_v1_message.message_id);
|
||||
TEST_ASSERT_EQUAL(5, stratum_api_v1_message.message_id);
|
||||
TEST_ASSERT_EQUAL(STRATUM_RESULT, stratum_api_v1_message.method);
|
||||
TEST_ASSERT_TRUE(stratum_api_v1_message.response_success);
|
||||
}
|
||||
@ -147,13 +154,21 @@ TEST_CASE("Parse stratum result success with larger id", "[stratum]")
|
||||
|
||||
TEST_CASE("Parse stratum result error", "[stratum]")
|
||||
{
|
||||
StratumApiV1Message stratum_api_v1_setup_message = {};
|
||||
const char* resp1 = "{\"id\":4,\"result\":null,\"error\":[21,\"Job not found\",\"\"]}";
|
||||
STRATUM_V1_parse(&stratum_api_v1_setup_message, resp1);
|
||||
TEST_ASSERT_EQUAL(4, stratum_api_v1_setup_message.message_id);
|
||||
TEST_ASSERT_EQUAL(STRATUM_RESULT_SETUP, stratum_api_v1_setup_message.method);
|
||||
TEST_ASSERT_FALSE(stratum_api_v1_setup_message.response_success);
|
||||
TEST_ASSERT_EQUAL_STRING("Job not found", stratum_api_v1_setup_message.error_str);
|
||||
|
||||
StratumApiV1Message stratum_api_v1_message = {};
|
||||
const char *json_string = "{\"id\":1,\"result\":null,\"error\":[21,\"Job not found\",\"\"]}";
|
||||
const char* json_string = "{\"id\":5,\"result\":null,\"error\":[21,\"Job not found\",\"\"]}";
|
||||
STRATUM_V1_parse(&stratum_api_v1_message, json_string);
|
||||
TEST_ASSERT_EQUAL(1, stratum_api_v1_message.message_id);
|
||||
TEST_ASSERT_EQUAL(5, stratum_api_v1_message.message_id);
|
||||
TEST_ASSERT_EQUAL(STRATUM_RESULT, stratum_api_v1_message.method);
|
||||
TEST_ASSERT_FALSE(stratum_api_v1_message.response_success);
|
||||
TEST_ASSERT_EQUAL("Job not found", stratum_api_v1_message.error_str);
|
||||
TEST_ASSERT_EQUAL_STRING("Job not found", stratum_api_v1_message.error_str);
|
||||
}
|
||||
|
||||
TEST_CASE("Parse stratum result alternative error", "[stratum]")
|
||||
|
Loading…
x
Reference in New Issue
Block a user