fixes datastore_blockchain_id integration test

This commit is contained in:
Aaron Blankstein
2017-08-18 14:25:01 -04:00
parent c49c225b10
commit 4d333728cd

View File

@@ -88,31 +88,31 @@ def scenario( wallets, **kw ):
# tell serialization-checker that value_hash can be ignored here
print "BLOCKSTACK_SERIALIZATION_CHECK_IGNORE value_hash"
sys.stdout.flush()
testlib.next_block( **kw )
# sign in and make a token
# sign in and make a token
datastore_pk = keylib.ECPrivateKey(wallets[-1].privkey).to_hex()
res = testlib.blockstack_cli_app_signin("foo.test", datastore_pk, 'http://localhost:8888', ['store_read', 'store_write', 'store_admin'])
if 'error' in res:
print json.dumps(res, indent=4, sort_keys=True)
error = True
return
return
# export to environment
# export to environment
blockstack_client.set_secret("BLOCKSTACK_API_SESSION", res['token'])
ses = res['token']
datastore_id_res = testlib.blockstack_cli_datastore_get_id( datastore_pk )
datastore_id = datastore_id_res['datastore_id']
# use random data for file
# use random data for file
file_data = None
with open('/dev/urandom', 'r') as f:
file_data = f.read(16384)
# make datastore
# make datastore
res = testlib.blockstack_cli_create_datastore( 'foo.test', datastore_pk, ['disk'], ses )
if 'error' in res:
print "failed to create datastore: {}".format(res['error'])
@@ -142,10 +142,10 @@ def scenario( wallets, **kw ):
print 'wrong errno in error {}'.format(res)
return False
# stat directories
# stat directories
for dpath in ['/dir1', '/dir2', '/dir1/dir3', '/dir1/dir3/dir4']:
print 'stat {}'.format(dpath)
res = testlib.blockstack_cli_datastore_stat( "foo.test", datastore_id, dpath, None )
res = testlib.blockstack_cli_datastore_stat( "foo.test", datastore_id, dpath, ses )
if 'error' in res:
print 'failed to stat {}: {}'.format(dpath, res['error'])
return False
@@ -154,10 +154,10 @@ def scenario( wallets, **kw ):
print 'not a directory: {}, {}'.format(dpath, res)
return False
# list directories
# list directories
for dpath, expected in [('/', ['dir1', 'dir2']), ('/dir1', ['dir3']), ('/dir1/dir3', ['dir4']), ('/dir1/dir3/dir4', [])]:
print 'listdir {}'.format(dpath)
res = testlib.blockstack_cli_datastore_listdir( "foo.test", datastore_id, dpath, None )
res = testlib.blockstack_cli_datastore_listdir( "foo.test", datastore_id, dpath, ses )
if 'error' in res:
print 'failed to listdir {}: {}'.format(dpath, res['error'])
return False
@@ -167,12 +167,12 @@ def scenario( wallets, **kw ):
print 'invalid directory: expected:\n{}\ngot:\n{}\n'.format(expected, res)
return False
for child in expected:
for child in expected:
if not res['children'].has_key(child):
print 'invalid directory: missing {} in {}'.format(child, res)
return False
# put files
# put files
for dpath in ['/file1', '/file2', '/dir1/file3', '/dir1/dir3/file4', '/dir1/dir3/dir4/file5']:
print 'putfile {}'.format(dpath)
data = '{} hello {}'.format(file_data, dpath)
@@ -184,7 +184,7 @@ def scenario( wallets, **kw ):
# stat files
for dpath in ['/file1', '/file2', '/dir1/file3', '/dir1/dir3/file4', '/dir1/dir3/dir4/file5']:
print 'stat {}'.format(dpath)
res = testlib.blockstack_cli_datastore_stat( "foo.test", datastore_id, dpath, None )
res = testlib.blockstack_cli_datastore_stat( "foo.test", datastore_id, dpath, ses )
if 'error' in res:
print 'failed to stat {}: {}'.format(dpath, res['error'])
return False
@@ -193,10 +193,10 @@ def scenario( wallets, **kw ):
print 'not a file: {}, {}'.format(dpath, res)
return False
# list directories again
# list directories again
for dpath, expected in [('/', ['dir1', 'dir2', 'file1', 'file2']), ('/dir1', ['dir3', 'file3']), ('/dir1/dir3', ['dir4', 'file4']), ('/dir1/dir3/dir4', ['file5'])]:
print 'listdir {}'.format(dpath)
res = testlib.blockstack_cli_datastore_listdir( "foo.test", datastore_id, dpath, None )
res = testlib.blockstack_cli_datastore_listdir( "foo.test", datastore_id, dpath, ses )
if 'error' in res:
print 'failed to listdir {}: {}'.format(dpath, res['error'])
return False
@@ -205,15 +205,15 @@ def scenario( wallets, **kw ):
print 'invalid directory: expected:\n{}\ngot:\n{}\n'.format(expected, res)
return False
for child in expected:
for child in expected:
if not res['children'].has_key(child):
print 'invalid directory: missing {} in {}'.format(child, res)
return False
# get files
for dpath in ['/file1', '/file2', '/dir1/file3', '/dir1/dir3/file4', '/dir1/dir3/dir4/file5']:
print 'getfile {}'.format(dpath)
res = testlib.blockstack_cli_datastore_getfile( "foo.test", datastore_id, dpath, None )
res = testlib.blockstack_cli_datastore_getfile( "foo.test", datastore_id, dpath, ses )
if 'error' in res:
print 'failed to getfile {}: {}'.format(dpath, res['error'])
return False
@@ -222,7 +222,7 @@ def scenario( wallets, **kw ):
print 'failed to read {}'.format(dpath)
return False
# put files again!
# put files again!
for dpath in ['/file1', '/file2', '/dir1/file3', '/dir1/dir3/file4', '/dir1/dir3/dir4/file5']:
print 'putfile {}'.format(dpath)
data = '{} hello 2 {}'.format(file_data, dpath)
@@ -234,7 +234,7 @@ def scenario( wallets, **kw ):
# get files again!
for dpath in ['/file1', '/file2', '/dir1/file3', '/dir1/dir3/file4', '/dir1/dir3/dir4/file5']:
print 'getfile {}'.format(dpath)
res = testlib.blockstack_cli_datastore_getfile( "foo.test", datastore_id, dpath, None )
res = testlib.blockstack_cli_datastore_getfile( "foo.test", datastore_id, dpath, ses )
if 'error' in res:
print 'failed to getfile {}: {}'.format(dpath, res['error'])
return False
@@ -254,7 +254,7 @@ def scenario( wallets, **kw ):
# stat files (should all fail)
for dpath in ['/file1', '/file2', '/dir1/file3', '/dir1/dir3/file4', '/dir1/dir3/dir4/file5']:
print 'stat {} (expect failure)'.format(dpath)
res = testlib.blockstack_cli_datastore_stat( "foo.test", datastore_id, dpath, None )
res = testlib.blockstack_cli_datastore_stat( "foo.test", datastore_id, dpath, ses )
if 'error' not in res or 'errno' not in res:
print 'accidentally succeeded to stat {}: {}'.format(dpath, res)
return False
@@ -262,11 +262,11 @@ def scenario( wallets, **kw ):
if res['errno'] != errno.ENOENT:
print 'wrong errno: {}'.format(res)
return False
# get files (should all fail)
for dpath in ['/file1', '/file2', '/dir1/file3', '/dir1/dir3/file4', '/dir1/dir3/dir4/file5']:
print 'getfile {} (expect failure)'.format(dpath)
res = testlib.blockstack_cli_datastore_getfile( "foo.test", datastore_id, dpath, None )
res = testlib.blockstack_cli_datastore_getfile( "foo.test", datastore_id, dpath, ses )
if 'error' not in res or 'errno' not in res:
print 'accidentally succeeded to get {}: {}'.format(dpath, res)
return False
@@ -275,10 +275,10 @@ def scenario( wallets, **kw ):
print 'wrong errno: {}'.format(res)
return False
# list directories, 3rd time
# list directories, 3rd time
for dpath, expected in [('/', ['dir1', 'dir2']), ('/dir1', ['dir3']), ('/dir1/dir3', ['dir4']), ('/dir1/dir3/dir4', [])]:
print 'listdir {}'.format(dpath)
res = testlib.blockstack_cli_datastore_listdir( "foo.test", datastore_id, dpath, None )
res = testlib.blockstack_cli_datastore_listdir( "foo.test", datastore_id, dpath, ses )
if 'error' in res:
print 'failed to listdir {}: {}'.format(dpath, res['error'])
return False
@@ -287,12 +287,12 @@ def scenario( wallets, **kw ):
print 'invalid directory: expected:\n{}\ngot:\n{}\n'.format(expected, res)
return False
for child in expected:
for child in expected:
if not res['children'].has_key(child):
print 'invalid directory: missing {} in {}'.format(child, res)
return False
# remove directories
# remove directories
for dpath in ['/dir1/dir3/dir4', '/dir1/dir3', '/dir2', '/dir1']:
print 'rmdir {}'.format(dpath)
res = testlib.blockstack_cli_datastore_rmdir( "foo.test", datastore_pk, dpath, ses )
@@ -303,7 +303,7 @@ def scenario( wallets, **kw ):
# stat directories (should all fail)
for dpath in ['/dir1/dir3/dir4', '/dir1/dir3', '/dir2', '/dir1']:
print 'stat {} (expect failure)'.format(dpath)
res = testlib.blockstack_cli_datastore_stat( "foo.test", datastore_id, dpath, None )
res = testlib.blockstack_cli_datastore_stat( "foo.test", datastore_id, dpath, ses )
if 'error' not in res or 'errno' not in res:
print 'accidentally succeeded to stat {}: {}'.format(dpath, res)
return False
@@ -312,10 +312,10 @@ def scenario( wallets, **kw ):
print 'wrong errno: {}'.format(res)
return False
# list directories (should all fail)
# list directories (should all fail)
for dpath, expected in [('/dir1', ['dir3']), ('/dir1/dir3', ['dir4']), ('/dir1/dir3/dir4', [])]:
print 'listdir {} (expect failure)'.format(dpath)
res = testlib.blockstack_cli_datastore_listdir( "foo.test", datastore_id, dpath, None )
res = testlib.blockstack_cli_datastore_listdir( "foo.test", datastore_id, dpath, ses )
if 'error' not in res or 'errno' not in res:
print 'accidentally succeeded to list {}: {}'.format(dpath, res)
return False
@@ -324,7 +324,7 @@ def scenario( wallets, **kw ):
print 'wrong errno: {}'.format(res)
return False
# remove directories again (should fail)
# remove directories again (should fail)
for dpath in ['/dir1/dir3/dir4', '/dir1/dir3', '/dir2', '/dir1']:
print 'rmdir {} (expect failure)'.format(dpath)
res = testlib.blockstack_cli_datastore_rmdir( "foo.test", datastore_pk, dpath, ses )
@@ -336,9 +336,9 @@ def scenario( wallets, **kw ):
print 'wrong errno on rmdir: {}'.format(res)
return False
# root should be empty
# root should be empty
print 'listdir {}'.format('/')
res = testlib.blockstack_cli_datastore_listdir( "foo.test", datastore_id, '/', None )
res = testlib.blockstack_cli_datastore_listdir( "foo.test", datastore_id, '/', ses )
if 'error' in res:
print 'failed to listdir /: {}'.format(res['error'])
return False
@@ -347,7 +347,7 @@ def scenario( wallets, **kw ):
print 'root still has children: {}'.format(res['children'].keys())
return False
# delete datastore
# delete datastore
print 'delete datastore'
res = testlib.blockstack_cli_delete_datastore( "foo.test", datastore_pk, ses )
if 'error' in res:
@@ -355,7 +355,7 @@ def scenario( wallets, **kw ):
print json.dumps(res)
return False
# no more data in disk driver
# no more data in disk driver
names = os.listdir("/tmp/blockstack-disk/mutable")
if names != ['foo.test']:
print 'improper cleanup'
@@ -372,20 +372,20 @@ def check( state_engine ):
print "Key operation failed."
return False
# not revealed, but ready
# not revealed, but ready
ns = state_engine.get_namespace_reveal( "test" )
if ns is not None:
print "namespace not ready"
return False
return False
ns = state_engine.get_namespace( "test" )
if ns is None:
print "no namespace"
return False
return False
if ns['namespace_id'] != 'test':
print "wrong namespace"
return False
return False
names = ['foo.test']
wallet_keys_list = [wallet_keys]
@@ -403,17 +403,17 @@ def check( state_engine ):
if preorder is not None:
print "still have preorder"
return False
# registered
# registered
name_rec = state_engine.get_name( name )
if name_rec is None:
print "name does not exist"
return False
return False
# owned
# owned
if name_rec['address'] != wallets[wallet_owner].addr or name_rec['sender'] != pybitcoin.make_pay_to_address_script(wallets[wallet_owner].addr):
print "name has wrong owner"
return False
return False
# try to authenticate