@@ -77,19 +77,17 @@ def verify_store_signature(store_response, duration, verifying_key) :
77
77
result = client .store_blocks ([block_data ], duration = default_duration )
78
78
79
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" )
85
-
86
- block_ids = result ['block_ids' ]
80
+ if r < 0 :
81
+ raise RuntimeError ("unknown error occured during signature verification; {}" .format (r ))
82
+ if r == 0 :
83
+ raise ValueError ("storage signature verification failed" )
84
+
85
+ block_ids = result .get ('block_ids' )
86
+ if block_ids is None or type (block_ids ) != list :
87
+ raise RuntimeError ('invalid response from block store' )
88
+
87
89
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" )
90
+ raise ValueError ("too many blocks stored, expected 1 got {}" .format (len (block_ids )))
93
91
94
92
block_id = result ['block_ids' ][0 ]
95
93
@@ -117,19 +115,20 @@ def verify_store_signature(store_response, duration, verifying_key) :
117
115
block_data .append (os .urandom (10 ))
118
116
block_data .append (os .urandom (10 ))
119
117
result = client .store_blocks (block_data , duration = default_duration )
120
-
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" )
127
-
128
- block_ids = result ['block_ids' ]
129
118
logger .info ('RESULT: %s' , result )
130
119
120
+ r = verify_store_signature (result , default_duration , client .verifying_key )
121
+ if r < 0 :
122
+ raise RuntimeError ("unknown error occured during signature verification; {}" .format (r ))
123
+ if r == 0 :
124
+ raise ValueError ("storage signature verification failed" )
125
+
126
+ block_ids = result .get ('block_ids' )
127
+ if block_ids is None or type (block_ids ) != list :
128
+ raise RuntimeError ('invalid response from block store' )
129
+
131
130
if len (block_ids ) != 3 :
132
- raise ValueError ("block_ids should contain 3 blocks: {}" .format (len (block_ids )))
131
+ raise ValueError ("too many blocks stored, expected 3 got {}" .format (len (block_ids )))
133
132
134
133
except Exception as e :
135
134
logger .error ('bulk upload test failed; %s' , str (e ))
0 commit comments