Add test case for broadcast_trx_with_callback API
This commit is contained in:
parent
22e7c44984
commit
b787d62d06
1 changed files with 42 additions and 0 deletions
|
|
@ -9,6 +9,7 @@
|
|||
#include <graphene/chain/proposal_object.hpp>
|
||||
#include <graphene/chain/witness_object.hpp>
|
||||
#include <graphene/chain/protocol/committee_member.hpp>
|
||||
#include <graphene/app/api.hpp>
|
||||
#include <fc/crypto/digest.hpp>
|
||||
|
||||
#include "../common/database_fixture.hpp"
|
||||
|
|
@ -419,3 +420,44 @@ BOOST_AUTO_TEST_CASE( check_passes_for_duplicated_betting_market_or_group )
|
|||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
BOOST_FIXTURE_TEST_SUITE(network_broadcast_api_tests, database_fixture)
|
||||
|
||||
BOOST_AUTO_TEST_CASE( broadcast_transaction_with_callback_test ) {
|
||||
try {
|
||||
|
||||
uint32_t called = 0;
|
||||
auto callback = [&]( const variant& v )
|
||||
{
|
||||
++called;
|
||||
};
|
||||
|
||||
fc::ecc::private_key cid_key = fc::ecc::private_key::regenerate( fc::digest("key") );
|
||||
const account_id_type cid_id = create_account( "cid", cid_key.get_public_key() ).id;
|
||||
fund( cid_id(db) );
|
||||
|
||||
auto nb_api = std::make_shared< graphene::app::network_broadcast_api >( app );
|
||||
|
||||
set_expiration( db, trx );
|
||||
transfer_operation trans;
|
||||
trans.from = cid_id;
|
||||
trans.to = account_id_type();
|
||||
trans.amount = asset(1);
|
||||
trx.operations.push_back( trans );
|
||||
sign( trx, cid_key );
|
||||
|
||||
nb_api->broadcast_transaction_with_callback( callback, trx );
|
||||
|
||||
trx.operations.clear();
|
||||
trx.signatures.clear();
|
||||
|
||||
generate_block();
|
||||
|
||||
fc::usleep(fc::milliseconds(200)); // sleep a while to execute callback in another thread
|
||||
|
||||
BOOST_CHECK_EQUAL( called, 1 );
|
||||
|
||||
} FC_LOG_AND_RETHROW()
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
|
|
|||
Loading…
Reference in a new issue