From 0295f103876afe199a5639c1a12b494f2cb59c98 Mon Sep 17 00:00:00 2001 From: theoreticalbts Date: Thu, 6 Aug 2015 13:01:58 -0400 Subject: [PATCH] block_tests.cpp: Implement optional_tapos test to ensure backend doesn't force TaPoS --- tests/tests/block_tests.cpp | 65 +++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/tests/tests/block_tests.cpp b/tests/tests/block_tests.cpp index 129a2085..2c84005f 100644 --- a/tests/tests/block_tests.cpp +++ b/tests/tests/block_tests.cpp @@ -498,6 +498,71 @@ BOOST_AUTO_TEST_CASE( tapos ) } } +BOOST_FIXTURE_TEST_CASE( optional_tapos, database_fixture ) +{ + try + { + ACTORS( (alice)(bob) ); + + generate_block(); + + BOOST_TEST_MESSAGE( "Create transaction" ); + + transfer( account_id_type(), alice_id, asset( 1000000 ) ); + transfer_operation op; + op.from = alice_id; + op.to = bob_id; + op.amount = asset( 1000 ); + signed_transaction tx; + tx.operations.push_back( op ); + set_expiration( db, tx ); + + BOOST_TEST_MESSAGE( "ref_block_num=0, ref_block_prefix=0" ); + + tx.ref_block_num = 0; + tx.ref_block_prefix = 0; + tx.signatures.clear(); + sign( tx, alice_private_key ); + PUSH_TX( db, tx ); + + BOOST_TEST_MESSAGE( "proper ref_block_num, ref_block_prefix" ); + + set_expiration( db, tx ); + tx.signatures.clear(); + sign( tx, alice_private_key ); + PUSH_TX( db, tx ); + + BOOST_TEST_MESSAGE( "ref_block_num=0, ref_block_prefix=12345678" ); + + tx.ref_block_num = 0; + tx.ref_block_prefix = 0x12345678; + tx.signatures.clear(); + sign( tx, alice_private_key ); + GRAPHENE_REQUIRE_THROW( PUSH_TX( db, tx ), fc::exception ); + + BOOST_TEST_MESSAGE( "ref_block_num=1, ref_block_prefix=12345678" ); + + tx.ref_block_num = 1; + tx.ref_block_prefix = 0x12345678; + tx.signatures.clear(); + sign( tx, alice_private_key ); + GRAPHENE_REQUIRE_THROW( PUSH_TX( db, tx ), fc::exception ); + + BOOST_TEST_MESSAGE( "ref_block_num=9999, ref_block_prefix=12345678" ); + + tx.ref_block_num = 9999; + tx.ref_block_prefix = 0x12345678; + tx.signatures.clear(); + sign( tx, alice_private_key ); + GRAPHENE_REQUIRE_THROW( PUSH_TX( db, tx ), fc::exception ); + } + catch (fc::exception& e) + { + edump((e.to_detail_string())); + throw; + } +} + BOOST_FIXTURE_TEST_CASE( maintenance_interval, database_fixture ) { try {