Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

reflector_init fix #6781

Merged
merged 1 commit into from
Feb 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libraries/chain/include/eosio/chain/abi_serializer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ namespace impl {
* @tparam Reslover - callable with the signature (const name& code_account) -> optional<abi_def>
*/
template<typename T, typename Resolver>
class abi_from_variant_visitor : reflector_init_visitor<T>
class abi_from_variant_visitor : public reflector_init_visitor<T>
{
public:
abi_from_variant_visitor( const variant_object& _vo, T& v, Resolver _resolver, abi_traverse_context& _ctx )
Expand Down
1 change: 0 additions & 1 deletion libraries/chain/transaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,6 @@ packed_transaction::packed_transaction( transaction&& t, vector<signature_type>&
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<packed_transaction>::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" );
Expand Down
5 changes: 5 additions & 0 deletions unittests/misc_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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);
Expand Down