def check( state_engine ): global error, wallet_keys, wallet_keys_2, foo_output, bar_output, baz_output config_path = os.environ['BLOCKSTACK_FILE_CONFIG'] if error: print "test failed during scenario" return False # not revealed, but ready ns = state_engine.get_namespace_reveal( "test" ) if ns is not None: print "namespace not ready" return False ns = state_engine.get_namespace( "test" ) if ns is None: print "no namespace" return False if ns['namespace_id'] != 'test': print "wrong namespace" return False # not preordered preorder = state_engine.get_name_preorder( "foo.test", pybitcoin.make_pay_to_address_script(wallets[2].addr), wallets[3].addr ) if preorder is not None: print "still have preorder" return False # not preordered preorder = state_engine.get_name_preorder( "bar.test", pybitcoin.make_pay_to_address_script(wallets[5].addr), wallets[6].addr ) if preorder is not None: print "still have preorder" return False # registered name_rec = state_engine.get_name( "foo.test" ) if name_rec is None: print "name does not exist" return False # owned if name_rec['address'] != wallets[3].addr or name_rec['sender'] != pybitcoin.make_pay_to_address_script(wallets[3].addr): print "foo.test name has wrong owner" return False # registered name_rec = state_engine.get_name( "bar.test" ) if name_rec is None: print "name does not exist" return False # owned if name_rec['address'] != wallets[6].addr or name_rec['sender'] != pybitcoin.make_pay_to_address_script(wallets[6].addr): print "bar.test name has wrong owner" return False # files are no longer listed in foo.test for name in ['foo.test']: listing = blockstack_file.file_list( 'foo.test', config_path=config_paths[name], wallet_keys=wallet_keys[name] ) if 'error' in listing: print "no listing: %s" % listing['error'] return False if len(listing['listing']) != 0: print "still listed: %s" % listing['listing'] return False # print benchmark data for sz in file_sizes: print "" print "put %s: %s" % (sz, ",".join([str(f) for f in put_benchmark_data[sz]])) print "get %s: %s" % (sz, ",".join([str(f) for f in get_benchmark_data[sz]])) print "" return True
def check(state_engine): global error, wallet_keys, wallet_keys_2, foo_output, bar_output, baz_output config_path = os.environ['BLOCKSTACK_FILE_CONFIG'] if error: print "test failed during scenario" return False # not revealed, but ready ns = state_engine.get_namespace_reveal("test") if ns is not None: print "namespace not ready" return False ns = state_engine.get_namespace("test") if ns is None: print "no namespace" return False if ns['namespace_id'] != 'test': print "wrong namespace" return False # not preordered preorder = state_engine.get_name_preorder( "foo.test", pybitcoin.make_pay_to_address_script(wallets[2].addr), wallets[3].addr) if preorder is not None: print "still have preorder" return False # not preordered preorder = state_engine.get_name_preorder( "bar.test", pybitcoin.make_pay_to_address_script(wallets[5].addr), wallets[6].addr) if preorder is not None: print "still have preorder" return False # registered name_rec = state_engine.get_name("foo.test") if name_rec is None: print "name does not exist" return False # owned if name_rec['address'] != wallets[3].addr or name_rec[ 'sender'] != pybitcoin.make_pay_to_address_script(wallets[3].addr): print "foo.test name has wrong owner" return False # registered name_rec = state_engine.get_name("bar.test") if name_rec is None: print "name does not exist" return False # owned if name_rec['address'] != wallets[6].addr or name_rec[ 'sender'] != pybitcoin.make_pay_to_address_script(wallets[6].addr): print "bar.test name has wrong owner" return False # files check out for path in [foo_output, bar_output]: with open(path, "r") as f: dat = f.read() if dat != TEST_OUTPUT_FILE: print "wrong data: %s" % path return False # files are no longer listed in foo.test or bar.test for name in ['foo.test', 'bar.test']: listing = blockstack_file.file_list('foo.test', config_path=config_paths[name], wallet_keys=wallet_keys[name]) if 'error' in listing: print "no listing: %s" % listing['error'] return False if len(listing['listing']) != 0: print "still listed: %s" % listing['listing'] return False # baz still has a file listing = blockstack_file.file_list('baz.test', config_path=config_paths[name], wallet_keys=wallet_keys[name]) if 'error' in listing: print "no listing: %s" % listing['error'] return False if len(listing['listing']) != 1: print "invalid listing: %s" % listing['listing'] return False if listing['listing'][0]['data_id'] != 'files:config-file-from-baz.test': print 'not present in listing: %s' % listing['listing'] return False return True
def check(state_engine): global error, wallet_keys, wallet_keys_2, foo_output, bar_output, baz_output config_path = os.environ['BLOCKSTACK_FILE_CONFIG'] if error: print "test failed during scenario" return False # not revealed, but ready ns = state_engine.get_namespace_reveal("test") if ns is not None: print "namespace not ready" return False ns = state_engine.get_namespace("test") if ns is None: print "no namespace" return False if ns['namespace_id'] != 'test': print "wrong namespace" return False # not preordered preorder = state_engine.get_name_preorder( "foo.test", pybitcoin.make_pay_to_address_script(wallets[2].addr), wallets[3].addr) if preorder is not None: print "still have preorder" return False # not preordered preorder = state_engine.get_name_preorder( "bar.test", pybitcoin.make_pay_to_address_script(wallets[5].addr), wallets[6].addr) if preorder is not None: print "still have preorder" return False # registered name_rec = state_engine.get_name("foo.test") if name_rec is None: print "name does not exist" return False # owned if name_rec['address'] != wallets[3].addr or name_rec[ 'sender'] != pybitcoin.make_pay_to_address_script(wallets[3].addr): print "foo.test name has wrong owner" return False # registered name_rec = state_engine.get_name("bar.test") if name_rec is None: print "name does not exist" return False # owned if name_rec['address'] != wallets[6].addr or name_rec[ 'sender'] != pybitcoin.make_pay_to_address_script(wallets[6].addr): print "bar.test name has wrong owner" return False # files are no longer listed in foo.test for name in ['foo.test']: listing = blockstack_file.file_list('foo.test', config_path=config_paths[name], wallet_keys=wallet_keys[name]) if 'error' in listing: print "no listing: %s" % listing['error'] return False if len(listing['listing']) != 0: print "still listed: %s" % listing['listing'] return False # print benchmark data for sz in file_sizes: print "" print "put %s: %s" % (sz, ",".join( [str(f) for f in put_benchmark_data[sz]])) print "get %s: %s" % (sz, ",".join( [str(f) for f in get_benchmark_data[sz]])) print "" return True
def check( state_engine ): global error, wallet_keys, wallet_keys_2, foo_output, bar_output, baz_output config_path = os.environ['BLOCKSTACK_FILE_CONFIG'] if error: print "test failed during scenario" return False # not revealed, but ready ns = state_engine.get_namespace_reveal( "test" ) if ns is not None: print "namespace not ready" return False ns = state_engine.get_namespace( "test" ) if ns is None: print "no namespace" return False if ns['namespace_id'] != 'test': print "wrong namespace" return False # not preordered preorder = state_engine.get_name_preorder( "foo.test", pybitcoin.make_pay_to_address_script(wallets[2].addr), wallets[3].addr ) if preorder is not None: print "still have preorder" return False # not preordered preorder = state_engine.get_name_preorder( "bar.test", pybitcoin.make_pay_to_address_script(wallets[5].addr), wallets[6].addr ) if preorder is not None: print "still have preorder" return False # registered name_rec = state_engine.get_name( "foo.test" ) if name_rec is None: print "name does not exist" return False # owned if name_rec['address'] != wallets[3].addr or name_rec['sender'] != pybitcoin.make_pay_to_address_script(wallets[3].addr): print "foo.test name has wrong owner" return False # registered name_rec = state_engine.get_name( "bar.test" ) if name_rec is None: print "name does not exist" return False # owned if name_rec['address'] != wallets[6].addr or name_rec['sender'] != pybitcoin.make_pay_to_address_script(wallets[6].addr): print "bar.test name has wrong owner" return False # files check out for path in [foo_output, bar_output]: with open(path, "r") as f: dat = f.read() if dat != TEST_OUTPUT_FILE: print "wrong data: %s" % path return False # files are no longer listed in foo.test or bar.test for name in ['foo.test', 'bar.test']: listing = blockstack_file.file_list( 'foo.test', config_path=config_paths[name], wallet_keys=wallet_keys[name] ) if 'error' in listing: print "no listing: %s" % listing['error'] return False if len(listing['listing']) != 0: print "still listed: %s" % listing['listing'] return False # baz still has a file listing = blockstack_file.file_list( 'baz.test', config_path=config_paths[name], wallet_keys=wallet_keys[name] ) if 'error' in listing: print "no listing: %s" % listing['error'] return False if len(listing['listing']) != 1: print "invalid listing: %s" % listing['listing'] return False if listing['listing'][0]['data_id'] != 'files:config-file-from-baz.test': print 'not present in listing: %s' % listing['listing'] return False return True