@@ -121,7 +121,7 @@ string U128Str(unsigned __int128 i)
121
121
}
122
122
123
123
template <typename T>
124
- void CallAction (tester& test, T ac, const vector<account_name>& scope = {N (testapi)}) {
124
+ transaction_trace CallAction (tester& test, T ac, const vector<account_name>& scope = {N (testapi)}) {
125
125
signed_transaction trx;
126
126
127
127
auto pl = vector<permission_level>{{scope[0 ], config::active_name}};
@@ -138,10 +138,11 @@ void CallAction(tester& test, T ac, const vector<account_name>& scope = {N(testa
138
138
auto res = test.push_transaction (trx);
139
139
BOOST_CHECK_EQUAL (res.status , transaction_receipt::executed);
140
140
test.produce_block ();
141
+ return res;
141
142
}
142
143
143
144
template <typename T>
144
- void CallFunction (tester& test, T ac, const vector<char >& data, const vector<account_name>& scope = {N (testapi)}) {
145
+ transaction_trace CallFunction (tester& test, T ac, const vector<char >& data, const vector<account_name>& scope = {N (testapi)}) {
145
146
{
146
147
signed_transaction trx;
147
148
@@ -160,6 +161,7 @@ void CallFunction(tester& test, T ac, const vector<char>& data, const vector<acc
160
161
auto res = test.push_transaction (trx);
161
162
BOOST_CHECK_EQUAL (res.status , transaction_receipt::executed);
162
163
test.produce_block ();
164
+ return res;
163
165
}
164
166
}
165
167
@@ -223,23 +225,6 @@ struct MySink : public bio::sink
223
225
};
224
226
uint32_t last_fnc_err = 0 ;
225
227
226
- #define CAPTURE (STREAM, EXEC ) \
227
- {\
228
- capture.clear (); \
229
- bio::stream_buffer<MySink> sb; sb.open (MySink ()); \
230
- std::streambuf *oldbuf = std::STREAM.rdbuf (&sb); \
231
- EXEC; \
232
- std::STREAM.rdbuf (oldbuf); \
233
- }
234
-
235
- #define CAPTURE_AND_PRE_TEST_PRINT (METHOD ) \
236
- { \
237
- BOOST_TEST_MESSAGE ( " Running test_print::" << METHOD ); \
238
- CAPTURE ( cerr, CALL_TEST_FUNCTION ( *this , " test_print" , METHOD, {} ) ); \
239
- BOOST_CHECK_EQUAL ( capture.size (), 7 ); \
240
- captured = capture[3 ]; \
241
- }
242
-
243
228
/* ************************************************************************************
244
229
* action_tests test case
245
230
*************************************************************************************/
@@ -625,10 +610,9 @@ BOOST_FIXTURE_TEST_CASE(transaction_tests, tester) { try {
625
610
626
611
// test test_read_transaction
627
612
// this is a bit rough, but I couldn't figure out a better way to compare the hashes
628
- CAPTURE ( cerr, CALL_TEST_FUNCTION ( *this , " test_transaction" , " test_read_transaction" , {} ) );
629
- BOOST_CHECK_EQUAL ( capture.size (), 7 );
613
+ auto tx_trace = CALL_TEST_FUNCTION ( *this , " test_transaction" , " test_read_transaction" , {} );
630
614
string sha_expect = " bdeb5b58dda272e4b23ee7d2a5f0ff034820c156364893b758892e06fa39e7fe" ;
631
- BOOST_CHECK_EQUAL (capture[ 3 ] == sha_expect, true );
615
+ BOOST_CHECK_EQUAL (tx_trace. action_traces . front (). console == sha_expect, true );
632
616
// test test_tapos_block_num
633
617
CALL_TEST_FUNCTION (*this , " test_transaction" , " test_tapos_block_num" , fc::raw::pack (control->head_block_num ()) );
634
618
@@ -755,7 +739,7 @@ BOOST_FIXTURE_TEST_CASE(db_tests, tester) { try {
755
739
CALL_TEST_FUNCTION ( *this , " test_db" , " idx64_general" , {});
756
740
CALL_TEST_FUNCTION ( *this , " test_db" , " idx64_lowerbound" , {});
757
741
CALL_TEST_FUNCTION ( *this , " test_db" , " idx64_upperbound" , {});
758
-
742
+
759
743
} FC_LOG_AND_RETHROW () }
760
744
/* ************************************************************************************
761
745
* multi_index_tests test case
@@ -1032,41 +1016,48 @@ BOOST_FIXTURE_TEST_CASE(print_tests, tester) { try {
1032
1016
string captured = " " ;
1033
1017
1034
1018
// test prints
1035
- CAPTURE_AND_PRE_TEST_PRINT (" test_prints" );
1036
- BOOST_CHECK_EQUAL (captured == " abcefg" , true );
1037
-
1038
- // test prints_l
1039
- CAPTURE_AND_PRE_TEST_PRINT (" test_prints_l" );
1040
- BOOST_CHECK_EQUAL (captured == " abatest" , true );
1041
-
1042
- // test printi
1043
- CAPTURE_AND_PRE_TEST_PRINT (" test_printi" );
1044
- BOOST_CHECK_EQUAL ( captured.substr (0 ,1 ), I64Str (0 ) );
1045
- BOOST_CHECK_EQUAL ( captured.substr (1 ,6 ), I64Str (556644 ) );
1046
- BOOST_CHECK_EQUAL ( captured.substr (7 , capture[3 ].size ()), I64Str (-1 ) );
1047
-
1048
- // test printui
1049
- CAPTURE_AND_PRE_TEST_PRINT (" test_printui" );
1050
- BOOST_CHECK_EQUAL ( captured.substr (0 ,1 ), U64Str (0 ) );
1051
- BOOST_CHECK_EQUAL ( captured.substr (1 ,6 ), U64Str (556644 ) );
1052
- BOOST_CHECK_EQUAL ( captured.substr (7 , capture[3 ].size ()), U64Str (-1 ) ); // "18446744073709551615"
1053
-
1054
- // test printn
1055
- CAPTURE_AND_PRE_TEST_PRINT (" test_printn" );
1056
- BOOST_CHECK_EQUAL ( captured.substr (0 ,5 ), " abcde" );
1057
- BOOST_CHECK_EQUAL ( captured.substr (5 , 5 ), " ab.de" );
1058
- BOOST_CHECK_EQUAL ( captured.substr (10 , 6 ), " 1q1q1q" );
1059
- BOOST_CHECK_EQUAL ( captured.substr (16 , 11 ), " abcdefghijk" );
1060
- BOOST_CHECK_EQUAL ( captured.substr (27 , 12 ), " abcdefghijkl" );
1061
- BOOST_CHECK_EQUAL ( captured.substr (39 , 13 ), " abcdefghijkl1" );
1062
- BOOST_CHECK_EQUAL ( captured.substr (52 , 13 ), " abcdefghijkl1" );
1063
- BOOST_CHECK_EQUAL ( captured.substr (65 , 13 ), " abcdefghijkl1" );
1064
-
1065
- // test printi128
1066
- CAPTURE_AND_PRE_TEST_PRINT (" test_printi128" );
1067
- BOOST_CHECK_EQUAL ( captured.substr (0 , 39 ), U128Str (-1 ) );
1068
- BOOST_CHECK_EQUAL ( captured.substr (39 , 1 ), U128Str (0 ) );
1069
- BOOST_CHECK_EQUAL ( captured.substr (40 , 11 ), U128Str (87654323456 ) );
1019
+ auto tx1_trace = CALL_TEST_FUNCTION ( *this , " test_print" , " test_prints" , {} );
1020
+ auto tx1_act_cnsl = tx1_trace.action_traces .front ().console ;
1021
+ BOOST_CHECK_EQUAL (tx1_act_cnsl == " abcefg" , true );
1022
+
1023
+ // test prints_l
1024
+ auto tx2_trace = CALL_TEST_FUNCTION ( *this , " test_print" , " test_prints_l" , {} );
1025
+ auto tx2_act_cnsl = tx2_trace.action_traces .front ().console ;
1026
+ BOOST_CHECK_EQUAL (tx2_act_cnsl == " abatest" , true );
1027
+
1028
+
1029
+ // test printi
1030
+ auto tx3_trace = CALL_TEST_FUNCTION ( *this , " test_print" , " test_printi" , {} );
1031
+ auto tx3_act_cnsl = tx3_trace.action_traces .front ().console ;
1032
+ BOOST_CHECK_EQUAL ( tx3_act_cnsl.substr (0 ,1 ), I64Str (0 ) );
1033
+ BOOST_CHECK_EQUAL ( tx3_act_cnsl.substr (1 ,6 ), I64Str (556644 ) );
1034
+ BOOST_CHECK_EQUAL ( tx3_act_cnsl.substr (7 , std::string::npos), I64Str (-1 ) );
1035
+
1036
+ // test printui
1037
+ auto tx4_trace = CALL_TEST_FUNCTION ( *this , " test_print" , " test_printui" , {} );
1038
+ auto tx4_act_cnsl = tx4_trace.action_traces .front ().console ;
1039
+ BOOST_CHECK_EQUAL ( tx4_act_cnsl.substr (0 ,1 ), U64Str (0 ) );
1040
+ BOOST_CHECK_EQUAL ( tx4_act_cnsl.substr (1 ,6 ), U64Str (556644 ) );
1041
+ BOOST_CHECK_EQUAL ( tx4_act_cnsl.substr (7 , std::string::npos), U64Str (-1 ) ); // "18446744073709551615"
1042
+
1043
+ // test printn
1044
+ auto tx5_trace = CALL_TEST_FUNCTION ( *this , " test_print" , " test_printn" , {} );
1045
+ auto tx5_act_cnsl = tx5_trace.action_traces .front ().console ;
1046
+ BOOST_CHECK_EQUAL ( tx5_act_cnsl.substr (0 ,5 ), " abcde" );
1047
+ BOOST_CHECK_EQUAL ( tx5_act_cnsl.substr (5 , 5 ), " ab.de" );
1048
+ BOOST_CHECK_EQUAL ( tx5_act_cnsl.substr (10 , 6 ), " 1q1q1q" );
1049
+ BOOST_CHECK_EQUAL ( tx5_act_cnsl.substr (16 , 11 ), " abcdefghijk" );
1050
+ BOOST_CHECK_EQUAL ( tx5_act_cnsl.substr (27 , 12 ), " abcdefghijkl" );
1051
+ BOOST_CHECK_EQUAL ( tx5_act_cnsl.substr (39 , 13 ), " abcdefghijkl1" );
1052
+ BOOST_CHECK_EQUAL ( tx5_act_cnsl.substr (52 , 13 ), " abcdefghijkl1" );
1053
+ BOOST_CHECK_EQUAL ( tx5_act_cnsl.substr (65 , 13 ), " abcdefghijkl1" );
1054
+
1055
+ // test printi128
1056
+ auto tx6_trace = CALL_TEST_FUNCTION ( *this , " test_print" , " test_printi128" , {} );
1057
+ auto tx6_act_cnsl = tx6_trace.action_traces .front ().console ;
1058
+ BOOST_CHECK_EQUAL ( tx6_act_cnsl.substr (0 , 39 ), U128Str (-1 ) );
1059
+ BOOST_CHECK_EQUAL ( tx6_act_cnsl.substr (39 , 1 ), U128Str (0 ) );
1060
+ BOOST_CHECK_EQUAL ( tx6_act_cnsl.substr (40 , 11 ), U128Str (87654323456 ) );
1070
1061
1071
1062
} FC_LOG_AND_RETHROW () }
1072
1063
0 commit comments