def scenario(wallets, **kw): testlib.blockstack_namespace_preorder("id", wallets[1].addr, wallets[0].privkey) testlib.next_block(**kw) testlib.blockstack_namespace_reveal( "id", 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("id", 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.id", "0123456789abcdef", recipient_address='mi8mUNSFC9EoGXmjPF8vKqCUSfGE2fbD4V') 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) r = blockstack_client.actions.cli_get_registrar_info(None) assert 'errors' not in r['register'][0] # 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 the update to go off for i in xrange(0, 8): testlib.next_block(**kw) # drain the wallet print >> sys.stderr, "Lets drain the wallet." testlib.blockstack_cli_withdraw("0123456789abcdef", 'mi8mUNSFC9EoGXmjPF8vKqCUSfGE2fbD4V') print >> sys.stderr, "Drained!" for i in xrange(0, 11): testlib.next_block(**kw) print >> sys.stderr, "Waiting 10 seconds for the backend to acknowledge update" time.sleep(10)
def scenario(wallets, **kw): 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) for j in xrange(0, 3): resp = testlib.blockstack_cli_register("foo_%s.test" % j, "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 them up print >> sys.stderr, "Waiting 10 seconds for the backend to submit the registers on foo_%s.test" % j time.sleep(10) # wait for the registers to get confirmed for i in xrange(0, 15): # tell serialization-checker that value_hash can be ignored here 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 registrations on foo_%s.test" % j time.sleep(10) # wait for update to get confirmed for i in xrange(0, 15): # 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 on foo_%s.test" % j time.sleep(10)
def scenario( wallets, **kw ): 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): 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) # let's make sure the zonefile propagates... res = testlib.blockstack_REST_call("GET", "/v1/names/foo.test", None) if 'error' in res or res['http_status'] != 200: res['test'] = 'Failed to get name bar.test' print json.dumps(res) return False response_json = json.loads(res['raw']) # assert that we're getting a mainnet address if response_json['address'] != "1K4SCfqffVHTnHvqsW2whH1Jn57dDjDdQA": print "Address returned to REST call isn't converted to mainnet!" print "Returned: {}, Expected: {}".format(response_json['address'], "1K4SCfqffVHTnHvqsW2whH1Jn57dDjDdQA") return False
def scenario( wallets, **kw ): testlib.blockstack_namespace_preorder( "id", wallets[1].addr, wallets[0].privkey ) testlib.next_block( **kw ) testlib.blockstack_namespace_reveal( "id", 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( "id", 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.id", "0123456789abcdef", recipient_address = 'mi8mUNSFC9EoGXmjPF8vKqCUSfGE2fbD4V') 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) r = blockstack_client.actions.cli_get_registrar_info(None) assert 'errors' not in r['register'][0] # 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 the update to go off for i in xrange(0, 8): testlib.next_block( **kw ) # drain the wallet print >> sys.stderr, "Lets drain the wallet." testlib.blockstack_cli_withdraw( "0123456789abcdef", 'mi8mUNSFC9EoGXmjPF8vKqCUSfGE2fbD4V' ) print >> sys.stderr, "Drained!" for i in xrange(0, 11): testlib.next_block( **kw ) print >> sys.stderr, "Waiting 10 seconds for the backend to acknowledge update" time.sleep(10)
def scenario(wallets, **kw): 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, None) for i in xrange(0, 5): resp = testlib.blockstack_cli_register("foo_%s.test" % i, "0123456789abcdef") if 'error' in resp: print >> sys.stderr, json.dumps(resp, indent=4, sort_keys=True) return False # wait for tx confirmation # (takes a few secs) for i in xrange(0, 6): testlib.next_block(**kw) # wait for the preorder to get confirmed for i in xrange(0, 12): testlib.next_block(**kw) # wait for the poller to pick them up print >> sys.stderr, "Waiting 10 seconds for the backend to submit the registers" time.sleep(10) # wait for the registers to get confirmed for i in xrange(0, 12): testlib.next_block(**kw) print >> sys.stderr, "Waiting 10 seconds for the backend to acknowledge registrations" 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)
def scenario( wallets, **kw ): 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 ) driver_urls = blockstack_client.storage.make_mutable_data_urls('foo.test', use_only=['dht', 'disk']) zonefile = blockstack_client.zonefile.make_empty_zonefile('foo.test', wallets[4].pubkey_hex, urls=driver_urls) zonefile_txt = blockstack_zones.make_zone_file( zonefile, origin='foo.test', ttl=3600 ) wallet = testlib.blockstack_client_initialize_wallet( "0123456789abcdef", wallets[2].privkey, wallets[3].privkey, None ) resp = testlib.blockstack_cli_register( "foo.test", "0123456789abcdef", zonefile=zonefile_txt, recipient_address=wallets[4].addr ) 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) # wait for transfer to get confirmed for i in xrange(0, 12): testlib.next_block( **kw ) print >> sys.stderr, "Waiting 10 seconds for the backend to acknowledge transfer" time.sleep(10)
def scenario( wallets, **kw ): 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, None ) for i in xrange(0, 5): resp = testlib.blockstack_cli_register( "foo_%s.test" % i, "0123456789abcdef" ) if 'error' in resp: print >> sys.stderr, json.dumps(resp, indent=4, sort_keys=True) return False # wait for tx confirmation # (takes a few secs) for i in xrange(0, 6): testlib.next_block( **kw ) # wait for the preorder to get confirmed for i in xrange(0, 12): testlib.next_block( **kw ) # wait for the poller to pick them up print >> sys.stderr, "Waiting 10 seconds for the backend to submit the registers" time.sleep(10) # wait for the registers to get confirmed for i in xrange(0, 12): testlib.next_block( **kw ) print >> sys.stderr, "Waiting 10 seconds for the backend to acknowledge registrations" 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)
def scenario( wallets, **kw ): 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 ) for j in xrange(0, 3): resp = testlib.blockstack_cli_register( "foo_%s.test" % j, "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 them up print >> sys.stderr, "Waiting 10 seconds for the backend to submit the registers on foo_%s.test" % j time.sleep(10) # wait for the registers to get confirmed for i in xrange(0, 15): # tell serialization-checker that value_hash can be ignored here 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 registrations on foo_%s.test" % j time.sleep(10) # wait for update to get confirmed for i in xrange(0, 15): # 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 on foo_%s.test" % j time.sleep(10)
def scenario(wallets, **kw): start_transaction_broadcaster() start_subdomain_registrar() testlib.blockstack_namespace_preorder("id", wallets[1].addr, wallets[0].privkey) testlib.next_block(**kw) testlib.blockstack_namespace_reveal( "id", 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("id", 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.id", "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)
def scenario(wallets, **kw): 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) wallet = testlib.blockstack_client_initialize_wallet( "0123456789abcdef", wallets[2].privkey, wallets[3].privkey, wallets[4].privkey) args = ARGS() ret = actions.cli_withdraw(args, "0123456789abcdef", False) print ret tx = ret['tx'] # these should end up having the SAME utxo. resp = testlib.blockstack_cli_register("foo.test", "0123456789abcdef") if 'error' in resp: import sys print >> sys.stderr, json.dumps(resp, indent=4, sort_keys=True) return False testlib.next_block(**kw) testlib.broadcast_tx(tx) for i in xrange(0, 12): testlib.next_block(**kw)
def scenario( wallets, **kw ): 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 ) wallet = testlib.blockstack_client_initialize_wallet( "0123456789abcdef", wallets[2].privkey, wallets[3].privkey, wallets[4].privkey ) args = ARGS() ret = actions.cli_withdraw(args, "0123456789abcdef", False) print ret tx = ret['tx'] # these should end up having the SAME utxo. 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 testlib.next_block( **kw ) testlib.broadcast_tx(tx) 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_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 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) # transfer to a new address resp = testlib.blockstack_cli_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): # 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 the transfer" time.sleep(10) 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[0].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(15) # 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(15) # wait for 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(15) # transfer to a new address resp = testlib.blockstack_cli_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): # 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 the transfer" time.sleep(15) testlib.next_block(**kw)
def scenario(wallets, **kw): global owner_address 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) payment_address = virtualchain.BitcoinPrivateKey( wallets[2].privkey).public_key().address() owner_address = virtualchain.BitcoinPrivateKey( wallets[3].privkey).public_key().address() testlib.delete_wallet() wallet_files = testlib.list_wallet_backups() if len(wallet_files) > 0: print "still have {}".format(wallet_files) return False # import a single-sig wallet, with a data key res = testlib.blockstack_cli_import_wallet("0123456789abcdef", wallets[2].privkey, wallets[3].privkey, wallets[4].privkey) if 'error' in res: print json.dumps(res, indent=4, sort_keys=True) return False # should still be none wallet_files = testlib.list_wallet_backups() if len(wallet_files) > 0: print "still have {} after import".format(wallet_files) return False testlib.start_api("0123456789abcdef") # register 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): 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)
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) # store a new zonefile data_pubkey = wallet['data_pubkey'] zonefile = blockstack_client.zonefile.make_empty_zonefile( "foo.test", data_pubkey ) assert blockstack_client.user.put_immutable_data_zonefile( zonefile, "testdata", blockstack_client.get_data_hash("testdata") ) zonefile_txt = blockstack_zones.make_zone_file( zonefile ) zonefile_hash = blockstack_client.storage.get_zonefile_data_hash( zonefile_txt ) print >> sys.stderr, "\n\nzonefile hash: %s\nzonefile:\n%s\n\n" % (zonefile_hash, zonefile_txt) # will store to queue test_proxy = testlib.make_proxy() config_path = test_proxy.config_path conf = blockstack_client.config.get_config(config_path) queuedb_path = conf['queue_path'] # update the zonefile hash, but not the zonefile. resp = testlib.blockstack_cli_set_zonefile_hash( "foo.test", zonefile_hash ) if 'error' in resp: print >> sys.stderr, "\nFailed to set zonefile hash: %s\n" % resp return False txhash = resp['transaction_hash'] 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) # stop endpoint print >> sys.stderr, "\nstopping RPC daemon\n" config_dir = os.path.dirname(test_proxy.config_path) blockstack_client.rpc.local_api_stop(config_dir=config_dir) time.sleep(3) # store to queue res = blockstack_client.backend.queue.queue_append("update", "foo.test", txhash, payment_address=wallets[2].addr, owner_address=wallets[3].addr, config_path=test_proxy.config_path, zonefile_data=zonefile_txt, zonefile_hash=zonefile_hash, path=queuedb_path ) # verify that we can sync the zonefile, using the in-queue zonefile resp = testlib.blockstack_cli_sync_zonefile( "foo.test" ) if 'error' in resp: print >> sys.stderr, "\nfailed to sync zonefile: %s\n" % resp return False blockstack_client.backend.queue.queuedb_remove("update", "foo.test", txhash, path=queuedb_path ) print >> sys.stderr, "\nstarting RPC daemon\n" testlib.start_api("0123456789abcdef") # store a new zonefile zonefile = blockstack_client.zonefile.make_empty_zonefile( "foo.test", data_pubkey ) blockstack_client.user.put_immutable_data_zonefile( zonefile, "testdata2", blockstack_client.get_data_hash("testdata") ) zonefile_txt = blockstack_zones.make_zone_file( zonefile ) zonefile_hash = blockstack_client.storage.get_zonefile_data_hash( zonefile_txt ) # store locally res = blockstack_client.zonefile.store_name_zonefile("foo.test", zonefile, None, storage_drivers=['disk']) if 'error' in res: print >> sys.stderr, "\nFailed to store zonefile: %s\n" % res return False # update the zonefile hash, but not the zonefile. resp = testlib.blockstack_cli_set_zonefile_hash( "foo.test", zonefile_hash ) if 'error' in resp: print >> sys.stderr, "\nFailed to set zonefile hash: %s\n" % resp return False 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 ) # verify that we can sync the zonefile, using the on-disk zonefile resp = testlib.blockstack_cli_sync_zonefile( "foo.test" ) if 'error' in resp: print >> sys.stderr, "update 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 acknowedge the update" time.sleep(10)
def scenario(wallets, **kw): global owner_address 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) legacy_wallet = testlib.make_legacy_wallet(wallets[2].privkey, "0123456789abcdef") testlib.store_wallet(legacy_wallet) res = testlib.blockstack_cli_setup_wallet("0123456789abcdef") if 'error' in res: print json.dumps(res, indent=4, sort_keys=True) return False if not res.has_key('backup_wallet'): print "no backup_wallet" print json.dumps(res, indent=4, sort_keys=True) return False if not os.path.exists(res['backup_wallet']): print "backup wallet doesn't exist" print json.dumps(res, indent=4, sort_keys=True) return False res = testlib.instantiate_wallet() if 'error' in res: print json.dumps(res, indent=4, sort_keys=True) return False payment_address = str(res['payment_address']) owner_address = str(res['owner_address']) # fill wallet with 5 BTC res = testlib.send_funds(wallets[3].privkey, 5 * 10**8, payment_address) if 'error' in res: print "failed to fill wallet" print json.dumps(res) return False testlib.next_block(**kw) # register 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): 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)
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 put_result, wallet_keys, datasets, zonefile_hash, dataset_change wallet = testlib.blockstack_client_initialize_wallet( "0123456789abcdef", wallets[2].privkey, wallets[3].privkey, wallets[4].privkey) test_proxy = testlib.TestAPIProxy() blockstack_client.set_default_proxy(test_proxy) wallet_keys = blockstack_client.make_wallet_keys( owner_privkey=wallets[3].privkey, data_privkey=wallets[4].privkey) 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) 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 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 for the backend to acknowledge registration" time.sleep(10) # wait for initial update to get confirmed for i in xrange(0, 12): # tell serialization-checker that value_hash can be ignored here print "BLOCKSTACK_SERIALIZATION_CHECK_IGNORE value_hash" sys.stdout.flush() testlib.next_block(**kw) print >> sys.stderr, "Waiting for the backend to acknowledge update" time.sleep(10) # wait for zonefile/profile replication for i in xrange(0, 12): testlib.next_block(**kw) print >> sys.stderr, "Waiting for the backend to replicate zonefile and profile" time.sleep(10) # make a few accounts res = testlib.blockstack_cli_put_account("foo.test", "serviceFoo", "serviceFooID", "foo://bar.com", "0123456789abcdef", extra_data='foofield=foo!', wallet_keys=wallet_keys) if 'error' in res: res['test'] = 'Failed to create foo.test serviceFoo account' print json.dumps(res, indent=4, sort_keys=True) error = True return time.sleep(2) res = testlib.blockstack_cli_put_account("foo.test", "serviceBar", "serviceBarID", "bar://baz.com", "0123456789abcdef", extra_data='barfield=bar!', wallet_keys=wallet_keys) if 'error' in res: res['test'] = 'Failed to create foo.test serviceBar account' print json.dumps(res, indent=4, sort_keys=True) error = True return time.sleep(2) # put some data put_result = testlib.blockstack_cli_put_mutable( "foo.test", "hello_world_1", json.dumps(datasets[0]), password="******") if 'error' in put_result: print json.dumps(put_result, indent=4, sort_keys=True) return False testlib.next_block(**kw) time.sleep(1) put_result = testlib.blockstack_cli_put_mutable( "foo.test", "hello_world_2", json.dumps(datasets[1]), password="******") if 'error' in put_result: print json.dumps(put_result, indent=4, sort_keys=True) return False time.sleep(2) put_result = testlib.blockstack_cli_put_mutable( "foo.test", "hello_world_3", json.dumps(datasets[2]), password="******") if 'error' in put_result: print json.dumps(put_result, indent=4, sort_keys=True) return False time.sleep(2) # increment data version too datasets[0]['buf'] = [] for i in xrange(0, 5): datasets[0]["dataset_change"] = dataset_change datasets[0]['buf'].append(i) put_result = testlib.blockstack_cli_put_mutable( "foo.test", "hello_world_1", json.dumps(datasets[0]), password="******") if 'error' in put_result: print json.dumps(put_result, indent=4, sort_keys=True) return False time.sleep(2) testlib.next_block(**kw)
def scenario( wallets, **kw ): global put_result, wallet_keys, datasets, zonefile_hash, dataset_change wallet = testlib.blockstack_client_initialize_wallet( "0123456789abcdef", wallets[2].privkey, wallets[3].privkey, wallets[4].privkey ) test_proxy = testlib.TestAPIProxy() blockstack_client.set_default_proxy( test_proxy ) wallet_keys = blockstack_client.make_wallet_keys( owner_privkey=wallets[3].privkey, data_privkey=wallets[4].privkey ) 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 ) 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 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 for the backend to acknowledge registration" time.sleep(10) # wait for initial update to get confirmed for i in xrange(0, 12): # tell serialization-checker that value_hash can be ignored here print "BLOCKSTACK_SERIALIZATION_CHECK_IGNORE value_hash" sys.stdout.flush() testlib.next_block( **kw ) print >> sys.stderr, "Waiting for the backend to acknowledge update" time.sleep(10) # wait for zonefile/profile replication for i in xrange(0, 12): testlib.next_block( **kw ) print >> sys.stderr, "Waiting for the backend to replicate zonefile and profile" time.sleep(10) # make a few accounts res = testlib.blockstack_cli_put_account("foo.test", "serviceFoo", "serviceFooID", "foo://bar.com", "0123456789abcdef", extra_data='foofield=foo!', wallet_keys=wallet_keys) if 'error' in res: res['test'] = 'Failed to create foo.test serviceFoo account' print json.dumps(res, indent=4, sort_keys=True) error = True return time.sleep(2) res = testlib.blockstack_cli_put_account("foo.test", "serviceBar", "serviceBarID", "bar://baz.com", "0123456789abcdef", extra_data='barfield=bar!', wallet_keys=wallet_keys) if 'error' in res: res['test'] = 'Failed to create foo.test serviceBar account' print json.dumps(res, indent=4, sort_keys=True) error = True return time.sleep(2) # put some data put_result = testlib.blockstack_cli_put_mutable( "foo.test", "hello_world_1", json.dumps(datasets[0]), password="******") if 'error' in put_result: print json.dumps(put_result, indent=4, sort_keys=True) return False testlib.next_block( **kw ) time.sleep(2) put_result = testlib.blockstack_cli_put_mutable( "foo.test", "hello_world_2", json.dumps(datasets[1]), password="******", \ storage_drivers=['blockstack_server'], storage_drivers_exclusive=True) if 'error' in put_result: print json.dumps(put_result, indent=4, sort_keys=True) return False time.sleep(2) put_result = testlib.blockstack_cli_put_mutable( "foo.test", "hello_world_3", json.dumps(datasets[2]), password="******", \ storage_drivers=['blockstack_server'], storage_drivers_exclusive=True) if 'error' in put_result: print json.dumps(put_result, indent=4, sort_keys=True) return False time.sleep(2) # increment data version too datasets[0]['buf'] = [] for i in xrange(0, 5): datasets[0]["dataset_change"] = dataset_change datasets[0]['buf'].append(i) put_result = testlib.blockstack_cli_put_mutable( "foo.test", "hello_world_1", json.dumps(datasets[0]), password="******", \ storage_drivers=['blockstack_server'], storage_drivers_exclusive=True) if 'error' in put_result: print json.dumps(put_result, indent=4, sort_keys=True ) return False time.sleep(2) testlib.next_block( **kw )
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): testlib.blockstack_namespace_preorder("id", wallets[1].addr, wallets[0].privkey) testlib.next_block(**kw) testlib.blockstack_namespace_reveal( "id", 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("id", wallets[1].privkey) testlib.next_block(**kw) config_path = os.environ.get("BLOCKSTACK_CLIENT_CONFIG", None) config_dir = os.path.dirname(config_path) conf = blockstack_client.get_config(config_path) assert conf api_pass = conf['api_password'] wallet = testlib.blockstack_client_initialize_wallet( "0123456789abcdef", wallets[2].privkey, wallets[3].privkey, wallets[4].privkey) resp = testlib.blockstack_cli_register("foo.id", "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) test_data = [{ 'hash': '34fdcde8b75440c5cb82480a14b4f3d731a67dc4', 'string': '$ORIGIN aaron.id\n$TTL 3600\n_http._tcp URI 10 1 "https://gaia.blockstack.org/hub/34bNQUVgyhSrA8XpM4HkerHUUdNmLpiyj7/0/profile.json"', 'decoded': None, 'b64': False }, { 'hash': 'd4fbae5d1f66f1ae0431e35bcd5a98782adc29ba', 'decoded': '$ORIGIN baron.id\n$TTL 3600\n_http._tcp URI 10 1 "https://gaia.blockstack.org/hub/34bNQUVgyhSrA8XpM4HkerHUUdNmLpiyj7/0/profile.json"', 'string': 'JE9SSUdJTiBiYXJvbi5pZAokVFRMIDM2MDAKX2h0dHAuX3RjcCBVUkkgMTAgMSAiaHR0cHM6Ly9nYWlhLmJsb2Nrc3RhY2sub3JnL2h1Yi8zNGJOUVVWZ3loU3JBOFhwTTRIa2VySFVVZE5tTHBpeWo3LzAvcHJvZmlsZS5qc29uIg==', 'b64': True }] for datum in test_data: post_data = {} if datum['b64']: key = 'zonefile_b64' else: key = 'zonefile' post_data[key] = datum['string'] zfhash = datum['hash'] res = testlib.blockstack_REST_call("PUT", "/v1/names/foo.id/zonefile", None, api_pass=api_pass, data={'zonefile_hash': zfhash}) if 'error' in res or res['http_status'] != 202: res['test'] = 'failed to update zonefile hash' print json.dumps(res) return False print >> sys.stderr, "Waiting 10 seconds for the backend to submit the register" time.sleep(10) # wait for update to get confirmed for i in xrange(0, 10): testlib.next_block(**kw) print 'Wait for second update to be confirmed' time.sleep(10) res = testlib.blockstack_REST_call("GET", "/v1/names/foo.id", None, api_pass=api_pass) if 'error' in res or res['http_status'] != 200: res['test'] = 'Failed to get name foo.id' print json.dumps(res) return False # update set? if res['response']['zonefile_hash'] != zfhash: res['test'] = 'failed to set zonefile hash' print json.dumps(res) return False res = testlib.blockstack_REST_call("POST", "/v1/zonefile/", None, api_pass=api_pass, data=post_data) if 'error' in res or res['http_status'] != 200: res['test'] = 'failed to announce zonefile' print json.dumps(res) return False print 'Broadcasted zonefile' time.sleep(10) res = testlib.blockstack_REST_call("GET", "/v1/names/foo.id", None, api_pass=api_pass) if 'error' in res or res['http_status'] != 200: res['test'] = 'Failed to get name foo.id' print json.dumps(res) return False if res['response']['zonefile'] != datum['string'] and \ res['response']['zonefile'] != datum['decoded']: res['test'] = 'failed to set zonefile string' print json.dumps(res) return False
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 owner_address 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 ) # pre-0.13 wallet legacy_wallet = testlib.make_legacy_013_wallet( wallets[2].privkey, wallets[4].privkey, "0123456789abcdef" ) testlib.store_wallet( legacy_wallet ) res = testlib.blockstack_cli_setup_wallet("0123456789abcdef") if 'error' in res: print json.dumps(res, indent=4, sort_keys=True) return False if not res.has_key('backup_wallet'): print "no backup_wallet" print json.dumps(res, indent=4, sort_keys=True) return False if not os.path.exists(res['backup_wallet']): print "backup wallet doesn't exist" print json.dumps(res, indent=4, sort_keys=True) return False res = testlib.instantiate_wallet() if 'error' in res: print json.dumps(res, indent=4, sort_keys=True) return False payment_address = str(res['payment_address']) owner_address = str(res['owner_address']) # fill wallet with 5 BTC res = testlib.send_funds( wallets[3].privkey, 5 * 10**8, payment_address ) if 'error' in res: print "failed to fill wallet" print json.dumps(res) return False testlib.next_block( **kw ) # register 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): 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)
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[5].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 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) # 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_cli_update( "foo.test", zonefile_json, "0123456789abcdef" ) if 'error' in resp: print >> sys.stderr, "update error: %s" % resp['error'] return False zonefile_hash = resp['value_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) # transfer to a new address resp = testlib.blockstack_cli_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): # 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 the transfer" time.sleep(10) # regenerate the wallet, with the new owner address wallet = testlib.blockstack_client_set_wallet( "0123456789abcdef", wallets[5].privkey, wallets[4].privkey, wallets[5].privkey ) # send another update, changing the zonefile again # pay for it using the same payment address zonefile = blockstack_client.user.make_empty_user_zonefile( "foo.test", new_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['value_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)
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) # 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_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) # store a new zonefile data_pubkey = wallet['data_pubkey'] zonefile = blockstack_client.user.make_empty_user_zonefile( "foo.test", data_pubkey ) assert blockstack_client.user.put_immutable_data_zonefile( zonefile, "testdata", blockstack_client.get_data_hash("testdata") ) zonefile_txt = blockstack_zones.make_zone_file( zonefile ) zonefile_hash = blockstack_client.storage.get_zonefile_data_hash( zonefile_txt ) print >> sys.stderr, "\n\nzonefile hash: %s\nzonefile:\n%s\n\n" % (zonefile_hash, zonefile_txt) # will store to queue test_proxy = testlib.make_proxy() config_path = test_proxy.config_path conf = blockstack_client.config.get_config(config_path) queuedb_path = conf['queue_path'] # update the zonefile hash, but not the zonefile. resp = testlib.blockstack_cli_set_zonefile_hash( "foo.test", zonefile_hash ) if 'error' in resp: print >> sys.stderr, "\nFailed to set zonefile hash: %s\n" % resp return False txhash = resp['transaction_hash'] 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) # stop endpoint print >> sys.stderr, "\nstopping RPC daemon\n" config_dir = os.path.dirname(test_proxy.config_path) blockstack_client.rpc.local_rpc_stop(config_dir=config_dir) time.sleep(3) # store to queue res = blockstack_client.backend.queue.queue_append("update", "foo.test", txhash, payment_address=wallets[2].addr, owner_address=wallets[3].addr, config_path=test_proxy.config_path, zonefile_data=zonefile_txt, zonefile_hash=zonefile_hash, path=queuedb_path ) # verify that we can sync the zonefile, using the in-queue zonefile resp = testlib.blockstack_cli_sync_zonefile( "foo.test" ) if 'error' in resp: print >> sys.stderr, "\nfailed to sync zonefile: %s\n" % resp return False blockstack_client.backend.queue.queuedb_remove("update", "foo.test", txhash, path=queuedb_path ) print >> sys.stderr, "\nstarting RPC daemon\n" blockstack_client.actions.start_rpc_endpoint(config_dir, password="******") time.sleep(3) # store a new zonefile zonefile = blockstack_client.user.make_empty_user_zonefile( "foo.test", data_pubkey ) blockstack_client.user.put_immutable_data_zonefile( zonefile, "testdata2", blockstack_client.get_data_hash("testdata") ) zonefile_txt = blockstack_zones.make_zone_file( zonefile ) zonefile_hash = blockstack_client.storage.get_zonefile_data_hash( zonefile_txt ) # store locally res = blockstack_client.profile.store_name_zonefile("foo.test", zonefile, None, storage_drivers=['disk']) if 'error' in res: print >> sys.stderr, "\nFailed to store zonefile: %s\n" % res return False # update the zonefile hash, but not the zonefile. resp = testlib.blockstack_cli_set_zonefile_hash( "foo.test", zonefile_hash ) if 'error' in resp: print >> sys.stderr, "\nFailed to set zonefile hash: %s\n" % resp return False 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 ) # verify that we can sync the zonefile, using the on-disk zonefile resp = testlib.blockstack_cli_sync_zonefile( "foo.test" ) if 'error' in resp: print >> sys.stderr, "update 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 acknowedge the update" time.sleep(10)
def scenario( wallets, **kw ): global owner_address, payment_address 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 ) payment_address = wallets[5].addr owner_address = wallets[6].addr testlib.delete_wallet() wallet_files = testlib.list_wallet_backups() if len(wallet_files) > 0: print "still have {}".format(wallet_files) return False # import a single-sig wallet, with a data key payment_str = "{},{},{},{},{}".format(2,3,wallets[5].pks[0],wallets[5].pks[1],wallets[5].pks[2]) owner_str = "{},{},{},{},{}".format(2,3,wallets[6].pks[0],wallets[6].pks[1],wallets[6].pks[2]) res = testlib.blockstack_cli_import_wallet( "0123456789abcdef", payment_str, owner_str, wallets[4].privkey ) if 'error' in res: print json.dumps(res, indent=4, sort_keys=True) return False # should still be none wallet_files = testlib.list_wallet_backups() if len(wallet_files) > 0: print "still have {} after import".format(wallet_files) return False testlib.start_api("0123456789abcdef") # register 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): 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)
def scenario(wallets, **kw): 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): 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) # let's make sure the zonefile propagates... res = testlib.blockstack_REST_call("GET", "/v1/names/foo.test", None) if 'error' in res or res['http_status'] != 200: res['test'] = 'Failed to get name bar.test' print json.dumps(res) return False response_json = json.loads(res['raw']) # assert that we're getting a mainnet address if response_json['address'] != "1K4SCfqffVHTnHvqsW2whH1Jn57dDjDdQA": print "Address returned to REST call isn't converted to mainnet!" print "Returned: {}, Expected: {}".format( response_json['address'], "1K4SCfqffVHTnHvqsW2whH1Jn57dDjDdQA") return False
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[5].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(15) # 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(15) # wait for 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(15) # 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(15) # transfer to a new address resp = testlib.blockstack_cli_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): # 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 the transfer" time.sleep(15) # regenerate the wallet, with the new owner address wallet = testlib.blockstack_client_set_wallet("0123456789abcdef", wallets[5].privkey, wallets[4].privkey, wallets[5].privkey) res = testlib.start_api("0123456789abcdef") if 'error' in res: print 'failed to start API: {}'.format(res) return False # send another update, changing the zonefile again # pay for it using the same payment address zonefile = blockstack_client.zonefile.make_empty_zonefile( "foo.test", new_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(15)
def scenario( wallets, **kw ): start_transaction_broadcaster() start_subdomain_registrar() testlib.blockstack_namespace_preorder( "id", wallets[1].addr, wallets[0].privkey ) testlib.next_block( **kw ) testlib.blockstack_namespace_reveal( "id", 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( "id", 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.id", "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) # now, queue a registration. requests.post('http://localhost:3000/register', json = { 'zonefile' : 'hello world', 'name' : 'bar', 'owner_address': '1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa' }) # force a batch out of the subdomain registrar requests.post('http://localhost:3000/issue_batch', headers = {'Authorization': 'bearer tester129'}) for i in xrange(0, 12): testlib.next_block( **kw ) print >> sys.stderr, "Waiting 10 seconds for the backend to pickup first batch" time.sleep(10) # now, queue another registration requests.post('http://localhost:3000/register', json = { 'zonefile' : 'hello world', 'name' : 'zap', 'owner_address': '1Ez69SnzzmePmZX3WpEzMKTrcBF2gpNQ55' }) res = testlib.blockstack_REST_call('GET', '/v1/names/zap.foo.id', None) if 'error' in res: res['test'] = 'Failed to query zap.foo.id' print json.dumps(res) return False if res['http_status'] != 200: res['test'] = 'HTTP status {}, response = {} on name lookup'.format(res['http_status'], res['response']) print json.dumps(res) return False name_info = res['response'] try: if (name_info['zonefile'] != 'hello world' or name_info['address'] != '1Ez69SnzzmePmZX3WpEzMKTrcBF2gpNQ55'): res['test'] = 'Unexpected name info lookup for zap.foo.id' print 'zap.foo.id JSON:' print json.dumps(name_info) return False except: res['test'] = 'Unexpected name info lookup for zap.foo.id' print 'zap.foo.id JSON:' print json.dumps(name_info) return False