def scenario(wallets, **kw): global wallet_keys, wallet_keys_2, error, index_file_data, resource_data wallet_keys = testlib.blockstack_client_initialize_wallet( "0123456789abcdef", wallets[5].privkey, wallets[3].privkey, wallets[4].privkey) wallet_keys_2 = testlib.blockstack_client_initialize_wallet( "0123456789abcdef", wallets[9].privkey, wallets[7].privkey, wallets[8].privkey) test_proxy = testlib.TestAPIProxy() blockstack_client.set_default_proxy(test_proxy) testlib.blockstack_namespace_preorder("test", wallets[1].addr, wallets[0].privkey) testlib.next_block(**kw) testlib.blockstack_namespace_reveal( "test", wallets[1].addr, 52595, 250, 4, [6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 10, 10, wallets[0].privkey) testlib.next_block(**kw) testlib.blockstack_namespace_ready("test", wallets[1].privkey) testlib.next_block(**kw) testlib.blockstack_name_preorder("foo.test", wallets[2].privkey, wallets[3].addr) testlib.blockstack_name_preorder("bar.test", wallets[6].privkey, wallets[7].addr) testlib.next_block(**kw) testlib.blockstack_name_register("foo.test", wallets[2].privkey, wallets[3].addr) testlib.blockstack_name_register("bar.test", wallets[6].privkey, wallets[7].addr) testlib.next_block(**kw) # migrate profiles res = testlib.migrate_profile("foo.test", proxy=test_proxy, wallet_keys=wallet_keys) if 'error' in res: res['test'] = 'Failed to initialize foo.test profile' print json.dumps(res, indent=4, sort_keys=True) error = True return res = testlib.migrate_profile("bar.test", proxy=test_proxy, wallet_keys=wallet_keys_2) if 'error' in res: res['test'] = 'Failed to initialize bar.test profile' print json.dumps(res, indent=4, sort_keys=True) error = True return # tell serialization-checker that value_hash can be ignored here print "BLOCKSTACK_SERIALIZATION_CHECK_IGNORE value_hash" sys.stdout.flush() testlib.next_block(**kw) res = testlib.start_api("0123456789abcdef") if 'error' in res: print 'failed to start API: {}'.format(res) return False data_pk = wallets[-1].privkey data_pub = wallets[-1].pubkey_hex config_path = os.environ.get("BLOCKSTACK_CLIENT_CONFIG", None) # make an index file index_file_path = "/tmp/name_preorder_register_update_app_auth.foo.test.index.html" with open(index_file_path, "w") as f: f.write(index_file_data) testlib.blockstack_client_set_wallet("0123456789abcdef", wallets[5].privkey, wallets[3].privkey, wallets[4].privkey) res = testlib.start_api("0123456789abcdef") if 'error' in res: print 'failed to start API: {}'.format(res) return False # register an application under foo.test res = testlib.blockstack_cli_app_publish("foo.test", "ping.app", "node_read", index_file_path, password="******") if 'error' in res: res['test'] = 'Failed to register foo.test/bar app' print json.dumps(res, indent=4, sort_keys=True) error = True return # activate bar.test testlib.blockstack_client_set_wallet("0123456789abcdef", wallets[9].privkey, wallets[7].privkey, wallets[8].privkey) res = testlib.start_api("0123456789abcdef") if 'error' in res: print 'failed to start API: {}'.format(res) return False # sign in pk = 'ce100586279d3b127b7dcc137fcc2f18b272bb2b43bdaea3584d0ea17087ec0201' pubk = keylib.ECPrivateKey(pk).public_key().to_hex() res = testlib.blockstack_cli_app_signin("foo.test", pk, "ping.app", ["node_read"]) if 'error' in res: res['test'] = 'Failed to signin: {}'.format(res['error']) print json.dumps(res, indent=4, sort_keys=True) error = True return ses = res['token'] res = testlib.blockstack_REST_call("GET", "/v1/ping", ses) if res['http_status'] != 200: print "failed to GET /api/v1/ping" print json.dumps(res, indent=4, sort_keys=True) error = True return False if res['response']['status'] != 'alive': print "failed to GET /api/v1/ping" print json.dumps(res, indent=4, sort_keys=True) error = True return False # access index.html res = testlib.blockstack_REST_call( "GET", "/v1/resources/foo.test/ping.app?name=index.html&pubkey={}".format( wallets[4].pubkey_hex), ses) if 'error' in res or res['http_status'] != 200: print 'failed to GET /v1/resources?name=/index.html' print json.dumps(res) error = True return False if res['raw'] != index_file_data: print 'expected {}\ngot {}\n'.format(index_file_data, res['raw']) print json.dumps(res) error = True return False testlib.next_block(**kw)
def scenario(wallets, **kw): global wallet_keys, error, index_file_data, resource_data wallet_keys = testlib.blockstack_client_initialize_wallet( "0123456789abcdef", wallets[5].privkey, wallets[3].privkey, wallets[4].privkey) test_proxy = testlib.TestAPIProxy() blockstack_client.set_default_proxy(test_proxy) testlib.blockstack_namespace_preorder("test", wallets[1].addr, wallets[0].privkey) testlib.next_block(**kw) testlib.blockstack_namespace_reveal( "test", wallets[1].addr, 52595, 250, 4, [6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 10, 10, wallets[0].privkey) testlib.next_block(**kw) testlib.blockstack_namespace_ready("test", wallets[1].privkey) testlib.next_block(**kw) testlib.blockstack_name_preorder("foo.test", wallets[2].privkey, wallets[3].addr) testlib.next_block(**kw) testlib.blockstack_name_register("foo.test", wallets[2].privkey, wallets[3].addr) testlib.next_block(**kw) # migrate profiles res = testlib.migrate_profile("foo.test", proxy=test_proxy, wallet_keys=wallet_keys) if 'error' in res: res['test'] = 'Failed to initialize foo.test profile' print json.dumps(res, indent=4, sort_keys=True) error = True return # tell serialization-checker that value_hash can be ignored here print "BLOCKSTACK_SERIALIZATION_CHECK_IGNORE value_hash" sys.stdout.flush() testlib.next_block(**kw) data_pk = wallets[-1].privkey data_pub = wallets[-1].pubkey_hex config_path = os.environ.get("BLOCKSTACK_CLIENT_CONFIG", None) # make an index file index_file_path = "/tmp/name_preorder_register_update_app_publish.foo.test.index.html" with open(index_file_path, "w") as f: f.write(index_file_data) # register an application under foo.test res = testlib.blockstack_cli_app_publish("foo.test", "ping.app", "node_read", index_file_path, password="******") if 'error' in res: res['test'] = 'Failed to register foo.test/bar app' print json.dumps(res, indent=4, sort_keys=True) return False # put mutable data, to be accessed as a resource resource_file_path = "/tmp/name_preorder_register_update_app_publish.foo.test.resource" with open(resource_file_path, "w") as f: f.write(resource_data) res = testlib.blockstack_cli_app_put_resource("foo.test", "ping.app", "hello_world", resource_file_path, password="******") if 'error' in res: res['test'] = 'Failed to store app resource' print json.dumps(res, indent=4, sort_keys=True) return False testlib.next_block(**kw)
def scenario( wallets, **kw ): global wallet_keys, wallet_keys_2, error, index_file_data, resource_data wallet_keys = testlib.blockstack_client_initialize_wallet( "0123456789abcdef", wallets[5].privkey, wallets[3].privkey, wallets[4].privkey ) wallet_keys_2 = testlib.blockstack_client_initialize_wallet( "0123456789abcdef", wallets[9].privkey, wallets[7].privkey, wallets[8].privkey ) test_proxy = testlib.TestAPIProxy() blockstack_client.set_default_proxy( test_proxy ) testlib.blockstack_namespace_preorder( "test", wallets[1].addr, wallets[0].privkey ) testlib.next_block( **kw ) testlib.blockstack_namespace_reveal( "test", wallets[1].addr, 52595, 250, 4, [6,5,4,3,2,1,0,0,0,0,0,0,0,0,0,0], 10, 10, wallets[0].privkey ) testlib.next_block( **kw ) testlib.blockstack_namespace_ready( "test", wallets[1].privkey ) testlib.next_block( **kw ) testlib.blockstack_name_preorder( "foo.test", wallets[2].privkey, wallets[3].addr ) testlib.blockstack_name_preorder( "bar.test", wallets[6].privkey, wallets[7].addr ) testlib.next_block( **kw ) testlib.blockstack_name_register( "foo.test", wallets[2].privkey, wallets[3].addr ) testlib.blockstack_name_register( "bar.test", wallets[6].privkey, wallets[7].addr ) testlib.next_block( **kw ) # migrate profiles res = testlib.migrate_profile( "foo.test", proxy=test_proxy, wallet_keys=wallet_keys ) if 'error' in res: res['test'] = 'Failed to initialize foo.test profile' print json.dumps(res, indent=4, sort_keys=True) error = True return res = testlib.migrate_profile( "bar.test", proxy=test_proxy, wallet_keys=wallet_keys_2 ) if 'error' in res: res['test'] = 'Failed to initialize bar.test profile' print json.dumps(res, indent=4, sort_keys=True) error = True return # tell serialization-checker that value_hash can be ignored here print "BLOCKSTACK_SERIALIZATION_CHECK_IGNORE value_hash" sys.stdout.flush() testlib.next_block( **kw ) res = testlib.start_api("0123456789abcdef") if 'error' in res: print 'failed to start API: {}'.format(res) return False data_pk = wallets[-1].privkey data_pub = wallets[-1].pubkey_hex config_path = os.environ.get("BLOCKSTACK_CLIENT_CONFIG", None) # make an index file index_file_path = "/tmp/name_preorder_register_update_app_auth.foo.test.index.html" with open(index_file_path, "w") as f: f.write(index_file_data) testlib.blockstack_client_set_wallet( "0123456789abcdef", wallets[5].privkey, wallets[3].privkey, wallets[4].privkey ) res = testlib.start_api("0123456789abcdef") if 'error' in res: print 'failed to start API: {}'.format(res) return False # register an application under foo.test res = testlib.blockstack_cli_app_publish("foo.test", "ping.app", "node_read", index_file_path, password="******" ) if 'error' in res: res['test'] = 'Failed to register foo.test/bar app' print json.dumps(res, indent=4, sort_keys=True) error = True return # activate bar.test testlib.blockstack_client_set_wallet( "0123456789abcdef", wallets[9].privkey, wallets[7].privkey, wallets[8].privkey ) res = testlib.start_api("0123456789abcdef") if 'error' in res: print 'failed to start API: {}'.format(res) return False # sign in pk = 'ce100586279d3b127b7dcc137fcc2f18b272bb2b43bdaea3584d0ea17087ec0201' pubk = keylib.ECPrivateKey(pk).public_key().to_hex() res = testlib.blockstack_cli_app_signin("foo.test", pk, "ping.app", ["node_read"]) if 'error' in res: res['test'] = 'Failed to signin: {}'.format(res['error']) print json.dumps(res, indent=4, sort_keys=True) error = True return ses = res['token'] res = testlib.blockstack_REST_call("GET", "/v1/ping", ses) if res['http_status'] != 200: print "failed to GET /api/v1/ping" print json.dumps(res, indent=4, sort_keys=True) error = True return False if res['response']['status'] != 'alive': print "failed to GET /api/v1/ping" print json.dumps(res, indent=4, sort_keys=True) error = True return False # access index.html res = testlib.blockstack_REST_call("GET", "/v1/resources/foo.test/ping.app?name=index.html&pubkey={}".format(wallets[4].pubkey_hex), ses) if 'error' in res or res['http_status'] != 200: print 'failed to GET /v1/resources?name=/index.html' print json.dumps(res) error = True return False if res['raw'] != index_file_data: print 'expected {}\ngot {}\n'.format(index_file_data, res['raw']) print json.dumps(res) error = True return False testlib.next_block( **kw )
def scenario( wallets, **kw ): global wallet_keys, error, index_file_data, resource_data wallet_keys = testlib.blockstack_client_initialize_wallet( "0123456789abcdef", wallets[5].privkey, wallets[3].privkey, wallets[4].privkey ) test_proxy = testlib.TestAPIProxy() blockstack_client.set_default_proxy( test_proxy ) testlib.blockstack_namespace_preorder( "test", wallets[1].addr, wallets[0].privkey ) testlib.next_block( **kw ) testlib.blockstack_namespace_reveal( "test", wallets[1].addr, 52595, 250, 4, [6,5,4,3,2,1,0,0,0,0,0,0,0,0,0,0], 10, 10, wallets[0].privkey ) testlib.next_block( **kw ) testlib.blockstack_namespace_ready( "test", wallets[1].privkey ) testlib.next_block( **kw ) testlib.blockstack_name_preorder( "foo.test", wallets[2].privkey, wallets[3].addr ) testlib.next_block( **kw ) testlib.blockstack_name_register( "foo.test", wallets[2].privkey, wallets[3].addr ) testlib.next_block( **kw ) # migrate profiles res = testlib.migrate_profile( "foo.test", proxy=test_proxy, wallet_keys=wallet_keys ) if 'error' in res: res['test'] = 'Failed to initialize foo.test profile' print json.dumps(res, indent=4, sort_keys=True) error = True return # tell serialization-checker that value_hash can be ignored here print "BLOCKSTACK_SERIALIZATION_CHECK_IGNORE value_hash" sys.stdout.flush() testlib.next_block( **kw ) data_pk = wallets[-1].privkey data_pub = wallets[-1].pubkey_hex config_path = os.environ.get("BLOCKSTACK_CLIENT_CONFIG", None) # make an index file index_file_path = "/tmp/name_preorder_register_update_app_publish.foo.test.index.html" with open(index_file_path, "w") as f: f.write(index_file_data) # register an application under foo.test res = testlib.blockstack_cli_app_publish("foo.test", "ping.app", "node_read", index_file_path, password="******" ) if 'error' in res: res['test'] = 'Failed to register foo.test/bar app' print json.dumps(res, indent=4, sort_keys=True) return False # put mutable data, to be accessed as a resource resource_file_path = "/tmp/name_preorder_register_update_app_publish.foo.test.resource" with open(resource_file_path, "w") as f: f.write(resource_data) res = testlib.blockstack_cli_app_put_resource("foo.test", "ping.app", "hello_world", resource_file_path, password="******" ) if 'error' in res: res['test'] = 'Failed to store app resource' print json.dumps(res, indent=4, sort_keys=True) return False testlib.next_block( **kw )