@@ -42,7 +42,8 @@ void test_generate_address(void) {
4242
4343 for (size_t count = 0 ; count < TEST_COUNT ; count ++ ) {
4444 test_time_start (& start_time );
45- TEST_ASSERT_FALSE (
45+ TEST_ASSERT_EQUAL_INT32 (
46+ SC_OK ,
4647 api_generate_address (& ta_core .tangle , & ta_core .service , & json_result ));
4748 test_time_end (& start_time , & end_time , & sum );
4849 free (json_result );
@@ -56,7 +57,8 @@ void test_get_tips_pair(void) {
5657
5758 for (size_t count = 0 ; count < TEST_COUNT ; count ++ ) {
5859 test_time_start (& start_time );
59- TEST_ASSERT_FALSE (
60+ TEST_ASSERT_EQUAL_INT32 (
61+ SC_OK ,
6062 api_get_tips_pair (& ta_core .tangle , & ta_core .service , & json_result ));
6163 test_time_end (& start_time , & end_time , & sum );
6264 free (json_result );
@@ -70,7 +72,8 @@ void test_get_tips(void) {
7072
7173 for (size_t count = 0 ; count < TEST_COUNT ; count ++ ) {
7274 test_time_start (& start_time );
73- TEST_ASSERT_FALSE (api_get_tips (& ta_core .service , & json_result ));
75+ TEST_ASSERT_EQUAL_INT32 (SC_OK ,
76+ api_get_tips (& ta_core .service , & json_result ));
7477 test_time_end (& start_time , & end_time , & sum );
7578 free (json_result );
7679 }
@@ -88,8 +91,9 @@ void test_send_transfer(void) {
8891
8992 for (size_t count = 0 ; count < TEST_COUNT ; count ++ ) {
9093 test_time_start (& start_time );
91- TEST_ASSERT_FALSE (api_send_transfer (& ta_core .tangle , & ta_core .service , json ,
92- & json_result ));
94+ TEST_ASSERT_EQUAL_INT32 (
95+ SC_OK , api_send_transfer (& ta_core .tangle , & ta_core .service , json ,
96+ & json_result ));
9397 test_time_end (& start_time , & end_time , & sum );
9498 free (json_result );
9599 }
@@ -102,8 +106,9 @@ void test_get_transaction_object(void) {
102106
103107 for (size_t count = 0 ; count < TEST_COUNT ; count ++ ) {
104108 test_time_start (& start_time );
105- TEST_ASSERT_FALSE (api_get_transaction_object (& ta_core .service , TRYTES_81_3 ,
106- & json_result ));
109+ TEST_ASSERT_EQUAL_INT32 (
110+ SC_OK , api_get_transaction_object (& ta_core .service , TRYTES_81_3 ,
111+ & json_result ));
107112 test_time_end (& start_time , & end_time , & sum );
108113 free (json_result );
109114 }
@@ -116,8 +121,10 @@ void test_find_transactions_by_tag(void) {
116121
117122 for (size_t count = 0 ; count < TEST_COUNT ; count ++ ) {
118123 test_time_start (& start_time );
119- TEST_ASSERT_FALSE (api_find_transactions_by_tag (& ta_core .service ,
120- FIND_TAG_MSG , & json_result ));
124+
125+ TEST_ASSERT_EQUAL_INT32 (
126+ SC_OK , api_find_transactions_by_tag (& ta_core .service , FIND_TAG_MSG ,
127+ & json_result ));
121128 test_time_end (& start_time , & end_time , & sum );
122129 free (json_result );
123130 }
@@ -130,24 +137,57 @@ void test_find_transactions_obj_by_tag(void) {
130137
131138 for (size_t count = 0 ; count < TEST_COUNT ; count ++ ) {
132139 test_time_start (& start_time );
133- TEST_ASSERT_FALSE (api_find_transactions_obj_by_tag (
134- & ta_core .service , FIND_TAG_MSG , & json_result ));
140+
141+ TEST_ASSERT_EQUAL_INT32 (
142+ SC_OK , api_find_transactions_obj_by_tag (& ta_core .service , FIND_TAG_MSG ,
143+ & json_result ));
135144 test_time_end (& start_time , & end_time , & sum );
136145 free (json_result );
137146 }
138147 printf ("Average time of find_tx_obj_by_tag: %lf\n" , sum / TEST_COUNT );
139148}
140149
150+ void test_send_mam_message (void ) {
151+ double sum = 0 ;
152+
153+ char * bundle_hash_result ;
154+ char * channel_id_result ;
155+
156+ for (size_t count = 0 ; count < TEST_COUNT ; count ++ ) {
157+ test_time_start (& start_time );
158+ TEST_ASSERT_EQUAL_INT32 (
159+ SC_OK ,
160+ api_mam_send_message (& ta_core .tangle , & ta_core .service , TEST_PAYLOAD ,
161+ & bundle_hash_result , & channel_id_result ));
162+ test_time_end (& start_time , & end_time , & sum );
163+
164+ for (size_t i = 0 ; i < FLEX_TRIT_SIZE_243 ; i ++ ) {
165+ printf ("%c" , channel_id_result [i ]);
166+ }
167+ printf ("\n" );
168+ printf ("Bundle: " );
169+ for (size_t i = 0 ; i < FLEX_TRIT_SIZE_243 ; i ++ ) {
170+ printf ("%c" , bundle_hash_result [i ]);
171+ }
172+ printf ("\n" );
173+
174+ free (bundle_hash_result );
175+ free (channel_id_result );
176+ }
177+ printf ("Average time of receive_mam_message: %lf\n" , sum / TEST_COUNT );
178+ }
179+
141180void test_receive_mam_message (void ) {
142181 char * json_result ;
143182 double sum = 0 ;
144- status_t ret = SC_OK ;
183+
145184 for (size_t count = 0 ; count < TEST_COUNT ; count ++ ) {
146- clock_gettime (CLOCK_REALTIME , & start_time );
147- ret = api_receive_mam_message (& ta_core .service , TEST_BUNDLE_HASH ,
148- & json_result );
149- TEST_ASSERT_EQUAL_INT32 (ret , SC_OK );
150- clock_gettime (CLOCK_REALTIME , & end_time );
185+ test_time_start (& start_time );
186+
187+ TEST_ASSERT_EQUAL_INT32 (
188+ SC_OK , api_receive_mam_message (& ta_core .service , TEST_BUNDLE_HASH ,
189+ & json_result ));
190+ test_time_end (& start_time , & end_time , & sum );
151191 free (json_result );
152192 }
153193 printf ("Average time of receive_mam_message: %lf\n" , sum / TEST_COUNT );
@@ -167,6 +207,7 @@ int main(void) {
167207 RUN_TEST (test_find_transactions_by_tag );
168208 RUN_TEST (test_find_transactions_obj_by_tag );
169209 RUN_TEST (test_receive_mam_message );
210+ RUN_TEST (test_send_mam_message );
170211 ta_config_destroy (& ta_core .service );
171212 return UNITY_END ();
172213}
0 commit comments