Skip to content

Commit 7b41abb

Browse files
committed
Add rpc response codes.
1 parent 8a6c0c0 commit 7b41abb

3 files changed

Lines changed: 35 additions & 2 deletions

File tree

include/bitcoin/server/error.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,10 @@ enum error_t : uint8_t
6060
/// server (rpc response codes)
6161
not_found,
6262
not_implemented,
63-
invalid_argument
63+
invalid_argument,
64+
argument_overflow,
65+
target_overflow,
66+
server_error
6467
};
6568

6669
// No current need for error_code equivalence mapping.

src/error.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,10 @@ DEFINE_ERROR_T_MESSAGE_MAP(error)
5050
// server (rpc response codes)
5151
{ not_found, "not_found" },
5252
{ not_implemented, "not_implemented" },
53-
{ invalid_argument, "invalid_argument" }
53+
{ invalid_argument, "invalid_argument" },
54+
{ argument_overflow, "argument_overflow" },
55+
{ target_overflow, "target_overflow" },
56+
{ server_error, "server_error" }
5457
};
5558

5659
DEFINE_ERROR_T_CATEGORY(error, "server", "server code")

test/error.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,4 +209,31 @@ BOOST_AUTO_TEST_CASE(error_t__code__invalid_argument__true_expected_message)
209209
BOOST_REQUIRE_EQUAL(ec.message(), "invalid_argument");
210210
}
211211

212+
BOOST_AUTO_TEST_CASE(error_t__code__argument_overflow__true_expected_message)
213+
{
214+
constexpr auto value = error::argument_overflow;
215+
const auto ec = code(value);
216+
BOOST_REQUIRE(ec);
217+
BOOST_REQUIRE(ec == value);
218+
BOOST_REQUIRE_EQUAL(ec.message(), "argument_overflow");
219+
}
220+
221+
BOOST_AUTO_TEST_CASE(error_t__code__target_overflow__true_expected_message)
222+
{
223+
constexpr auto value = error::target_overflow;
224+
const auto ec = code(value);
225+
BOOST_REQUIRE(ec);
226+
BOOST_REQUIRE(ec == value);
227+
BOOST_REQUIRE_EQUAL(ec.message(), "target_overflow");
228+
}
229+
230+
BOOST_AUTO_TEST_CASE(error_t__code__server_error__true_expected_message)
231+
{
232+
constexpr auto value = error::server_error;
233+
const auto ec = code(value);
234+
BOOST_REQUIRE(ec);
235+
BOOST_REQUIRE(ec == value);
236+
BOOST_REQUIRE_EQUAL(ec.message(), "server_error");
237+
}
238+
212239
BOOST_AUTO_TEST_SUITE_END()

0 commit comments

Comments
 (0)