From 755da1adb3d9e657f62cd632c568e94966f2913a Mon Sep 17 00:00:00 2001 From: Lin Huang Date: Tue, 2 Apr 2024 14:12:44 -0400 Subject: [PATCH] Add get_row_by_id to libtester --- libraries/testing/include/eosio/testing/tester.hpp | 1 + libraries/testing/tester.cpp | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/libraries/testing/include/eosio/testing/tester.hpp b/libraries/testing/include/eosio/testing/tester.hpp index ee2862d405..6ca6dbf922 100644 --- a/libraries/testing/include/eosio/testing/tester.hpp +++ b/libraries/testing/include/eosio/testing/tester.hpp @@ -338,6 +338,7 @@ namespace eosio { namespace testing { const account_name& account ) const; vector get_row_by_account( name code, name scope, name table, const account_name& act ) const; + vector get_row_by_id( name code, name scope, name table, uint64_t id ) const; map get_last_produced_block_map()const { return last_produced_block; }; void set_last_produced_block_map( const map& lpb ) { last_produced_block = lpb; } diff --git a/libraries/testing/tester.cpp b/libraries/testing/tester.cpp index 7e1efb0177..9ee5099bc6 100644 --- a/libraries/testing/tester.cpp +++ b/libraries/testing/tester.cpp @@ -1047,8 +1047,11 @@ namespace eosio { namespace testing { return asset(result, asset_symbol); } - vector base_tester::get_row_by_account( name code, name scope, name table, const account_name& act ) const { + return get_row_by_id( code, scope, table, act.to_uint64_t() ); + } + + vector base_tester::get_row_by_id( name code, name scope, name table, uint64_t id ) const { vector data; const auto& db = control->db(); const auto* t_id = db.find( boost::make_tuple( code, scope, table ) ); @@ -1059,8 +1062,8 @@ namespace eosio { namespace testing { const auto& idx = db.get_index(); - auto itr = idx.lower_bound( boost::make_tuple( t_id->id, act.to_uint64_t() ) ); - if ( itr == idx.end() || itr->t_id != t_id->id || act.to_uint64_t() != itr->primary_key ) { + auto itr = idx.lower_bound( boost::make_tuple( t_id->id, id ) ); + if ( itr == idx.end() || itr->t_id != t_id->id || id != itr->primary_key ) { return data; } @@ -1069,7 +1072,6 @@ namespace eosio { namespace testing { return data; } - vector base_tester::to_uint8_vector(const string& s) { vector v(s.size()); copy(s.begin(), s.end(), v.begin());