Skip to content

Commit

Permalink
Name of the argument in list_voter_proposals chaged from voter to start
Browse files Browse the repository at this point in the history
  • Loading branch information
Dariusz Kedzierski authored and Mariusz-Trela committed Apr 25, 2019
1 parent e9a5b5b commit c0cbc5f
Show file tree
Hide file tree
Showing 12 changed files with 33 additions and 33 deletions.
4 changes: 2 additions & 2 deletions libraries/plugins/apis/condenser_api/condenser_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1929,13 +1929,13 @@ namespace detail
CHECK_ARG_SIZE( 5 )
FC_ASSERT( _sps_api, "sps_api_plugin not enabled." );
steem::plugins::sps::list_voter_proposals_args list_args;
list_args.voter = args[0].as<account_name_type>();
list_args.start = args[0].as<fc::variant>();
list_args.order_by = args[1].as< steem::plugins::sps::order_by_type >();
list_args.order_direction = args[2].as<steem::plugins::sps::order_direction_type>();
list_args.limit = args[3].as<int>();
list_args.status = args[4].as<steem::plugins::sps::proposal_status>();
//return _sps_api->list_voter_proposals( {args[0].as<account_name_type>, args[1].as< steem::plugins::sps::order_by_type >, args[2].as<steem::plugins::sps::order_direction_type>, args[3].as<int>, args[4].as<int>} );
//return _sps_api->list_voter_proposals( {args[0].as<fc::variant>, args[1].as< steem::plugins::sps::order_by_type >, args[2].as<steem::plugins::sps::order_direction_type>, args[3].as<int>, args[4].as<int>} );
return _sps_api->list_voter_proposals( list_args );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ namespace steem { namespace plugins { namespace sps {
struct list_voter_proposals_args
{
// list only proposal voted by this voter
account_name_type voter;
fc::variant start;
// name of the field by which results will be sored
order_by_type order_by;
// sorting order (ascending or descending) of the result vector
Expand Down Expand Up @@ -234,7 +234,7 @@ FC_REFLECT(steem::plugins::sps::list_proposals_args,
);

FC_REFLECT(steem::plugins::sps::list_voter_proposals_args,
(voter)
(start)
(order_by)
(order_direction)
(limit)
Expand Down
2 changes: 1 addition & 1 deletion libraries/plugins/apis/sps_api/sps_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ DEFINE_API_IMPL(sps_api_impl, list_voter_proposals) {
list_voter_proposals_return result;

const auto& idx = _db.get_index<proposal_vote_index, by_voter_proposal>();
auto itr = idx.lower_bound(args.voter);
auto itr = idx.lower_bound(args.start.as<account_name_type>());
auto end = idx.end();

if (args.status != proposal_status::all) // avoid not needed rewrite in case of active set to all
Expand Down
2 changes: 1 addition & 1 deletion libraries/wallet/include/steem/wallet/remote_node_api.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ struct remote_node_api
flat_set< uint32_t > get_market_history_buckets();

steem::plugins::sps::list_proposals_return list_proposals(fc::variant _start, steem::plugins::sps::order_by_type _order_by, steem::plugins::sps::order_direction_type _order_type, int _limit, steem::plugins::sps::proposal_status _status);
steem::plugins::sps::list_voter_proposals_return list_voter_proposals(account_name_type _voter, steem::plugins::sps::order_by_type _order_by, steem::plugins::sps::order_direction_type _order_type, int _limit, steem::plugins::sps::proposal_status _status);
steem::plugins::sps::list_voter_proposals_return list_voter_proposals(fc::variant _start, steem::plugins::sps::order_by_type _order_by, steem::plugins::sps::order_direction_type _order_type, int _limit, steem::plugins::sps::proposal_status _status);
steem::plugins::sps::find_proposals_return find_proposals(flat_set<uint64_t> _ids);
};

Expand Down
4 changes: 2 additions & 2 deletions libraries/wallet/include/steem/wallet/wallet.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1113,13 +1113,13 @@ class wallet_api

/**
* List proposals of given voter
* @param _voter - given voter,
* @param _start - starting value for querying results,
* @param _order_by - name a field for sorting operation,
* @param _order_type - set print order asc - ascdending, desc - descending,
* @param _limit - query limit
* @param _status - List only results with given status (inactive, active, all).
*/
list_voter_proposals_return list_voter_proposals(account_name_type _voter,
list_voter_proposals_return list_voter_proposals(fc::variant _start,
std::string _order_by = "creator",
std::string _order_type = "desc",
int _limit = 10,
Expand Down
2 changes: 1 addition & 1 deletion libraries/wallet/remote_node_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ steem::plugins::sps::list_proposals_return remote_node_api::list_proposals(fc::v
FC_ASSERT( false );
}

steem::plugins::sps::list_voter_proposals_return remote_node_api::list_voter_proposals(account_name_type _voter, steem::plugins::sps::order_by_type _order_by, steem::plugins::sps::order_direction_type _order_type, int _limit, steem::plugins::sps::proposal_status _status)
steem::plugins::sps::list_voter_proposals_return remote_node_api::list_voter_proposals(fc::variant _start, steem::plugins::sps::order_by_type _order_by, steem::plugins::sps::order_direction_type _order_type, int _limit, steem::plugins::sps::proposal_status _status)
{
FC_ASSERT( false );
}
Expand Down
8 changes: 4 additions & 4 deletions libraries/wallet/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2505,7 +2505,7 @@ condenser_api::legacy_signed_transaction wallet_api::follow( string follower, st
return steem::plugins::sps::list_proposals_return ();
}

steem::plugins::sps::list_voter_proposals_return wallet_api::list_voter_proposals(account_name_type _voter,
steem::plugins::sps::list_voter_proposals_return wallet_api::list_voter_proposals(fc::variant _start,
std::string _order_by,
std::string _order_type,
int _limit,
Expand All @@ -2517,20 +2517,20 @@ condenser_api::legacy_signed_transaction wallet_api::follow( string follower, st
FC_ASSERT(!_status.empty());

steem::plugins::sps::list_voter_proposals_args args;
args.voter = _voter;
args.start = _start;
args.order_by = steem::plugins::sps::to_order_by(_order_by);
args.order_direction = steem::plugins::sps::to_order_direction(_order_type);
args.limit = _limit;
args.status = steem::plugins::sps::to_proposal_status(_status);

ddump((args.voter));
ddump((args.start));
ddump((args.order_by));
ddump((args.order_direction));
ddump((args.limit));
ddump((args.status));

try {
return my->_remote_api->list_voter_proposals(args.voter, args.order_by, args.order_direction, args.limit, args.status);
return my->_remote_api->list_voter_proposals(args.start, args.order_by, args.order_direction, args.limit, args.status);
} catch( fc::exception& _e) {
elog("Caught exception while executig list_voter_proposals: ${error}", ("error", _e));
} catch( std::exception& _e ) {
Expand Down
2 changes: 1 addition & 1 deletion python_scripts/tests/api_tests/sps_api/sps_api_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@
- name: "list_voter_proposals"
- variable_binds:
- method: "list_voter_proposals"
- args: '{"voter" : "blocktrades", "order_by":"by_creator", "order_direction":"direction_ascending","limit" : 1, "status":"active"}}'
- args: '{"start" : "blocktrades", "order_by":"by_creator", "order_direction":"direction_ascending","limit" : 1, "status":"active"}}'
- <<: *base_test

Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
for by in order_by:
for direct in order_direction:
for act in active:
call_args = {"voter":"initminer", "order_by":by, "order_direction":direct, "limit":10, "status":act}
call_args = {"start":"initminer", "order_by":by, "order_direction":direct, "limit":10, "status":act}
call_and_check(wallet.list_voter_proposals, call_args, "args")


Expand Down
26 changes: 13 additions & 13 deletions tests/api_tests/sps_api_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,17 @@
def get_random_id():
return str(uuid.uuid4())

def list_voter_proposals(voter, order_by, order_direction, limit, active):
def list_voter_proposals(start, order_by, order_direction, limit, status):
payload = {
"jsonrpc" : "2.0",
"id" : get_random_id(),
"method" : "sps_api.list_voter_proposals",
"params" : {
"voter" : voter,
"start" : start,
"order_by" : order_by,
"order_direction" : order_direction,
"limit" : limit,
"active" : active
"status" : status
}
}
ret = json.dumps(payload)
Expand All @@ -59,7 +59,7 @@ def find_proposals(id_set):
logger.info("New payload: {}".format(ret))
return ret

def list_proposals(start, order_by, order_direction, limit, active):
def list_proposals(start, order_by, order_direction, limit, status):
payload = {
"jsonrpc" : "2.0",
"id" : get_random_id(),
Expand All @@ -69,30 +69,30 @@ def list_proposals(start, order_by, order_direction, limit, active):
"order_by" : order_by,
"order_direction" : order_direction,
"limit" : limit,
"active" : active
"status" : status
}
}
ret = json.dumps(payload)
logger.info("New payload: {}".format(ret))
return ret

def condenser_list_proposals(start, order_by, order_direction, limit, active):
def condenser_list_proposals(start, order_by, order_direction, limit, status):
payload = {
"jsonrpc" : "2.0",
"id" : get_random_id(),
"method" : "condenser_api.list_proposals",
"params" : [start, order_by, order_direction, limit, active]
"params" : [start, order_by, order_direction, limit, status]
}
ret = json.dumps(payload)
logger.info("New payload: {}".format(ret))
return ret

def condenser_list_voter_proposals(voter, order_by, order_direction, limit, active):
def condenser_list_voter_proposals(start, order_by, order_direction, limit, status):
payload = {
"jsonrpc" : "2.0",
"id" : get_random_id(),
"method" : "condenser_api.list_voter_proposals",
"params" : [voter, order_by, order_direction, limit, active]
"params" : [start, order_by, order_direction, limit, status]
}
ret = json.dumps(payload)
logger.info("New payload: {}".format(ret))
Expand Down Expand Up @@ -133,19 +133,19 @@ def run_test(test_name, expected_result, url, payload):
payload = find_proposals([1234, 2, 3, 4])
run_test("Basic find_proposal test", None, url, payload)

payload = list_proposals("blocktrades", "by_creator", "direction_ascending", 1, 1)
payload = list_proposals("blocktrades", "by_creator", "direction_ascending", 1, "all")
run_test("Basic list_proposals test", None, url, payload)

payload = list_voter_proposals("blocktrades", "by_creator", "direction_ascending", 1, 1)
payload = list_voter_proposals("blocktrades", "by_creator", "direction_ascending", 1, "all")
run_test("Basic list_voter_proposals test", None, url, payload)

logger.info("Running SPS API tests via condeser API")
payload = condenser_find_proposals([1234, 2, 3, 4])
run_test("Basic find_proposal test", None, url, payload)

payload = condenser_list_proposals("blocktrades", "by_creator", "direction_ascending", 1, 1)
payload = condenser_list_proposals("blocktrades", "by_creator", "direction_ascending", 1, "all")
run_test("Basic list_proposals test", None, url, payload)

payload = condenser_list_voter_proposals("blocktrades", "by_creator", "direction_ascending", 1, 1)
payload = condenser_list_voter_proposals("blocktrades", "by_creator", "direction_ascending", 1, "all")
run_test("Basic list_voter_proposals test", None, url, payload)

8 changes: 4 additions & 4 deletions tests/db_fixture/database_fixture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1061,11 +1061,11 @@ list_proposals_return t_proposal_database_fixture< T >::list_proposals(fc::varia
}

template< typename T>
list_voter_proposals_return t_proposal_database_fixture< T >::list_voter_proposals(account_name_type _voter, std::string _order_by, std::string _order_type, int _limit, std::string _status)
list_voter_proposals_return t_proposal_database_fixture< T >::list_voter_proposals(fc::variant _start, std::string _order_by, std::string _order_type, int _limit, std::string _status)
{
auto api = appbase::app().get_plugin< steem::plugins::sps::sps_api_plugin >().api;
steem::plugins::sps::list_voter_proposals_args args;
args.voter = _voter;
args.start = _start;
args.order_by = steem::plugins::sps::to_order_by(_order_by);
args.order_direction = steem::plugins::sps::to_order_direction(_order_type);
args.limit = _limit;
Expand Down Expand Up @@ -1166,7 +1166,7 @@ template void t_proposal_database_fixture< clean_database_fixture >::transfer_ve
template void t_proposal_database_fixture< clean_database_fixture >::transfer( std::string from, std::string to, asset amount, const fc::ecc::private_key& key );
template bool t_proposal_database_fixture< clean_database_fixture >::exist_proposal( int64_t id );
template list_proposals_return t_proposal_database_fixture< clean_database_fixture >::list_proposals(fc::variant _start, std::string _order_by, std::string _order_type, int _limit, std::string _status);
template list_voter_proposals_return t_proposal_database_fixture< clean_database_fixture >::list_voter_proposals(account_name_type _voter, std::string _order_by, std::string _order_type, int _limit, std::string _status);
template list_voter_proposals_return t_proposal_database_fixture< clean_database_fixture >::list_voter_proposals(fc::variant _start, std::string _order_by, std::string _order_type, int _limit, std::string _status);
template find_proposals_return t_proposal_database_fixture< clean_database_fixture >::find_proposals(flat_set<uint64_t> _proposal_ids);
template void t_proposal_database_fixture< clean_database_fixture >::remove_proposal(account_name_type _deleter, flat_set<int64_t> _proposal_id, const fc::ecc::private_key& _key);
template bool t_proposal_database_fixture< clean_database_fixture >::find_vote_for_proposal(const std::string& _user, int64_t _proposal_id);
Expand All @@ -1180,7 +1180,7 @@ template void t_proposal_database_fixture< database_fixture >::transfer_vests( s
template void t_proposal_database_fixture< database_fixture >::transfer( std::string from, std::string to, asset amount, const fc::ecc::private_key& key );
template bool t_proposal_database_fixture< database_fixture >::exist_proposal( int64_t id );
template list_proposals_return t_proposal_database_fixture< database_fixture >::list_proposals(fc::variant _start, std::string _order_by, std::string _order_type, int _limit, std::string _status);
template list_voter_proposals_return t_proposal_database_fixture< database_fixture >::list_voter_proposals(account_name_type _voter, std::string _order_by, std::string _order_type, int _limit, std::string _status) ;
template list_voter_proposals_return t_proposal_database_fixture< database_fixture >::list_voter_proposals(fc::variant _start, std::string _order_by, std::string _order_type, int _limit, std::string _status) ;
template find_proposals_return t_proposal_database_fixture< database_fixture >::find_proposals(flat_set<uint64_t> _proposal_ids);
template void t_proposal_database_fixture< database_fixture >::remove_proposal(account_name_type _deleter, flat_set<int64_t> _proposal_id, const fc::ecc::private_key& _key);
template bool t_proposal_database_fixture< database_fixture >::find_vote_for_proposal(const std::string& _user, int64_t _proposal_id);
Expand Down
2 changes: 1 addition & 1 deletion tests/db_fixture/database_fixture.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ struct t_proposal_database_fixture : public T

bool exist_proposal( int64_t id );
steem::plugins::sps::list_proposals_return list_proposals(fc::variant _start, std::string _order_by, std::string _order_type, int _limit, std::string _status) ;
steem::plugins::sps::list_voter_proposals_return list_voter_proposals(account_name_type _voter, std::string _order_by, std::string _order_type, int _limit, std::string _status) ;
steem::plugins::sps::list_voter_proposals_return list_voter_proposals(fc::variant _start, std::string _order_by, std::string _order_type, int _limit, std::string _status) ;
steem::plugins::sps::find_proposals_return find_proposals(flat_set<uint64_t> _proposal_ids);
void remove_proposal(account_name_type _deleter, flat_set<int64_t> _proposal_id, const fc::ecc::private_key& _key);

Expand Down

0 comments on commit c0cbc5f

Please sign in to comment.