def check(state_engine): global wallet_keys, error, index_file_data, resource_data config_path = os.environ.get("BLOCKSTACK_CLIENT_CONFIG") assert config_path if error: print "Key operation failed." 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 names = ['foo.test', 'bar.test'] wallet_keys_list = [wallet_keys, wallet_keys_2] test_proxy = testlib.TestAPIProxy() for i in xrange(0, len(names)): name = names[i] wallet_payer = 3 * (i + 1) - 1 + i wallet_owner = 3 * (i + 1) + i wallet_data_pubkey = 3 * (i + 1) + 1 + i wallet_keys = wallet_keys_list[i] # not preordered preorder = state_engine.get_name_preorder( name, virtualchain.make_payment_script(wallets[wallet_payer].addr), wallets[wallet_owner].addr) if preorder is not None: print "still have preorder" return False # registered name_rec = state_engine.get_name(name) if name_rec is None: print "name does not exist" return False # owned if name_rec['address'] != wallets[wallet_owner].addr or name_rec[ 'sender'] != virtualchain.make_payment_script( wallets[wallet_owner].addr): print "name {} has wrong owner".format(name) return False # get app config app_config = testlib.blockstack_cli_app_get_config("foo.test", "ping.app") if 'error' in app_config: print "failed to get app config\n{}\n".format( json.dumps(app_config, indent=4, sort_keys=True)) return False # inspect... app_config = app_config['config'] print json.dumps(app_config, indent=4, sort_keys=True) if app_config['driver_hints'] != []: print "Invalid driver hints\n{}\n".format( json.dumps(app_config, indent=4, sort_keys=True)) return False if app_config['api_methods'] != ['node_read']: print "Invalid API list\n{}\n".format( json.dumps(app_config, indent=4, sort_keys=True)) return False if len(app_config['index_uris']) != 1: print "Invalid URI records\n{}\n".format( json.dumps(app_config, indent=4, sort_keys=True)) return False if app_config['blockchain_id'] != 'foo.test': print "invalid blockchain ID\n{}\n".format(app_config) return False return True
def check(state_engine): global wallet_keys, error, index_file_data, resource_data if error: print "Key operation failed." 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 names = ['foo.test'] wallet_keys_list = [wallet_keys] test_proxy = testlib.TestAPIProxy() for i in xrange(0, len(names)): name = names[i] wallet_payer = 3 * (i + 1) - 1 wallet_owner = 3 * (i + 1) wallet_data_pubkey = 3 * (i + 1) + 1 wallet_keys = wallet_keys_list[i] # not preordered preorder = state_engine.get_name_preorder( name, pybitcoin.make_pay_to_address_script(wallets[wallet_payer].addr), wallets[wallet_owner].addr) if preorder is not None: print "still have preorder" return False # registered name_rec = state_engine.get_name(name) if name_rec is None: print "name does not exist" return False # 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 # get app config app_config = testlib.blockstack_cli_app_get_config( "foo.test", "ping.app") if 'error' in app_config: print "failed to get app config\n{}\n".format( json.dumps(app_config, indent=4, sort_keys=True)) return False # inspect... app_config = app_config['config'] if app_config['driver_hints'] != []: print "Invalid driver hints\n{}\n".format( json.dumps(app_config, indent=4, sort_keys=True)) return False if app_config['api_methods'] != ['node_read']: print "Invalid API list\n{}\n".format( json.dumps(app_config, indent=4, sort_keys=True)) return False if len(app_config['index_uris']) != 1: print "Invalid URI records\n{}\n".format( json.dumps(app_config, indent=4, sort_keys=True)) return False if app_config['blockchain_id'] != 'foo.test': print "invalid blockchain ID\n{}\n".format(app_config) return False # get index file index_file = testlib.blockstack_cli_app_get_resource( "foo.test", "ping.app", "index.html") if 'error' in index_file: print "failed to get index file\n{}\n".format( json.dumps(index_file, indent=4, sort_keys=True)) return False if index_file['res'] != index_file_data: print "got wrong index file:\n{}\n".format( index_file['index_file']) return False # get resource resource_data_res = testlib.blockstack_cli_app_get_resource( "foo.test", "ping.app", "hello_world") if 'error' in resource_data_res: print "failed to get resource hello_world\n{}\n".format( json.dumps(resource_data, indent=4, sort_keys=True)) return False if resource_data_res['res'] != resource_data: print "got wrong resource data:\n{}\nexpected:\n{}\n".format( resource_data_res['res'], resource_data) return False return True
def check( state_engine ): global wallet_keys, error, index_file_data, resource_data config_path = os.environ.get("BLOCKSTACK_CLIENT_CONFIG") assert config_path if error: print "Key operation failed." 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 names = ['foo.test', 'bar.test'] wallet_keys_list = [wallet_keys, wallet_keys_2] test_proxy = testlib.TestAPIProxy() for i in xrange(0, len(names)): name = names[i] wallet_payer = 3 * (i+1) - 1 + i wallet_owner = 3 * (i+1) + i wallet_data_pubkey = 3 * (i+1) + 1 + i wallet_keys = wallet_keys_list[i] # not preordered preorder = state_engine.get_name_preorder( name, pybitcoin.make_pay_to_address_script(wallets[wallet_payer].addr), wallets[wallet_owner].addr ) if preorder is not None: print "still have preorder" return False # registered name_rec = state_engine.get_name( name ) if name_rec is None: print "name does not exist" return False # 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".format(name) return False # get app config app_config = testlib.blockstack_cli_app_get_config( "foo.test", "ping.app" ) if 'error' in app_config: print "failed to get app config\n{}\n".format(json.dumps(app_config, indent=4, sort_keys=True)) return False # inspect... app_config = app_config['config'] print json.dumps(app_config, indent=4, sort_keys=True) if app_config['driver_hints'] != []: print "Invalid driver hints\n{}\n".format(json.dumps(app_config, indent=4, sort_keys=True)) return False if app_config['api_methods'] != ['node_read']: print "Invalid API list\n{}\n".format(json.dumps(app_config, indent=4, sort_keys=True)) return False if len(app_config['index_uris']) != 1: print "Invalid URI records\n{}\n".format(json.dumps(app_config, indent=4, sort_keys=True)) return False if app_config['blockchain_id'] != 'foo.test': print "invalid blockchain ID\n{}\n".format(app_config) return False return True
def check( state_engine ): global wallet_keys, error, index_file_data, resource_data if error: print "Key operation failed." 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 names = ['foo.test'] wallet_keys_list = [wallet_keys] test_proxy = testlib.TestAPIProxy() for i in xrange(0, len(names)): name = names[i] wallet_payer = 3 * (i+1) - 1 wallet_owner = 3 * (i+1) wallet_data_pubkey = 3 * (i+1) + 1 wallet_keys = wallet_keys_list[i] # not preordered preorder = state_engine.get_name_preorder( name, pybitcoin.make_pay_to_address_script(wallets[wallet_payer].addr), wallets[wallet_owner].addr ) if preorder is not None: print "still have preorder" return False # registered name_rec = state_engine.get_name( name ) if name_rec is None: print "name does not exist" return False # 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 # get app config app_config = testlib.blockstack_cli_app_get_config( "foo.test", "ping.app" ) if 'error' in app_config: print "failed to get app config\n{}\n".format(json.dumps(app_config, indent=4, sort_keys=True)) return False # inspect... app_config = app_config['config'] if app_config['driver_hints'] != []: print "Invalid driver hints\n{}\n".format(json.dumps(app_config, indent=4, sort_keys=True)) return False if app_config['api_methods'] != ['node_read']: print "Invalid API list\n{}\n".format(json.dumps(app_config, indent=4, sort_keys=True)) return False if len(app_config['index_uris']) != 1: print "Invalid URI records\n{}\n".format(json.dumps(app_config, indent=4, sort_keys=True)) return False if app_config['blockchain_id'] != 'foo.test': print "invalid blockchain ID\n{}\n".format(app_config) return False # get index file index_file = testlib.blockstack_cli_app_get_resource("foo.test", "ping.app", "index.html") if 'error' in index_file: print "failed to get index file\n{}\n".format(json.dumps(index_file, indent=4, sort_keys=True)) return False if index_file['res'] != index_file_data: print "got wrong index file:\n{}\n".format(index_file['index_file']) return False # get resource resource_data_res = testlib.blockstack_cli_app_get_resource("foo.test", "ping.app", "hello_world") if 'error' in resource_data_res: print "failed to get resource hello_world\n{}\n".format(json.dumps(resource_data, indent=4, sort_keys=True)) return False if resource_data_res['res'] != resource_data: print "got wrong resource data:\n{}\nexpected:\n{}\n".format(resource_data_res['res'], resource_data) return False return True