diff --git a/contrib/epee/include/storages/portable_storage_val_converters.h b/contrib/epee/include/storages/portable_storage_val_converters.h index caf7a322..f2c49f0e 100644 --- a/contrib/epee/include/storages/portable_storage_val_converters.h +++ b/contrib/epee/include/storages/portable_storage_val_converters.h @@ -129,7 +129,20 @@ POP_VS_WARNINGS template struct convert_to_integral { - static void convert(const from_type& from, to_type& to) + static void convert(const const std::string& from, uint64_t& to) + { + //attempt to convert string to unsigned int + try + { + to = std::stoull(from); + }catch(...) + { + ASSERT_AND_THROW_WRONG_CONVERSION(); + } + } + + template + static void convert(const from_type_t& from, to_type_t& to) { ASSERT_AND_THROW_WRONG_CONVERSION(); } diff --git a/tests/functional_tests/main.cpp b/tests/functional_tests/main.cpp index b275bd4a..d211a3bc 100644 --- a/tests/functional_tests/main.cpp +++ b/tests/functional_tests/main.cpp @@ -109,7 +109,7 @@ int main(int argc, char* argv[]) command_line::add_arg(desc_options, arg_crypto_tests); - test_serialization(); + test_serialization2(); po::variables_map vm; bool r = command_line::handle_error_helper(desc_options, [&]() diff --git a/tests/functional_tests/transactions_flow_test.cpp b/tests/functional_tests/transactions_flow_test.cpp index be76d998..b6128929 100644 --- a/tests/functional_tests/transactions_flow_test.cpp +++ b/tests/functional_tests/transactions_flow_test.cpp @@ -386,6 +386,26 @@ bool test_serialization() return true; } + +struct test_serialization_2 +{ + uint64_t var1; + uint64_t var2; + BEGIN_KV_SERIALIZE_MAP() + KV_SERIALIZE(var1) + KV_SERIALIZE(var2) + END_KV_SERIALIZE_MAP() +}; + +bool test_serialization2() +{ + test_serialization_2 ee = {}; + std::string json_buf = "{\"var1\": 111, \"var2\": \"222\"}"; + epee::serialization::load_t_from_json(ee, json_buf); + std::string json_buf2 = epee::serialization::store_t_to_json(ee); + return true; +} + bool transactions_flow_test( std::wstring path_source_wallet, std::string source_wallet_pass, std::wstring path_terget_wallet, std::string target_wallet_pass, diff --git a/tests/functional_tests/transactions_flow_test.h b/tests/functional_tests/transactions_flow_test.h index 7f7aa528..ac023efc 100644 --- a/tests/functional_tests/transactions_flow_test.h +++ b/tests/functional_tests/transactions_flow_test.h @@ -16,4 +16,5 @@ bool transactions_flow_test( std::string& daemon_addr_a, std::string& daemon_addr_b, size_t mix_in_factor, size_t action = TRANSACTIONS_FLOW_TESTACTION_DEFAULT, uint64_t max_tx_in_pool = 10000); -bool test_serialization(); \ No newline at end of file +bool test_serialization(); +bool test_serialization2(); \ No newline at end of file