def scenario(wallets, **kw): global snv_consensus, snv_block_id, last_consensus, last_block_id 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) testlib.blockstack_name_register("foo.test", wallets[2].privkey, wallets[3].addr) testlib.next_block(**kw) snv_block_id = testlib.get_current_block() snv_consensus = testlib.get_consensus_at(snv_block_id) testlib.blockstack_name_update("foo.test", "11" * 20, wallets[3].privkey) testlib.next_block(**kw) last_block_id = testlib.get_current_block() last_consensus = testlib.get_consensus_at(last_block_id)
def scenario( wallets, **kw ): global snv_consensus, snv_block_id, last_consensus, last_block_id testlib.blockstore_namespace_preorder( "test", wallets[1].addr, wallets[0].privkey ) testlib.next_block( **kw ) testlib.blockstore_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.blockstore_namespace_ready( "test", wallets[1].privkey ) testlib.next_block( **kw ) testlib.blockstore_name_preorder( "foo.test", wallets[2].privkey, wallets[3].addr ) testlib.next_block( **kw ) testlib.blockstore_name_register( "foo.test", wallets[2].privkey, wallets[3].addr ) testlib.next_block( **kw ) snv_block_id = testlib.get_current_block() snv_consensus = testlib.get_consensus_at( snv_block_id ) testlib.blockstore_name_update( "foo.test", "11" * 20, wallets[3].privkey ) testlib.next_block( **kw ) last_block_id = testlib.get_current_block() last_consensus = testlib.get_consensus_at( last_block_id )
def scenario(wallets, **kw): global last_consensus, snv_block_id 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_name_preorder_multi( ["foo.test", "bar.test", "baz.test"], wallets[2].privkey, [wallets[3].addr, wallets[4].addr, wallets[5].addr]) if 'error' in resp: print json.dumps(resp, indent=4) sys.exit(1) testlib.next_block(**kw) preorder_consensus = testlib.get_consensus_at(testlib.get_current_block()) resp = testlib.blockstack_name_register("foo.test", wallets[2].privkey, wallets[3].addr) if 'error' in resp: print json.dumps(resp, indent=4) sys.exit(1) testlib.next_block(**kw) resp = testlib.blockstack_name_register("bar.test", wallets[2].privkey, wallets[4].addr) if 'error' in resp: print json.dumps(resp, indent=4) sys.exit(1) resp = testlib.blockstack_name_register("baz.test", wallets[2].privkey, wallets[5].addr) if 'error' in resp: print json.dumps(resp, indent=4) sys.exit(1) testlib.next_block(**kw) # all blocks registered here snv_block_id = testlib.get_current_block(**kw) testlib.next_block(**kw) last_consensus = testlib.get_consensus_at(testlib.get_current_block(**kw), **kw)
def scenario( wallets, **kw ): global txids global consensuses testlib.blockstore_namespace_preorder( "test", wallets[1].addr, wallets[0].privkey ) testlib.next_block( **kw ) testlib.blockstore_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.blockstore_namespace_ready( "test", wallets[1].privkey ) testlib.next_block( **kw ) testlib.blockstore_name_preorder( "foo.test", wallets[2].privkey, wallets[3].addr ) testlib.next_block( **kw ) testlib.blockstore_name_register( "foo.test", wallets[2].privkey, wallets[3].addr ) testlib.next_block( **kw ) testlib.next_block( **kw ) # do a sequence of updates, every other block for i in xrange( 0, 20 ): if (i % 2) != 0: update_hash = ("%02x" % (i)) * 20 resp = testlib.blockstore_name_update( "foo.test", update_hash, wallets[3].privkey ) txids[ update_hash ] = resp['transaction_hash'] consensuses[ update_hash ] = testlib.get_consensus_at( testlib.get_current_block( **kw ), **kw ) testlib.next_block( **kw ) 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 ) testlib.blockstack_name_register( "foo.test", wallets[2].privkey, wallets[3].addr ) testlib.next_block( **kw ) # wait for a bit... for i in xrange(0, 10): testlib.next_block( **kw ) resp = testlib.blockstack_name_renew( "foo.test", wallets[3].privkey ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) global snv_consensus, snv_block_id snv_block_id = testlib.get_current_block() snv_consensus = testlib.get_consensus_at( snv_block_id ) testlib.next_block( **kw )
def scenario( wallets, **kw ): testlib.blockstore_namespace_preorder( "test", wallets[1].addr, wallets[0].privkey ) testlib.next_block( **kw ) testlib.blockstore_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.blockstore_namespace_ready( "test", wallets[1].privkey ) testlib.next_block( **kw ) testlib.blockstore_name_preorder( "foo.test", wallets[2].privkey, wallets[3].addr ) testlib.next_block( **kw ) testlib.blockstore_name_register( "foo.test", wallets[2].privkey, wallets[3].addr ) testlib.next_block( **kw ) testlib.blockstore_name_update( "foo.test", "11" * 20, wallets[3].privkey ) testlib.next_block( **kw ) consensus_hash = testlib.get_consensus_at( testlib.get_current_block( **kw ), **kw ) # lots of blocks later... for i in xrange(0, 50): testlib.next_block( **kw ) # update with stale consensus hash (should fail) testlib.blockstore_name_update( "foo.test", "22" * 20, wallets[3].privkey, consensus_hash=consensus_hash ) testlib.next_block( **kw )
def scenario( wallets, **kw ): global snv_block_id, last_consensus testlib.blockstack_namespace_preorder( "test", wallets[1].addr, wallets[0].privkey ) testlib.next_block( **kw ) # NOTE: names expire in 13 blocks testlib.blockstack_namespace_reveal( "test", wallets[1].addr, 13, 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 ) testlib.blockstack_name_register( "foo.test", wallets[2].privkey, wallets[3].addr ) testlib.next_block( **kw ) snv_block_id = testlib.get_current_block() for i in xrange(0, 15): testlib.next_block( **kw ) last_consensus = testlib.get_consensus_at( testlib.get_current_block() )
def scenario(wallets, **kw): global debug, consensus resp = testlib.ysi_namespace_preorder("test", wallets[1].addr, wallets[0].privkey) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) resp = testlib.ysi_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) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) resp = testlib.ysi_namespace_ready("test", wallets[1].privkey) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) resp = testlib.ysi_name_preorder("foo.test", wallets[2].privkey, wallets[3].addr) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) resp = testlib.ysi_name_register("foo.test", wallets[2].privkey, wallets[3].addr) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) resp = testlib.ysi_name_transfer("foo.test", wallets[4].addr, True, wallets[3].privkey) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) resp = testlib.ysi_name_transfer("foo.test", wallets[0].addr, True, wallets[4].privkey) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) resp = testlib.ysi_name_update("foo.test", "11" * 20, wallets[0].privkey) if debug or 'error' in resp: print json.dumps(resp, indent=4) consensus = testlib.get_consensus_at(testlib.get_current_block(**kw), **kw) testlib.next_block(**kw)
def scenario(wallets, **kw): testlib.blockstore_namespace_preorder("test", wallets[1].addr, wallets[0].privkey) testlib.next_block(**kw) # NOTE: names expire in 13 blocks testlib.blockstore_namespace_reveal( "test", wallets[1].addr, 13, 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.blockstore_namespace_ready("test", wallets[1].privkey) testlib.next_block(**kw) testlib.blockstore_name_preorder("foo.test", wallets[2].privkey, wallets[3].addr) testlib.next_block(**kw) testlib.blockstore_name_register("foo.test", wallets[2].privkey, wallets[3].addr) testlib.next_block(**kw) global snv_block_id, snv_consensus snv_block_id = testlib.get_current_block() snv_consensus = testlib.get_consensus_at(snv_block_id) for i in xrange(0, 15): testlib.next_block(**kw)
def scenario(wallets, **kw): testlib.blockstore_namespace_preorder("test", wallets[1].addr, wallets[0].privkey) testlib.next_block(**kw) testlib.blockstore_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.blockstore_namespace_ready("test", wallets[1].privkey) testlib.next_block(**kw) testlib.blockstore_name_preorder("foo.test", wallets[2].privkey, wallets[3].addr) testlib.next_block(**kw) testlib.blockstore_name_register("foo.test", wallets[2].privkey, wallets[3].addr) testlib.next_block(**kw) global snv_block_id, snv_consensus snv_block_id = testlib.get_current_block() snv_consensus = testlib.get_consensus_at(snv_block_id) resp = testlib.blockstore_name_revoke("foo.test", wallets[3].privkey) testlib.next_block(**kw)
def scenario(wallets, **kw): global snv_block_id, last_consensus testlib.blockstack_namespace_preorder("test", wallets[1].addr, wallets[0].privkey) testlib.next_block(**kw) # NOTE: names expire in 5 * NAMESPACE_LIFETIME_MULTIPLIER blocks testlib.blockstack_namespace_reveal( "test", wallets[1].addr, 5, 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) testlib.blockstack_name_register("foo.test", wallets[2].privkey, wallets[3].addr) testlib.next_block(**kw) snv_block_id = testlib.get_current_block() for i in xrange(0, 5 * NAMESPACE_LIFETIME_MULTIPLIER): testlib.next_block(**kw) # this one expires the name testlib.next_block(**kw) last_consensus = testlib.get_consensus_at(testlib.get_current_block())
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 ) testlib.blockstack_name_register( "foo.test", wallets[2].privkey, wallets[3].addr ) testlib.next_block( **kw ) testlib.blockstack_name_update( "foo.test", "11" * 20, wallets[3].privkey ) testlib.next_block( **kw ) consensus_hash = testlib.get_consensus_at( testlib.get_current_block( **kw ), **kw ) # lots of blocks later... for i in xrange(0, 50): testlib.next_block( **kw ) # update with stale consensus hash (should fail) print "\n\nsend update with consensus hash %s\n\n" % consensus_hash testlib.blockstack_name_update( "foo.test", "22" * 20, wallets[3].privkey, consensus_hash=consensus_hash ) testlib.next_block( **kw )
def scenario( wallets, **kw ): testlib.blockstore_namespace_preorder( "test", wallets[1].addr, wallets[0].privkey ) testlib.next_block( **kw ) testlib.blockstore_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.blockstore_namespace_ready( "test", wallets[1].privkey ) testlib.next_block( **kw ) testlib.blockstore_name_preorder( "foo.test", wallets[2].privkey, wallets[3].addr ) testlib.next_block( **kw ) testlib.blockstore_name_register( "foo.test", wallets[2].privkey, wallets[3].addr ) testlib.next_block( **kw ) # wait for a bit... for i in xrange(0, 10): testlib.next_block( **kw ) resp = testlib.blockstore_name_renew( "foo.test", wallets[3].privkey ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) global snv_consensus, snv_block_id snv_block_id = testlib.get_current_block() snv_consensus = testlib.get_consensus_at( snv_block_id ) testlib.next_block( **kw )
def scenario( wallets, **kw ): global last_consensus, snv_block_id 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_name_preorder_multi( ["foo.test", "bar.test", "baz.test"], wallets[2].privkey, [wallets[3].addr, wallets[4].addr, wallets[5].addr] ) if 'error' in resp: print json.dumps( resp, indent=4 ) sys.exit(1) testlib.next_block( **kw ) preorder_consensus = testlib.get_consensus_at( testlib.get_current_block() ) resp = testlib.blockstack_name_register( "foo.test", wallets[2].privkey, wallets[3].addr ) if 'error' in resp: print json.dumps( resp, indent=4 ) sys.exit(1) testlib.next_block( **kw ) resp = testlib.blockstack_name_register( "bar.test", wallets[2].privkey, wallets[4].addr ) if 'error' in resp: print json.dumps( resp, indent=4 ) sys.exit(1) resp = testlib.blockstack_name_register( "baz.test", wallets[2].privkey, wallets[5].addr ) if 'error' in resp: print json.dumps( resp, indent=4 ) sys.exit(1) testlib.next_block( **kw ) # all blocks registered here snv_block_id = testlib.get_current_block( **kw ) testlib.next_block( **kw ) last_consensus = testlib.get_consensus_at( testlib.get_current_block( **kw ), **kw )
def scenario( wallets, **kw ): global snv_block_id_foo, snv_txid_bar, snv_txid_baz, last_consensus # make a test namespace resp = testlib.blockstack_namespace_preorder( "test", wallets[1].addr, wallets[0].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) resp = 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 ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) resp = testlib.blockstack_name_import( "foo.test", wallets[3].addr, "11" * 20, wallets[1].privkey ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) snv_block_id_foo = testlib.get_current_block() resp = testlib.blockstack_name_import( "bar.test", wallets[5].addr, "33" * 20, wallets[1].privkey ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) resp = testlib.blockstack_name_import( "baz.test", wallets[6].addr, "33" * 20, wallets[1].privkey ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) resp = testlib.blockstack_namespace_ready( "test", wallets[1].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) resp = testlib.blockstack_name_transfer( "bar.test", wallets[4].addr, True, wallets[5].privkey ) if 'error' in resp: print json.dumps( resp, indent=4 ) snv_txid_bar = resp['transaction_hash'] testlib.next_block( **kw ) resp = testlib.blockstack_name_update( "baz.test", "22" * 20, wallets[6].privkey ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) last_consensus = testlib.get_consensus_at( testlib.get_current_block() )
def scenario(wallets, **kw): global final_consensus 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_name_preorder_multi( ["foo.test", "bar.test", "baz.test"], wallets[2].privkey, [wallets[3].addr, wallets[4].addr, wallets[5].addr]) if 'error' in resp: print json.dumps(resp, indent=4) sys.exit(1) testlib.next_block(**kw) preorder_consensus = testlib.get_consensus_at(testlib.get_current_block()) resp = testlib.blockstack_name_register("foo.test", wallets[2].privkey, wallets[3].addr) if 'error' in resp: print json.dumps(resp, indent=4) sys.exit(1) resp = testlib.blockstack_name_register("bar.test", wallets[2].privkey, wallets[4].addr) if 'error' in resp: print json.dumps(resp, indent=4) sys.exit(1) testlib.next_block(**kw) # should cause the whole thing to fail, since we didn't preorder this separately resp = testlib.blockstack_name_register("goo.test", wallets[2].privkey, wallets[5].addr) if 'error' in resp: print json.dumps(resp, indent=4) sys.exit(1) resp = testlib.blockstack_name_register("baz.test", wallets[2].privkey, wallets[5].addr) if 'error' in resp: print json.dumps(resp, indent=4) sys.exit(1) testlib.next_block(**kw)
def scenario(wallets, **kw): global debug resp = testlib.blockstore_namespace_preorder("test", wallets[1].addr, wallets[0].privkey) if debug or "error" in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) resp = testlib.blockstore_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, ) if debug or "error" in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) resp = testlib.blockstore_namespace_ready("test", wallets[1].privkey) if debug or "error" in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) resp = testlib.blockstore_name_preorder("foo.test", wallets[2].privkey, wallets[3].addr) if debug or "error" in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) resp = testlib.blockstore_name_register("foo.test", wallets[2].privkey, wallets[3].addr) if debug or "error" in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) resp = testlib.blockstore_name_transfer("foo.test", wallets[4].addr, True, wallets[3].privkey) if debug or "error" in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) global snv_consensus, snv_block_id snv_block_id = testlib.get_current_block() snv_consensus = testlib.get_consensus_at(snv_block_id)
def scenario( wallets, **kw ): global snv_block_id_foo, snv_serial_number_bar, snv_serial_number_baz, last_consensus, snv_txid_bar, snv_txid_baz testlib.ysi_namespace_preorder( "test", wallets[1].addr, wallets[0].privkey ) testlib.next_block( **kw ) testlib.ysi_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.ysi_namespace_ready( "test", wallets[1].privkey ) testlib.next_block( **kw ) testlib.ysi_name_preorder( "foo.test", wallets[2].privkey, wallets[3].addr ) testlib.next_block( **kw ) testlib.ysi_name_register( "foo.test", wallets[2].privkey, wallets[3].addr ) testlib.next_block( **kw ) snv_block_id_foo = testlib.get_current_block() testlib.next_block( **kw ) testlib.next_block( **kw ) testlib.next_block( **kw ) testlib.next_block( **kw ) testlib.next_block( **kw ) bar_preorder = testlib.ysi_name_preorder( "bar.test", wallets[4].privkey, wallets[5].addr ) testlib.next_block( **kw ) snv_serial_number_bar = "%s-%s" % (testlib.get_current_block(), 1 ) snv_txid_bar = bar_preorder['transaction_hash'] testlib.ysi_name_register( "bar.test", wallets[4].privkey, wallets[5].addr ) testlib.next_block( **kw ) testlib.next_block( **kw ) testlib.next_block( **kw ) testlib.next_block( **kw ) testlib.next_block( **kw ) testlib.next_block( **kw ) baz_preorder = testlib.ysi_name_preorder( "baz.test", wallets[6].privkey, wallets[7].addr ) testlib.next_block( **kw ) snv_serial_number_baz = "%s-%s" % (testlib.get_current_block(), 1 ) snv_txid_baz = baz_preorder['transaction_hash'] testlib.ysi_name_register( "baz.test", wallets[6].privkey, wallets[7].addr ) testlib.next_block( **kw ) last_consensus = testlib.get_consensus_at( testlib.get_current_block() )
def scenario( wallets, **kw ): global debug, consensus resp = testlib.blockstack_namespace_preorder( "test", wallets[1].addr, wallets[0].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) resp = 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 ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) resp = testlib.blockstack_namespace_ready( "test", wallets[1].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) resp = testlib.blockstack_name_preorder( "foo.test", wallets[2].privkey, wallets[3].addr ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) resp = testlib.blockstack_name_register( "foo.test", wallets[2].privkey, wallets[3].addr ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) resp = testlib.blockstack_name_transfer( "foo.test", wallets[4].addr, True, wallets[3].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) resp = testlib.blockstack_name_transfer( "foo.test", wallets[0].addr, True, wallets[4].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) resp = testlib.blockstack_name_update( "foo.test", "11" * 20, wallets[0].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) consensus = testlib.get_consensus_at( testlib.get_current_block( **kw ), **kw ) testlib.next_block( **kw )
def scenario( wallets, **kw ): global snv_block_id_foo, snv_serial_number_bar, snv_serial_number_baz, last_consensus, snv_txid_bar, snv_txid_baz 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 ) testlib.blockstack_name_register( "foo.test", wallets[2].privkey, wallets[3].addr ) testlib.next_block( **kw ) snv_block_id_foo = testlib.get_current_block() testlib.next_block( **kw ) testlib.next_block( **kw ) testlib.next_block( **kw ) testlib.next_block( **kw ) testlib.next_block( **kw ) bar_preorder = testlib.blockstack_name_preorder( "bar.test", wallets[4].privkey, wallets[5].addr ) testlib.next_block( **kw ) snv_serial_number_bar = "%s-%s" % (testlib.get_current_block(), 0 ) snv_txid_bar = bar_preorder['transaction_hash'] testlib.blockstack_name_register( "bar.test", wallets[4].privkey, wallets[5].addr ) testlib.next_block( **kw ) testlib.next_block( **kw ) testlib.next_block( **kw ) testlib.next_block( **kw ) testlib.next_block( **kw ) testlib.next_block( **kw ) baz_preorder = testlib.blockstack_name_preorder( "baz.test", wallets[6].privkey, wallets[7].addr ) testlib.next_block( **kw ) snv_serial_number_baz = "%s-%s" % (testlib.get_current_block(), 0 ) snv_txid_baz = baz_preorder['transaction_hash'] testlib.blockstack_name_register( "baz.test", wallets[6].privkey, wallets[7].addr ) testlib.next_block( **kw ) last_consensus = testlib.get_consensus_at( testlib.get_current_block() )
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, 10, 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 ) consensus_hash = testlib.get_consensus_at( testlib.get_current_block(**kw), **kw) testlib.next_block( **kw ) testlib.next_block( **kw ) # preorder, register, update, expire (multiple times) for i in xrange(2, 11): resp = testlib.blockstack_name_preorder( "foo.test", wallets[i].privkey, wallets[(i+1)%11].addr, consensus_hash=consensus_hash ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) consensus_hash = testlib.get_consensus_at( testlib.get_current_block(**kw), **kw) testlib.next_block( **kw ) testlib.next_block( **kw ) resp = testlib.blockstack_name_register( "foo.test", wallets[i].privkey, wallets[(i+1)%11].addr ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) consensus_hash = testlib.get_consensus_at( testlib.get_current_block(**kw), **kw) testlib.next_block( **kw ) testlib.next_block( **kw ) resp = testlib.blockstack_name_transfer( "foo.test", wallets[i].addr, True, wallets[(i+1)%11].privkey, consensus_hash=consensus_hash ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) consensus_hash = testlib.get_consensus_at( testlib.get_current_block(**kw), **kw) testlib.next_block( **kw ) testlib.next_block( **kw ) resp = testlib.blockstack_name_update( "foo.test", ("%02x" % i) * 20, wallets[i].privkey, consensus_hash=consensus_hash ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) consensus_hash = testlib.get_consensus_at( testlib.get_current_block(**kw), **kw) testlib.next_block( **kw ) testlib.next_block( **kw ) if i == 10: break testlib.next_block( **kw ) consensus_hash = testlib.get_consensus_at( testlib.get_current_block(**kw), **kw) testlib.next_block( **kw ) testlib.next_block( **kw )
def scenario(wallets, **kw): global last_consensus, snv_block_id # make a test namespace resp = testlib.blockstore_namespace_preorder("test", wallets[1].addr, wallets[0].privkey) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) resp = testlib.blockstore_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) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) resp = testlib.blockstore_name_import("foo.test", wallets[3].addr, "11" * 20, wallets[1].privkey) if 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) snv_block_id = testlib.get_current_block() resp = testlib.blockstore_namespace_ready("test", wallets[1].privkey) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) resp = testlib.blockstore_name_transfer("foo.test", wallets[4].addr, True, wallets[3].privkey) if 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) resp = testlib.blockstore_name_update("foo.test", "22" * 20, wallets[4].privkey) if 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) last_consensus = testlib.get_consensus_at(testlib.get_current_block())
def scenario(wallets, **kw): global debug resp = testlib.blockstack_namespace_preorder("test", wallets[1].addr, wallets[0].privkey) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) resp = 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) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) resp = testlib.blockstack_namespace_ready("test", wallets[1].privkey) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) resp = testlib.blockstack_name_preorder("foo.test", wallets[2].privkey, wallets[3].addr) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) resp = testlib.blockstack_name_register("foo.test", wallets[2].privkey, wallets[3].addr) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) resp = testlib.blockstack_name_transfer("foo.test", wallets[4].addr, True, wallets[3].privkey) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) global snv_consensus, snv_block_id snv_block_id = testlib.get_current_block() snv_consensus = testlib.get_consensus_at(snv_block_id)
def scenario(wallets, **kw): global final_consensus 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_name_preorder_multi( ["foo.test", "bar.test", "baz.test"], wallets[2].privkey, [wallets[3].addr, wallets[4].addr, wallets[5].addr]) if 'error' in resp: print json.dumps(resp, indent=4) sys.exit(1) testlib.next_block(**kw) preorder_consensus = testlib.get_consensus_at(testlib.get_current_block()) # these should all fail, since they're paired with the wrong addresses resp = testlib.blockstack_name_register("foo.test", wallets[2].privkey, wallets[5].addr) if 'error' in resp: print json.dumps(resp, indent=4) sys.exit(1) resp = testlib.blockstack_name_register("bar.test", wallets[2].privkey, wallets[3].addr) if 'error' in resp: print json.dumps(resp, indent=4) sys.exit(1) resp = testlib.blockstack_name_register("baz.test", wallets[2].privkey, wallets[4].addr) if 'error' in resp: print json.dumps(resp, indent=4) sys.exit(1) testlib.next_block(**kw)
def scenario( wallets, **kw ): global final_consensus testlib.blockstore_namespace_preorder( "test", wallets[1].addr, wallets[0].privkey ) testlib.next_block( **kw ) testlib.blockstore_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.blockstore_namespace_ready( "test", wallets[1].privkey ) testlib.next_block( **kw ) resp = testlib.blockstore_name_preorder_multi( ["foo.test", "bar.test", "baz.test"], wallets[2].privkey, [wallets[3].addr, wallets[4].addr, wallets[5].addr] ) if 'error' in resp: print json.dumps( resp, indent=4 ) sys.exit(1) testlib.next_block( **kw ) preorder_consensus = testlib.get_consensus_at( testlib.get_current_block() ) resp = testlib.blockstore_name_register( "foo.test", wallets[2].privkey, wallets[3].addr ) if 'error' in resp: print json.dumps( resp, indent=4 ) sys.exit(1) resp = testlib.blockstore_name_register( "bar.test", wallets[2].privkey, wallets[4].addr ) if 'error' in resp: print json.dumps( resp, indent=4 ) sys.exit(1) testlib.next_block( **kw ) # should cause the whole thing to fail, since we didn't preorder this separately resp = testlib.blockstore_name_register( "goo.test", wallets[2].privkey, wallets[5].addr ) if 'error' in resp: print json.dumps( resp, indent=4 ) sys.exit(1) resp = testlib.blockstore_name_register( "baz.test", wallets[2].privkey, wallets[5].addr ) if 'error' in resp: print json.dumps( resp, indent=4 ) sys.exit(1) testlib.next_block( **kw )
def scenario( wallets, **kw ): global last_consensus, snv_block_id # make a test namespace resp = testlib.blockstore_namespace_preorder( "test", wallets[1].addr, wallets[0].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) resp = testlib.blockstore_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 ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) resp = testlib.blockstore_name_import( "foo.test", wallets[3].addr, "11" * 20, wallets[1].privkey ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) snv_block_id = testlib.get_current_block() resp = testlib.blockstore_namespace_ready( "test", wallets[1].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) resp = testlib.blockstore_name_transfer( "foo.test", wallets[4].addr, True, wallets[3].privkey ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) resp = testlib.blockstore_name_update( "foo.test", "22" * 20, wallets[4].privkey ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) last_consensus = testlib.get_consensus_at( testlib.get_current_block() )
def scenario(wallets, **kw): global txids global consensuses 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) testlib.blockstack_name_register("foo.test", wallets[2].privkey, wallets[3].addr) testlib.next_block(**kw) testlib.next_block(**kw) # do a sequence of updates, every other block for i in xrange(0, 20): if (i % 2) != 0: update_hash = ("%02x" % (i)) * 20 resp = testlib.blockstack_name_update("foo.test", update_hash, wallets[3].privkey) txids[update_hash] = resp['transaction_hash'] consensuses[update_hash] = testlib.get_consensus_at( testlib.get_current_block(**kw), **kw) testlib.next_block(**kw) testlib.next_block(**kw)
def scenario( wallets, **kw ): global final_consensus testlib.blockstore_namespace_preorder( "test", wallets[1].addr, wallets[0].privkey ) testlib.next_block( **kw ) testlib.blockstore_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.blockstore_namespace_ready( "test", wallets[1].privkey ) testlib.next_block( **kw ) resp = testlib.blockstore_name_preorder_multi( ["foo.test", "bar.test", "baz.test"], wallets[2].privkey, [wallets[3].addr, wallets[4].addr, wallets[5].addr] ) if 'error' in resp: print json.dumps( resp, indent=4 ) sys.exit(1) testlib.next_block( **kw ) preorder_consensus = testlib.get_consensus_at( testlib.get_current_block() ) # these should all fail, since they're paired with the wrong addresses resp = testlib.blockstore_name_register( "foo.test", wallets[2].privkey, wallets[5].addr ) if 'error' in resp: print json.dumps( resp, indent=4 ) sys.exit(1) resp = testlib.blockstore_name_register( "bar.test", wallets[2].privkey, wallets[3].addr ) if 'error' in resp: print json.dumps( resp, indent=4 ) sys.exit(1) resp = testlib.blockstore_name_register( "baz.test", wallets[2].privkey, wallets[4].addr ) if 'error' in resp: print json.dumps( resp, indent=4 ) sys.exit(1) 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 ) testlib.blockstack_name_register( "foo.test", wallets[2].privkey, wallets[3].addr ) testlib.next_block( **kw ) global snv_block_id, snv_consensus snv_block_id = testlib.get_current_block() snv_consensus = testlib.get_consensus_at( snv_block_id ) resp = testlib.blockstack_name_revoke( "foo.test", wallets[3].privkey ) testlib.next_block( **kw )
def scenario( wallets, **kw ): global last_consensus, snv_block_id # make a test namespace resp = testlib.blockstore_namespace_preorder( "test", wallets[1].addr, wallets[0].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) resp = testlib.blockstore_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 ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) resp = testlib.blockstore_namespace_ready( "test", wallets[1].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # preorder 3 names in the same block: foo.test, bar.test, baz.test 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]] resp = testlib.blockstore_name_preorder_multi( names, wallets[2].privkey, [wallets[5].addr, wallets[6].addr, wallets[7].addr]) if 'error' in resp: print json.dumps( resp, indent=4 ) sys.exit(1) testlib.next_block( **kw ) # regster 3 names in the same block for i in xrange(0, len(names)): name = names[i] preorder_wallet = name_preorder_wallets[i] register_wallet = name_register_wallets[i] resp = testlib.blockstore_name_register( name, wallets[2].privkey, register_wallet.addr ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) snv_block_id = testlib.get_current_block( **kw ) # update 3 names in the same block for i in xrange(0, len(names)): name = names[i] register_wallet = name_register_wallets[i] resp = testlib.blockstore_name_update( name, str(i + 1) * 40, register_wallet.privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # transfer 3 names in the same block for i in xrange(0, len(names)): name = names[i] register_wallet = name_register_wallets[i] transfer_wallet = name_transfer_wallets[i] resp = testlib.blockstore_name_transfer( name, transfer_wallet.addr, True, register_wallet.privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # exchange after transfer... tmp = name_register_wallets name_register_wallets = name_transfer_wallets name_transfer_wallets = tmp # renew 3 names in the same block for i in xrange(0, len(names)): name = names[i] register_wallet = name_register_wallets[i] resp = testlib.blockstore_name_renew( name, register_wallet.privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # revoke 3 names in the same block for i in xrange(0, len(names)): name = names[i] register_wallet = name_register_wallets[i] resp = testlib.blockstore_name_revoke( name, register_wallet.privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) # iterate the blocks a few times for i in xrange(0, 5): testlib.next_block( **kw ) last_consensus = testlib.get_consensus_at( testlib.get_current_block( **kw ), **kw )
def scenario(wallets, **kw): global debug resp = testlib.blockstack_namespace_preorder("test", wallets[1].addr, wallets[0].privkey) if 'error' in resp: print json.dumps(resp, indent=4) return False testlib.next_block(**kw) resp = 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) if 'error' in resp: print json.dumps(resp, indent=4) return False testlib.next_block(**kw) resp = testlib.blockstack_namespace_ready("test", wallets[1].privkey) if 'error' in resp: print json.dumps(resp, indent=4) return False testlib.next_block(**kw) resp = testlib.blockstack_name_preorder("foo.test", wallets[2].privkey, wallets[3].addr) if 'error' in resp: print json.dumps(resp, indent=4) return False testlib.next_block(**kw) resp = testlib.blockstack_name_register("foo.test", wallets[2].privkey, wallets[3].addr) if 'error' in resp: print json.dumps(resp, indent=4) return False testlib.next_block(**kw) resp = testlib.blockstack_name_transfer("foo.test", wallets[4].addr, True, wallets[3].privkey) if 'error' in resp: print json.dumps(resp, indent=4) return False testlib.next_block(**kw) # consensus hash should be the one from the last NAME_TRANSFER db = testlib.get_state_engine() name_rec = db.get_name('foo.test') if name_rec['consensus_hash'] != testlib.get_consensus_at( testlib.get_current_block(**kw) - 1): print 'wrong consensus hash: expected {}'.format( testlib.get_consensus_at(testlib.get_current_block(**kw) - 1)) print json.dumps(name_rec, indent=4, sort_keys=True) return False resp = testlib.blockstack_name_update("foo.test", "11" * 20, wallets[4].privkey) if 'error' in resp: print json.dumps(resp, indent=4) return False testlib.next_block(**kw) # consensus hash should be the one from the last NAME_UPDATE db = testlib.get_state_engine() name_rec = db.get_name('foo.test') if name_rec['consensus_hash'] != testlib.get_consensus_at( testlib.get_current_block(**kw) - 1): print 'wrong consensus hash: expected {}'.format( testlib.get_consensus_at(testlib.get_current_block(**kw) - 1)) print json.dumps(name_rec, indent=4, sort_keys=True) return False update_ch = name_rec['consensus_hash'] resp = testlib.blockstack_name_renew("foo.test", wallets[4].privkey) if 'error' in resp: print json.dumps(resp, indent=4) return False testlib.next_block(**kw) # consensus hash should be the one from the last NAME_UPDATE db = testlib.get_state_engine() name_rec = db.get_name('foo.test') if name_rec['consensus_hash'] != update_ch: print 'wrong consensus hash: expected {}'.format(update_ch) print json.dumps(name_rec, indent=4, sort_keys=True) return False resp = testlib.blockstack_name_transfer("foo.test", wallets[3].addr, True, wallets[4].privkey) if 'error' in resp: print json.dumps(resp, indent=4) return False testlib.next_block(**kw) # consensus hash should be the one from the last NAME_UPDATE db = testlib.get_state_engine() name_rec = db.get_name('foo.test') if name_rec['consensus_hash'] != update_ch: print 'wrong consensus hash: expected {}'.format(update_ch) print json.dumps(name_rec, indent=4, sort_keys=True) return False
def scenario( wallets, **kw ): global update_blocks, transfer_blocks, update_hashes, transfer_recipients testlib.blockstack_namespace_preorder( "test", wallets[1].addr, wallets[0].privkey ) testlib.next_block( **kw ) testlib.blockstack_namespace_reveal( "test", wallets[1].addr, 10, 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 ) consensus_hash = testlib.get_consensus_at( testlib.get_current_block(**kw), **kw) testlib.next_block( **kw ) testlib.next_block( **kw ) # preorder, register, update, expire (multiple times) # account for namespace lifetime multipler (in 0.0.14) for i in xrange(2, 5): resp = testlib.blockstack_name_preorder( "foo.test", wallets[i].privkey, wallets[(i+1)%11].addr, consensus_hash=consensus_hash ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) consensus_hash = testlib.get_consensus_at( testlib.get_current_block(**kw), **kw) testlib.next_block( **kw ) testlib.next_block( **kw ) resp = testlib.blockstack_name_register( "foo.test", wallets[i].privkey, wallets[(i+1)%11].addr ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) consensus_hash = testlib.get_consensus_at( testlib.get_current_block(**kw), **kw) testlib.next_block( **kw ) testlib.next_block( **kw ) resp = testlib.blockstack_name_update( "foo.test", ("%02x" % i) * 20, wallets[(i+1)%11].privkey, consensus_hash=consensus_hash ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) update_blocks.append( testlib.get_current_block( **kw )) update_hashes.append( ("%02x" % i) * 20 ) consensus_hash = testlib.get_consensus_at( testlib.get_current_block(**kw), **kw) testlib.next_block( **kw ) testlib.next_block( **kw ) resp = testlib.blockstack_name_transfer( "foo.test", wallets[i].addr, True, wallets[(i+1)%11].privkey, consensus_hash=consensus_hash ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) transfer_blocks.append( testlib.get_current_block( **kw ) ) transfer_recipients.append( wallets[i].addr ) consensus_hash = testlib.get_consensus_at( testlib.get_current_block(**kw), **kw) testlib.next_block( **kw ) testlib.next_block( **kw ) if i == 4: break # eat up the rest of the lifetime for j in xrange(0, 10 * NAMESPACE_LIFETIME_MULTIPLIER - 10): testlib.next_block( **kw ) consensus_hash = testlib.get_consensus_at( testlib.get_current_block(**kw), **kw) testlib.next_block( **kw ) testlib.next_block( **kw ) testlib.next_block( **kw )
def scenario( wallets, **kw ): testlib.blockstack_namespace_preorder( "test", wallets[1].addr, wallets[0].privkey ) testlib.next_block( **kw ) # note: lifetime of a name is 10 * NAMESPACE_LIFETIME_MULTIPLIER # we will make sure this all fails by *not* honoring this testlib.blockstack_namespace_reveal( "test", wallets[1].addr, 10, 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 ) consensus_hash = testlib.get_consensus_at( testlib.get_current_block(**kw), **kw) testlib.next_block( **kw ) testlib.next_block( **kw ) # preorder, register, update, expire (twice, with incorrect assumption about namespace lifetime) for i in xrange(2, 4): resp = testlib.blockstack_name_preorder( "foo.test", wallets[i].privkey, wallets[(i+1)%11].addr, consensus_hash=consensus_hash, safety_checks=False ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) consensus_hash = testlib.get_consensus_at( testlib.get_current_block(**kw), **kw) testlib.next_block( **kw ) testlib.next_block( **kw ) resp = testlib.blockstack_name_register( "foo.test", wallets[i].privkey, wallets[(i+1)%11].addr, safety_checks=False ) testlib.next_block( **kw ) if 'error' in resp: print json.dumps( resp, indent=4 ) if i == 3: testlib.expect_snv_fail_at( "foo.test", testlib.get_current_block(**kw)) consensus_hash = testlib.get_consensus_at( testlib.get_current_block(**kw), **kw) testlib.next_block( **kw ) testlib.next_block( **kw ) resp = testlib.blockstack_name_transfer( "foo.test", wallets[i].addr, True, wallets[(i+1)%11].privkey, consensus_hash=consensus_hash, safety_checks=False ) testlib.next_block( **kw ) if 'error' in resp: print json.dumps( resp, indent=4 ) if i == 3: testlib.expect_snv_fail_at( "foo.test", testlib.get_current_block(**kw)) consensus_hash = testlib.get_consensus_at( testlib.get_current_block(**kw), **kw) testlib.next_block( **kw ) testlib.next_block( **kw ) resp = testlib.blockstack_name_update( "foo.test", ("%02x" % i) * 20, wallets[i].privkey, consensus_hash=consensus_hash, safety_checks=False ) testlib.next_block( **kw ) if 'error' in resp: print json.dumps( resp, indent=4 ) if i == 3: testlib.expect_snv_fail_at( "foo.test", testlib.get_current_block(**kw)) break consensus_hash = testlib.get_consensus_at( testlib.get_current_block(**kw), **kw) testlib.next_block( **kw ) testlib.next_block( **kw ) if i == 3: break
def scenario(wallets, **kw): global debug # TODO: insert delayed consensus hashes resp = testlib.blockstack_namespace_preorder("test", wallets[1].addr, wallets[0].privkey) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) resp = 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) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) resp = testlib.blockstack_namespace_ready("test", wallets[1].privkey) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) consensus_hash = testlib.get_consensus_at(testlib.get_current_block(**kw), **kw) resp = testlib.blockstack_name_preorder("foo.test", wallets[2].privkey, wallets[3].addr, wallet=wallets[3], consensus_hash=consensus_hash) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) resp = testlib.blockstack_name_register("foo.test", wallets[2].privkey, wallets[3].addr, wallet=wallets[3]) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) # ping-ping a bit... 3 --> 4 --> 5 --> 4 --> 5 --> 4 resp = testlib.blockstack_name_transfer("foo.test", wallets[4].addr, True, wallets[3].privkey, safety_checks=False) if debug or 'error' in resp: print json.dumps(resp, indent=4) resp = testlib.blockstack_name_transfer("foo.test", wallets[5].addr, True, wallets[4].privkey, safety_checks=False) if debug or 'error' in resp: print json.dumps(resp, indent=4) resp = testlib.blockstack_name_transfer("foo.test", wallets[4].addr, True, wallets[5].privkey, safety_checks=False) if debug or 'error' in resp: print json.dumps(resp, indent=4) resp = testlib.blockstack_name_transfer("foo.test", wallets[5].addr, True, wallets[4].privkey, safety_checks=False) if debug or 'error' in resp: print json.dumps(resp, indent=4) resp = testlib.blockstack_name_transfer("foo.test", wallets[4].addr, True, wallets[5].privkey, safety_checks=False) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) # update (4) resp = testlib.blockstack_name_update("foo.test", "11" * 20, wallets[4].privkey, safety_checks=False) if debug or 'error' in resp: print json.dumps(resp, indent=4) # ping-ping a bit... 4 --> 5 --> 4 --> 5 --> 4 --> 5 resp = testlib.blockstack_name_transfer("foo.test", wallets[5].addr, True, wallets[4].privkey, consensus_hash=consensus_hash, safety_checks=False) if debug or 'error' in resp: print json.dumps(resp, indent=4) resp = testlib.blockstack_name_transfer("foo.test", wallets[4].addr, True, wallets[5].privkey, consensus_hash=consensus_hash, safety_checks=False) if debug or 'error' in resp: print json.dumps(resp, indent=4) resp = testlib.blockstack_name_transfer("foo.test", wallets[5].addr, True, wallets[4].privkey, consensus_hash=consensus_hash, safety_checks=False) if debug or 'error' in resp: print json.dumps(resp, indent=4) resp = testlib.blockstack_name_transfer("foo.test", wallets[4].addr, True, wallets[5].privkey, consensus_hash=consensus_hash, safety_checks=False) if debug or 'error' in resp: print json.dumps(resp, indent=4) resp = testlib.blockstack_name_transfer("foo.test", wallets[5].addr, True, wallets[4].privkey, consensus_hash=consensus_hash, safety_checks=False) if debug or 'error' in resp: print json.dumps(resp, indent=4) # now update (5) resp = testlib.blockstack_name_update("foo.test", "22" * 20, wallets[5].privkey, safety_checks=False) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) # update transfer resp = testlib.blockstack_name_transfer("foo.test", wallets[4].addr, True, wallets[5].privkey, safety_checks=False) if debug or 'error' in resp: print json.dumps(resp, indent=4) resp = testlib.blockstack_name_update("foo.test", "33" * 20, wallets[4].privkey, safety_checks=False) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) # update --> transfer --> transfer --> update resp = testlib.blockstack_name_update("foo.test", "44" * 20, wallets[4].privkey, safety_checks=False) if debug or 'error' in resp: print json.dumps(resp, indent=4) resp = testlib.blockstack_name_transfer("foo.test", wallets[5].addr, True, wallets[4].privkey, consensus_hash=consensus_hash, safety_checks=False) if debug or 'error' in resp: print json.dumps(resp, indent=4) resp = testlib.blockstack_name_transfer("foo.test", wallets[4].addr, True, wallets[5].privkey, consensus_hash=consensus_hash, safety_checks=False) if debug or 'error' in resp: print json.dumps(resp, indent=4) resp = testlib.blockstack_name_update("foo.test", "55" * 20, wallets[4].privkey, safety_checks=False) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) # update --> transfer --> update --> transfer resp = testlib.blockstack_name_update("foo.test", "66" * 20, wallets[4].privkey, safety_checks=False) if debug or 'error' in resp: print json.dumps(resp, indent=4) resp = testlib.blockstack_name_transfer("foo.test", wallets[5].addr, True, wallets[4].privkey, safety_checks=False) if debug or 'error' in resp: print json.dumps(resp, indent=4) resp = testlib.blockstack_name_update("foo.test", "11" * 20, wallets[5].privkey, safety_checks=False) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) # transfer resp = testlib.blockstack_name_transfer("foo.test", wallets[4].addr, True, wallets[5].privkey, consensus_hash=consensus_hash, safety_checks=False) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw)
def scenario( wallets, **kw ): global debug, expected_consensus resp = testlib.blockstack_namespace_preorder( "test", wallets[1].addr, wallets[0].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) resp = 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 ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) resp = testlib.blockstack_namespace_ready( "test", wallets[1].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) resp = testlib.blockstack_name_preorder( "foo.test", wallets[2].privkey, wallets[3].addr ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) resp = testlib.blockstack_name_preorder( "foo2.test", wallets[2].privkey, wallets[3].addr ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) resp = testlib.blockstack_name_register( "foo.test", wallets[2].privkey, wallets[3].addr ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) resp = testlib.blockstack_name_register( "foo2.test", wallets[2].privkey, wallets[3].addr ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) resp = testlib.blockstack_name_update( "foo2.test", "11" * 20, wallets[3].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) resp = testlib.blockstack_name_update( "foo.test", "11" * 20, wallets[3].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) # this is the hash that must be present in the name after the TRANSFER expected_consensus = testlib.get_consensus_at( testlib.get_current_block(**kw), **kw) testlib.next_block( **kw ) testlib.next_block( **kw ) testlib.next_block( **kw ) resp = testlib.blockstack_name_transfer( "foo.test", wallets[4].addr, True, wallets[3].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) resp = testlib.blockstack_name_transfer( "foo2.test", wallets[4].addr, True, wallets[3].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw )
def scenario( wallets, **kw ): global last_consensus, snv_block_id # make a test namespace resp = testlib.blockstack_namespace_preorder( "test", wallets[1].addr, wallets[0].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) resp = 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 ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) resp = testlib.blockstack_namespace_ready( "test", wallets[1].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # preorder 3 names in the same block: foo.test, bar.test, baz.test 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]] resp = testlib.blockstack_name_preorder_multi( names, wallets[2].privkey, [wallets[5].addr, wallets[6].addr, wallets[7].addr]) if 'error' in resp: print json.dumps( resp, indent=4 ) sys.exit(1) testlib.next_block( **kw ) # regster 3 names in the same block for i in xrange(0, len(names)): name = names[i] preorder_wallet = name_preorder_wallets[i] register_wallet = name_register_wallets[i] resp = testlib.blockstack_name_register( name, wallets[2].privkey, register_wallet.addr ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) snv_block_id = testlib.get_current_block( **kw ) # update 3 names in the same block for i in xrange(0, len(names)): name = names[i] register_wallet = name_register_wallets[i] resp = testlib.blockstack_name_update( name, str(i + 1) * 40, register_wallet.privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # transfer 3 names in the same block for i in xrange(0, len(names)): name = names[i] register_wallet = name_register_wallets[i] transfer_wallet = name_transfer_wallets[i] resp = testlib.blockstack_name_transfer( name, transfer_wallet.addr, True, register_wallet.privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # exchange after transfer... tmp = name_register_wallets name_register_wallets = name_transfer_wallets name_transfer_wallets = tmp # renew 3 names in the same block for i in xrange(0, len(names)): name = names[i] register_wallet = name_register_wallets[i] resp = testlib.blockstack_name_renew( name, register_wallet.privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # revoke 3 names in the same block for i in xrange(0, len(names)): name = names[i] register_wallet = name_register_wallets[i] resp = testlib.blockstack_name_revoke( name, register_wallet.privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) # iterate the blocks a few times for i in xrange(0, 5): testlib.next_block( **kw ) last_consensus = testlib.get_consensus_at( testlib.get_current_block( **kw ), **kw )
def scenario(wallets, **kw): global debug, consensus, small_unspents res = check_utxo_consumption( "test", wallets[0], wallets[1], wallets[2], ['namespace_preorder', 'namespace_reveal', 'namespace_ready'], wallets[1].addr, **kw) if 'error' in res: return False expected_utxo_count = res['expected_utxo_count'] # do the preorder resp = testlib.blockstack_namespace_preorder("test", wallets[1].addr, wallets[0].privkey) if debug or 'error' in resp: print simplejson.dumps(resp, indent=4) testlib.next_block(**kw) # verify that all the small UTXOs are NOT consumed bitcoind = testlib.connect_bitcoind() bitcoind.ping() txdata = bitcoind.getrawtransaction(resp['transaction_hash'], 1) if len(txdata['vin']) != 1: print simplejson.dumps(txdata, indent=4) print "wrong number of inputs: {} != 1".format(len(txdata['vin'])) return False if spent_small_transaction(resp['transaction_hash']): return False # finish ordering the namespace resp = 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) if debug or 'error' in resp: print simplejson.dumps(resp, indent=4) if spent_small_transaction(resp['transaction_hash']): return False testlib.next_block(**kw) resp = testlib.blockstack_namespace_ready("test", wallets[1].privkey) if debug or 'error' in resp: print simplejson.dumps(resp, indent=4) if spent_small_transaction(resp['transaction_hash']): return False testlib.next_block(**kw) res = check_utxo_consumption( "foo.test", wallets[2], wallets[3], wallets[4], ['preorder', 'register', 'update', 'transfer'], wallets[4].addr, **kw) if 'error' in res: return False expected_utxo_count = res['expected_utxo_count'] resp = testlib.blockstack_name_preorder("foo.test", wallets[2].privkey, wallets[3].addr) if debug or 'error' in resp: print simplejson.dumps(resp, indent=4) if spent_small_transaction(resp['transaction_hash']): return False testlib.next_block(**kw) # verify that all the small UTXOs are NOT consumed bitcoind = testlib.connect_bitcoind() bitcoind.ping() txdata = bitcoind.getrawtransaction(resp['transaction_hash'], 1) if len(txdata['vin']) != 1: print simplejson.dumps(txdata, indent=4) print "wrong number of inputs: {} != {}".format( len(txdata['vin']), expected_utxo_count) return False # proceed to register resp = testlib.blockstack_name_register("foo.test", wallets[2].privkey, wallets[3].addr) if debug or 'error' in resp: print simplejson.dumps(resp, indent=4) if spent_small_transaction(resp['transaction_hash']): return False testlib.next_block(**kw) # verify that all the UTXOs are consumed bitcoind = testlib.connect_bitcoind() bitcoind.ping() txdata = bitcoind.getrawtransaction(resp['transaction_hash'], 1) if len(txdata['vin']) != 1: print simplejson.dumps(txdata, indent=4) print "wrong number of inputs: {} != {}".format( len(txdata['vin']), expected_utxo_count) return False # make a few small UTXOs for the preorder payment addr for i in xrange(0, 3): res = testlib.send_funds(wallets[1].privkey, 10000, testlib.get_default_payment_wallet().addr) if 'error' in res: print simplejson.dumps(res, indent=4, sort_keys=True) return False testlib.next_block(**kw) small_unspents.append(res['transaction_hash']) utxos = testlib.get_utxos(testlib.get_default_payment_wallet().addr) assert len(utxos) > 3 resp = testlib.blockstack_name_update("foo.test", "11" * 20, wallets[3].privkey) if debug or 'error' in resp: print simplejson.dumps(resp, indent=4) if spent_small_transaction(resp['transaction_hash']): return False consensus = testlib.get_consensus_at(testlib.get_current_block(**kw), **kw) testlib.next_block(**kw) # inspect the transaction: only 3 UTXOs should have been consumed (2 owner UTXOs and 1 payment UTXO) txdata = testlib.connect_bitcoind().getrawtransaction( resp['transaction_hash'], 1) if len(txdata['vin']) != 3: print simplejson.dumps(txdata, indent=4) print "too many inputs" return False # make a few more small UTXOs for the preorder payment addr for i in xrange(0, 3): res = testlib.send_funds(wallets[1].privkey, 10000, testlib.get_default_payment_wallet().addr) if 'error' in res: print simplejson.dumps(res, indent=4, sort_keys=True) return False testlib.next_block(**kw) small_unspents.append(res['transaction_hash']) utxos = testlib.get_utxos(testlib.get_default_payment_wallet().addr) assert len(utxos) > 3 resp = testlib.blockstack_name_transfer("foo.test", wallets[4].addr, True, wallets[3].privkey) if debug or 'error' in resp: print simplejson.dumps(resp, indent=4) # inspect the transaction: only 2 UTXOs should have been consumed (1 owner UTXO and 1 payment UTXO) txdata = testlib.connect_bitcoind().getrawtransaction( resp['transaction_hash'], 1) if len(txdata['vin']) != 2: print simplejson.dumps(txdata, indent=4) print "too many inputs" return False if spent_small_transaction(resp['transaction_hash']): return False testlib.next_block(**kw) # make a few more small UTXOs for the preorder payment addr for i in xrange(0, 3): res = testlib.send_funds(wallets[1].privkey, 10000, testlib.get_default_payment_wallet().addr) if 'error' in res: print simplejson.dumps(res, indent=4, sort_keys=True) return False testlib.next_block(**kw) small_unspents.append(res['transaction_hash']) utxos = testlib.get_utxos(testlib.get_default_payment_wallet().addr) assert len(utxos) > 3 resp = testlib.blockstack_name_renew("foo.test", wallets[4].privkey) if debug or 'error' in resp: print simplejson.dumps(resp, indent=4) # inspect the transaction: only 3 UTXOs should have been consumed (2 owner UTXO and 1 payment UTXO) # NOTE: produces two UTXOs: an "owner" utxo and the change for the owner address txdata = testlib.connect_bitcoind().getrawtransaction( resp['transaction_hash'], 1) if len(txdata['vin']) != 3: print simplejson.dumps(txdata, indent=4) print "too many inputs" return False if spent_small_transaction(resp['transaction_hash']): return False testlib.next_block(**kw) # make a few more small UTXOs for the preorder payment addr for i in xrange(0, 3): res = testlib.send_funds(wallets[1].privkey, 10000, testlib.get_default_payment_wallet().addr) if 'error' in res: print simplejson.dumps(res, indent=4, sort_keys=True) return False testlib.next_block(**kw) small_unspents.append(res['transaction_hash']) utxos = testlib.get_utxos(testlib.get_default_payment_wallet().addr) assert len(utxos) > 3 resp = testlib.blockstack_name_revoke("foo.test", wallets[4].privkey) if debug or 'error' in resp: print simplejson.dumps(resp, indent=4) # inspect the transaction: only 3 UTXOs should have been consumed (2 owner UTXO and 1 payment UTXO) txdata = testlib.connect_bitcoind().getrawtransaction( resp['transaction_hash'], 1) if len(txdata['vin']) != 3: print simplejson.dumps(txdata, indent=4) print "too many inputs" return False if spent_small_transaction(resp['transaction_hash']): return False testlib.next_block(**kw) '''
def scenario(wallets, **kw): global import_block # make a test namespace resp = testlib.blockstack_namespace_preorder("test", wallets[1].addr, wallets[0].privkey) if 'error' in resp: print json.dumps(resp, indent=4) return False testlib.next_block(**kw) resp = testlib.blockstack_namespace_reveal( "test", wallets[1].addr, 10, 250, 4, [6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 10, 10, wallets[0].privkey) if 'error' in resp: print json.dumps(resp, indent=4) return False testlib.next_block(**kw) resp = testlib.blockstack_name_import("foo.test", wallets[3].addr, "11" * 20, wallets[1].privkey) if 'error' in resp: print json.dumps(resp, indent=4) return False testlib.next_block(**kw) import_block = testlib.get_current_block(**kw) resp = testlib.blockstack_namespace_ready("test", wallets[1].privkey) if 'error' in resp: print json.dumps(resp, indent=4) return False testlib.next_block(**kw) resp = testlib.blockstack_name_transfer("foo.test", wallets[4].addr, True, wallets[3].privkey) if 'error' in resp: print resp return False testlib.next_block(**kw) # consensus hash should be the one from the last NAME_TRANSFER db = testlib.get_state_engine() name_rec = db.get_name('foo.test') if name_rec['consensus_hash'] != testlib.get_consensus_at( testlib.get_current_block(**kw) - 1): print 'wrong consensus hash: expected {}'.format( testlib.get_consensus_at(testlib.get_current_block(**kw) - 1)) print json.dumps(name_rec, indent=4, sort_keys=True) return False resp = testlib.blockstack_name_update("foo.test", "22" * 20, wallets[4].privkey) if 'error' in resp: print resp return False testlib.next_block(**kw) # consensus hash should be the one from the last NAME_UPDATE db = testlib.get_state_engine() name_rec = db.get_name('foo.test') if name_rec['consensus_hash'] != testlib.get_consensus_at( testlib.get_current_block(**kw) - 1): print 'wrong consensus hash: expected {}'.format( testlib.get_consensus_at(testlib.get_current_block(**kw) - 1)) print json.dumps(name_rec, indent=4, sort_keys=True) return False update_ch = name_rec['consensus_hash'] resp = testlib.blockstack_name_transfer("foo.test", wallets[3].addr, True, wallets[4].privkey) if 'error' in resp: print resp return False testlib.next_block(**kw) # consensus hash should be the one from the last NAME_UPDATE db = testlib.get_state_engine() name_rec = db.get_name('foo.test') if name_rec['consensus_hash'] != update_ch: print 'wrong consensus hash: expected {}'.format(update_ch) print json.dumps(name_rec, indent=4, sort_keys=True) return False # wait for expiration (with multipler)... for i in xrange(0, 10 * NAMESPACE_LIFETIME_MULTIPLIER): testlib.next_block(**kw) # re-register testlib.blockstack_name_preorder("foo.test", wallets[7].privkey, wallets[8].addr) testlib.next_block(**kw) testlib.blockstack_name_register("foo.test", wallets[7].privkey, wallets[8].addr) testlib.next_block(**kw) # consensus hash must be None db = testlib.get_state_engine() name_rec = db.get_name('foo.test') if name_rec['consensus_hash'] is not None: print 'wrong consensus hash: expected {}'.format(None) print json.dumps(name_rec, indent=4, sort_keys=True) return False resp = testlib.blockstack_name_transfer("foo.test", wallets[0].addr, True, wallets[8].privkey) if 'error' in resp: print resp return False testlib.next_block(**kw) # consensus hash should be the one from the last NAME_TRANSFER db = testlib.get_state_engine() name_rec = db.get_name('foo.test') if name_rec['consensus_hash'] != testlib.get_consensus_at( testlib.get_current_block(**kw) - 1): print 'wrong consensus hash: expected {}'.format( testlib.get_consensus_at(testlib.get_current_block(**kw) - 1)) print json.dumps(name_rec, indent=4, sort_keys=True) return False resp = testlib.blockstack_name_transfer("foo.test", wallets[8].addr, True, wallets[0].privkey) if 'error' in resp: print resp return False testlib.next_block(**kw) # consensus hash should be the one from the last NAME_TRANSFER db = testlib.get_state_engine() name_rec = db.get_name('foo.test') if name_rec['consensus_hash'] != testlib.get_consensus_at( testlib.get_current_block(**kw) - 1): print 'wrong consensus hash: expected {}'.format( testlib.get_consensus_at(testlib.get_current_block(**kw) - 1)) print json.dumps(name_rec, indent=4, sort_keys=True) return False resp = testlib.blockstack_name_update("foo.test", "33" * 20, wallets[8].privkey) if 'error' in resp: print resp return False testlib.next_block(**kw) # consensus hash should be the one from the last NAME_UPDATE db = testlib.get_state_engine() name_rec = db.get_name('foo.test') if name_rec['consensus_hash'] != testlib.get_consensus_at( testlib.get_current_block(**kw) - 1): print 'wrong consensus hash: expected {}'.format( testlib.get_consensus_at(testlib.get_current_block(**kw) - 1)) print json.dumps(name_rec, indent=4, sort_keys=True) return False
def scenario( wallets, **kw ): global debug # TODO: insert delayed consensus hashes resp = testlib.blockstack_namespace_preorder( "test", wallets[1].addr, wallets[0].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) resp = 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 ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) resp = testlib.blockstack_namespace_ready( "test", wallets[1].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) consensus_hash = testlib.get_consensus_at( testlib.get_current_block(**kw), **kw) resp = testlib.blockstack_name_preorder( "foo.test", wallets[2].privkey, wallets[3].addr, wallet=wallets[3], consensus_hash=consensus_hash ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) resp = testlib.blockstack_name_register( "foo.test", wallets[2].privkey, wallets[3].addr, wallet=wallets[3] ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # ping-ping a bit... 3 --> 4 --> 5 --> 4 --> 5 --> 4 resp = testlib.blockstack_name_transfer( "foo.test", wallets[4].addr, True, wallets[3].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) resp = testlib.blockstack_name_transfer( "foo.test", wallets[5].addr, True, wallets[4].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) resp = testlib.blockstack_name_transfer( "foo.test", wallets[4].addr, True, wallets[5].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) resp = testlib.blockstack_name_transfer( "foo.test", wallets[5].addr, True, wallets[4].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) resp = testlib.blockstack_name_transfer( "foo.test", wallets[4].addr, True, wallets[5].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # update (4) resp = testlib.blockstack_name_update( "foo.test", "11" * 20, wallets[4].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) # ping-ping a bit... 4 --> 5 --> 4 --> 5 --> 4 --> 5 resp = testlib.blockstack_name_transfer( "foo.test", wallets[5].addr, True, wallets[4].privkey, consensus_hash=consensus_hash ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) resp = testlib.blockstack_name_transfer( "foo.test", wallets[4].addr, True, wallets[5].privkey, consensus_hash=consensus_hash ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) resp = testlib.blockstack_name_transfer( "foo.test", wallets[5].addr, True, wallets[4].privkey, consensus_hash=consensus_hash ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) resp = testlib.blockstack_name_transfer( "foo.test", wallets[4].addr, True, wallets[5].privkey, consensus_hash=consensus_hash ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) resp = testlib.blockstack_name_transfer( "foo.test", wallets[5].addr, True, wallets[4].privkey, consensus_hash=consensus_hash ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) # now update (5) resp = testlib.blockstack_name_update( "foo.test", "22" * 20, wallets[5].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # update transfer resp = testlib.blockstack_name_transfer( "foo.test", wallets[4].addr, True, wallets[5].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) resp = testlib.blockstack_name_update( "foo.test", "33" * 20, wallets[4].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # update --> transfer --> transfer --> update resp = testlib.blockstack_name_update( "foo.test", "44" * 20, wallets[4].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) resp = testlib.blockstack_name_transfer( "foo.test", wallets[5].addr, True, wallets[4].privkey, consensus_hash=consensus_hash ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) resp = testlib.blockstack_name_transfer( "foo.test", wallets[4].addr, True, wallets[5].privkey, consensus_hash=consensus_hash ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) resp = testlib.blockstack_name_update( "foo.test", "55" * 20, wallets[4].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # update --> transfer --> update --> transfer resp = testlib.blockstack_name_update( "foo.test", "66" * 20, wallets[4].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) resp = testlib.blockstack_name_transfer( "foo.test", wallets[5].addr, True, wallets[4].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) resp = testlib.blockstack_name_update( "foo.test", "11" * 20, wallets[5].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # transfer resp = testlib.blockstack_name_transfer( "foo.test", wallets[4].addr, True, wallets[5].privkey, consensus_hash=consensus_hash ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw )
def scenario( wallets, **kw ): testlib.blockstack_namespace_preorder( "test", wallets[1].addr, wallets[0].privkey ) testlib.next_block( **kw ) # note: lifetime of a name is 10 * NAMESPACE_LIFETIME_MULTIPLIER # we will make sure this all fails by *not* honoring this testlib.blockstack_namespace_reveal( "test", wallets[1].addr, 10, 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 ) consensus_hash = testlib.get_consensus_at( testlib.get_current_block(**kw), **kw) testlib.next_block( **kw ) testlib.next_block( **kw ) # preorder, register, update, expire (twice, with incorrect assumption about namespace lifetime) for i in xrange(2, 4): resp = testlib.blockstack_name_preorder( "foo.test", wallets[i].privkey, wallets[(i+1)%11].addr, consensus_hash=consensus_hash, safety_checks=False ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) consensus_hash = testlib.get_consensus_at( testlib.get_current_block(**kw), **kw) testlib.next_block( **kw ) testlib.next_block( **kw ) resp = testlib.blockstack_name_register( "foo.test", wallets[i].privkey, wallets[(i+1)%11].addr, safety_checks=False ) testlib.next_block( **kw ) if 'error' in resp: print json.dumps( resp, indent=4 ) if i == 3: testlib.expect_snv_fail_at( "foo.test", testlib.get_current_block(**kw)) consensus_hash = testlib.get_consensus_at( testlib.get_current_block(**kw), **kw) testlib.next_block( **kw ) testlib.next_block( **kw ) resp = testlib.blockstack_name_transfer( "foo.test", wallets[i].addr, True, wallets[(i+1)%11].privkey, consensus_hash=consensus_hash, safety_checks=False ) testlib.next_block( **kw ) if 'error' in resp: print json.dumps( resp, indent=4 ) if i == 3: testlib.expect_snv_fail_at( "foo.test", testlib.get_current_block(**kw)) consensus_hash = testlib.get_consensus_at( testlib.get_current_block(**kw), **kw) testlib.next_block( **kw ) testlib.next_block( **kw ) resp = testlib.blockstack_name_update( "foo.test", ("%02x" % i) * 20, wallets[i].privkey, consensus_hash=consensus_hash, safety_checks=False ) testlib.next_block( **kw ) if 'error' in resp: print json.dumps( resp, indent=4 ) if i == 3: testlib.expect_snv_fail_at( "foo.test", testlib.get_current_block(**kw)) break consensus_hash = testlib.get_consensus_at( testlib.get_current_block(**kw), **kw) testlib.next_block( **kw ) testlib.next_block( **kw ) if i == 3: break
def refresh_chain_tip(self): bitcoind = testlib.connect_bitcoind() self.block_height = bitcoind.getblockcount() self.consensus_hash = testlib.get_consensus_at(self.block_height); self.last_block_operations = blockstack.lib.client.get_blockstack_transactions_at(self.block_height, hostport='http://localhost:16264') self.last_block_height_check = time.time()
def scenario(wallets, **kw): global debug resp = testlib.blockstack_namespace_preorder("test", wallets[1].addr, wallets[0].privkey) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) resp = 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) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) resp = testlib.blockstack_name_import("foo.test", wallets[3].addr, "11" * 20, wallets[1].privkey) if 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) resp = testlib.blockstack_namespace_ready("test", wallets[1].privkey) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) # consensus hash should be None db = testlib.get_state_engine() name_rec = db.get_name('foo.test') if name_rec['consensus_hash'] is not None: print 'wrong consensus hash: expected None' print json.dumps(name_rec, indent=4, sort_keys=True) return False # ping-ping a bit... 3 --> 4 --> 5 --> 4 --> 5 --> 4 resp = testlib.blockstack_name_transfer("foo.test", wallets[4].addr, True, wallets[3].privkey) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) # consensus hash should be the one from the last NAME_TRANSFER db = testlib.get_state_engine() name_rec = db.get_name('foo.test') if name_rec['consensus_hash'] != testlib.get_consensus_at( testlib.get_current_block(**kw) - 1): print 'wrong consensus hash: expected {}'.format( testlib.get_consensus_at(testlib.get_current_block(**kw) - 1)) print json.dumps(name_rec, indent=4, sort_keys=True) return False resp = testlib.blockstack_name_transfer("foo.test", wallets[5].addr, True, wallets[4].privkey) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) # consensus hash should be the one from the last NAME_TRANSFER db = testlib.get_state_engine() name_rec = db.get_name('foo.test') if name_rec['consensus_hash'] != testlib.get_consensus_at( testlib.get_current_block(**kw) - 1): print 'wrong consensus hash: expected {}'.format( testlib.get_consensus_at(testlib.get_current_block(**kw) - 1)) print json.dumps(name_rec, indent=4, sort_keys=True) return False resp = testlib.blockstack_name_transfer("foo.test", wallets[4].addr, True, wallets[5].privkey) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) # consensus hash should be the one from the last NAME_TRANSFER db = testlib.get_state_engine() name_rec = db.get_name('foo.test') if name_rec['consensus_hash'] != testlib.get_consensus_at( testlib.get_current_block(**kw) - 1): print 'wrong consensus hash: expected {}'.format( testlib.get_consensus_at(testlib.get_current_block(**kw) - 1)) print json.dumps(name_rec, indent=4, sort_keys=True) return False resp = testlib.blockstack_name_transfer("foo.test", wallets[5].addr, True, wallets[4].privkey) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) # consensus hash should be the one from the last NAME_TRANSFER db = testlib.get_state_engine() name_rec = db.get_name('foo.test') if name_rec['consensus_hash'] != testlib.get_consensus_at( testlib.get_current_block(**kw) - 1): print 'wrong consensus hash: expected {}'.format( testlib.get_consensus_at(testlib.get_current_block(**kw) - 1)) print json.dumps(name_rec, indent=4, sort_keys=True) return False resp = testlib.blockstack_name_transfer("foo.test", wallets[4].addr, True, wallets[5].privkey) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) # consensus hash should be the one from the last NAME_TRANSFER db = testlib.get_state_engine() name_rec = db.get_name('foo.test') if name_rec['consensus_hash'] != testlib.get_consensus_at( testlib.get_current_block(**kw) - 1): print 'wrong consensus hash: expected {}'.format( testlib.get_consensus_at(testlib.get_current_block(**kw) - 1)) print json.dumps(name_rec, indent=4, sort_keys=True) return False # update (4) resp = testlib.blockstack_name_update("foo.test", "11" * 20, wallets[4].privkey) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) # consensus hash should be the one from the last NAME_UPDATE db = testlib.get_state_engine() name_rec = db.get_name('foo.test') if name_rec['consensus_hash'] != testlib.get_consensus_at( testlib.get_current_block(**kw) - 1): print 'wrong consensus hash: expected {}'.format( testlib.get_consensus_at(testlib.get_current_block(**kw) - 1)) print json.dumps(name_rec, indent=4, sort_keys=True) return False update_ch = name_rec['consensus_hash'] # ping-ping a bit... 4 --> 5 --> 4 --> 5 --> 4 --> 5 resp = testlib.blockstack_name_transfer("foo.test", wallets[5].addr, True, wallets[4].privkey) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) # consensus hash should be the one from the last NAME_UPDATE db = testlib.get_state_engine() name_rec = db.get_name('foo.test') if name_rec['consensus_hash'] != update_ch: print 'wrong consensus hash: expected {}'.format(update_ch) print json.dumps(name_rec, indent=4, sort_keys=True) return False resp = testlib.blockstack_name_transfer("foo.test", wallets[4].addr, True, wallets[5].privkey) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) # consensus hash should be the one from the last NAME_UPDATE db = testlib.get_state_engine() name_rec = db.get_name('foo.test') if name_rec['consensus_hash'] != update_ch: print 'wrong consensus hash: expected {}'.format(update_ch) print json.dumps(name_rec, indent=4, sort_keys=True) return False resp = testlib.blockstack_name_transfer("foo.test", wallets[5].addr, True, wallets[4].privkey) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) # consensus hash should be the one from the last NAME_UPDATE db = testlib.get_state_engine() name_rec = db.get_name('foo.test') if name_rec['consensus_hash'] != update_ch: print 'wrong consensus hash: expected {}'.format(update_ch) print json.dumps(name_rec, indent=4, sort_keys=True) return False resp = testlib.blockstack_name_transfer("foo.test", wallets[4].addr, True, wallets[5].privkey) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) # consensus hash should be the one from the last NAME_UPDATE db = testlib.get_state_engine() name_rec = db.get_name('foo.test') if name_rec['consensus_hash'] != update_ch: print 'wrong consensus hash: expected {}'.format(update_ch) print json.dumps(name_rec, indent=4, sort_keys=True) return False resp = testlib.blockstack_name_transfer("foo.test", wallets[5].addr, True, wallets[4].privkey) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) # consensus hash should be the one from the last NAME_UPDATE db = testlib.get_state_engine() name_rec = db.get_name('foo.test') if name_rec['consensus_hash'] != update_ch: print 'wrong consensus hash: expected {}'.format(update_ch) print json.dumps(name_rec, indent=4, sort_keys=True) return False # now update (5) resp = testlib.blockstack_name_update("foo.test", "22" * 20, wallets[5].privkey) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) # consensus hash should be the one from the last NAME_UPDATE db = testlib.get_state_engine() name_rec = db.get_name('foo.test') if name_rec['consensus_hash'] != testlib.get_consensus_at( testlib.get_current_block(**kw) - 1): print 'wrong consensus hash: expected {}'.format( testlib.get_consensus_at(testlib.get_current_block(**kw) - 1)) print json.dumps(name_rec, indent=4, sort_keys=True) return False update_ch = testlib.get_consensus_at(testlib.get_current_block(**kw) - 1) resp = testlib.blockstack_name_transfer("foo.test", wallets[4].addr, True, wallets[5].privkey) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) # consensus hash should be the one from the last NAME_UPDATE db = testlib.get_state_engine() name_rec = db.get_name('foo.test') if name_rec['consensus_hash'] != update_ch: print 'wrong consensus hash: expected {}'.format(update_ch) print json.dumps(name_rec, indent=4, sort_keys=True) return False resp = testlib.blockstack_name_update("foo.test", "33" * 20, wallets[4].privkey) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) # consensus hash should be the one from the last NAME_UPDATE db = testlib.get_state_engine() name_rec = db.get_name('foo.test') if name_rec['consensus_hash'] != testlib.get_consensus_at( testlib.get_current_block(**kw) - 1): print 'wrong consensus hash: expected {}'.format( testlib.get_consensus_at(testlib.get_current_block(**kw) - 1)) print json.dumps(name_rec, indent=4, sort_keys=True) return False update_ch = testlib.get_consensus_at(testlib.get_current_block(**kw) - 1) resp = testlib.blockstack_name_update("foo.test", "44" * 20, wallets[4].privkey) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) # consensus hash should be the one from the last NAME_UPDATE db = testlib.get_state_engine() name_rec = db.get_name('foo.test') if name_rec['consensus_hash'] != testlib.get_consensus_at( testlib.get_current_block(**kw) - 1): print 'wrong consensus hash: expected {}'.format( testlib.get_consensus_at(testlib.get_current_block(**kw) - 1)) print json.dumps(name_rec, indent=4, sort_keys=True) return False update_ch = testlib.get_consensus_at(testlib.get_current_block(**kw) - 1) resp = testlib.blockstack_name_transfer("foo.test", wallets[5].addr, True, wallets[4].privkey) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) # consensus hash should be the one from the last NAME_UPDATE db = testlib.get_state_engine() name_rec = db.get_name('foo.test') if name_rec['consensus_hash'] != update_ch: print 'wrong consensus hash: expected {}'.format( testlib.get_consensus_at(testlib.get_current_block(**kw) - 1)) print json.dumps(name_rec, indent=4, sort_keys=True) return False resp = testlib.blockstack_name_transfer("foo.test", wallets[4].addr, True, wallets[5].privkey) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) # consensus hash should be the one from the last NAME_UPDATE db = testlib.get_state_engine() name_rec = db.get_name('foo.test') if name_rec['consensus_hash'] != update_ch: print 'wrong consensus hash: expected {}'.format( testlib.get_consensus_at(testlib.get_current_block(**kw) - 1)) print json.dumps(name_rec, indent=4, sort_keys=True) return False resp = testlib.blockstack_name_update("foo.test", "55" * 20, wallets[4].privkey) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) # consensus hash should be the one from the last NAME_UPDATE db = testlib.get_state_engine() name_rec = db.get_name('foo.test') if name_rec['consensus_hash'] != testlib.get_consensus_at( testlib.get_current_block(**kw) - 1): print 'wrong consensus hash: expected {}'.format( testlib.get_consensus_at(testlib.get_current_block(**kw) - 1)) print json.dumps(name_rec, indent=4, sort_keys=True) return False update_ch = testlib.get_consensus_at(testlib.get_current_block(**kw) - 1) resp = testlib.blockstack_name_update("foo.test", "66" * 20, wallets[4].privkey) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) # consensus hash should be the one from the last NAME_UPDATE db = testlib.get_state_engine() name_rec = db.get_name('foo.test') if name_rec['consensus_hash'] != testlib.get_consensus_at( testlib.get_current_block(**kw) - 1): print 'wrong consensus hash: expected {}'.format( testlib.get_consensus_at(testlib.get_current_block(**kw) - 1)) print json.dumps(name_rec, indent=4, sort_keys=True) return False update_ch = testlib.get_consensus_at(testlib.get_current_block(**kw) - 1) resp = testlib.blockstack_name_transfer("foo.test", wallets[5].addr, True, wallets[4].privkey) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) # consensus hash should be the one from the last NAME_UPDATE db = testlib.get_state_engine() name_rec = db.get_name('foo.test') if name_rec['consensus_hash'] != update_ch: print 'wrong consensus hash: expected {}'.format(update_ch) print json.dumps(name_rec, indent=4, sort_keys=True) return False resp = testlib.blockstack_name_update("foo.test", "11" * 20, wallets[5].privkey) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) # consensus hash should be the one from the last NAME_UPDATE db = testlib.get_state_engine() name_rec = db.get_name('foo.test') if name_rec['consensus_hash'] != testlib.get_consensus_at( testlib.get_current_block(**kw) - 1): print 'wrong consensus hash: expected {}'.format( testlib.get_consensus_at(testlib.get_current_block(**kw) - 1)) print json.dumps(name_rec, indent=4, sort_keys=True) return False update_ch = testlib.get_consensus_at(testlib.get_current_block(**kw) - 1) resp = testlib.blockstack_name_transfer("foo.test", wallets[4].addr, True, wallets[5].privkey) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) # consensus hash should be the one from the last NAME_UPDATE db = testlib.get_state_engine() name_rec = db.get_name('foo.test') if name_rec['consensus_hash'] != update_ch: print 'wrong consensus hash: expected {}'.format(update_ch) print json.dumps(name_rec, indent=4, sort_keys=True) return False
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, 10, 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) consensus_hash = testlib.get_consensus_at(testlib.get_current_block(**kw), **kw) testlib.next_block(**kw) testlib.next_block(**kw) # preorder, register, update, expire (multiple times) for i in xrange(2, 11): resp = testlib.blockstack_name_preorder("foo.test", wallets[i].privkey, wallets[(i + 1) % 11].addr, consensus_hash=consensus_hash) if 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) consensus_hash = testlib.get_consensus_at( testlib.get_current_block(**kw), **kw) testlib.next_block(**kw) testlib.next_block(**kw) resp = testlib.blockstack_name_register("foo.test", wallets[i].privkey, wallets[(i + 1) % 11].addr) if 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) consensus_hash = testlib.get_consensus_at( testlib.get_current_block(**kw), **kw) testlib.next_block(**kw) testlib.next_block(**kw) resp = testlib.blockstack_name_transfer("foo.test", wallets[i].addr, True, wallets[(i + 1) % 11].privkey, consensus_hash=consensus_hash) if 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) consensus_hash = testlib.get_consensus_at( testlib.get_current_block(**kw), **kw) testlib.next_block(**kw) testlib.next_block(**kw) resp = testlib.blockstack_name_update("foo.test", ("%02x" % i) * 20, wallets[i].privkey, consensus_hash=consensus_hash) if 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) consensus_hash = testlib.get_consensus_at( testlib.get_current_block(**kw), **kw) testlib.next_block(**kw) testlib.next_block(**kw) if i == 10: break testlib.next_block(**kw) consensus_hash = testlib.get_consensus_at( testlib.get_current_block(**kw), **kw) testlib.next_block(**kw) testlib.next_block(**kw)
def scenario(wallets, **kw): global debug, consensus resp = testlib.blockstack_namespace_preorder("test", wallets[1].addr, wallets[0].privkey) if 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) resp = 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) if 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) resp = testlib.blockstack_namespace_ready("test", wallets[1].privkey) if 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) resp = testlib.blockstack_name_preorder("foo.test", wallets[2].privkey, wallets[3].addr) if 'error' in resp: print json.dumps(resp, indent=4) resp = testlib.blockstack_name_preorder("bar.test", wallets[2].privkey, wallets[3].addr) if 'error' in resp: print json.dumps(resp, indent=4) resp = testlib.blockstack_name_preorder("baz.test", wallets[2].privkey, wallets[3].addr) if 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) resp = testlib.blockstack_name_register("foo.test", wallets[2].privkey, wallets[3].addr) if 'error' in resp: print json.dumps(resp, indent=4) return False resp = testlib.blockstack_name_register("bar.test", wallets[2].privkey, wallets[3].addr) if 'error' in resp: print json.dumps(resp, indent=4) return False resp = testlib.blockstack_name_register("baz.test", wallets[2].privkey, wallets[3].addr) if 'error' in resp: print json.dumps(resp, indent=4) return False testlib.next_block(**kw) # foo.test: NAME_PREORDER, NAME_REGISTRATION, NAME_TRANSFER. # baz.test: NAME_PREORDER, NAME_REGISTRATION, NAME_TRANSFER # in both cases, the consensus hash should be the one from the NAME_TRANSFER, # since there was no prior consensus hash. resp = testlib.blockstack_name_transfer("foo.test", wallets[4].addr, True, wallets[3].privkey) if 'error' in resp: print resp return False resp = testlib.blockstack_name_transfer("baz.test", wallets[4].addr, True, wallets[3].privkey) if 'error' in resp: print resp return False testlib.next_block(**kw) for name in ['foo.test', 'baz.test']: db = testlib.get_state_engine() name_rec = db.get_name(name, include_history=False) if name_rec['consensus_hash'] is None: print 'NAME_TRANSFER did not set the consensus hash: {}'.format( name_rec) return False if name_rec['consensus_hash'] != testlib.get_consensus_at( testlib.get_current_block(**kw) - 1): print 'NAME_TRANSFER set wrong consensus hash (expected {}): {}'.format( testlib.get_consensus_at(testlib.get_current_block(**kw) - 1), name_rec['consensus_hash']) return False # bar.test: NAME_PREORDER, NAME_REGISTRATION, NAME_UPDATE # the consensus hash should be the one from the NAME_UPDATE resp = testlib.blockstack_name_update('bar.test', '11' * 20, wallets[3].privkey) if 'error' in resp: print resp return False testlib.next_block(**kw) db = testlib.get_state_engine() name_rec = db.get_name('bar.test', include_history=False) bar_update_ch = name_rec['consensus_hash'] assert bar_update_ch, 'No consensus hash set on update' if bar_update_ch != testlib.get_consensus_at( testlib.get_current_block(**kw) - 1): print 'NAME_UPDATE did not set consensus hash {} (got {}): {}'.format( testlib.get_consensus_at(testlib.get_current_block(**kw) - 1), bar_update_ch, name_rec) return False # bar.test: NAME_PREORDER, NAME_REGISTRATION, NAME_UPDATE, NAME_TRANSFER # the consensus hash should still be the one from the NAME_UPDATE resp = testlib.blockstack_name_transfer('bar.test', wallets[4].addr, True, wallets[3].privkey) if 'error' in resp: print resp return False testlib.next_block(**kw) db = testlib.get_state_engine() name_rec = db.get_name('bar.test', include_history=False) if name_rec['consensus_hash'] != bar_update_ch: print 'update consensus hash not preserved (expected {}): {}'.format( bar_update_ch, name_rec) return False # foo.test: NAME_PREORDER, NAME_REGISTRATION, NAME_TRANSFER, NAME_UPDATE # the consensus hash should be from foo.test's NAME_UPDATE resp = testlib.blockstack_name_update('foo.test', '22' * 20, wallets[4].privkey) if 'error' in resp: print resp return False # bar.test: NAME_PREORDER, NAME_REGISTRATION, NAME_UPDATE, NAME_TRANSFER, NAME_UPDATE # the consensus hash should be from bar.test's last NAME_UPDATE resp = testlib.blockstack_name_update('bar.test', '33' * 20, wallets[4].privkey) if 'error' in resp: print resp return False # baz.test: NAME_PREORDER, NAME_REGISTRATION, NAME_TRANSFER, NAME_TRANSFER # the consensus hash should be from the last NAME_TRANSFER resp = testlib.blockstack_name_transfer('baz.test', wallets[3].addr, True, wallets[4].privkey) if 'error' in resp: print resp return False testlib.next_block(**kw) db = testlib.get_state_engine() name_rec = db.get_name('foo.test', include_history=False) name_history = db.get_name_at('foo.test', testlib.get_current_block(**kw)) foo_update_ch = name_rec['consensus_hash'] # foo.test: consensus hash should match that of the previously-sent update now. if name_rec['consensus_hash'] != testlib.get_consensus_at( testlib.get_current_block(**kw) - 1): print 'NAME_UPDATE did not set consensus hash for foo.test (expected {}): {}'.format( testlib.get_consensus_at(testlib.get_current_block(**kw) - 1), name_rec) return False # foo.test: name's history's consensus hash should match the update as well if name_history[0]['consensus_hash'] != testlib.get_consensus_at( testlib.get_current_block(**kw) - 1): print 'NAME_UPDATE did not match consensus hash in history for foo.test (expected {}): {}'.format( testlib.get_consensus_at(testlib.get_current_block(**kw) - 1), name_history[0]) return False name_rec = db.get_name('bar.test', include_history=False) name_history = db.get_name_at('bar.test', testlib.get_current_block(**kw)) bar_update_ch = name_rec['consensus_hash'] # bar.test: consensus hash should match the update's consensus hash if name_rec['consensus_hash'] != testlib.get_consensus_at( testlib.get_current_block(**kw) - 1): print 'NAME_UPDATE did not set consensus hash for bar.test (expected {}): {}'.format( testlib.get_consensus_at(testlib.get_current_block(**kw) - 1), name_rec) return False # bar.test: name's history's consensus hash should match the update as well if name_history[0]['consensus_hash'] != testlib.get_consensus_at( testlib.get_current_block(**kw) - 1): print 'NAME_UPDATE did not match consensus hash in history for bar.test (expected {}): {}'.format( testlib.get_consensus_at(testlib.get_current_block(**kw) - 1), name_history[0]) return False db = testlib.get_state_engine() name_rec = db.get_name('baz.test', include_history=False) name_history = db.get_name_at('baz.test', testlib.get_current_block(**kw)) # baz.test: consensus hash should match that of previously-sent NAME_TRANSFER if name_rec['consensus_hash'] != testlib.get_consensus_at( testlib.get_current_block(**kw) - 1): print 'NAME_TRANSFER did not set consensus hash for baz.test (expected {}): {}'.format( testlib.get_consensus_at(testlib.get_current_block(**kw) - 1), name_rec) return False # baz.test: name's history's consensus hash should have been set to the last NAME_TRANSFER consensus hash if name_history[0]['consensus_hash'] != testlib.get_consensus_at( testlib.get_current_block(**kw) - 1): print 'NAME_TRANSFER did not match consensus hash in history for baz.test (expected {}): {}'.format( testlib.get_consensus_at(testlib.get_current_block(**kw) - 1), name_history[0]) return False # foo.test: NAME_PREORDER, NAME_REGISTRATION, NAME_TRANSFER, NAME_UPDATE, NAME_TRANSFER # foo.test's consensus hash should be that of its last NAME_UPDATE resp = testlib.blockstack_name_transfer('foo.test', wallets[3].addr, True, wallets[4].privkey) if 'error' in resp: print resp return False # bar.test: NAME_PREORDER, NAME_REGISTRATION, NAME_UPDATE, NAME_TRANSFER, NAME_UPDATE, NAME_TRANSFER # bar.test's consensus hash should be that of its last NAME_UPDATE resp = testlib.blockstack_name_transfer('bar.test', wallets[3].addr, True, wallets[4].privkey) if 'error' in resp: print resp return False # baz.test: NAME_PREORDER, NAME_REGISTRATION, NAME_TRANSFER, NAME_TRANSFER, NAME_TRANSFER # baz.test's consensus hash should be that of the last NAME_TRANSFER still resp = testlib.blockstack_name_transfer('baz.test', wallets[4].addr, True, wallets[3].privkey) if 'error' in resp: print resp return False testlib.next_block(**kw) db = testlib.get_state_engine() name_rec = db.get_name('foo.test', include_history=False) name_history = db.get_name_at('foo.test', testlib.get_current_block(**kw)) # foo.test's last NAME_UPDATE set the consensus hash if name_rec['consensus_hash'] != foo_update_ch: print 'NAME_TRANSFER did not preserve previous consensus hash for foo.test (expected {}): {}'.format( foo_update_ch, name_rec) return False # foo.test's last-history-inserted consensus hash should be from the NAME_UPDATE if name_history[0]['consensus_hash'] != foo_update_ch: print 'NAME_UPDATE did not match consensus hash in history for foo.test (expected {}): {}'.format( foo_update_ch, name_history[0]) return False db = testlib.get_state_engine() name_rec = db.get_name('bar.test', include_history=False) name_history = db.get_name_at('bar.test', testlib.get_current_block(**kw)) # bar.test's last NAME_UPDATE set the consensus hash if name_rec['consensus_hash'] != bar_update_ch: print 'NAME_TRANSFER did not preserve previous consensus hash for bar.test (expected {}): {}'.format( bar_update_ch, name_rec) return False # bar.test's last-history-inserted consensus hash should be from the NAME_UPDATE if name_history[0]['consensus_hash'] != bar_update_ch: print 'NAME_UPDATE did not match consensus hash in history for bar.test (expected {}): {}'.format( bar_update_ch, name_history[0]) return False db = testlib.get_state_engine() name_rec = db.get_name('baz.test', include_history=False) name_history = db.get_name_at('baz.test', testlib.get_current_block(**kw)) # baz.test's last NAME_TRANSFER set the consensus hash if name_rec['consensus_hash'] != testlib.get_consensus_at( testlib.get_current_block(**kw) - 1): print 'NAME_TRANSFER did not preserve previous consensus hash for baz.test (expected {}): {}'.format( testlib.get_consensus_at(testlib.get_current_block(**kw) - 1), name_rec) return False # baz.test's last-history-inserted consensus hash should be from the NAME_TRANSFER if name_history[0]['consensus_hash'] != testlib.get_consensus_at( testlib.get_current_block(**kw) - 1): print 'NAME_TRANSFER did not match consensus hash in history for baz.test (expected {}): {}'.format( testlib.get_consensus_at(testlib.get_current_block(**kw) - 1), name_history[0]) return False # foo.test: NAME_PREORDER, NAME_REGISTRATION, NAME_TRANSFER, NAME_UPDATE, NAME_TRANSFER, NAME_TRANSFER # foo.test's consensus hash should be that of its last NAME_UPDATE resp = testlib.blockstack_name_transfer('foo.test', wallets[4].addr, True, wallets[3].privkey) if 'error' in resp: print resp return False # bar.test: NAME_PREORDER, NAME_REGISTRATION, NAME_UPDATE, NAME_TRANSFER, NAME_UPDATE, NAME_TRANSFER, NAME_TRANSFER # bar.test's consensus hash should be that of its last NAME_UPDATE resp = testlib.blockstack_name_transfer('bar.test', wallets[4].addr, True, wallets[3].privkey) if 'error' in resp: print resp return False testlib.next_block(**kw) db = testlib.get_state_engine() name_rec = db.get_name('foo.test', include_history=False) name_history = db.get_name_at('foo.test', testlib.get_current_block(**kw)) # foo.test's last NAME_UPDATE set the consensus hash if name_rec['consensus_hash'] != foo_update_ch: print 'NAME_TRANSFER did not preserve previous consensus hash (expected {}): {}'.format( foo_update_ch, name_rec) return False # foo.test's last-history-inserted consensus hash should be from NAME_UPDATE if name_history[0]['consensus_hash'] != foo_update_ch: print 'NAME_UPDATE did not match consensus hash in history (expected {}): {}'.format( foo_update_ch, name_history[0]) return False name_rec = db.get_name('bar.test', include_history=False) name_history = db.get_name_at('bar.test', testlib.get_current_block(**kw)) # bar.test's last NAME_UPDATE set the consensus hash if name_rec['consensus_hash'] != bar_update_ch: print 'NAME_TRANSFER did not preserve previous consensus hash (expected {}): {}'.format( bar_update_ch, name_rec) return False # bar.test's last-history-inserted consensus hash should be from the NAME_UPDATE if name_history[0]['consensus_hash'] != bar_update_ch: print 'NAME_UPDATE did not match consensus hash in history (expected {}): {}'.format( bar_update_ch, name_history[0]) return False
def scenario(wallets, **kw): global update_blocks, transfer_blocks, update_hashes, transfer_recipients testlib.ysi_namespace_preorder("test", wallets[1].addr, wallets[0].privkey) testlib.next_block(**kw) testlib.ysi_namespace_reveal( "test", wallets[1].addr, 10, 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.ysi_namespace_ready("test", wallets[1].privkey) testlib.next_block(**kw) consensus_hash = testlib.get_consensus_at(testlib.get_current_block(**kw), **kw) testlib.next_block(**kw) testlib.next_block(**kw) # preorder, register, update, expire (multiple times) # account for namespace lifetime multipler (in 0.0.14) for i in xrange(2, 5): resp = testlib.ysi_name_preorder("foo.test", wallets[i].privkey, wallets[(i + 1) % 11].addr, consensus_hash=consensus_hash) if 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) consensus_hash = testlib.get_consensus_at( testlib.get_current_block(**kw), **kw) testlib.next_block(**kw) testlib.next_block(**kw) resp = testlib.ysi_name_register("foo.test", wallets[i].privkey, wallets[(i + 1) % 11].addr) if 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) consensus_hash = testlib.get_consensus_at( testlib.get_current_block(**kw), **kw) testlib.next_block(**kw) testlib.next_block(**kw) resp = testlib.ysi_name_update("foo.test", ("%02x" % i) * 20, wallets[(i + 1) % 11].privkey, consensus_hash=consensus_hash) if 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) update_blocks.append(testlib.get_current_block(**kw)) update_hashes.append(("%02x" % i) * 20) consensus_hash = testlib.get_consensus_at( testlib.get_current_block(**kw), **kw) testlib.next_block(**kw) testlib.next_block(**kw) resp = testlib.ysi_name_transfer("foo.test", wallets[i].addr, True, wallets[(i + 1) % 11].privkey, consensus_hash=consensus_hash) if 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) transfer_blocks.append(testlib.get_current_block(**kw)) transfer_recipients.append(wallets[i].addr) consensus_hash = testlib.get_consensus_at( testlib.get_current_block(**kw), **kw) testlib.next_block(**kw) testlib.next_block(**kw) if i == 4: break # eat up the rest of the lifetime for j in xrange(0, 10 * NAMESPACE_LIFETIME_MULTIPLIER - 10): testlib.next_block(**kw) consensus_hash = testlib.get_consensus_at( testlib.get_current_block(**kw), **kw) testlib.next_block(**kw) testlib.next_block(**kw) testlib.next_block(**kw)
def scenario(wallets, **kw): global FOO_ZONEFILE_HASH, HELLO_FOO_ZONEFILE_HASH, CONSENSUS_HASH zf_template = "$ORIGIN {}\n$TTL 3600\n{}" zf_default_url = '_https._tcp URI 10 1 "https://raw.githubusercontent.com/nobody/content/profile.md"' hello_foo_zonefile = zf_template.format('bar.foo.test', zf_default_url) foo_zonefile = zf_template.format( 'foo.test', subdomains.make_subdomain_txt('hello.foo.test', 'foo.test', wallets[3].addr, 0, hello_foo_zonefile, wallets[3].privkey)) HELLO_FOO_ZONEFILE_HASH = blockstack.lib.storage.get_zonefile_data_hash( hello_foo_zonefile) FOO_ZONEFILE_HASH = blockstack.lib.storage.get_zonefile_data_hash( foo_zonefile) 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) testlib.blockstack_name_register("foo.test", wallets[2].privkey, wallets[3].addr, zonefile_hash=FOO_ZONEFILE_HASH) testlib.next_block(**kw) testlib.blockstack_put_zonefile(foo_zonefile) testlib.next_block(**kw) CONSENSUS_HASH = testlib.get_consensus_at(testlib.get_current_block(**kw)) errors = [] fixtures = get_fixtures() for entry in fixtures: url = 'http://localhost:16268' + entry['route'] res = requests.get(url, allow_redirects=False) res_status = res.status_code res_txt = res.text res_json = None try: res_json = res.json() except: pass if 'status' in entry and entry['status'] != res_status: err = '{}: status {} (expected {})\nbody: {}'.format( url, res_status, entry['status'], res_txt) print >> sys.stderr, err errors.append(err) if 'body' in entry and ( (res_json is not None and entry['body'] != res_json) or (res_json is None and res_txt != entry['body'])): err = '{}: wrong body {} (expected {})'.format( url, res_txt, entry['body']) print >> sys.stderr, err errors.append(err) if len(errors) > 0: print >> sys.stderr, json.dumps(errors, indent=4) return False