Skip to content

Commit

Permalink
Debug
Browse files Browse the repository at this point in the history
  • Loading branch information
RickiNano committed Jan 19, 2025
1 parent 7a153b7 commit 5101153
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions nano/rpc_test/rpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2388,41 +2388,47 @@ TEST (rpc, decimal_nano_to_raw)
auto node1 = add_ipc_enabled_node (system);
auto const rpc_ctx = add_rpc (system, node1);

std::cout << "1";
// One raw as decimal
boost::property_tree::ptree request1;
request1.put ("action", "decimal_nano_to_raw");
request1.put ("amount", "0.000000000000000000000000000001");
auto response (wait_response (system, rpc_ctx, request1));
ASSERT_EQ ("1", response.get<std::string> ("amount"));

std::cout << "2";
// Precision overflow (less than one raw)
boost::property_tree::ptree requesta;
requesta.put ("action", "decimal_nano_to_raw");
requesta.put ("amount", "0.0000000000000000000000000000001");
response = wait_response (system, rpc_ctx, requesta);
ASSERT_EQ (std::error_code (nano::error_common::invalid_amount).message (), response.get<std::string> ("error"));

std::cout << "3";
// Zero as decimal
boost::property_tree::ptree request2;
request2.put ("action", "decimal_nano_to_raw");
request2.put ("amount", "0.00");
response = wait_response (system, rpc_ctx, request2);
ASSERT_EQ ("0", response.get<std::string> ("amount"));

std::cout << "4";
// Integer only
boost::property_tree::ptree request3;
request3.put ("action", "decimal_nano_to_raw");
request3.put ("amount", "5");
response = wait_response (system, rpc_ctx, request3);
ASSERT_EQ ((5 * nano::nano_ratio).convert_to<std::string> (), response.get<std::string> ("amount"));

std::cout << "5";
// Integer value as decimal
boost::property_tree::ptree request4;
request4.put ("action", "decimal_nano_to_raw");
request4.put ("amount", "7.00000");
response = wait_response (system, rpc_ctx, request4);
ASSERT_EQ ((7 * nano::nano_ratio).convert_to<std::string> (), response.get<std::string> ("amount"));

std::cout << "6";
// Negative value
boost::property_tree::ptree request5;
request5.put ("action", "decimal_nano_to_raw");
Expand All @@ -2431,20 +2437,23 @@ TEST (rpc, decimal_nano_to_raw)
std::cout << response.get<std::string> ("error");
ASSERT_EQ (std::error_code (nano::error_common::invalid_amount).message (), response.get<std::string> ("error"));

std::cout << "7";
// Multiple decimal seperators.
boost::property_tree::ptree request6;
request6.put ("action", "decimal_nano_to_raw");
request6.put ("amount", "7.234.154");
response = wait_response (system, rpc_ctx, request6);
ASSERT_EQ (std::error_code (nano::error_common::invalid_amount).message (), response.get<std::string> ("error"));

std::cout << "8";
// Comma as decimal seperator
boost::property_tree::ptree request7;
request7.put ("action", "decimal_nano_to_raw");
request7.put ("amount", "3,14");
response = wait_response (system, rpc_ctx, request7);
ASSERT_EQ (std::error_code (nano::error_common::invalid_amount).message (), response.get<std::string> ("error"));

std::cout << "9";
// Empty input
boost::property_tree::ptree request8;
request8.put ("action", "decimal_nano_to_raw");
Expand Down

0 comments on commit 5101153

Please sign in to comment.