def scenario( wallets, **kw ): global zonefile_hash 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 ) 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, 12): 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, 12): # warn the serialization checker that this changes behavior from 0.13 print "BLOCKSTACK_SERIALIZATION_CHECK_IGNORE value_hash" sys.stdout.flush() testlib.next_block( **kw ) print >> sys.stderr, "Waiting 10 seconds for the backend to acknowledge registration" time.sleep(10) # wait for initial update to get confirmed for i in xrange(0, 12): # warn the serialization checker that this changes behavior from 0.13 print "BLOCKSTACK_SERIALIZATION_CHECK_IGNORE value_hash" sys.stdout.flush() testlib.next_block( **kw ) print >> sys.stderr, "Waiting 10 seconds for the backend to acknowledge update" time.sleep(10) # what's the name's renewal block? proxy = testlib.make_proxy() res = blockstack_client.get_name_blockchain_record( "foo.test", proxy=proxy ) if 'error' in res: print >> sys.stderr, json.dumps(res, indent=4, sort_keys=True) return False old_expire_block = res['expire_block'] # send an update, changing the zonefile data_pubkey = wallet['data_pubkey'] zonefile = blockstack_client.zonefile.make_empty_zonefile( "foo.test", data_pubkey ) blockstack_client.user.put_immutable_data_zonefile( zonefile, "testdata", blockstack_client.get_data_hash("testdata"), data_url="file:///testdata") zonefile_json = json.dumps(zonefile) resp = testlib.blockstack_cli_update( "foo.test", zonefile_json, "0123456789abcdef" ) if 'error' in resp: print >> sys.stderr, "update error: %s" % resp['error'] return False zonefile_hash = resp['zonefile_hash'] # wait for it to go through for i in xrange(0, 12): # warn the serialization checker that this changes behavior from 0.13 print "BLOCKSTACK_SERIALIZATION_CHECK_IGNORE value_hash" sys.stdout.flush() testlib.next_block( **kw ) print >> sys.stderr, "Waiting 10 seconds for the backend to acknowedge the update" time.sleep(10) # wait for it to go through for i in xrange(0, 12): # warn the serialization checker that this changes behavior from 0.13 print "BLOCKSTACK_SERIALIZATION_CHECK_IGNORE value_hash" sys.stdout.flush() testlib.next_block( **kw ) # revoke it resp = testlib.blockstack_cli_revoke( "foo.test", "0123456789abcdef" ) if 'error' in resp: print >> sys.stderr, "Revoke request failed:\n%s" % json.dumps(resp, indent=4, sort_keys=True) return False print >> sys.stderr, "Waiting 10 seconds for the backend to acknowledge the revoke" time.sleep(10) # wait for it to go through for i in xrange(0, 12): testlib.next_block( **kw )
def scenario(wallets, **kw): global zonefile_hash 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) resp = testlib.blockstack_rpc_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, 12): 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, 12): 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, 12): testlib.next_block(**kw) print >> sys.stderr, "Waiting 10 seconds for the backend to acknowledge update" time.sleep(10) # send an update, changing the zonefile data_pubkey = wallet['data_pubkey'] zonefile = blockstack_client.user.make_empty_user_zonefile( "foo.test", data_pubkey) blockstack_client.user.put_immutable_data_zonefile( zonefile, "testdata", blockstack_client.get_data_hash("testdata"), data_url="file:///testdata") zonefile_json = json.dumps(zonefile) resp = testlib.blockstack_rpc_update("foo.test", zonefile_json, "0123456789abcdef") if 'error' in resp: print >> sys.stderr, "update error: %s" % resp['error'] return False zonefile_hash = resp['zonefile_hash'] # wait for it to go through for i in xrange(0, 12): testlib.next_block(**kw) print >> sys.stderr, "Waiting 10 seconds for the backend to acknowedge the update" time.sleep(10) # transfer to a new address resp = testlib.blockstack_rpc_transfer("foo.test", wallets[4].addr, "0123456789abcdef") if 'error' in resp: print >> sys.stderr, "transfer error: %s" % resp['error'] return False # wait for it to go through for i in xrange(0, 12): testlib.next_block(**kw) print >> sys.stderr, "Waiting 10 seconds for the backend to acknowledge the transfer" time.sleep(10) # regenerate the wallet, with the new owner address wallet = testlib.blockstack_client_set_wallet("0123456789abcdef", wallets[2].privkey, wallets[4].privkey, wallets[4].privkey) # renew it, using the same payment key resp = testlib.blockstack_rpc_renew("foo.test", "0123456789abcdef") if 'error' in resp: print >> sys.stderr, "Renewal request failed:\n%s" % json.dumps( resp, indent=4, sort_keys=True) return False print >> sys.stderr, "Waiting 10 seconds for the backend to acknowledge the renewal" time.sleep(10) proxy = testlib.make_proxy() res = blockstack_client.get_name_blockchain_record("foo.test", proxy=proxy) if 'error' in res: print >> sys.stderr, json.dumps(res, indent=4, sort_keys=True) return False new_expire_block = res['expire_block'] if old_expire_block >= new_expire_block + 12: # didn't go through print >> sys.stderr, "Renewal didn't go through: %s --> %s" % ( old_expire_block, new_expire_block) return False
def scenario( wallets, **kw ): global zonefile_hash, final_balance, new_expire_block 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 ) 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, 12): 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, 12): # warn the serialization checker that this changes behavior from 0.13 print "BLOCKSTACK_SERIALIZATION_CHECK_IGNORE value_hash" sys.stdout.flush() testlib.next_block( **kw ) print >> sys.stderr, "Waiting 10 seconds for the backend to acknowledge registration" time.sleep(10) # wait for initial update to get confirmed for i in xrange(0, 12): # warn the serialization checker that this changes behavior from 0.13 print "BLOCKSTACK_SERIALIZATION_CHECK_IGNORE value_hash" sys.stdout.flush() testlib.next_block( **kw ) print >> sys.stderr, "Waiting 10 seconds for the backend to acknowledge update" time.sleep(10) # what's the name's renewal block? proxy = testlib.make_proxy() res = blockstack_client.get_name_blockchain_record( "foo.test", proxy=proxy ) if 'error' in res: print >> sys.stderr, json.dumps(res, indent=4, sort_keys=True) return False old_expire_block = res['expire_block'] # send an update, changing the zonefile data_pubkey = wallet['data_pubkey'] zonefile = blockstack_client.zonefile.make_empty_zonefile( "foo.test", data_pubkey ) blockstack_client.user.put_immutable_data_zonefile( zonefile, "testdata", blockstack_client.get_data_hash("testdata"), data_url="file:///testdata") zonefile_json = json.dumps(zonefile) resp = testlib.blockstack_cli_update( "foo.test", zonefile_json, "0123456789abcdef" ) if 'error' in resp: print >> sys.stderr, "update error: %s" % resp['error'] return False zonefile_hash = resp['zonefile_hash'] # wait for it to go through for i in xrange(0, 12): # warn the serialization checker that this changes behavior from 0.13 print "BLOCKSTACK_SERIALIZATION_CHECK_IGNORE value_hash" sys.stdout.flush() testlib.next_block( **kw ) print >> sys.stderr, "Waiting 10 seconds for the backend to acknowedge the update" time.sleep(10) # wait for it to go through for i in xrange(0, 12): # warn the serialization checker that this changes behavior from 0.13 print "BLOCKSTACK_SERIALIZATION_CHECK_IGNORE value_hash" sys.stdout.flush() testlib.next_block( **kw ) # renew it resp = testlib.blockstack_cli_renew( "foo.test", "0123456789abcdef" ) if 'error' in resp: print >> sys.stderr, "Renewal request failed:\n%s" % json.dumps(resp, indent=4, sort_keys=True) return False print >> sys.stderr, "Waiting 10 seconds for the backend to acknowledge the renewal" time.sleep(10) # wait for it to go through for i in xrange(0, 6): # warn the serialization checker that this changes behavior from 0.13 print "BLOCKSTACK_SERIALIZATION_CHECK_IGNORE value_hash" sys.stdout.flush() testlib.next_block( **kw ) # verify that it's in the queue queue_state = testlib.blockstack_cli_info() if 'error' in queue_state: print json.dumps(queue_state) return False if not queue_state.has_key('queues'): print 'no queues' print json.dumps(queue_state) return False if not queue_state['queues'].has_key('renew'): print 'no renew queue' print json.dumps(queue_state) return False if len(queue_state['queues']['renew']) != 1: print 'wrong renew state' print json.dumps(queue_state) return False if queue_state['queues']['renew'][0]['name'] != 'foo.test': print 'wrong name' print json.dumps(queue_state) return False # wait for it to go through for i in xrange(0, 6): # warn the serialization checker that this changes behavior from 0.13 print "BLOCKSTACK_SERIALIZATION_CHECK_IGNORE value_hash" sys.stdout.flush() testlib.next_block( **kw ) proxy = testlib.make_proxy() res = blockstack_client.get_name_blockchain_record( "foo.test", proxy=proxy ) if 'error' in res: print >> sys.stderr, json.dumps(res, indent=4, sort_keys=True) return False new_expire_block = res['expire_block'] if old_expire_block >= new_expire_block + 12: # didn't go through print >> sys.stderr, "Renewal didn't go through: %s --> %s" % (old_expire_block, new_expire_block) return False if res['op'] != blockstack_client.config.NAME_REGISTRATION + ":": print >> sys.stderr, "Renewal didn't go through (last op is %s)" % res['op'] error = True return False final_balance = testlib.getbalance( wallets[2].addr )
def scenario(wallets, **kw): global zonefile_hash 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) 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, 12): 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, 12): # warn the serialization checker that this changes behavior from 0.13 print "BLOCKSTACK_SERIALIZATION_CHECK_IGNORE value_hash" sys.stdout.flush() testlib.next_block(**kw) print >> sys.stderr, "Waiting 10 seconds for the backend to acknowledge registration" time.sleep(10) # wait for initial update to get confirmed for i in xrange(0, 12): # warn the serialization checker that this changes behavior from 0.13 print "BLOCKSTACK_SERIALIZATION_CHECK_IGNORE value_hash" sys.stdout.flush() testlib.next_block(**kw) print >> sys.stderr, "Waiting 10 seconds for the backend to acknowledge update" time.sleep(10) # wait for zonefile posting for i in xrange(0, 12): # warn the serialization checker that this changes behavior from 0.13 print "BLOCKSTACK_SERIALIZATION_CHECK_IGNORE value_hash" sys.stdout.flush() testlib.next_block(**kw) print >> sys.stderr, "Waiting 10 seconds for the backend to send zonefile" time.sleep(10) # what's the name's renewal block? proxy = testlib.make_proxy() res = blockstack_client.get_name_blockchain_record("foo.test", proxy=proxy) if 'error' in res: print >> sys.stderr, json.dumps(res, indent=4, sort_keys=True) return False old_expire_block = res['expire_block'] # send an update, changing the zonefile data_pubkey = wallet['data_pubkey'] zonefile = blockstack_client.zonefile.make_empty_zonefile( "foo.test", data_pubkey) blockstack_client.user.put_immutable_data_zonefile( zonefile, "testdata", blockstack_client.get_data_hash("testdata"), data_url="file:///testdata") zonefile_json = json.dumps(zonefile) resp = testlib.blockstack_cli_update("foo.test", zonefile_json, "0123456789abcdef") if 'error' in resp: print >> sys.stderr, "update error: %s" % resp['error'] return False zonefile_hash = resp['zonefile_hash'] # wait for it to go through for i in xrange(0, 12): # warn the serialization checker that this changes behavior from 0.13 print "BLOCKSTACK_SERIALIZATION_CHECK_IGNORE value_hash" sys.stdout.flush() testlib.next_block(**kw) print >> sys.stderr, "Waiting 10 seconds for the backend to acknowedge the update" time.sleep(10) # wait for it to go through for i in xrange(0, 12): # warn the serialization checker that this changes behavior from 0.13 print "BLOCKSTACK_SERIALIZATION_CHECK_IGNORE value_hash" sys.stdout.flush() testlib.next_block(**kw) # revoke it resp = testlib.blockstack_cli_revoke("foo.test", "0123456789abcdef") if 'error' in resp: print >> sys.stderr, "Revoke request failed:\n%s" % json.dumps( resp, indent=4, sort_keys=True) return False print >> sys.stderr, "Waiting 10 seconds for the backend to acknowledge the revoke" time.sleep(10) # wait for it to go through for i in xrange(0, 12): testlib.next_block(**kw)
def scenario( wallets, **kw ): global zonefile_hash 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 ) resp = testlib.blockstack_rpc_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, 12): 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, 12): 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, 12): testlib.next_block( **kw ) print >> sys.stderr, "Waiting 10 seconds for the backend to acknowledge update" time.sleep(10) # send an update, changing the zonefile data_pubkey = wallet['data_pubkey'] zonefile = blockstack_client.user.make_empty_user_zonefile( "foo.test", data_pubkey ) blockstack_client.user.put_immutable_data_zonefile( zonefile, "testdata", blockstack_client.get_data_hash("testdata"), data_url="file:///testdata") zonefile_json = json.dumps(zonefile) resp = testlib.blockstack_rpc_update( "foo.test", zonefile_json, "0123456789abcdef" ) if 'error' in resp: print >> sys.stderr, "update error: %s" % resp['error'] return False zonefile_hash = resp['zonefile_hash'] # wait for it to go through for i in xrange(0, 12): testlib.next_block( **kw ) print >> sys.stderr, "Waiting 10 seconds for the backend to acknowedge the update" time.sleep(10) # transfer to a new address resp = testlib.blockstack_rpc_transfer( "foo.test", wallets[4].addr, "0123456789abcdef" ) if 'error' in resp: print >> sys.stderr, "transfer error: %s" % resp['error'] return False # wait for it to go through for i in xrange(0, 12): testlib.next_block( **kw ) print >> sys.stderr, "Waiting 10 seconds for the backend to acknowledge the transfer" time.sleep(10) # regenerate the wallet, with the new owner address wallet = testlib.blockstack_client_set_wallet( "0123456789abcdef", wallets[2].privkey, wallets[4].privkey, wallets[4].privkey ) # renew it, using the same payment key resp = testlib.blockstack_rpc_renew( "foo.test", "0123456789abcdef" ) if 'error' in resp: print >> sys.stderr, "Renewal request failed:\n%s" % json.dumps(resp, indent=4, sort_keys=True) return False print >> sys.stderr, "Waiting 10 seconds for the backend to acknowledge the renewal" time.sleep(10) proxy = testlib.make_proxy() res = blockstack_client.get_name_blockchain_record( "foo.test", proxy=proxy ) if 'error' in res: print >> sys.stderr, json.dumps(res, indent=4, sort_keys=True) return False new_expire_block = res['expire_block'] if old_expire_block >= new_expire_block + 12: # didn't go through print >> sys.stderr, "Renewal didn't go through: %s --> %s" % (old_expire_block, new_expire_block) return False