def check(state_engine): global last_consensus, snv_block_id # not revealed, but ready ns = state_engine.get_namespace_reveal("test") if ns is not None: return False ns = state_engine.get_namespace("test") if ns is None: return False if ns['namespace_id'] != 'test': return False # not preordered for i in xrange(0, len(wallets)): preorder = state_engine.get_name_preorder( "foo.test", pybitcoin.make_pay_to_address_script(wallets[i].addr), wallets[(i + 1) % 5].addr) if preorder is not None: print "preordered" return False # registered name_rec = state_engine.get_name("foo.test") if name_rec is None: print "no name" return False # updated, and data preserved if name_rec['value_hash'] != "22" * 20: print "wrong value hash" return False # transferred if name_rec['address'] != wallets[4].addr or name_rec[ 'sender'] != pybitcoin.make_pay_to_address_script(wallets[4].addr): print "wrong owner" return False # snv lookup works test_proxy = testlib.TestAPIProxy() blockstack_client.set_default_proxy(test_proxy) spv_headers_path = test_proxy.spv_headers_path snv_rec = blockstack_client.snv_lookup("foo.test", snv_block_id, last_consensus, proxy=test_proxy) if 'error' in snv_rec: print json.dumps(snv_rec, indent=4) return False print snv_rec return True
def check(state_engine): global snv_block_id, last_consensus # not revealed, but ready ns = state_engine.get_namespace_reveal("test") if ns is not None: return False ns = state_engine.get_namespace("test") if ns is None: return False if ns['namespace_id'] != 'test': return False # not preordered preorder = state_engine.get_name_preorder( "foo.test", virtualchain.make_payment_script(wallets[2].addr), wallets[3].addr) if preorder is not None: print "preorder exists" return False # registered name_rec = state_engine.get_name("foo.test") if name_rec is None: print "no such name" return False # owned by if name_rec['address'] != wallets[3].addr or name_rec[ 'sender'] != virtualchain.make_payment_script(wallets[3].addr): print "wrong owner" return False # revoked if not name_rec['revoked']: return False # snv lookup works test_proxy = testlib.TestAPIProxy() blockstack_client.set_default_proxy(test_proxy) snv_rec = blockstack_client.snv_lookup("foo.test", snv_block_id, last_consensus, proxy=test_proxy) if 'error' in snv_rec: print json.dumps(snv_rec, indent=4) return False print snv_rec return True
def check(state_engine): global snv_block_id, last_block_id, last_consensus # not revealed, but ready ns = state_engine.get_namespace_reveal("test") if ns is not None: return False ns = state_engine.get_namespace("test") if ns is None: return False if ns['namespace_id'] != 'test': return False # not preordered preorder = state_engine.get_name_preorder( "foo.test", pybitcoin.make_pay_to_address_script(wallets[2].addr), wallets[3].addr) if preorder is not None: return False # registered name_rec = state_engine.get_name("foo.test") if name_rec is None: return False # owned by if name_rec['address'] != wallets[3].addr or name_rec[ 'sender'] != pybitcoin.make_pay_to_address_script(wallets[3].addr): return False # renewed (11 blocks later) if name_rec['last_renewed'] - 11 != name_rec['first_registered']: print name_rec['last_renewed'] print name_rec['first_registered'] return False # snv lookup works test_proxy = testlib.TestAPIProxy() blockstack_client.set_default_proxy(test_proxy) # snv_rec = snv_client.snv( "foo.test", lastblock, lastconsensus, snv_block_id, snv_consensus, proxy=test_proxy ) snv_rec = blockstack_client.snv_lookup("foo.test", snv_block_id, last_consensus, proxy=test_proxy) if 'error' in snv_rec: print json.dumps(snv_rec, indent=4) return False print snv_rec return True
def check(state_engine): global snv_block_id, snv_consensus # not revealed, but ready ns = state_engine.get_namespace_reveal("test") if ns is not None: print "'test' not revealed" return False ns = state_engine.get_namespace("test") if ns is None: print "'test' not found" return False if ns['namespace_id'] != 'test': print "'test' not returned" return False # not preordered preorder = state_engine.get_name_preorder( "foo.test", pybitcoin.make_pay_to_address_script(wallets[2].addr), wallets[3].addr) if preorder is not None: print "'foo.test' still preordered" return False # registered name_rec = state_engine.get_name("foo.test") if name_rec is None: print "'foo.test' not registered" return False # transferred if name_rec['address'] != wallets[4].addr or name_rec[ 'sender'] != pybitcoin.make_pay_to_address_script(wallets[4].addr): print "'foo.test' invalid owner" return False # snv lookup works test_proxy = testlib.TestAPIProxy() blockstack_client.set_default_proxy(test_proxy) snv_rec = blockstack_client.snv_lookup("foo.test", snv_block_id, snv_consensus, proxy=test_proxy) if 'error' in snv_rec: print json.dumps(snv_rec, indent=4) return False print snv_rec return True
def check( state_engine ): global last_consensus, snv_block_id # not revealed, but ready ns = state_engine.get_namespace_reveal( "test" ) if ns is not None: return False ns = state_engine.get_namespace( "test" ) if ns is None: return False if ns['namespace_id'] != 'test': return False # not preordered for i in xrange(0, len(wallets)): preorder = state_engine.get_name_preorder( "foo.test", pybitcoin.make_pay_to_address_script(wallets[i].addr), wallets[(i+1)%5].addr ) if preorder is not None: print "preordered" return False # registered name_rec = state_engine.get_name( "foo.test" ) if name_rec is None: print "no name" return False # updated, and data preserved if name_rec['value_hash'] != "22" * 20: print "wrong value hash" return False # transferred if name_rec['address'] != wallets[4].addr or name_rec['sender'] != pybitcoin.make_pay_to_address_script( wallets[4].addr ): print "wrong owner" return False # snv lookup works test_proxy = testlib.TestAPIProxy() blockstack_client.set_default_proxy( test_proxy ) spv_headers_path = test_proxy.spv_headers_path snv_rec = blockstack_client.snv_lookup( "foo.test", snv_block_id, last_consensus, proxy=test_proxy ) if 'error' in snv_rec: print json.dumps(snv_rec, indent=4 ) return False print snv_rec return True
def check( state_engine ): global snv_block_id, last_consensus # not revealed, but ready ns = state_engine.get_namespace_reveal( "test" ) if ns is not None: return False ns = state_engine.get_namespace( "test" ) if ns is None: return False if ns['namespace_id'] != 'test': return False # not preordered preorder = state_engine.get_name_preorder( "foo.test", pybitcoin.make_pay_to_address_script(wallets[2].addr), wallets[3].addr ) if preorder is not None: print "preorder exists" return False # registered name_rec = state_engine.get_name( "foo.test" ) if name_rec is None: print "no such name" return False # owned by if name_rec['address'] != wallets[3].addr or name_rec['sender'] != pybitcoin.make_pay_to_address_script(wallets[3].addr): print "wrong owner" return False # revoked if not name_rec['revoked']: return False # snv lookup works test_proxy = testlib.TestAPIProxy() blockstack_client.set_default_proxy( test_proxy ) snv_rec = blockstack_client.snv_lookup( "foo.test", snv_block_id, last_consensus, proxy=test_proxy ) if 'error' in snv_rec: print json.dumps(snv_rec, indent=4 ) return False print snv_rec return True
def check(state_engine): global snv_block_id, last_consensus # not revealed, but ready ns = state_engine.get_namespace_reveal("test") if ns is not None: return False ns = state_engine.get_namespace("test") if ns is None: return False if ns['namespace_id'] != 'test': return False # not preordered preorder = state_engine.get_name_preorder( "foo.test", pybitcoin.make_pay_to_address_script(wallets[2].addr), wallets[3].addr) if preorder is not None: return False # not registered name_rec = state_engine.get_name("foo.test") if name_rec is not None: print "Not expired:" print json.dumps(name_rec, indent=4) return False # snv lookup works test_proxy = testlib.TestAPIProxy() blockstack_client.set_default_proxy(test_proxy) snv_rec = blockstack_client.snv_lookup("foo.test", snv_block_id, last_consensus, proxy=test_proxy) if 'error' in snv_rec: print json.dumps(snv_rec, indent=4) print "Expected (%s, %s) from (%s, %s)" % (snv_block_id, snv_consensus, lastblock, lastconsensus) return False print snv_rec return True
def check( state_engine ): global snv_block_id, last_consensus # not revealed, but ready ns = state_engine.get_namespace_reveal( "test" ) if ns is not None: return False ns = state_engine.get_namespace( "test" ) if ns is None: return False if ns['namespace_id'] != 'test': return False # not preordered preorder = state_engine.get_name_preorder( "foo.test", pybitcoin.make_pay_to_address_script(wallets[2].addr), wallets[3].addr ) if preorder is not None: return False # not registered name_rec = state_engine.get_name( "foo.test" ) if name_rec is not None: print "Not expired:" print json.dumps( name_rec, indent=4 ) return False # snv lookup works test_proxy = testlib.TestAPIProxy() blockstack_client.set_default_proxy( test_proxy ) snv_rec = blockstack_client.snv_lookup( "foo.test", snv_block_id, last_consensus, proxy=test_proxy ) if 'error' in snv_rec: print json.dumps(snv_rec, indent=4 ) print "Expected (%s, %s) from (%s, %s)" % (snv_block_id, snv_consensus, lastblock, lastconsensus) return False print snv_rec return True
def check( state_engine ): global last_consensus, snv_block_id # not revealed, but ready ns = state_engine.get_namespace_reveal( "test" ) if ns is not None: return False ns = state_engine.get_namespace( "test" ) if ns is None: return False if ns['namespace_id'] != 'test': return False names = ['foo.test', 'bar.test', 'baz.test'] name_preorder_wallets = [wallets[2], wallets[3], wallets[4]] name_register_wallets = [wallets[5], wallets[6], wallets[7]] name_transfer_wallets = [wallets[6], wallets[7], wallets[5]] test_proxy = testlib.TestAPIProxy() blockstack_client.set_default_proxy( test_proxy ) for i in xrange(0, len(names)): name = names[i] name_preorder_wallet = name_preorder_wallets[i] name_register_wallet = name_register_wallets[i] name_transfer_wallet = name_transfer_wallets[i] # not preordered preorder = state_engine.get_name_preorder( name, pybitcoin.make_pay_to_address_script(name_preorder_wallet.addr), name_register_wallet.addr ) if preorder is not None: return False # registered name_rec = state_engine.get_name( name ) if name_rec is None: return False # data is gone if name_rec['value_hash'] is not None: return False # owned by the right transfer wallet if name_rec['address'] != name_transfer_wallet.addr or name_rec['sender'] != pybitcoin.make_pay_to_address_script(name_transfer_wallet.addr): return False # renewed if name_rec['last_renewed'] == name_rec['first_registered']: return False # revoked if not name_rec['revoked']: return False # snv lookup works snv_rec = blockstack_client.snv_lookup( name, snv_block_id, last_consensus, proxy=test_proxy ) if 'error' in snv_rec: print json.dumps(snv_rec, indent=4 ) return False return True
def check( state_engine ): global snv_block_id_foo, snv_txid_bar, last_consensus # not revealed, but ready ns = state_engine.get_namespace_reveal( "test" ) if ns is not None: return False ns = state_engine.get_namespace( "test" ) if ns is None: return False if ns['namespace_id'] != 'test': return False # not preordered for i in xrange(0, len(wallets)): for name in ["foo.test", "bar.test", "baz.test"]: preorder = state_engine.get_name_preorder( name, pybitcoin.make_pay_to_address_script(wallets[i].addr), wallets[(i+1)%5].addr ) if preorder is not None: print "preordered" return False # but still registered for name in ["foo.test", "bar.test", "baz.test"]: name_rec = state_engine.get_name( name ) if name_rec is None: print "no name" return False # updated, and data preserved name_rec = state_engine.get_name( "baz.test" ) if name_rec['value_hash'] != "22" * 20: print "wrong value hash" return False # transferred name_rec = state_engine.get_name( "bar.test" ) if name_rec['address'] != wallets[4].addr or name_rec['sender'] != pybitcoin.make_pay_to_address_script( wallets[4].addr ): print "wrong owner" return False # snv lookup works # NOTE: cannot use serial numbers here, since a NAME_IMPORT does not contain a consensus hash. test_proxy = testlib.TestAPIProxy() blockstack_client.set_default_proxy( test_proxy ) snv_rec = blockstack_client.snv_lookup( "foo.test", snv_block_id_foo, last_consensus, proxy=test_proxy ) if 'error' in snv_rec: print json.dumps(snv_rec, indent=4 ) print "failed to look up foo.test from consensus hash %s" % last_consensus return False # can use bar.test's NAME_TRANSFER txid to verify foo.test, since it has a consensus hash snv_rec_bar_tx = blockstack_client.snv_lookup( "foo.test", snv_block_id_foo, snv_txid_bar, proxy=test_proxy ) if 'error' in snv_rec_bar_tx: print json.dumps( snv_rec_bar_tx, indent=4 ) print "failed to look up foo.test from transaction %s" % snv_txid_bar return False if snv_rec != snv_rec_bar_tx: print "--------" print json.dumps(snv_rec, indent=4 ) print "" print json.dumps(snv_rec_bar_tx, indent=4 ) print "" print "Not equal" return False print snv_rec return True
def check(state_engine): global last_consensus, snv_block_id # not revealed, but ready ns = state_engine.get_namespace_reveal("test") if ns is not None: return False ns = state_engine.get_namespace("test") if ns is None: return False if ns['namespace_id'] != 'test': return False # there won't be a preorder for an individual name... preorder = state_engine.get_name_preorder( "foo.test", pybitcoin.make_pay_to_address_script(wallets[2].addr), wallets[3].addr) if preorder is not None: print "found name preorder for 'foo.test'" return False # there won't be a preorder for all names either preorder = state_engine.get_name_preorder_multi( ['foo.test', 'bar.test', 'baz.test'], \ pybitcoin.make_pay_to_address_script(wallets[2].addr), \ [wallets[3].addr, wallets[4].addr, wallets[5].addr]) if preorder is not None: print "Preorder found for foo.test, bar.test, baz.test" return False prev_name_rec = None test_proxy = testlib.TestAPIProxy() blockstack_client.set_default_proxy(test_proxy) # each name will be registered for name, wallet in [('foo.test', wallets[3]), \ ('bar.test', wallets[4]), \ ('baz.test', wallets[5])]: name_rec = state_engine.get_name(name) if name_rec is None: print "No name record for %s" % name return False if name_rec['address'] != wallet.addr: print "'%s' not owned by '%s'" % (name, wallet.addr) return False if name_rec['sender'] != pybitcoin.make_pay_to_address_script( wallet.addr): print "'%s' not controlled by '%s'" % ( name, pybitcoin.make_pay_to_address_script(wallet.addr)) return False if prev_name_rec is not None and prev_name_rec['history'] != name_rec[ 'history']: print "'%s' does not have the same preorder as '%s'" % ( prev_name_rec['name'], name_rec['name']) return False prev_name_rec = name_rec # snv lookup works snv_rec = blockstack_client.snv_lookup(name, snv_block_id, last_consensus, proxy=test_proxy) if 'error' in snv_rec: print json.dumps(snv_rec, indent=4) return False return True
def check( state_engine ): global snv_block_id_foo global snv_serial_number_bar global snv_serial_number_baz global snv_txid_bar global snv_txid_baz global last_consensus # not revealed, but ready ns = state_engine.get_namespace_reveal( "test" ) if ns is not None: return False ns = state_engine.get_namespace( "test" ) if ns is None: return False if ns['namespace_id'] != 'test': return False # not preordered preorder = state_engine.get_name_preorder( "foo.test", pybitcoin.make_pay_to_address_script(wallets[2].addr), wallets[3].addr ) if preorder is not None: return False # registered name_rec = state_engine.get_name( "foo.test" ) if name_rec is None: return False # owned by if name_rec['address'] != wallets[3].addr or name_rec['sender'] != pybitcoin.make_pay_to_address_script(wallets[3].addr): return False # not preordered preorder = state_engine.get_name_preorder( "bar.test", pybitcoin.make_pay_to_address_script(wallets[4].addr), wallets[5].addr ) if preorder is not None: return False # registered name_rec = state_engine.get_name( "bar.test" ) if name_rec is None: return False # owned by if name_rec['address'] != wallets[5].addr or name_rec['sender'] != pybitcoin.make_pay_to_address_script(wallets[5].addr): return False # not preordered preorder = state_engine.get_name_preorder( "baz.test", pybitcoin.make_pay_to_address_script(wallets[6].addr), wallets[7].addr ) if preorder is not None: return False # registered name_rec = state_engine.get_name( "baz.test" ) if name_rec is None: return False # owned by if name_rec['address'] != wallets[7].addr or name_rec['sender'] != pybitcoin.make_pay_to_address_script(wallets[7].addr): return False # snv lookup works test_proxy = testlib.TestAPIProxy() blockstack_client.set_default_proxy( test_proxy ) snv_rec = blockstack_client.snv_lookup( "foo.test", snv_block_id_foo, last_consensus, proxy=test_proxy ) if 'error' in snv_rec: print json.dumps(snv_rec, indent=4 ) return False # can use bar.test's serial number to verify foo.test snv_rec_bar = blockstack_client.snv_lookup( "foo.test", snv_block_id_foo, snv_serial_number_bar, proxy=test_proxy ) if 'error' in snv_rec_bar: print json.dumps(snv_rec_bar, indent=4 ) return False # can use baz.test's serial number to verify foo.test snv_rec_baz = blockstack_client.snv_lookup( "foo.test", snv_block_id_foo, snv_serial_number_baz, proxy=test_proxy ) if 'error' in snv_rec_baz: print json.dumps( snv_rec_baz, indent=4 ) return False # can use bar.test's preorder txid to verify foo.test snv_rec_bar_tx = blockstack_client.snv_lookup( "foo.test", snv_block_id_foo, snv_txid_bar, proxy=test_proxy ) if 'error' in snv_rec_bar_tx: print json.dumps( snv_rec_bar_tx, indent=4 ) return False # can use baz.test's preorder txid to verify foo.test snv_rec_baz_tx = blockstack_client.snv_lookup( "foo.test", snv_block_id_foo, snv_txid_baz, proxy=test_proxy ) if 'error' in snv_rec_baz_tx: print json.dumps( snv_rec_baz_tx, indent=4 ) return False # we have to have gotten the same record back in all cases for name, s1, s2 in [("snv_rec to snv_rec_bar", snv_rec, snv_rec_bar), \ ("snv_rec to snv_rec_baz", snv_rec, snv_rec_baz), \ ("snv_rec to snv_rec_bar_tx", snv_rec, snv_rec_bar_tx), \ ("snv_rec to snv_rec_baz_tx", snv_rec, snv_rec_baz_tx)]: if s1 != s2: print "--------" print name print json.dumps(s1, indent=4 ) print "" print json.dumps(s2, indent=4 ) print "" print "Not equal" return False print snv_rec return True
def snv_all_names(state_engine): """ Verify that we can use the consensus hash from each consensus-bearing operation to verify all prior name operations. """ global all_consensus_hashes global api_call_history global snv_fail global snv_fail_at test_proxy = TestAPIProxy() blockstack_client.set_default_proxy(test_proxy) all_names = {} # map name to {"block_id":..., "consensus_hash":...} for api_call in api_call_history: log.debug("API call: %s %s at %s" % (api_call.method, api_call.name, api_call.block_id)) name = None opcode = None if api_call.method.startswith( "register" ) and not api_call.method.startswith("register_multi"): name = api_call.name opcode = "NAME_REGISTRATION" elif api_call.method.startswith("name_import"): name = api_call.name opcode = "NAME_IMPORT" if name is not None: block_id = int(api_call.block_id) consensus_hash = all_consensus_hashes[block_id] if not all_names.has_key(name): all_names[name] = {} all_names[name][block_id] = { "consensus_hash": consensus_hash, "opcode": opcode } if api_call.result.has_key('transaction_hash'): all_names[name][block_id]['txid'] = api_call.result[ 'transaction_hash'] log.debug("SNV verify %s names" % len(all_names.keys())) for name in all_names.keys(): for block_id in all_names[name].keys(): consensus_hash = all_names[name][block_id]['consensus_hash'] txid = all_names[name][block_id].get('txid', None) opcode = all_names[name][block_id].get('opcode', None) log.debug("SNV verify %s (from %s)" % (name, block_id)) for i in xrange(block_id + 1, max(all_consensus_hashes.keys()) + 1): trusted_block_id = i trusted_consensus_hash = all_consensus_hashes[i] snv_rec = blockstack_client.snv_lookup(name, block_id, trusted_consensus_hash, proxy=test_proxy) if 'error' in snv_rec: if name in snv_fail: log.debug("SNV lookup %s failed as expected" % name) continue if name in snv_fail_at.get(block_id, []): log.debug("SNV lookup %s failed at %s as expected" % (name, block_id)) continue print json.dumps(snv_rec, indent=4) return False if snv_rec['name'] != name: print "mismatch name" print json.dumps(snv_rec, indent=4) return False if opcode is not None and snv_rec['opcode'] != opcode: print "mismatch opcode" print json.dumps(snv_rec, indent=4) return False if name in snv_fail: print "looked up name '%s' that was supposed to fail SNV" % name return False # QUIRK: if imported, then the fee must be a float. otherwise, it must be an int if snv_rec['opcode'] == 'NAME_IMPORT' and type( snv_rec['op_fee']) != float: print "QUIRK: NAME_IMPORT: fee isn't a float" return False log.debug("SNV verified %s with (%s,%s) back to (%s,%s)" % (name, trusted_block_id, trusted_consensus_hash, block_id, consensus_hash)) return True
def check( state_engine ): global last_consensus, snv_block_id # not revealed, but ready ns = state_engine.get_namespace_reveal( "test" ) if ns is not None: return False ns = state_engine.get_namespace( "test" ) if ns is None: return False if ns['namespace_id'] != 'test': return False # there won't be a preorder for an individual name... preorder = state_engine.get_name_preorder( "foo.test", pybitcoin.make_pay_to_address_script(wallets[2].addr), wallets[3].addr ) if preorder is not None: print "found name preorder for 'foo.test'" return False # there won't be a preorder for all names either preorder = state_engine.get_name_preorder_multi( ['foo.test', 'bar.test', 'baz.test'], \ pybitcoin.make_pay_to_address_script(wallets[2].addr), \ [wallets[3].addr, wallets[4].addr, wallets[5].addr]) if preorder is not None: print "Preorder found for foo.test, bar.test, baz.test" return False prev_name_rec = None test_proxy = testlib.TestAPIProxy() blockstack_client.set_default_proxy( test_proxy ) # each name will be registered for name, wallet in [('foo.test', wallets[3]), \ ('bar.test', wallets[4]), \ ('baz.test', wallets[5])]: name_rec = state_engine.get_name( name ) if name_rec is None: print "No name record for %s" % name return False if name_rec['address'] != wallet.addr: print "'%s' not owned by '%s'" % (name, wallet.addr) return False if name_rec['sender'] != pybitcoin.make_pay_to_address_script(wallet.addr): print "'%s' not controlled by '%s'" % (name, pybitcoin.make_pay_to_address_script(wallet.addr)) return False if prev_name_rec is not None and prev_name_rec['history'] != name_rec['history']: print "'%s' does not have the same preorder as '%s'" % (prev_name_rec['name'], name_rec['name']) return False prev_name_rec = name_rec # snv lookup works snv_rec = blockstack_client.snv_lookup( name, snv_block_id, last_consensus, proxy=test_proxy ) if 'error' in snv_rec: print json.dumps(snv_rec, indent=4 ) return False return True
def check(state_engine): global snv_block_id_foo global snv_serial_number_bar global snv_serial_number_baz global snv_txid_bar global snv_txid_baz global last_consensus # not revealed, but ready ns = state_engine.get_namespace_reveal("test") if ns is not None: return False ns = state_engine.get_namespace("test") if ns is None: return False if ns['namespace_id'] != 'test': return False # not preordered preorder = state_engine.get_name_preorder( "foo.test", pybitcoin.make_pay_to_address_script(wallets[2].addr), wallets[3].addr) if preorder is not None: return False # registered name_rec = state_engine.get_name("foo.test") if name_rec is None: return False # owned by if name_rec['address'] != wallets[3].addr or name_rec[ 'sender'] != pybitcoin.make_pay_to_address_script(wallets[3].addr): return False # not preordered preorder = state_engine.get_name_preorder( "bar.test", pybitcoin.make_pay_to_address_script(wallets[4].addr), wallets[5].addr) if preorder is not None: return False # registered name_rec = state_engine.get_name("bar.test") if name_rec is None: return False # owned by if name_rec['address'] != wallets[5].addr or name_rec[ 'sender'] != pybitcoin.make_pay_to_address_script(wallets[5].addr): return False # not preordered preorder = state_engine.get_name_preorder( "baz.test", pybitcoin.make_pay_to_address_script(wallets[6].addr), wallets[7].addr) if preorder is not None: return False # registered name_rec = state_engine.get_name("baz.test") if name_rec is None: return False # owned by if name_rec['address'] != wallets[7].addr or name_rec[ 'sender'] != pybitcoin.make_pay_to_address_script(wallets[7].addr): return False # snv lookup works test_proxy = testlib.TestAPIProxy() blockstack_client.set_default_proxy(test_proxy) snv_rec = blockstack_client.snv_lookup("foo.test", snv_block_id_foo, last_consensus, proxy=test_proxy) if 'error' in snv_rec: print json.dumps(snv_rec, indent=4) return False # can use bar.test's serial number to verify foo.test snv_rec_bar = blockstack_client.snv_lookup("foo.test", snv_block_id_foo, snv_serial_number_bar, proxy=test_proxy) if 'error' in snv_rec_bar: print json.dumps(snv_rec_bar, indent=4) return False # can use baz.test's serial number to verify foo.test snv_rec_baz = blockstack_client.snv_lookup("foo.test", snv_block_id_foo, snv_serial_number_baz, proxy=test_proxy) if 'error' in snv_rec_baz: print json.dumps(snv_rec_baz, indent=4) return False # can use bar.test's preorder txid to verify foo.test snv_rec_bar_tx = blockstack_client.snv_lookup("foo.test", snv_block_id_foo, snv_txid_bar, proxy=test_proxy) if 'error' in snv_rec_bar_tx: print json.dumps(snv_rec_bar_tx, indent=4) return False # can use baz.test's preorder txid to verify foo.test snv_rec_baz_tx = blockstack_client.snv_lookup("foo.test", snv_block_id_foo, snv_txid_baz, proxy=test_proxy) if 'error' in snv_rec_baz_tx: print json.dumps(snv_rec_baz_tx, indent=4) return False # we have to have gotten the same record back in all cases for name, s1, s2 in [("snv_rec to snv_rec_bar", snv_rec, snv_rec_bar), \ ("snv_rec to snv_rec_baz", snv_rec, snv_rec_baz), \ ("snv_rec to snv_rec_bar_tx", snv_rec, snv_rec_bar_tx), \ ("snv_rec to snv_rec_baz_tx", snv_rec, snv_rec_baz_tx)]: if s1 != s2: print "--------" print name print json.dumps(s1, indent=4) print "" print json.dumps(s2, indent=4) print "" print "Not equal" return False print snv_rec return True