diff --git a/python/pdo/test/storage.py b/python/pdo/test/storage.py index 0e4ee1ce..87ce836a 100644 --- a/python/pdo/test/storage.py +++ b/python/pdo/test/storage.py @@ -77,19 +77,17 @@ def verify_store_signature(store_response, duration, verifying_key) : result = client.store_blocks([block_data], duration=default_duration) r = verify_store_signature(result, default_duration, client.verifying_key) - if 1 != r: - raise ValueError("verify_store_signature error: {}".format(r)) - - if 'block_ids' not in result: - raise ValueError("block_ids not in result") - - block_ids = result['block_ids'] + if r < 0 : + raise RuntimeError("unknown error occured during signature verification; {}".format(r)) + if r == 0 : + raise ValueError("storage signature verification failed") + + block_ids = result.get('block_ids') + if block_ids is None or type(block_ids) != list : + raise RuntimeError('invalid response from block store') + if len(block_ids) != 1: - raise ValueError("len of block_ids is not 1: {}".format(len(block_ids))) - if list != type(result['block_ids']): - raise ValueError("block_ids not a list") - if len(result['block_ids']) < 1: - raise ValueError("no block in block_ids") + raise ValueError("too many blocks stored, expected 1 got {}".format(len(block_ids))) block_id = result['block_ids'][0] @@ -117,19 +115,20 @@ def verify_store_signature(store_response, duration, verifying_key) : block_data.append(os.urandom(10)) block_data.append(os.urandom(10)) result = client.store_blocks(block_data, duration=default_duration) - - r = verify_store_signature(result, default_duration, client.verifying_key) - if 1 != r: - raise ValueError("verify_store_signature error: {}".format(r)) - - if 'block_ids' not in result: - raise ValueError("block_ids not in result") - - block_ids = result['block_ids'] logger.info('RESULT: %s', result) + r = verify_store_signature(result, default_duration, client.verifying_key) + if r < 0 : + raise RuntimeError("unknown error occured during signature verification; {}".format(r)) + if r == 0 : + raise ValueError("storage signature verification failed") + + block_ids = result.get('block_ids') + if block_ids is None or type(block_ids) != list : + raise RuntimeError('invalid response from block store') + if len(block_ids) != 3: - raise ValueError("block_ids should contain 3 blocks: {}".format(len(block_ids))) + raise ValueError("too many blocks stored, expected 3 got {}".format(len(block_ids))) except Exception as e : logger.error('bulk upload test failed; %s', str(e))