def check(state_engine): global zonefile_hash # not revealed, but ready ns = state_engine.get_namespace_reveal("test") if ns is not None: print "namespace reveal exists" 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 # registered name_rec = state_engine.get_name("foo.test") if name_rec is None: print "name does not exist" return False # revoked if not name_rec['revoked']: print "not revoked" return False # owned by owner_address = wallets[4].addr if name_rec['address'] != owner_address or name_rec[ 'sender'] != virtualchain.make_payment_script(owner_address): print "sender is wrong" return False # no zonefile hash if name_rec['value_hash'] is not None: print "still have value hash" return False # doesn't show up in listing names_owned = testlib.blockstack_cli_names() if 'error' in names_owned: print "rpc names: %s" % names_owned['error'] return False if len(names_owned['names_owned']) != 0: print "owned: %s" % names_owned['names_owned'] return False # all queues are drained queue_info = testlib.blockstack_client_queue_state() if len(queue_info) > 0: print "Still in queue:\n%s" % json.dumps( queue_info, indent=4, sort_keys=True) return False return True
def check( state_engine ): global zonefile_hash # not revealed, but ready ns = state_engine.get_namespace_reveal( "test" ) if ns is not None: print "namespace reveal exists" 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 # registered name_rec = state_engine.get_name( "foo.test" ) if name_rec is None: print "name does not exist" return False # revoked if not name_rec['revoked']: print "not revoked" return False # owned by owner_address = wallets[4].addr if name_rec['address'] != owner_address or name_rec['sender'] != virtualchain.make_payment_script(owner_address): print "sender is wrong" return False # no zonefile hash if name_rec['value_hash'] is not None: print "still have value hash" return False # doesn't show up in listing names_owned = testlib.blockstack_cli_names() if 'error' in names_owned: print "rpc names: %s" % names_owned['error'] return False if len(names_owned['names_owned']) != 0: print "owned: %s" % names_owned['names_owned'] return False # all queues are drained queue_info = testlib.blockstack_client_queue_state() if len(queue_info) > 0: print "Still in queue:\n%s" % json.dumps(queue_info, indent=4, sort_keys=True) return False return True
def check(state_engine): global zonefile_hash # not revealed, but ready ns = state_engine.get_namespace_reveal("test") if ns is not None: print "namespace reveal exists" 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 # registered name_rec = state_engine.get_name("foo.test") if name_rec is None: print "name does not exist" return False # owned by owner_address = wallets[4].addr if name_rec['address'] != owner_address or name_rec[ 'sender'] != virtualchain.make_payment_script(owner_address): print "sender is wrong" return False # value hash if name_rec['value_hash'] != zonefile_hash: print "wrong zonefile hash: %s != %s" % (name_rec['value_hash'], zonefile_hash) return False # replicated? zonefile = testlib.blockstack_get_zonefile(zonefile_hash) if 'error' in zonefile: print "zonefile error: %s" % zonefile['error'] return False # right hash? if blockstack_client.hash_zonefile(zonefile) != zonefile_hash: print "wrong zonefile: %s != %s" % ( blockstack_client.hash_zonefile(zonefile), zonefile_hash) return False # latest key? if not zonefile.has_key("txt"): print "no txt:\n%s" % json.dumps(zonefile, indent=4, sort_keys=True) return False if len(zonefile['txt']) != 2: print "wrong number of txt records:\n%s" % json.dumps( zonefile, indent=4, sort_keys=True) return False for txtrec in zonefile['txt']: if txtrec['name'] == 'pubkey': if new_data_pubkey not in txtrec['txt']: print "wrong pubkey:\n%s" % json.dumps( zonefile, indent=4, sort_keys=True) print "missing %s" % new_data_pubkey return False names_owned = testlib.blockstack_cli_names() if 'error' in names_owned: print "rpc names: %s" % names_owned['error'] return False # we still own the name if len(names_owned['names_owned']) != 1: print "owned: %s" % names_owned['names_owned'] return False # all queues are drained queue_info = testlib.blockstack_client_queue_state() if len(queue_info) > 0: print "Still in queue:\n%s" % json.dumps( queue_info, indent=4, sort_keys=True) return False return True
def check(state_engine): global zonefile_hash # not revealed, but ready ns = state_engine.get_namespace_reveal("test") if ns is not None: print "namespace reveal exists" 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 # registered name_rec = state_engine.get_name("foo.test") if name_rec is None: print "name does not exist" return False # owned by owner_address = wallets[4].addr if name_rec['address'] != owner_address or name_rec[ 'sender'] != pybitcoin.make_pay_to_address_script(owner_address): print "sender is wrong" return False # value hash if name_rec['value_hash'] != zonefile_hash: print "wrong zonefile hash: %s != %s" % (name_rec['value_hash'], zonefile_hash) return False # replicated? zonefile = testlib.blockstack_get_zonefile(zonefile_hash) if 'error' in zonefile: print "zonefile error: %s" % zonefile['error'] return False # right hash? if blockstack_client.hash_zonefile(zonefile) != zonefile_hash: print "wrong zonefile: %s != %s" % ( blockstack_client.hash_zonefile(zonefile), zonefile_hash) return False names_owned = testlib.blockstack_cli_names() if 'error' in names_owned: print "rpc names: %s" % names_owned['error'] return False # we still own the name if len(names_owned['names_owned']) != 1: print "owned: %s" % names_owned['names_owned'] return False # all queues are drained queue_info = testlib.blockstack_client_queue_state() if len(queue_info) > 0: print "Still in queue:\n%s" % json.dumps( queue_info, indent=4, sort_keys=True) return False return True
def check( state_engine ): global zonefile_hash # not revealed, but ready ns = state_engine.get_namespace_reveal( "test" ) if ns is not None: print "namespace reveal exists" 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 # registered name_rec = state_engine.get_name( "foo.test" ) if name_rec is None: print "name does not exist" return False # owned by owner_address = wallets[4].addr if name_rec['address'] != owner_address or name_rec['sender'] != pybitcoin.make_pay_to_address_script(owner_address): print "sender is wrong" return False # value hash if name_rec['value_hash'] != zonefile_hash: print "wrong zonefile hash: %s != %s" % (name_rec['value_hash'], zonefile_hash) return False # replicated? zonefile = testlib.blockstack_get_zonefile( zonefile_hash ) if 'error' in zonefile: print "zonefile error: %s" % zonefile['error'] return False # right hash? if blockstack_client.hash_zonefile( zonefile ) != zonefile_hash: print "wrong zonefile: %s != %s" % (blockstack_client.hash_zonefile(zonefile), zonefile_hash) return False names_owned = testlib.blockstack_cli_names() if 'error' in names_owned: print "rpc names: %s" % names_owned['error'] return False # we still own the name if len(names_owned['names_owned']) != 1: print "owned: %s" % names_owned['names_owned'] return False # all queues are drained queue_info = testlib.blockstack_client_queue_state() if len(queue_info) > 0: print "Still in queue:\n%s" % json.dumps(queue_info, indent=4, sort_keys=True) return False return True
def check( state_engine ): global zonefile_hash # not revealed, but ready ns = state_engine.get_namespace_reveal( "test" ) if ns is not None: print "namespace reveal exists" 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 # registered name_rec = state_engine.get_name( "foo.test" ) if name_rec is None: print "name does not exist" return False # owned by owner_address = wallets[4].addr if name_rec['address'] != owner_address or name_rec['sender'] != virtualchain.make_payment_script(owner_address): print "sender is wrong" return False # value hash if name_rec['value_hash'] != zonefile_hash: print "wrong zonefile hash: %s != %s" % (name_rec['value_hash'], zonefile_hash) return False # replicated? zonefile = testlib.blockstack_get_zonefile( zonefile_hash ) if 'error' in zonefile: print "zonefile error: %s" % zonefile['error'] return False # right hash? if blockstack_client.hash_zonefile( zonefile ) != zonefile_hash: print "wrong zonefile: %s != %s" % (blockstack_client.hash_zonefile(zonefile), zonefile_hash) return False # latest key? if not zonefile.has_key("txt"): print "no txt:\n%s" % json.dumps(zonefile, indent=4, sort_keys=True) return False if len(zonefile['txt']) != 2: print "wrong number of txt records:\n%s" % json.dumps(zonefile, indent=4, sort_keys=True) return False for txtrec in zonefile['txt']: if txtrec['name'] == 'pubkey': if new_data_pubkey not in txtrec['txt']: print "wrong pubkey:\n%s" % json.dumps(zonefile, indent=4, sort_keys=True) print "missing %s" % new_data_pubkey return False names_owned = testlib.blockstack_cli_names() if 'error' in names_owned: print "rpc names: %s" % names_owned['error'] return False # we still own the name if len(names_owned['names_owned']) != 1: print "owned: %s" % names_owned['names_owned'] return False # all queues are drained queue_info = testlib.blockstack_client_queue_state() if len(queue_info) > 0: print "Still in queue:\n%s" % json.dumps(queue_info, indent=4, sort_keys=True) return False return True
def scenario( wallets, **kw ): global preorder_info, register_info, update_info, balance_before, balance_after, names_owned_before, names_owned_after, whois, blockchain_record, deposit_info, price_info global blockchain_history, zonefile_info, all_names_info, namespace_names_info, wallet_info, lookup_info, update_history, zonefile_history, names_info 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 ) wallet = testlib.blockstack_client_initialize_wallet( "0123456789abcdef", wallets[2].privkey, wallets[3].privkey, wallets[4].privkey ) balance_before = testlib.blockstack_cli_balance() deposit_info = testlib.blockstack_cli_deposit() price_info = testlib.blockstack_cli_price( "foo.test", password="******" ) wallet_info = testlib.blockstack_cli_wallet( "0123456789abcdef" ) resp = testlib.blockstack_cli_register( "foo.test", "0123456789abcdef" ) if 'error' in resp: print >> sys.stderr, json.dumps(resp, indent=4, sort_keys=True) return False # wait for the preorder to get confirmed for i in xrange(0, 5): testlib.next_block( **kw ) # queued? preorder_info = testlib.blockstack_cli_info() names_owned_before = testlib.blockstack_cli_get_names_owned_by_address( wallets[3].addr ) for i in xrange(0, 7): testlib.next_block( **kw ) # wait for the poller to pick it up print >> sys.stderr, "Waiting 10 seconds for the backend to submit the register" time.sleep(10) # wait for the register to get confirmed for i in xrange(0, 5): testlib.next_block( **kw ) # registered? register_info = testlib.blockstack_cli_info() names_info = testlib.blockstack_cli_names() for i in xrange(0, 7): testlib.next_block( **kw ) print >> sys.stderr, "Waiting 10 seconds for the backend to acknowledge registration" time.sleep(10) # wait for update to get confirmed for i in xrange(0, 5): testlib.next_block( **kw ) update_info = testlib.blockstack_cli_info() names_owned_after = testlib.blockstack_cli_get_names_owned_by_address( wallets[3].addr ) whois = testlib.blockstack_cli_whois( "foo.test" ) for i in xrange(0, 7): testlib.next_block( **kw ) print >> sys.stderr, "Waiting 10 seconds for the backend to acknowledge update" time.sleep(10) # put some immutable data put_immutable_info = testlib.blockstack_cli_put_immutable( "foo.test", "hello_world", '{"hello": "world"}' ) if 'error' in put_immutable_info: print "put_immutable failed" print json.dumps(put_immutable_info, indent=4, sort_keys=True) return False # wait for update to be confirmed for i in xrange(0, 12): testlib.next_block( **kw ) print >> sys.stderr, "Waiting 10 seconds for backend to acknowledge put-immutable update" time.sleep(10) balance_after = testlib.blockstack_cli_balance() blockchain_history = testlib.blockstack_cli_get_name_blockchain_history( "foo.test" ) zonefile_info = testlib.blockstack_cli_get_name_zonefile( "foo.test", json=False ) all_names_info = testlib.blockstack_cli_get_all_names(0) namespace_names_info = testlib.blockstack_cli_get_names_in_namespace("test", 0) lookup_info = testlib.blockstack_cli_lookup( "foo.test" ) update_history = testlib.blockstack_cli_list_update_history( "foo.test" ) zonefile_history = testlib.blockstack_cli_list_zonefile_history( "foo.test" ) blockchain_record = testlib.blockstack_cli_get_name_blockchain_record( "foo.test" )
def scenario(wallets, **kw): global preorder_info, register_info, update_info, balance_before, balance_after, names_owned_before, names_owned_after, whois, blockchain_record, deposit_info, price_info global blockchain_history, zonefile_info, all_names_info, namespace_names_info, wallet_info, lookup_info, update_history, zonefile_history, names_info 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) wallet = testlib.blockstack_client_initialize_wallet( "0123456789abcdef", wallets[2].privkey, wallets[3].privkey, wallets[4].privkey) balance_before = testlib.blockstack_cli_balance() deposit_info = testlib.blockstack_cli_deposit() price_info = testlib.blockstack_cli_price("foo.test", password="******") wallet_info = testlib.blockstack_cli_wallet("0123456789abcdef") resp = testlib.blockstack_cli_register("foo.test", "0123456789abcdef") if 'error' in resp: print >> sys.stderr, json.dumps(resp, indent=4, sort_keys=True) return False # wait for the preorder to get confirmed for i in xrange(0, 5): testlib.next_block(**kw) # queued? preorder_info = testlib.blockstack_cli_info() names_owned_before = testlib.blockstack_cli_get_names_owned_by_address( wallets[3].addr) for i in xrange(0, 7): testlib.next_block(**kw) # wait for the poller to pick it up print >> sys.stderr, "Waiting 10 seconds for the backend to submit the register" time.sleep(10) # wait for the register to get confirmed for i in xrange(0, 5): testlib.next_block(**kw) # registered? register_info = testlib.blockstack_cli_info() names_info = testlib.blockstack_cli_names() for i in xrange(0, 7): testlib.next_block(**kw) print >> sys.stderr, "Waiting 10 seconds for the backend to acknowledge registration" time.sleep(10) # wait for update to get confirmed for i in xrange(0, 5): testlib.next_block(**kw) update_info = testlib.blockstack_cli_info() names_owned_after = testlib.blockstack_cli_get_names_owned_by_address( wallets[3].addr) whois = testlib.blockstack_cli_whois("foo.test") for i in xrange(0, 7): testlib.next_block(**kw) print >> sys.stderr, "Waiting 10 seconds for the backend to acknowledge update" time.sleep(10) # put some immutable data put_immutable_info = testlib.blockstack_cli_put_immutable( "foo.test", "hello_world", '{"hello": "world"}') if 'error' in put_immutable_info: print "put_immutable failed" print json.dumps(put_immutable_info, indent=4, sort_keys=True) return False # wait for update to be confirmed for i in xrange(0, 12): testlib.next_block(**kw) print >> sys.stderr, "Waiting 10 seconds for backend to acknowledge put-immutable update" time.sleep(10) balance_after = testlib.blockstack_cli_balance() blockchain_history = testlib.blockstack_cli_get_name_blockchain_history( "foo.test") zonefile_info = testlib.blockstack_cli_get_name_zonefile("foo.test", json=False) all_names_info = testlib.blockstack_cli_get_all_names(0) namespace_names_info = testlib.blockstack_cli_get_names_in_namespace( "test", 0) lookup_info = testlib.blockstack_cli_lookup("foo.test") update_history = testlib.blockstack_cli_list_update_history("foo.test") zonefile_history = testlib.blockstack_cli_list_zonefile_history("foo.test") blockchain_record = testlib.blockstack_cli_get_name_blockchain_record( "foo.test")