diff options
author | Alexander Blair <snipa@jagtech.io> | 2020-08-16 12:43:38 -0700 |
---|---|---|
committer | Alexander Blair <snipa@jagtech.io> | 2020-08-16 12:43:38 -0700 |
commit | a08df6eb1beaf442ef6d9b27c1f47497b74d3471 (patch) | |
tree | ef0f0ac25c2932f26cdd0a389a4ad44ec2a97826 /tests | |
parent | Merge pull request #6601 (diff) | |
parent | Change ZMQ-JSON txextra to hex and remove unnecessary base fields (diff) | |
download | monero-a08df6eb1beaf442ef6d9b27c1f47497b74d3471.tar.xz |
Merge pull request #6603
4e2377995 Change ZMQ-JSON txextra to hex and remove unnecessary base fields (Lee Clagett)
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit_tests/json_serialization.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/tests/unit_tests/json_serialization.cpp b/tests/unit_tests/json_serialization.cpp index 1db923f7b..f76199e57 100644 --- a/tests/unit_tests/json_serialization.cpp +++ b/tests/unit_tests/json_serialization.cpp @@ -97,7 +97,7 @@ namespace rapidjson::Document doc; doc.Parse(reinterpret_cast<const char*>(buffer.data()), buffer.size()); - if (doc.HasParseError() || !doc.IsObject()) + if (doc.HasParseError()) { throw cryptonote::json::PARSE_FAIL(); } @@ -108,6 +108,21 @@ namespace } } // anonymous +TEST(JsonSerialization, VectorBytes) +{ + EXPECT_EQ(std::vector<std::uint8_t>{}, test_json(std::vector<std::uint8_t>{})); + EXPECT_EQ(std::vector<std::uint8_t>{0x00}, test_json(std::vector<std::uint8_t>{0x00})); +} + +TEST(JsonSerialization, InvalidVectorBytes) +{ + rapidjson::Document doc; + doc.SetString("1"); + + std::vector<std::uint8_t> out; + EXPECT_THROW(cryptonote::json::fromJsonValue(doc, out), cryptonote::json::BAD_INPUT); +} + TEST(JsonSerialization, MinerTransaction) { cryptonote::account_base acct; |