@@ -49,6 +49,12 @@ def eval_stat(time_cost, func_name):
49
49
"sec, including 95% of API call time consumption" )
50
50
51
51
52
+ def fill_nines (trytes , output_len ):
53
+ out_str = trytes + "9" * (output_len - len (trytes ))
54
+
55
+ return out_str
56
+
57
+
52
58
def gen_rand_trytes (tryte_len ):
53
59
trytes = ""
54
60
for i in range (tryte_len ):
@@ -130,7 +136,7 @@ def test_mam_send_msg(self):
130
136
131
137
response = []
132
138
for i in range (len (query_string )):
133
- logging .debug ("testing case = " + str (query_string [i ]))
139
+ logging .debug ("testing case = " + repr (query_string [i ]))
134
140
if i == 5 :
135
141
post_data_json = query_string [i ]
136
142
elif i == 6 :
@@ -247,7 +253,7 @@ def test_send_transfer(self):
247
253
248
254
response = []
249
255
for i in range (len (query_string )):
250
- logging .debug ("testing case = " + str (query_string [i ]))
256
+ logging .debug ("testing case = " + repr (query_string [i ]))
251
257
post_data = {
252
258
"value" : query_string [i ][0 ],
253
259
"message" : query_string [i ][1 ],
@@ -689,6 +695,68 @@ def test_generate_address(self):
689
695
690
696
eval_stat (time_cost , "generate_address" )
691
697
698
+ def test_send_trytes (self ):
699
+ logging .debug (
700
+ "\n ================================send_trytes================================"
701
+ )
702
+ # cmd
703
+ # 0. single 2673 trytes legal transaction object
704
+ # 1. multiple 2673 ligal trytes transaction object
705
+ # 2. single 200 trytes illegal transaction object
706
+ # 3. single single 3000 trytes illegal transaction object
707
+ # 4. single unicode illegal transaction object
708
+ # 5. empty trytes list
709
+ # 6. empty not trytes list object
710
+ rand_trytes = []
711
+ for i in range (2 ):
712
+ all_9_context = fill_nines ("" , 2673 - 81 * 3 )
713
+ tips_response = API ("/tips/pair/" , get_data = "" )
714
+ res_json = json .loads (tips_response ["content" ])
715
+ tips = res_json ["tips" ]
716
+
717
+ rand_trytes .append (all_9_context + tips [0 ] + tips [1 ] +
718
+ fill_nines ("" , 81 ))
719
+
720
+ query_string = [[rand_trytes [0 ]], [rand_trytes [0 ], rand_trytes [1 ]],
721
+ [gen_rand_trytes (200 )], [gen_rand_trytes (3000 )],
722
+ ["逼類不司" ], ["" ], "" ]
723
+
724
+ response = []
725
+ for i in range (len (query_string )):
726
+ logging .debug ("testing case = " + repr (query_string [i ]))
727
+ post_data = {"trytes" : query_string [i ]}
728
+ logging .debug ("post_data = " + repr (post_data ))
729
+ post_data_json = json .dumps (post_data )
730
+ response .append (API ("/tryte" , post_data = post_data_json ))
731
+
732
+ for i in range (len (response )):
733
+ logging .debug ("send_trytes i = " + str (i ) + ", res = " +
734
+ response [i ]["content" ] + ", status code = " +
735
+ response [i ]["status_code" ])
736
+
737
+ pass_case = [0 , 1 ]
738
+ for i in range (len (response )):
739
+ logging .debug ("send_trytes i = " + str (i ) + ", res = " +
740
+ response [i ]["content" ] + ", status code = " +
741
+ response [i ]["status_code" ])
742
+ if i in pass_case :
743
+ res_json = json .loads (response [i ]["content" ])
744
+
745
+ self .assertEqual (query_string [i ], res_json ["trytes" ])
746
+ else :
747
+ self .assertEqual (STATUS_CODE_500 , response [i ]["status_code" ])
748
+
749
+ # Time Statistics
750
+ time_cost = []
751
+ post_data = {"trytes" : [rand_trytes [0 ]]}
752
+ post_data_json = json .dumps (post_data )
753
+ for i in range (TIMES_TOTAL ):
754
+ start_time = time .time ()
755
+ API ("/tryte" , post_data = post_data_json )
756
+ time_cost .append (time .time () - start_time )
757
+
758
+ eval_stat (time_cost , "send trytes" )
759
+
692
760
693
761
"""
694
762
API List
0 commit comments