@@ -37,46 +37,11 @@ extern uint32_t HIVE_TESTING_GENESIS_TIMESTAMP;
3737#define GENERATE_BLOCK \
3838 hive::chain::test::_generate_block
3939
40- // See below
41- #define REQUIRE_OP_VALIDATION_SUCCESS ( op, field, value ) \
42- { \
43- const auto temp = op.field ; \
44- op.field = value; \
45- op.validate (); \
46- op.field = temp; \
47- }
48- #define REQUIRE_OP_EVALUATION_SUCCESS ( op, field, value ) \
49- { \
50- const auto temp = op.field ; \
51- op.field = value; \
52- trx.operations .back () = op; \
53- op.field = temp; \
54- push_transaction ( trx, fc::ecc::private_key (), ~0 ); \
55- }
56-
57- /* #define HIVE_REQUIRE_THROW( expr, exc_type ) \
58- { \
59- std::string req_throw_info = fc::json::to_string( \
60- fc::mutable_variant_object() \
61- ("source_file", __FILE__) \
62- ("source_lineno", __LINE__) \
63- ("expr", #expr) \
64- ("exc_type", #exc_type) \
65- ); \
66- if( fc::enable_record_assert_trip ) \
67- std::cout << "HIVE_REQUIRE_THROW begin " \
68- << req_throw_info << std::endl; \
69- BOOST_REQUIRE_THROW( expr, exc_type ); \
70- if( fc::enable_record_assert_trip ) \
71- std::cout << "HIVE_REQUIRE_THROW end " \
72- << req_throw_info << std::endl; \
73- }*/
74-
7540#define HIVE_REQUIRE_THROW ( expr, exc_type ) \
76- BOOST_REQUIRE_THROW ( expr, exc_type );
41+ BOOST_REQUIRE_THROW ( expr, exc_type )
7742
7843#define HIVE_CHECK_THROW ( expr, exc_type ) \
79- { \
44+ do { \
8045 std::string req_throw_info = fc::json::to_string ( \
8146 fc::mutable_variant_object () \
8247 (" source_file" , __FILE__) \
@@ -91,7 +56,7 @@ extern uint32_t HIVE_TESTING_GENESIS_TIMESTAMP;
9156 if ( fc::enable_record_assert_trip ) \
9257 std::cout << " HIVE_CHECK_THROW end " \
9358 << req_throw_info << std::endl; \
94- }
59+ } while ( false )
9560
9661#define HIVE_REQUIRE_EXCEPTION ( expr, assert_test, ex_type ) \
9762do { \
@@ -105,35 +70,6 @@ do { \
10570#define HIVE_REQUIRE_ASSERT ( expr, assert_test ) HIVE_REQUIRE_EXCEPTION ( expr, assert_test, fc::assert_exception )
10671#define HIVE_REQUIRE_CHAINBASE_ASSERT ( expr, assert_msg ) HIVE_REQUIRE_EXCEPTION ( expr, assert_msg, fc::exception )
10772
108- #define REQUIRE_OP_VALIDATION_FAILURE_2 ( op, field, value, exc_type ) \
109- { \
110- const auto temp = op.field ; \
111- op.field = value; \
112- HIVE_REQUIRE_THROW ( op.validate (), exc_type ); \
113- op.field = temp; \
114- }
115- #define REQUIRE_OP_VALIDATION_FAILURE ( op, field, value ) \
116- REQUIRE_OP_VALIDATION_FAILURE_2 ( op, field, value, fc::exception )
117-
118- #define REQUIRE_THROW_WITH_VALUE_2 (op, field, value, exc_type ) \
119- { \
120- auto bak = op.field ; \
121- op.field = value; \
122- trx.operations .back () = op; \
123- op.field = bak; \
124- HIVE_REQUIRE_THROW (push_transaction (trx, ~0 ), exc_type); \
125- }
126-
127- #define REQUIRE_THROW_WITH_VALUE ( op, field, value ) \
128- REQUIRE_THROW_WITH_VALUE_2 ( op, field, value, fc::exception )
129-
130- // /This simply resets v back to its default-constructed value. Requires v to have a working assignment operator and
131- // / default constructor.
132- #define RESET (v ) v = decltype (v)()
133- // /This allows me to build consecutive test cases. It's pretty ugly, but it works well enough for unit tests.
134- // / i.e. This allows a test on update_account to begin with the database at the end state of create_account.
135- #define INVOKE (test ) ((struct test *)this )->test_method (); trx.clear()
136-
13773// Default amount of VESTS (expressed in HIVE) implicitly granted to accounts created via ACTOR(S)
13874// macros. Most tests are not sensitive to the exact value; tests that are should pass an explicit
13975// amount (or NO_VESTING) and verify the chosen value does not change their results.
@@ -144,55 +80,37 @@ do { \
14480#define PREP_ACTOR (name ) \
14581 fc::ecc::private_key name ## _private_key = generate_private_key(BOOST_PP_STRINGIZE (name)); \
14682 fc::ecc::private_key name ## _post_key = generate_private_key(std::string( BOOST_PP_STRINGIZE (name) ) + " _post" ); \
147- public_key_type name ## _public_key = name ## _private_key.get_public_key();
83+ public_key_type name ## _public_key = name ## _private_key.get_public_key()
14884
14985#define ACTOR (initial_vesting, name ) \
150- PREP_ACTOR (name) \
86+ PREP_ACTOR (name); \
15187 account_create (BOOST_PP_STRINGIZE (name), name ## _public_key, name ## _post_key.get_public_key(), initial_vesting); \
152- account_id_type name ## _id = get_account_id(BOOST_PP_STRINGIZE (name)); (void )name ## _id;
88+ account_id_type name ## _id = get_account_id(BOOST_PP_STRINGIZE (name)); (void )name ## _id
15389
154- #define ACTORS_IMPL (r, data, elem ) ACTOR (data, elem)
90+ #define ACTORS_IMPL (r, data, elem ) ACTOR (data, elem);
15591#define ACTORS (initial_vesting, names ) BOOST_PP_SEQ_FOR_EACH (ACTORS_IMPL , initial_vesting, names) \
156- validate_database ();
92+ validate_database ()
15793
15894#define PREP_ACTOR_EXT (object, name ) \
15995 fc::ecc::private_key name ## _private_key = object.generate_private_key(BOOST_PP_STRINGIZE (name)); \
16096 fc::ecc::private_key name ## _post_key = object.generate_private_key(std::string( BOOST_PP_STRINGIZE (name) ) + " _post" ); \
161- public_key_type name ## _public_key = name ## _private_key.get_public_key();
97+ public_key_type name ## _public_key = name ## _private_key.get_public_key()
16298
16399#define ACTOR_EXT (object, initial_vesting, name ) \
164- PREP_ACTOR_EXT (object, name) \
100+ PREP_ACTOR_EXT (object, name); \
165101 object.account_create(BOOST_PP_STRINGIZE (name), name ## _public_key, name ## _post_key.get_public_key(), initial_vesting); \
166- account_id_type name ## _id = object.get_account_id(BOOST_PP_STRINGIZE (name)); (void )name ## _id;
102+ account_id_type name ## _id = object.get_account_id(BOOST_PP_STRINGIZE (name)); (void )name ## _id
167103
168- #define ACTORS_EXT_IMPL (r, data, elem ) ACTOR_EXT (BOOST_PP_TUPLE_ELEM (2 , 0 , data), BOOST_PP_TUPLE_ELEM (2 , 1 , data), elem)
104+ #define ACTORS_EXT_IMPL (r, data, elem ) ACTOR_EXT (BOOST_PP_TUPLE_ELEM (2 , 0 , data), BOOST_PP_TUPLE_ELEM (2 , 1 , data), elem);
169105#define ACTORS_EXT (object, initial_vesting, names ) BOOST_PP_SEQ_FOR_EACH (ACTORS_EXT_IMPL , (object, initial_vesting), names) \
170- object.validate_database();
106+ object.validate_database()
171107
172108#define ASSET ( s ) \
173109 hive::protocol::legacy_asset::from_string ( s ).to_asset()
174110
175111#define ISSUE_FUNDS ( account_name, _asset ) \
176112 issue_funds ( account_name, _asset ); \
177- generate_block ();
178-
179- #define OP2TX (OP,TX ) \
180- TX .operations.push_back( OP ); \
181- TX .set_expiration( db->head_block_time () + HIVE_MAX_TIME_UNTIL_EXPIRATION );
182-
183- #define PUSH_OP (OP,KEY ) \
184- { \
185- signed_transaction tx; \
186- OP2TX (OP ,tx) \
187- push_transaction ( tx, KEY ); \
188- }
189-
190- #define FAIL_WITH_OP (OP,KEY,EXCEPTION ) \
191- { \
192- signed_transaction tx; \
193- OP2TX (OP ,tx) \
194- HIVE_REQUIRE_THROW ( push_transaction ( tx, KEY ), EXCEPTION ); \
195- }
113+ generate_block ()
196114
197115namespace hive { namespace chain {
198116
0 commit comments