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_register_user('foo.test', wallets[2].privkey, wallets[3].privkey, **kw) # let's make sure the zonefile propagates... res = testlib.blockstack_REST_call("GET", "/v1/names/foo.test") 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.blockstack_namespace_preorder("reveal", 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.blockstack_namespace_reveal( "reveal", 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) testlib.blockstack_register_user('foo.id', wallets[2].privkey, wallets[3].privkey, **kw) print 'reveal key: {}'.format(wallets[1].privkey) print 'payment key: {}'.format(wallets[2].privkey) print 'address: {}'.format(wallets[3].addr)
def scenario(wallets, **kw): 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) testlib.blockstack_register_user('foo.id', wallets[2].privkey, wallets[3].privkey, **kw)
def scenario(wallets, **kw): testlib.blockstack_namespace_preorder("id", wallets[1].addr, wallets[0].privkey) testlib.next_block(**kw) # same price curve as public .id namespace 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) testlib.blockstack_register_user('foo.id', wallets[2].privkey, wallets[3].privkey, **kw) # do 1-minute block times forever while True: time.sleep(60) testlib.next_block(**kw)
def scenario(wallets, **kw): 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) testlib.blockstack_register_user("foo.id", wallets[2].privkey, wallets[3].privkey, **kw) # 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 SUBDOMAIN_PROC.kill()
def scenario(wallets, **kw): global GAIA_READ_URL global GAIA_READ_PORT global GAIA_WRITE_PORT global GAIA_WRITE_URL # get gaia hub info with open(os.path.join(os.environ['BLOCKSTACK_WORKING_DIR'], 'gaia.conf'), 'r') as f: GAIA_CONF = json.loads(f.read().strip()) try: GAIA_READ_PORT = urlparse.urlparse( GAIA_CONF['readURL']).netloc.split(':')[-1] GAIA_READ_PORT = int(GAIA_READ_PORT) except: GAIA_READ_PORT = 80 if os.environ.get('BLOCKSTACK_PUBLIC_TESTNET_GAIA_READ_PORT'): GAIA_READ_PORT = int( os.environ['BLOCKSTACK_PUBLIC_TESTNET_GAIA_READ_PORT']) read_urlinfo = urlparse.urlparse(GAIA_CONF['readURL']) GAIA_READ_URL = 'http://{}:{}'.format( read_urlinfo.netloc.split(':')[0], GAIA_READ_PORT) GAIA_WRITE_PORT = GAIA_CONF['port'] if os.environ.get('BLOCKSTACK_PUBLIC_TESTNET_GAIA_WRITE_PORT'): GAIA_WRITE_PORT = int( os.environ['BLOCKSTACK_PUBLIC_TESTNET_GAIA_WRITE_PORT']) GAIA_WRITE_URL = 'http://{}:{}'.format(GAIA_CONF['servername'], GAIA_WRITE_PORT) # fill in URL tb_conf_path = os.path.join(os.environ['BLOCKSTACK_WORKING_DIR'], 'transaction-broadcaster.conf') with open(tb_conf_path, 'r') as f: tb_conf = json.loads(f.read().strip()) testlib.blockstack_namespace_preorder("test", wallets[1].addr, wallets[0].privkey) testlib.next_block(**kw) testlib.blockstack_namespace_reveal( "test", wallets[1].addr, -1, 250, 4, [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 10, 10, wallets[0].privkey, version_bits=3) testlib.next_block(**kw) # import a name with the CLI res = testlib.nodejs_cli('name_import', 'hello_imports.test', 'ID-{}'.format(wallets[3].addr), 'http://*****:*****@Person', 'account': [] }, wallets[3].privkey) testlib.blockstack_put_profile('hello_imports.test', profile_data, wallets[3].privkey, 'http://*****:*****@Person', 'account': [] }, wallets[3].privkey) testlib.blockstack_put_profile('hello2.test', profile_data, wallets[3].privkey, 'http://localhost:4001') stop_subdomain_registrar()
def scenario( wallets, **kw ): global GAIA_READ_URL global GAIA_READ_PORT global GAIA_WRITE_PORT global GAIA_WRITE_URL global owner_privkey global owner_address # get gaia hub info with open(os.path.join(os.environ['BLOCKSTACK_WORKING_DIR'], 'gaia.conf'), 'r') as f: GAIA_CONF = json.loads(f.read().strip()) try: GAIA_READ_PORT = urlparse.urlparse(GAIA_CONF['readURL']).netloc.split(':')[-1] GAIA_READ_PORT = int(GAIA_READ_PORT) except: GAIA_READ_PORT = 80 if os.environ.get('BLOCKSTACK_PUBLIC_TESTNET_GAIA_READ_PORT'): GAIA_READ_PORT = int(os.environ['BLOCKSTACK_PUBLIC_TESTNET_GAIA_READ_PORT']) read_urlinfo = urlparse.urlparse(GAIA_CONF['readURL']) GAIA_READ_URL = 'http://{}:{}'.format(read_urlinfo.netloc.split(':')[0], GAIA_READ_PORT) GAIA_WRITE_PORT = GAIA_CONF['port'] if os.environ.get('BLOCKSTACK_PUBLIC_TESTNET_GAIA_WRITE_PORT'): GAIA_WRITE_PORT = int(os.environ['BLOCKSTACK_PUBLIC_TESTNET_GAIA_WRITE_PORT']) GAIA_WRITE_URL = 'http://{}:{}'.format(GAIA_CONF['servername'], GAIA_WRITE_PORT) testlib.blockstack_namespace_preorder( "test", wallets[1].addr, wallets[0].privkey ) testlib.next_block( **kw ) testlib.blockstack_namespace_reveal( "test", wallets[1].addr, -1, 250, 4, [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], 10, 10, wallets[0].privkey, version_bits=1) testlib.next_block( **kw ) testlib.blockstack_namespace_ready( "test", wallets[1].privkey ) testlib.next_block( **kw ) # register this user under a keychain res = testlib.nodejs_cli('make_keychain') res = json.loads(res) mnemonic = res['mnemonic'] owner_privkey = res['ownerKeyInfo']['privateKey'] owner_address = res['ownerKeyInfo']['idAddress'][3:] profile = { 'type': '@Person', 'account': [], 'name': 'Testy McTestface', } testlib.blockstack_register_user('foo.test', wallets[3].privkey, owner_privkey, profile=profile, profile_name='0/profile.json', **kw) # verify that we can look up this profile res = testlib.blockstack_get_profile('foo.test') if res['profile'] != profile: print 'wrong profile' print profile print res['profile'] return False # patch the profile to insert an app URL res = testlib.nodejs_cli('gaia_sethub', 'foo.test', GAIA_WRITE_URL, 'http://www.testapp.com', GAIA_WRITE_URL, mnemonic) res = testlib.blockstack_get_profile('foo.test') updated_profile = {} updated_profile.update(res['profile']) apps = updated_profile['apps'] del updated_profile['apps'] if updated_profile != profile: print 'wrong profile after sethub' print expected_profile print res['profile'] return False if not apps['http://www.testapp.com'].startswith(GAIA_READ_URL): print 'wrong app entry for testapp.com' print apps print GAIA_WRITE_URL return False print "" print "mnemnic: {}".format(mnemonic) print "hub url: {}".format(GAIA_WRITE_URL) print ""
def scenario(wallets, **kw): 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) testlib.blockstack_register_user("foo.id", wallets[2].privkey, wallets[3].privkey, **kw) # now, queue a few registrations. for i in range(0, len(wallets)): res = requests.post('http://localhost:3000/register', json={ 'zonefile': 'hello world {}'.format(i), 'name': 'bar{}'.format(i), 'owner_address': virtualchain.address_reencode( wallets[i].addr, network='mainnet') }) if res.status_code != 202: print 'bad POST status code {}'.format(res.status_code) return False time.sleep(1) # 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) # list all subdomains res = requests.get('http://localhost:3000/list/{}'.format(0)) if res.status_code != 200: print 'bad status code on list: {}'.format(res.status_code) return False listing = res.json() # should be in order by queue_ix (iterator) for i in range(0, len(wallets)): if listing[i]['name'] != 'bar{}.foo.id'.format(i): print 'wrong name: {}'.format(listing[i]) return False if listing[i]['address'] != virtualchain.address_reencode( wallets[i].addr, network='mainnet'): print 'wrong address: {}'.format(listing[i]) return False if listing[i]['sequence'] != 0: print 'wrong sequence: {}'.format(listing[i]) return False if listing[i]['zonefile'] != 'hello world {}'.format(i): print 'wrong zone file: {}'.format(listing[i]) return False if listing[i]['iterator'] != i + 1: print 'wrong iterator: {}'.format(listing[i]) return False # list all subdomains after the last one res = requests.get( 'http://localhost:3000/list/{}'.format(len(wallets) + 1)) if res.status_code != 200: print 'bad status code on list: {}'.format(res.status_code) return False listing = res.json() if len(listing) > 0: print 'got back more records' print listing return False SUBDOMAIN_PROC.kill()
def scenario(wallets, **kw): global GAIA_READ_URL global GAIA_READ_PORT global GAIA_WRITE_PORT global GAIA_WRITE_URL global owner_privkey global owner_address # get gaia hub info with open(os.path.join(os.environ['BLOCKSTACK_WORKING_DIR'], 'gaia.conf'), 'r') as f: GAIA_CONF = json.loads(f.read().strip()) try: GAIA_READ_PORT = urlparse.urlparse( GAIA_CONF['readURL']).netloc.split(':')[-1] GAIA_READ_PORT = int(GAIA_READ_PORT) except: GAIA_READ_PORT = 80 if os.environ.get('BLOCKSTACK_PUBLIC_TESTNET_GAIA_READ_PORT'): GAIA_READ_PORT = int( os.environ['BLOCKSTACK_PUBLIC_TESTNET_GAIA_READ_PORT']) read_urlinfo = urlparse.urlparse(GAIA_CONF['readURL']) GAIA_READ_URL = 'http://{}:{}'.format( read_urlinfo.netloc.split(':')[0], GAIA_READ_PORT) GAIA_WRITE_PORT = GAIA_CONF['port'] if os.environ.get('BLOCKSTACK_PUBLIC_TESTNET_GAIA_WRITE_PORT'): GAIA_WRITE_PORT = int( os.environ['BLOCKSTACK_PUBLIC_TESTNET_GAIA_WRITE_PORT']) GAIA_WRITE_URL = 'http://{}:{}'.format(GAIA_CONF['servername'], GAIA_WRITE_PORT) testlib.blockstack_namespace_preorder("test", wallets[1].addr, wallets[0].privkey) testlib.next_block(**kw) testlib.blockstack_namespace_reveal( "test", wallets[1].addr, -1, 250, 4, [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 10, 10, wallets[0].privkey, version_bits=1) testlib.next_block(**kw) testlib.blockstack_namespace_ready("test", wallets[1].privkey) testlib.next_block(**kw) # register this user under a keychain res = testlib.nodejs_cli('make_keychain') res = json.loads(res) mnemonic = res['mnemonic'] owner_privkey = res['ownerKeyInfo']['privateKey'] owner_address = res['ownerKeyInfo']['idAddress'][3:] profile = { 'type': '@Person', 'account': [], 'name': 'Testy McTestface', } testlib.blockstack_register_user('foo.test', wallets[3].privkey, owner_privkey, profile=profile, **kw) print "" print "mnemnic: {}".format(mnemonic) print "hub url: {}".format(GAIA_WRITE_URL) print ""
def scenario(wallets, **kw): global GAIA_READ_URL global GAIA_READ_PORT global GAIA_WRITE_PORT global GAIA_WRITE_URL global owner_privkey global owner_address # get gaia hub info with open(os.path.join(os.environ['BLOCKSTACK_WORKING_DIR'], 'gaia.conf'), 'r') as f: GAIA_CONF = json.loads(f.read().strip()) try: GAIA_READ_PORT = urlparse.urlparse( GAIA_CONF['readURL']).netloc.split(':')[-1] GAIA_READ_PORT = int(GAIA_READ_PORT) except: GAIA_READ_PORT = 80 if os.environ.get('BLOCKSTACK_PUBLIC_TESTNET_GAIA_READ_PORT'): GAIA_READ_PORT = int( os.environ['BLOCKSTACK_PUBLIC_TESTNET_GAIA_READ_PORT']) read_urlinfo = urlparse.urlparse(GAIA_CONF['readURL']) GAIA_READ_URL = 'http://{}:{}'.format( read_urlinfo.netloc.split(':')[0], GAIA_READ_PORT) GAIA_WRITE_PORT = GAIA_CONF['port'] if os.environ.get('BLOCKSTACK_PUBLIC_TESTNET_GAIA_WRITE_PORT'): GAIA_WRITE_PORT = int( os.environ['BLOCKSTACK_PUBLIC_TESTNET_GAIA_WRITE_PORT']) GAIA_WRITE_URL = 'http://{}:{}'.format(GAIA_CONF['servername'], GAIA_WRITE_PORT) GAIA_DISK_PATH = GAIA_CONF['diskSettings']['storageRootDirectory'] testlib.blockstack_namespace_preorder("test", wallets[1].addr, wallets[0].privkey) testlib.next_block(**kw) testlib.blockstack_namespace_reveal( "test", wallets[1].addr, -1, 250, 4, [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 10, 10, wallets[0].privkey, version_bits=3) testlib.next_block(**kw) testlib.blockstack_namespace_ready("test", wallets[1].privkey) testlib.next_block(**kw) # register this user under a keychain res = testlib.nodejs_cli('make_keychain') res = json.loads(res) mnemonic = res['mnemonic'] owner_privkey = res['ownerKeyInfo']['privateKey'] owner_address = res['ownerKeyInfo']['idAddress'][3:] testlib.blockstack_register_user('foo.test', wallets[3].privkey, owner_privkey, **kw) # get app keys res = testlib.nodejs_cli('get_app_keys', mnemonic, 'ID-{}'.format(owner_address), 'http://www.testapp.com') res = json.loads(res) app_privkey = res['keyInfo']['privateKey'] if res['keyInfo'][ 'privateKey'] != 'TODO' else res['legacyKeyInfo']['privateKey'] # patch the profile to insert an app URL res = testlib.nodejs_cli('gaia_sethub', 'foo.test', GAIA_WRITE_URL, 'http://www.testapp.com', GAIA_WRITE_URL, mnemonic) # store a bunch of data to Gaia tmpdir = os.path.join(os.environ['BLOCKSTACK_WORKING_DIR'], 'gaia_inputs') os.makedirs(tmpdir) count = 3 random_noise = os.urandom(32) for i in range(0, count): path = os.path.join(tmpdir, 'gaia-{}.txt'.format(i)) with open(path, 'w') as f: f.write('gaia data {}'.format(i)) f.write(random_noise) encrypted_path = os.path.join(tmpdir, 'gaia-{}-encrypted.txt'.format(i)) with open(encrypted_path, 'w') as f: f.write('gaia encrypted data {}'.format(i)) f.write(random_noise) print '\n\nputfile {}\n\n'.format(path) testlib.blockstack_gaia_putfile(app_privkey, path, '/foo/gaia-{}.txt'.format(i), GAIA_WRITE_URL, encrypt=False, sign=False) testlib.blockstack_gaia_putfile(app_privkey, encrypted_path, '/foo/gaia-{}-encrypted.txt'.format(i), GAIA_WRITE_URL, encrypt=True) testlib.blockstack_gaia_putfile(app_privkey, path, '/foo/gaia-{}-signed.txt'.format(i), GAIA_WRITE_URL, encrypt=False, sign=True) testlib.blockstack_gaia_putfile( app_privkey, encrypted_path, '/foo/gaia-{}-encrypted-signed.txt'.format(i), GAIA_WRITE_URL, encrypt=True, sign=True) # make sure they're all there res = testlib.blockstack_gaia_listfiles(app_privkey, GAIA_WRITE_URL) if len(res) != 5 * count: print json.dumps(res, indent=4, sort_keys=True) print 'wrong number of files: {}'.format(len(res)) return False for i in range(0, count): for filename in [ 'foo/gaia-{}.txt'.format(i), 'foo/gaia-{}-encrypted.txt'.format(i), 'foo/gaia-{}-signed.txt'.format(i), 'foo/gaia-{}-signed.txt.sig'.format(i), 'foo/gaia-{}-encrypted-signed.txt'.format(i) ]: if filename not in res: print json.dumps(res, indent=4, sort_keys=True) print 'missing {}'.format(filename) return False def check_reads(): # make sure we can get them all for i in range(0, count): for filename in [ 'foo/gaia-{}.txt'.format(i), 'foo/gaia-{}-encrypted.txt'.format(i), 'foo/gaia-{}-signed.txt'.format(i), 'foo/gaia-{}-encrypted-signed.txt'.format(i) ]: verify = 'signed' in filename decrypt = 'encrypted' in filename privkey = app_privkey if verify or decrypt else None expected_data = 'gaia encrypted data {}{}'.format( i, random_noise) if decrypt else 'gaia data {}{}'.format( i, random_noise) res = testlib.blockstack_gaia_getfile('foo.test', 'http://www.testapp.com', filename, privkey=privkey, verify=verify, decrypt=decrypt) if res != expected_data: print 'expected\n{}'.format(expected_data) print 'got\n{}'.format(res) import time time.sleep(1000000) return False return True res = check_reads() if not res: return False # dump the gaia hub and make sure they're all there dump_dir = os.path.join(os.environ['BLOCKSTACK_WORKING_DIR'], 'gaia-dump') res = testlib.blockstack_gaia_dump_bucket('foo.test', 'http://www.testapp.com', GAIA_WRITE_URL, mnemonic, dump_dir) if 'error' in res: print res return False app_storage_path = os.path.join( GAIA_DISK_PATH, virtualchain.address_reencode( virtualchain.get_privkey_address(app_privkey + '01'), network='mainnet')) def compare_directories(): for filename in os.listdir(dump_dir): app_storage_filename = os.path.join(app_storage_path, filename.replace('\\x2f', '/')) deserialized_filename = os.path.join(dump_dir, filename) d1 = open(deserialized_filename).read() d2 = open(app_storage_filename).read() if d1 != d2: print "{} and {} differ".format(app_storage_filename, deserialized_filename) return False for filename in os.listdir(os.path.join(app_storage_path, 'foo')): serialized_filename = os.path.join(dump_dir, 'foo\\x2f{}'.format(filename)) app_storage_filename = os.path.join(app_storage_path, 'foo', filename) d1 = open(serialized_filename).read() d2 = open(app_storage_filename).read() if d1 != d2: print "{} and {} differ".format(app_storage_filename, app_storage_filename) return False return True res = compare_directories() if not res: return False shutil.move(app_storage_path, '{}.bak'.format(app_storage_path)) os.makedirs(app_storage_path) # restore the gaia dump res = testlib.blockstack_gaia_restore_bucket('foo.test', 'http://www.testapp.com', GAIA_WRITE_URL, mnemonic, dump_dir) if 'error' in res: print res return False res = compare_directories() if not res: return False res = check_reads() if not res: return False
def scenario( wallets, **kw ): global TRANSACTION_BROADCASTER_URL global GAIA_READ_URL global GAIA_READ_PORT global GAIA_WRITE_PORT global GAIA_WRITE_URL # get gaia hub info with open(os.path.join(os.environ['BLOCKSTACK_WORKING_DIR'], 'gaia.conf'), 'r') as f: GAIA_CONF = json.loads(f.read().strip()) try: GAIA_READ_PORT = urlparse.urlparse(GAIA_CONF['readURL']).netloc.split(':')[-1] GAIA_READ_PORT = int(GAIA_READ_PORT) except: GAIA_READ_PORT = 80 if os.environ.get('BLOCKSTACK_PUBLIC_TESTNET_GAIA_READ_PORT'): GAIA_READ_PORT = int(os.environ['BLOCKSTACK_PUBLIC_TESTNET_GAIA_READ_PORT']) read_urlinfo = urlparse.urlparse(GAIA_CONF['readURL']) GAIA_READ_URL = 'http://{}:{}'.format(read_urlinfo.netloc.split(':')[0], GAIA_READ_PORT) GAIA_WRITE_PORT = GAIA_CONF['port'] if os.environ.get('BLOCKSTACK_PUBLIC_TESTNET_GAIA_WRITE_PORT'): GAIA_WRITE_PORT = int(os.environ['BLOCKSTACK_PUBLIC_TESTNET_GAIA_WRITE_PORT']) GAIA_WRITE_URL = 'http://{}:{}'.format(GAIA_CONF['servername'], GAIA_WRITE_PORT) # fill in URL tb_conf_path = os.path.join(os.environ['BLOCKSTACK_WORKING_DIR'], 'transaction-broadcaster.conf') with open(tb_conf_path, 'r') as f: tb_conf = json.loads(f.read().strip()) TRANSACTION_BROADCASTER_URL = 'http://{}:{}'.format(TESTNET_PUBLIC_HOST, tb_conf['port']) PORTNUM = int(os.environ.get('TESTNET_PORTNUM', '30001')) start_test_server(PORTNUM) testlib.blockstack_namespace_preorder( "id2", wallets[1].addr, wallets[0].privkey ) testlib.blockstack_namespace_preorder( "test", wallets[1].addr, wallets[0].privkey ) testlib.blockstack_namespace_preorder( "sandbox", wallets[1].addr, wallets[0].privkey ) testlib.next_block( **kw ) # same price curve as public .id namespace testlib.blockstack_namespace_reveal( "id2", 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, version_bits=3) testlib.blockstack_namespace_reveal( "test", wallets[1].addr, -1, 250, 4, [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], 10, 10, wallets[0].privkey, version_bits=3) testlib.blockstack_namespace_reveal( "sandbox", wallets[1].addr, -1, 250, 4, [6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], 10, 10, wallets[0].privkey, version_bits=3) testlib.next_block( **kw ) testlib.blockstack_namespace_ready( "id2", wallets[1].privkey ) testlib.blockstack_namespace_ready( "test", wallets[1].privkey ) testlib.blockstack_namespace_ready( "sandbox", wallets[1].privkey ) testlib.next_block( **kw ) testlib.blockstack_register_user(SUBDOMAIN_DOMAIN, SUBDOMAIN_PAYMENT_KEY, SUBDOMAIN_OWNER_KEY, gaia_host='{}:{}'.format(TESTNET_PUBLIC_HOST, GAIA_READ_PORT), **kw) start_subdomain_registrar() testlib.set_account_audits(False) print 'Testnet initialized' # do 1-minute block times forever while True: time.sleep(60) testlib.next_block(**kw)