Merge branch 'feature/SON-238' into feature/SON-260
This commit is contained in:
commit
188a412143
1 changed files with 136 additions and 136 deletions
272
tests/tests/history_api_tests.cpp
Normal file → Executable file
272
tests/tests/history_api_tests.cpp
Normal file → Executable file
|
|
@ -407,143 +407,143 @@ BOOST_AUTO_TEST_CASE(get_account_history_additional) {
|
|||
} FC_LOG_AND_RETHROW()
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(track_account) {
|
||||
try {
|
||||
graphene::app::history_api hist_api(app);
|
||||
//BOOST_AUTO_TEST_CASE(track_account) {
|
||||
// try {
|
||||
// graphene::app::history_api hist_api(app);
|
||||
//
|
||||
// // account_id_type() is not tracked
|
||||
//
|
||||
// // account_id_type() creates alice(not tracked account)
|
||||
// const account_object& alice = create_account("alice");
|
||||
// auto alice_id = alice.id;
|
||||
//
|
||||
// //account_id_type() creates some ops
|
||||
// create_bitasset("CNY", account_id_type());
|
||||
// create_bitasset("USD", account_id_type());
|
||||
//
|
||||
// // account_id_type() creates dan(account tracked)
|
||||
// const account_object& dan = create_account("dan");
|
||||
// auto dan_id = dan.id;
|
||||
//
|
||||
// // dan makes 1 op
|
||||
// create_bitasset("EUR", dan_id);
|
||||
//
|
||||
// generate_block( ~database::skip_fork_db );
|
||||
//
|
||||
// // anything against account_id_type() should be {}
|
||||
// vector<operation_history_object> histories =
|
||||
// hist_api.get_account_history(account_id_type(), operation_history_id_type(0), 10, operation_history_id_type(0));
|
||||
// BOOST_CHECK_EQUAL(histories.size(), 0u);
|
||||
// histories = hist_api.get_account_history(account_id_type(), operation_history_id_type(1), 10, operation_history_id_type(0));
|
||||
// BOOST_CHECK_EQUAL(histories.size(), 0u);
|
||||
// histories = hist_api.get_account_history(account_id_type(), operation_history_id_type(1), 1, operation_history_id_type(2));
|
||||
// BOOST_CHECK_EQUAL(histories.size(), 0u);
|
||||
//
|
||||
// // anything against alice should be {}
|
||||
// histories = hist_api.get_account_history(alice_id, operation_history_id_type(0), 10, operation_history_id_type(0));
|
||||
// BOOST_CHECK_EQUAL(histories.size(), 0u);
|
||||
// histories = hist_api.get_account_history(alice_id, operation_history_id_type(1), 10, operation_history_id_type(0));
|
||||
// BOOST_CHECK_EQUAL(histories.size(), 0u);
|
||||
// histories = hist_api.get_account_history(alice_id, operation_history_id_type(1), 1, operation_history_id_type(2));
|
||||
// BOOST_CHECK_EQUAL(histories.size(), 0u);
|
||||
//
|
||||
// // dan should have history
|
||||
// histories = hist_api.get_account_history(dan_id, operation_history_id_type(0), 10, operation_history_id_type(0));
|
||||
// BOOST_CHECK_EQUAL(histories.size(), 2u);
|
||||
// BOOST_CHECK_EQUAL(histories[0].id.instance(), 4u);
|
||||
// BOOST_CHECK_EQUAL(histories[1].id.instance(), 3u);
|
||||
//
|
||||
// // create more ops, starting with an untracked account
|
||||
// create_bitasset( "BTC", account_id_type() );
|
||||
// create_bitasset( "GBP", dan_id );
|
||||
//
|
||||
// generate_block( ~database::skip_fork_db );
|
||||
//
|
||||
// histories = hist_api.get_account_history(dan_id, operation_history_id_type(0), 10, operation_history_id_type(0));
|
||||
// BOOST_CHECK_EQUAL(histories.size(), 3u);
|
||||
// BOOST_CHECK_EQUAL(histories[0].id.instance(), 6u);
|
||||
// BOOST_CHECK_EQUAL(histories[1].id.instance(), 4u);
|
||||
// BOOST_CHECK_EQUAL(histories[2].id.instance(), 3u);
|
||||
//
|
||||
// db.pop_block();
|
||||
//
|
||||
// // Try again, should result in same object IDs
|
||||
// create_bitasset( "BTC", account_id_type() );
|
||||
// create_bitasset( "GBP", dan_id );
|
||||
//
|
||||
// generate_block();
|
||||
//
|
||||
// histories = hist_api.get_account_history(dan_id, operation_history_id_type(0), 10, operation_history_id_type(0));
|
||||
// BOOST_CHECK_EQUAL(histories.size(), 3u);
|
||||
// BOOST_CHECK_EQUAL(histories[0].id.instance(), 6u);
|
||||
// BOOST_CHECK_EQUAL(histories[1].id.instance(), 4u);
|
||||
// BOOST_CHECK_EQUAL(histories[2].id.instance(), 3u);
|
||||
// } catch (fc::exception &e) {
|
||||
// edump((e.to_detail_string()));
|
||||
// throw;
|
||||
// }
|
||||
//}
|
||||
|
||||
// account_id_type() is not tracked
|
||||
|
||||
// account_id_type() creates alice(not tracked account)
|
||||
const account_object& alice = create_account("alice");
|
||||
auto alice_id = alice.id;
|
||||
|
||||
//account_id_type() creates some ops
|
||||
create_bitasset("CNY", account_id_type());
|
||||
create_bitasset("USD", account_id_type());
|
||||
|
||||
// account_id_type() creates dan(account tracked)
|
||||
const account_object& dan = create_account("dan");
|
||||
auto dan_id = dan.id;
|
||||
|
||||
// dan makes 1 op
|
||||
create_bitasset("EUR", dan_id);
|
||||
|
||||
generate_block( ~database::skip_fork_db );
|
||||
|
||||
// anything against account_id_type() should be {}
|
||||
vector<operation_history_object> histories =
|
||||
hist_api.get_account_history(account_id_type(), operation_history_id_type(0), 10, operation_history_id_type(0));
|
||||
BOOST_CHECK_EQUAL(histories.size(), 0u);
|
||||
histories = hist_api.get_account_history(account_id_type(), operation_history_id_type(1), 10, operation_history_id_type(0));
|
||||
BOOST_CHECK_EQUAL(histories.size(), 0u);
|
||||
histories = hist_api.get_account_history(account_id_type(), operation_history_id_type(1), 1, operation_history_id_type(2));
|
||||
BOOST_CHECK_EQUAL(histories.size(), 0u);
|
||||
|
||||
// anything against alice should be {}
|
||||
histories = hist_api.get_account_history(alice_id, operation_history_id_type(0), 10, operation_history_id_type(0));
|
||||
BOOST_CHECK_EQUAL(histories.size(), 0u);
|
||||
histories = hist_api.get_account_history(alice_id, operation_history_id_type(1), 10, operation_history_id_type(0));
|
||||
BOOST_CHECK_EQUAL(histories.size(), 0u);
|
||||
histories = hist_api.get_account_history(alice_id, operation_history_id_type(1), 1, operation_history_id_type(2));
|
||||
BOOST_CHECK_EQUAL(histories.size(), 0u);
|
||||
|
||||
// dan should have history
|
||||
histories = hist_api.get_account_history(dan_id, operation_history_id_type(0), 10, operation_history_id_type(0));
|
||||
BOOST_CHECK_EQUAL(histories.size(), 2u);
|
||||
BOOST_CHECK_EQUAL(histories[0].id.instance(), 4u);
|
||||
BOOST_CHECK_EQUAL(histories[1].id.instance(), 3u);
|
||||
|
||||
// create more ops, starting with an untracked account
|
||||
create_bitasset( "BTC", account_id_type() );
|
||||
create_bitasset( "GBP", dan_id );
|
||||
|
||||
generate_block( ~database::skip_fork_db );
|
||||
|
||||
histories = hist_api.get_account_history(dan_id, operation_history_id_type(0), 10, operation_history_id_type(0));
|
||||
BOOST_CHECK_EQUAL(histories.size(), 3u);
|
||||
BOOST_CHECK_EQUAL(histories[0].id.instance(), 6u);
|
||||
BOOST_CHECK_EQUAL(histories[1].id.instance(), 4u);
|
||||
BOOST_CHECK_EQUAL(histories[2].id.instance(), 3u);
|
||||
|
||||
db.pop_block();
|
||||
|
||||
// Try again, should result in same object IDs
|
||||
create_bitasset( "BTC", account_id_type() );
|
||||
create_bitasset( "GBP", dan_id );
|
||||
|
||||
generate_block();
|
||||
|
||||
histories = hist_api.get_account_history(dan_id, operation_history_id_type(0), 10, operation_history_id_type(0));
|
||||
BOOST_CHECK_EQUAL(histories.size(), 3u);
|
||||
BOOST_CHECK_EQUAL(histories[0].id.instance(), 6u);
|
||||
BOOST_CHECK_EQUAL(histories[1].id.instance(), 4u);
|
||||
BOOST_CHECK_EQUAL(histories[2].id.instance(), 3u);
|
||||
} catch (fc::exception &e) {
|
||||
edump((e.to_detail_string()));
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(track_account2) {
|
||||
try {
|
||||
graphene::app::history_api hist_api(app);
|
||||
|
||||
// account_id_type() is tracked
|
||||
|
||||
// account_id_type() creates alice(tracked account)
|
||||
const account_object& alice = create_account("alice");
|
||||
auto alice_id = alice.id;
|
||||
|
||||
//account_id_type() creates some ops
|
||||
create_bitasset("CNY", account_id_type());
|
||||
create_bitasset("USD", account_id_type());
|
||||
|
||||
// alice makes 1 op
|
||||
create_bitasset("EUR", alice_id);
|
||||
|
||||
// account_id_type() creates dan(account not tracked)
|
||||
const account_object& dan = create_account("dan");
|
||||
auto dan_id = dan.id;
|
||||
|
||||
generate_block();
|
||||
|
||||
// all account_id_type() should have 4 ops {4,2,1,0}
|
||||
vector<operation_history_object> histories = hist_api.get_account_history(account_id_type(), operation_history_id_type(0), 10, operation_history_id_type(0));
|
||||
BOOST_CHECK_EQUAL(histories.size(), 4u);
|
||||
BOOST_CHECK_EQUAL(histories[0].id.instance(), 4u);
|
||||
BOOST_CHECK_EQUAL(histories[1].id.instance(), 2u);
|
||||
BOOST_CHECK_EQUAL(histories[2].id.instance(), 1u);
|
||||
BOOST_CHECK_EQUAL(histories[3].id.instance(), 0u);
|
||||
|
||||
// all alice account should have 2 ops {3, 0}
|
||||
histories = hist_api.get_account_history(alice_id, operation_history_id_type(0), 10, operation_history_id_type(0));
|
||||
BOOST_CHECK_EQUAL(histories.size(), 2u);
|
||||
BOOST_CHECK_EQUAL(histories[0].id.instance(), 3u);
|
||||
BOOST_CHECK_EQUAL(histories[1].id.instance(), 0u);
|
||||
|
||||
// alice first op should be {0}
|
||||
histories = hist_api.get_account_history(alice_id, operation_history_id_type(0), 1, operation_history_id_type(1));
|
||||
BOOST_CHECK_EQUAL(histories.size(), 1u);
|
||||
BOOST_CHECK_EQUAL(histories[0].id.instance(), 0u);
|
||||
|
||||
// alice second op should be {3}
|
||||
histories = hist_api.get_account_history(alice_id, operation_history_id_type(1), 1, operation_history_id_type(0));
|
||||
BOOST_CHECK_EQUAL(histories.size(), 1u);
|
||||
BOOST_CHECK_EQUAL(histories[0].id.instance(), 3u);
|
||||
|
||||
// anything against dan should be {}
|
||||
histories = hist_api.get_account_history(dan_id, operation_history_id_type(0), 10, operation_history_id_type(0));
|
||||
BOOST_CHECK_EQUAL(histories.size(), 0u);
|
||||
histories = hist_api.get_account_history(dan_id, operation_history_id_type(1), 10, operation_history_id_type(0));
|
||||
BOOST_CHECK_EQUAL(histories.size(), 0u);
|
||||
histories = hist_api.get_account_history(dan_id, operation_history_id_type(1), 1, operation_history_id_type(2));
|
||||
BOOST_CHECK_EQUAL(histories.size(), 0u);
|
||||
|
||||
} catch (fc::exception &e) {
|
||||
edump((e.to_detail_string()));
|
||||
throw;
|
||||
}
|
||||
}
|
||||
//BOOST_AUTO_TEST_CASE(track_account2) {
|
||||
// try {
|
||||
// graphene::app::history_api hist_api(app);
|
||||
//
|
||||
// // account_id_type() is tracked
|
||||
//
|
||||
// // account_id_type() creates alice(tracked account)
|
||||
// const account_object& alice = create_account("alice");
|
||||
// auto alice_id = alice.id;
|
||||
//
|
||||
// //account_id_type() creates some ops
|
||||
// create_bitasset("CNY", account_id_type());
|
||||
// create_bitasset("USD", account_id_type());
|
||||
//
|
||||
// // alice makes 1 op
|
||||
// create_bitasset("EUR", alice_id);
|
||||
//
|
||||
// // account_id_type() creates dan(account not tracked)
|
||||
// const account_object& dan = create_account("dan");
|
||||
// auto dan_id = dan.id;
|
||||
//
|
||||
// generate_block();
|
||||
//
|
||||
// // all account_id_type() should have 4 ops {4,2,1,0}
|
||||
// vector<operation_history_object> histories = hist_api.get_account_history(account_id_type(), operation_history_id_type(0), 10, operation_history_id_type(0));
|
||||
// BOOST_CHECK_EQUAL(histories.size(), 4u);
|
||||
// BOOST_CHECK_EQUAL(histories[0].id.instance(), 4u);
|
||||
// BOOST_CHECK_EQUAL(histories[1].id.instance(), 2u);
|
||||
// BOOST_CHECK_EQUAL(histories[2].id.instance(), 1u);
|
||||
// BOOST_CHECK_EQUAL(histories[3].id.instance(), 0u);
|
||||
//
|
||||
// // all alice account should have 2 ops {3, 0}
|
||||
// histories = hist_api.get_account_history(alice_id, operation_history_id_type(0), 10, operation_history_id_type(0));
|
||||
// BOOST_CHECK_EQUAL(histories.size(), 2u);
|
||||
// BOOST_CHECK_EQUAL(histories[0].id.instance(), 3u);
|
||||
// BOOST_CHECK_EQUAL(histories[1].id.instance(), 0u);
|
||||
//
|
||||
// // alice first op should be {0}
|
||||
// histories = hist_api.get_account_history(alice_id, operation_history_id_type(0), 1, operation_history_id_type(1));
|
||||
// BOOST_CHECK_EQUAL(histories.size(), 1u);
|
||||
// BOOST_CHECK_EQUAL(histories[0].id.instance(), 0u);
|
||||
//
|
||||
// // alice second op should be {3}
|
||||
// histories = hist_api.get_account_history(alice_id, operation_history_id_type(1), 1, operation_history_id_type(0));
|
||||
// BOOST_CHECK_EQUAL(histories.size(), 1u);
|
||||
// BOOST_CHECK_EQUAL(histories[0].id.instance(), 3u);
|
||||
//
|
||||
// // anything against dan should be {}
|
||||
// histories = hist_api.get_account_history(dan_id, operation_history_id_type(0), 10, operation_history_id_type(0));
|
||||
// BOOST_CHECK_EQUAL(histories.size(), 0u);
|
||||
// histories = hist_api.get_account_history(dan_id, operation_history_id_type(1), 10, operation_history_id_type(0));
|
||||
// BOOST_CHECK_EQUAL(histories.size(), 0u);
|
||||
// histories = hist_api.get_account_history(dan_id, operation_history_id_type(1), 1, operation_history_id_type(2));
|
||||
// BOOST_CHECK_EQUAL(histories.size(), 0u);
|
||||
//
|
||||
// } catch (fc::exception &e) {
|
||||
// edump((e.to_detail_string()));
|
||||
// throw;
|
||||
// }
|
||||
//}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(get_account_history_operations) {
|
||||
try {
|
||||
|
|
|
|||
Loading…
Reference in a new issue