@@ -75,15 +75,23 @@ def verify_store_signature(store_response, duration, verifying_key) :
75
75
try :
76
76
block_data = os .urandom (1000 )
77
77
result = client .store_blocks ([block_data ], duration = default_duration )
78
- assert result
79
78
80
- assert (1 == verify_store_signature (result , default_duration , client .verifying_key ))
79
+ r = verify_store_signature (result , default_duration , client .verifying_key )
80
+ if 1 != r :
81
+ raise ValueError ("verify_store_signature error: {}" .format (r ))
82
+
83
+ if 'block_ids' not in result :
84
+ raise ValueError ("block_ids not in result" )
81
85
82
86
block_ids = result ['block_ids' ]
83
- assert block_ids and len (block_ids ) == 1
87
+ if len (block_ids ) != 1 :
88
+ raise ValueError ("len of block_ids is not 1: {}" .format (len (block_ids )))
89
+ if list != type (result ['block_ids' ]):
90
+ raise ValueError ("block_ids not a list" )
91
+ if len (result ['block_ids' ]) < 1 :
92
+ raise ValueError ("no block in block_ids" )
84
93
85
94
block_id = result ['block_ids' ][0 ]
86
- assert block_id
87
95
88
96
except Exception as e :
89
97
logger .error ('put test failed; %s' , str (e ))
@@ -94,7 +102,8 @@ def verify_store_signature(store_response, duration, verifying_key) :
94
102
# -----------------------------------------------------------------
95
103
try :
96
104
verify_block_data = client .get_block (block_id )
97
- assert block_data == verify_block_data
105
+ if block_data != verify_block_data :
106
+ raise ValueError ("retrieved block data different than expected" )
98
107
except Exception as e :
99
108
logger .error ('verify put test failed; %s' , str (e ))
100
109
sys .exit (- 1 )
@@ -108,13 +117,19 @@ def verify_store_signature(store_response, duration, verifying_key) :
108
117
block_data .append (os .urandom (10 ))
109
118
block_data .append (os .urandom (10 ))
110
119
result = client .store_blocks (block_data , duration = default_duration )
111
- assert result
112
120
113
- assert (1 == verify_store_signature (result , default_duration , client .verifying_key ))
121
+ r = verify_store_signature (result , default_duration , client .verifying_key )
122
+ if 1 != r :
123
+ raise ValueError ("verify_store_signature error: {}" .format (r ))
124
+
125
+ if 'block_ids' not in result :
126
+ raise ValueError ("block_ids not in result" )
114
127
115
128
block_ids = result ['block_ids' ]
116
129
logger .info ('RESULT: %s' , result )
117
- assert block_ids and len (block_ids ) == 3
130
+
131
+ if len (block_ids ) != 3 :
132
+ raise ValueError ("block_ids should contain 3 blocks: {}" .format (len (block_ids )))
118
133
119
134
except Exception as e :
120
135
logger .error ('bulk upload test failed; %s' , str (e ))
@@ -126,7 +141,8 @@ def verify_store_signature(store_response, duration, verifying_key) :
126
141
try :
127
142
for i in range (len (block_ids )) :
128
143
verify_block_data = client .get_block (block_ids [i ])
129
- assert block_data [i ] == verify_block_data
144
+ if block_data [i ] != verify_block_data :
145
+ raise ValueError ("retrieved block data different than expected: index {}" .format (i ))
130
146
except Exception as e :
131
147
logger .error ('failed to verify bulk upload; %s' , str (e ))
132
148
sys .exit (- 1 )
@@ -137,7 +153,8 @@ def verify_store_signature(store_response, duration, verifying_key) :
137
153
try :
138
154
verify_block_data_list = client .get_blocks (block_ids )
139
155
for i in range (len (block_ids )) :
140
- assert block_data [i ] == verify_block_data_list [i ]
156
+ if block_data [i ] != verify_block_data_list [i ]:
157
+ raise ValueError ("retrieved block data different than expected in list: index {}" .format (i ))
141
158
except Exception as e :
142
159
logger .error ('failed to verify bulk upload; %s' , str (e ))
143
160
sys .exit (- 1 )
@@ -149,8 +166,10 @@ def verify_store_signature(store_response, duration, verifying_key) :
149
166
status = client .check_blocks (block_ids )
150
167
assert status and len (status ) == 3
151
168
for s in status :
152
- assert s ['size' ] == 10
153
- assert 0 < s ['duration' ] and s ['duration' ] <= default_duration
169
+ if s ['size' ] != 10 :
170
+ raise ValueError ("status size not 10: {}" .format (s ['size' ]))
171
+ if 0 >= s ['duration' ] and s ['duration' ] > default_duration :
172
+ raise ValueError ("block status duration not within range: {}" .format (s ['duration' ]))
154
173
155
174
except Exception as e :
156
175
logger .exception ('bulk status failed; %s' , str (e ))
0 commit comments