Merge pull request #91 from peerplays-network/GRPH-51
unit test for bitshares issue #325
This commit is contained in:
commit
6563644264
1 changed files with 34 additions and 1 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2015 Cryptonomex, Inc., and contributors.
|
* Copyright (c) 2017 Cryptonomex, Inc., and contributors.
|
||||||
*
|
*
|
||||||
* The MIT License
|
* The MIT License
|
||||||
*
|
*
|
||||||
|
|
@ -34,6 +34,8 @@
|
||||||
|
|
||||||
using namespace graphene::chain;
|
using namespace graphene::chain;
|
||||||
|
|
||||||
|
BOOST_FIXTURE_TEST_SUITE( database_tests, database_fixture )
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE( undo_test )
|
BOOST_AUTO_TEST_CASE( undo_test )
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
|
@ -59,3 +61,34 @@ BOOST_AUTO_TEST_CASE( undo_test )
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE( flat_index_test )
|
||||||
|
{
|
||||||
|
ACTORS((sam));
|
||||||
|
const auto& bitusd = create_bitasset("USDBIT", sam.id);
|
||||||
|
update_feed_producers(bitusd, {sam.id});
|
||||||
|
price_feed current_feed;
|
||||||
|
current_feed.settlement_price = bitusd.amount(100) / asset(100);
|
||||||
|
publish_feed(bitusd, sam, current_feed);
|
||||||
|
FC_ASSERT( bitusd.bitasset_data_id->instance == 0 );
|
||||||
|
FC_ASSERT( !(*bitusd.bitasset_data_id)(db).current_feed.settlement_price.is_null() );
|
||||||
|
try {
|
||||||
|
auto ses = db._undo_db.start_undo_session();
|
||||||
|
const auto& obj1 = db.create<asset_bitasset_data_object>( [&]( asset_bitasset_data_object& obj ){
|
||||||
|
obj.settlement_fund = 17;
|
||||||
|
});
|
||||||
|
FC_ASSERT( obj1.settlement_fund == 17 );
|
||||||
|
throw std::string("Expected");
|
||||||
|
// With flat_index, obj1 will not really be removed from the index
|
||||||
|
} catch ( const std::string& e )
|
||||||
|
{ // ignore
|
||||||
|
}
|
||||||
|
|
||||||
|
// force maintenance
|
||||||
|
const auto& dynamic_global_props = db.get<dynamic_global_property_object>(dynamic_global_property_id_type());
|
||||||
|
generate_blocks(dynamic_global_props.next_maintenance_time, true);
|
||||||
|
|
||||||
|
FC_ASSERT( !(*bitusd.bitasset_data_id)(db).current_feed.settlement_price.is_null() );
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_SUITE_END()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue