def check( state_engine ): global wallet_keys, dataset_1, data_hash_1, dataset_2, data_hash_2 # 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 # 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 "name has wrong owner" return False # have right hash if name_rec['value_hash'] != last_hash: print "Invalid zonefile hash (%s != %s)" % (name_rec['value_hash'], last_hash) return False # have no data test_proxy = testlib.TestAPIProxy() blockstack_client.set_default_proxy( test_proxy ) for i in xrange(0, len(datasets)): immutable_data = blockstack_client.get_immutable( "foo.test", zonefile_hashes[i] ) if immutable_data is not None and 'error' not in immutable_data: print "still have data for dataset %s\n%s" % (i, json.dumps(immutable_data,indent=4,sort_keys=True)) return False if immutable_data['error'] != 'No such immutable datum': print json.dumps(immutable_data,indent=4,sort_keys=True) return False immutable_data_by_name = blockstack_client.get_immutable_by_name( "foo.test", "hello_world_%s" % (i+1) ) if immutable_data_by_name is not None and 'error' not in immutable_data: print "still have data for dataset hello_world_%s\n%s" % (i, json.dumps(immutable_data,indent=4,sort_keys=True)) return False if immutable_data['error'] != 'No such immutable datum': print json.dumps(immutable_data,indent=4,sort_keys=True) return False return True
def check(state_engine): global error # 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 # 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 "name has wrong owner" return False # have right data test_proxy = testlib.TestAPIProxy() blockstack_client.set_default_proxy(test_proxy) # should always work for i in xrange(1, len(datasets)): immutable_data = blockstack_client.get_immutable_by_name( "foo.test", "hello_world_%s_immutable" % (i + 1), proxy=test_proxy) if immutable_data is None: print "No data received for immutable dataset %s" % i return False if 'error' in immutable_data: print "No data received for immutable dataset %s: %s" % ( i, immutable_data['error']) return False if not immutable_data.has_key('data'): print "Missing data\n%s" % json.dumps( immutable_data, indent=4, sort_keys=True) return False data_json = immutable_data['data'] if data_json != datasets[i]: print "did not get dataset %s\ngot %s\nexpected %s" % ( i, data_json, datasets[i]) return False mutable_data = blockstack_client.get_mutable("foo.test", "hello_world_%s_mutable" % (i + 1), proxy=test_proxy) if mutable_data is None: print "No data received for mutable dataset %s" % (i + 1) return False if 'error' in mutable_data: print "No data received for mutable dataset %s: %s" % ( i + 1, mutable_data['error']) return False data_json = mutable_data['data'] if data_json != datasets[i]: print "did not get dataset %s\ngot %s\nexpected %s" % ( i + 1, data_json, datasets[i]) return False # should fail immutable_data = blockstack_client.get_immutable_by_name( "foo.test", "hello_world_1_immutable", proxy=test_proxy) if immutable_data is not None and 'error' not in immutable_data: print "Got deleted immutable dataset" return False mutable_data = blockstack_client.get_mutable("foo.tesT", "hello_world_1_mutable", proxy=test_proxy) if mutable_data is not None and 'error' not in mutable_data: print "Got deleted mutable dataset" return False return True
def check( state_engine ): global error # 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 # 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 "name has wrong owner" return False # have right data test_proxy = testlib.TestAPIProxy() blockstack_client.set_default_proxy( test_proxy ) # should always work for i in xrange(1, len(datasets)): immutable_data = blockstack_client.get_immutable_by_name( "foo.test", "hello_world_%s_immutable" % (i+1), proxy=test_proxy ) if immutable_data is None: print "No data received for immutable dataset %s" % i return False if 'error' in immutable_data: print "No data received for immutable dataset %s: %s" % (i, immutable_data['error']) return False if not immutable_data.has_key('data'): print "Missing data\n%s" % json.dumps(immutable_data, indent=4, sort_keys=True) return False data_json = immutable_data['data'] if data_json != datasets[i]: print "did not get dataset %s\ngot %s\nexpected %s" % (i, data_json, datasets[i]) return False mutable_data = blockstack_client.get_mutable( "foo.test", "hello_world_%s_mutable" % (i+1), proxy=test_proxy ) if mutable_data is None: print "No data received for mutable dataset %s" % (i+1) return False if 'error' in mutable_data: print "No data received for mutable dataset %s: %s" % (i+1, mutable_data['error']) return False data_json = mutable_data['data'] if data_json != datasets[i]: print "did not get dataset %s\ngot %s\nexpected %s" % (i+1, data_json, datasets[i]) return False # should fail immutable_data = blockstack_client.get_immutable_by_name( "foo.test", "hello_world_1_immutable", proxy=test_proxy) if immutable_data is not None and 'error' not in immutable_data: print "Got deleted immutable dataset" return False mutable_data = blockstack_client.get_mutable( "foo.tesT", "hello_world_1_mutable", proxy=test_proxy ) if mutable_data is not None and 'error' not in mutable_data: print "Got deleted mutable dataset" return False return True
def check(state_engine): global wallet_keys, dataset_1, data_hash_1, dataset_2, data_hash_2 # 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 # 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 "name has wrong owner" return False # have right hash if name_rec['value_hash'] != last_hash: print "Invalid zonefile hash (%s != %s)" % (name_rec['value_hash'], last_hash) return False # have no data test_proxy = testlib.TestAPIProxy() blockstack_client.set_default_proxy(test_proxy) for i in xrange(0, len(datasets)): immutable_data = blockstack_client.get_immutable( "foo.test", zonefile_hashes[i]) if immutable_data is not None and 'error' not in immutable_data: print "still have data for dataset %s\n%s" % ( i, json.dumps(immutable_data, indent=4, sort_keys=True)) return False if immutable_data['error'] != 'No such immutable datum': print json.dumps(immutable_data, indent=4, sort_keys=True) return False immutable_data_by_name = blockstack_client.get_immutable_by_name( "foo.test", "hello_world_%s" % (i + 1)) if immutable_data_by_name is not None and 'error' not in immutable_data: print "still have data for dataset hello_world_%s\n%s" % ( i, json.dumps(immutable_data, indent=4, sort_keys=True)) return False if immutable_data['error'] != 'No such immutable datum': print json.dumps(immutable_data, indent=4, sort_keys=True) return False return True
def check( state_engine ): global wallet_keys, datasets, zonefile_hash if error: 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 name = "foo.test" wallet_payer = 2 wallet_owner = 3 wallet_data_pubkey = 4 # 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 # zonefile is NOT legacy user_zonefile = blockstack_client.profile.load_name_zonefile( name, zonefile_hash ) if 'error' in user_zonefile: print json.dumps(user_zonefile, indent=4, sort_keys=True) return False if blockstack_profiles.is_profile_in_legacy_format( user_zonefile ): print "legacy still" print json.dumps(user_zonefile, indent=4, sort_keys=True) return False # still have a profile with data user_profile = blockstack_client.profile.load_name_profile( name, user_zonefile, wallets[wallet_data_pubkey].addr, wallets[wallet_owner].addr ) if user_profile is None or 'error' in user_profile: if user_profile is not None: print json.dumps(user_profile, indent=4, sort_keys=True) else: print "\n\nprofile is None\n\n" return False # still have immutable data immutable_data_by_name = blockstack_client.get_immutable_by_name( "foo.test", "hello_world_immutable" ) if immutable_data_by_name is None: print "No data received by name for dataset %s" % i return False if 'error' in immutable_data_by_name: print "No data received for dataset hello_world_immutable" return False if not immutable_data_by_name.has_key('data'): print "Misisng data\n%s" % json.dumps(immutable_data_by_name, indent=4, sort_keys=True) return False data_json = immutable_data_by_name['data'] if data_json != {'hello': 'world'}: print "did not get dataset hello_world_immutable\ngot %s\nexpected %s" % (data_json, {'hello': 'world'}) return False # still have mutable data dat = blockstack_client.get_mutable( "foo.test", "hello_world_mutable" ) if dat is None: print "No hello_world_mutable" return False if 'error' in dat: print json.dumps(dat, indent=4, sort_keys=True) return False if dat['data'] != {'hello': 'world'}: print "did not get mutable dataset" return False return True