From 063b19ca67032321614afa45d1e8df8e442e621b Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Tue, 19 Feb 2019 17:00:16 -0600 Subject: [PATCH] Update to fc with reflector_init fix and add unittest for to/from variant of packed_transaction which requires the fix --- libraries/chain/include/eosio/chain/abi_serializer.hpp | 2 +- libraries/chain/transaction.cpp | 1 - libraries/fc | 2 +- unittests/misc_tests.cpp | 5 +++++ 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/libraries/chain/include/eosio/chain/abi_serializer.hpp b/libraries/chain/include/eosio/chain/abi_serializer.hpp index 5ba483c090d..398f219ced8 100644 --- a/libraries/chain/include/eosio/chain/abi_serializer.hpp +++ b/libraries/chain/include/eosio/chain/abi_serializer.hpp @@ -633,7 +633,7 @@ namespace impl { * @tparam Reslover - callable with the signature (const name& code_account) -> optional */ template - class abi_from_variant_visitor : reflector_init_visitor + class abi_from_variant_visitor : public reflector_init_visitor { public: abi_from_variant_visitor( const variant_object& _vo, T& v, Resolver _resolver, abi_traverse_context& _ctx ) diff --git a/libraries/chain/transaction.cpp b/libraries/chain/transaction.cpp index 08cd6a0222c..e1910ce02eb 100644 --- a/libraries/chain/transaction.cpp +++ b/libraries/chain/transaction.cpp @@ -327,7 +327,6 @@ packed_transaction::packed_transaction( transaction&& t, vector& void packed_transaction::reflector_init() { // called after construction, but always on the same thread and before packed_transaction passed to any other threads - static_assert(&fc::reflector_init_visitor::reflector_init, "FC with reflector_init required"); static_assert(fc::raw::has_feature_reflector_init_on_unpacked_reflected_types, "FC unpack needs to call reflector_init otherwise unpacked_trx will not be initialized"); EOS_ASSERT( unpacked_trx.expiration == time_point_sec(), tx_decompression_error, "packed_transaction already unpacked" ); diff --git a/libraries/fc b/libraries/fc index 45f6328635c..5b615cdac4e 160000 --- a/libraries/fc +++ b/libraries/fc @@ -1 +1 @@ -Subproject commit 45f6328635c1577bf91852359246c9451b334b3a +Subproject commit 5b615cdac4ef098b3400431f4ce0639b01233a01 diff --git a/unittests/misc_tests.cpp b/unittests/misc_tests.cpp index e321611c36d..49ce5ebce1f 100644 --- a/unittests/misc_tests.cpp +++ b/unittests/misc_tests.cpp @@ -645,6 +645,10 @@ BOOST_AUTO_TEST_CASE(transaction_test) { try { ds2.seekp(0); packed_transaction pkt4; fc::raw::unpack(ds2, pkt4); + // to/from variant + fc::variant pkt_v( pkt3 ); + packed_transaction pkt5; + fc::from_variant(pkt_v, pkt5); bytes raw3 = pkt3.get_raw_transaction(); bytes raw4 = pkt4.get_raw_transaction(); @@ -654,6 +658,7 @@ BOOST_AUTO_TEST_CASE(transaction_test) { try { BOOST_CHECK_EQUAL(true, std::equal(raw.begin(), raw.end(), raw4.begin())); BOOST_CHECK_EQUAL(pkt.get_signed_transaction().id(), pkt3.get_signed_transaction().id()); BOOST_CHECK_EQUAL(pkt.get_signed_transaction().id(), pkt4.get_signed_transaction().id()); + BOOST_CHECK_EQUAL(pkt.get_signed_transaction().id(), pkt5.get_signed_transaction().id()); // failure indicates reflector_init not working BOOST_CHECK_EQUAL(pkt.id(), pkt4.get_signed_transaction().id()); BOOST_CHECK_EQUAL(true, trx.expiration == pkt4.expiration()); BOOST_CHECK_EQUAL(true, trx.expiration == pkt4.get_signed_transaction().expiration);