Skip to content

Commit

Permalink
Merge pull request #91 from peerplays-network/GRPH-51
Browse files Browse the repository at this point in the history
unit test for bitshares issue #325
  • Loading branch information
bobinson authored Sep 6, 2019
2 parents c1d70bf + 8b5182e commit 6563644
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion tests/tests/database_tests.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015 Cryptonomex, Inc., and contributors.
* Copyright (c) 2017 Cryptonomex, Inc., and contributors.
*
* The MIT License
*
Expand Down Expand Up @@ -34,6 +34,8 @@

using namespace graphene::chain;

BOOST_FIXTURE_TEST_SUITE( database_tests, database_fixture )

BOOST_AUTO_TEST_CASE( undo_test )
{
try {
Expand All @@ -59,3 +61,34 @@ BOOST_AUTO_TEST_CASE( undo_test )
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()

0 comments on commit 6563644

Please sign in to comment.