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 ) resp = testlib.blockstack_name_preorder( "foo.test", wallets[2].privkey, wallets[3].addr ) if 'error' in resp: print json.dumps(resp) testlib.next_block( **kw ) # no name operations should work on this name, except register resp = testlib.blockstack_name_update( "foo.test", "11" * 20, wallets[3].privkey, safety_checks=False ) if 'error' in resp: print json.dumps(resp) testlib.next_block( **kw ) testlib.expect_snv_fail_at( "foo.test", testlib.get_current_block(**kw)) resp = testlib.blockstack_name_renew( "foo.test", wallets[3].privkey, safety_checks=False ) if 'error' in resp: print json.dumps(resp) testlib.next_block( **kw ) testlib.expect_snv_fail_at( "foo.test", testlib.get_current_block(**kw)) resp = testlib.blockstack_name_transfer( "foo.test", wallets[4].addr, True, wallets[3].privkey, safety_checks=False ) if 'error' in resp: print json.dumps(resp) testlib.next_block( **kw ) testlib.expect_snv_fail_at( "foo.test", testlib.get_current_block(**kw)) # try both addresses (should both fail) resp = testlib.blockstack_name_revoke( "foo.test", wallets[4].privkey, safety_checks=False) if 'error' in resp: print json.dumps(resp) testlib.next_block( **kw ) testlib.expect_snv_fail_at( "foo.test", testlib.get_current_block(**kw)) resp = testlib.blockstack_name_revoke( "foo.test", wallets[3].privkey, safety_checks=False ) if 'error' in resp: print json.dumps(resp) testlib.next_block( **kw ) testlib.expect_snv_fail_at( "foo.test", testlib.get_current_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) resp = testlib.blockstack_name_revoke("foo.test", wallets[4].privkey, safety_checks=False) 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) # should fail; not the owner resp = testlib.blockstack_name_revoke("foo.test", wallets[4].privkey, safety_checks=False) testlib.next_block(**kw) testlib.expect_snv_fail_at("foo.test", testlib.get_current_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) resp = testlib.blockstack_name_revoke("foo.test", wallets[3].privkey) print json.dumps(resp, indent=4) testlib.next_block(**kw)
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_update("foo.test", "11" * 20, wallets[3].privkey) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) resp = testlib.blockstack_name_revoke("foo.test", wallets[3].privkey) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) # should fail 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)
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 ) 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() resp = testlib.blockstack_name_revoke( "foo.test", wallets[3].privkey ) testlib.next_block( **kw ) last_consensus = testlib.get_consensus_at( testlib.get_current_block() )
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) 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() resp = testlib.blockstack_name_revoke("foo.test", wallets[3].privkey) testlib.next_block(**kw) last_consensus = testlib.get_consensus_at(testlib.get_current_block())
def scenario( wallets, **kw ): global register_block, revoke_block # 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, 6, 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 ) # wait for a bit... for i in xrange(0, 6): 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 ) # revoke it resp = testlib.blockstack_name_revoke( "foo.test", wallets[3].privkey ) if 'error' in resp: print json.dumps(resp, indent=4 ) testlib.next_block( **kw ) revoke_block = testlib.get_current_block( **kw ) # wait for it to expire for i in xrange(0, 6 * 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 ) register_block = testlib.get_current_block( **kw )
def scenario(wallets, **kw): # 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) 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) # revoke it resp = testlib.blockstack_name_revoke("foo.test", wallets[3].privkey) testlib.next_block(**kw)
def scenario( wallets, **kw ): global fail_blocks testlib.blockstack_namespace_preorder( "test", wallets[1].addr, wallets[0].privkey ) testlib.next_block( **kw ) testlib.blockstack_namespace_reveal( "test", wallets[1].addr, 2, 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 it to expire... for i in xrange(0, 2 * NAMESPACE_LIFETIME_MULTIPLIER + 1): testlib.next_block( **kw ) # verify that operations fail resp = testlib.blockstack_name_update( "foo.test", "11" * 20, wallets[3].privkey, safety_checks=False ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) fail_blocks.append( testlib.get_current_block( **kw ) ) testlib.expect_snv_fail_at( "foo.test", testlib.get_current_block(**kw)) # should fail resp = testlib.blockstack_name_transfer( "foo.test", wallets[4].addr, True, wallets[3].privkey, safety_checks=False ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) fail_blocks.append( testlib.get_current_block( **kw ) ) testlib.expect_snv_fail_at( "foo.test", testlib.get_current_block(**kw)) # should fail resp = testlib.blockstack_name_renew( "foo.test", wallets[3].privkey, safety_checks=False ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) fail_blocks.append( testlib.get_current_block( **kw ) ) testlib.expect_snv_fail_at( "foo.test", testlib.get_current_block(**kw)) # should fail resp = testlib.blockstack_name_revoke( "foo.test", wallets[3].privkey, safety_checks=False ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) fail_blocks.append( testlib.get_current_block( **kw )) testlib.expect_snv_fail_at( "foo.test", testlib.get_current_block(**kw))
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_update( "foo.test", "11" * 20, wallets[3].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) resp = testlib.blockstack_name_revoke( "foo.test", wallets[3].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # should fail 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 ) testlib.next_block( **kw ) testlib.expect_snv_fail_at( "foo.test", testlib.get_current_block(**kw))
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 ) resp = testlib.blockstack_name_revoke( "foo.test", wallets[4].privkey ) 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 ) 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 ) resp = testlib.blockstack_name_revoke( "foo.test", wallets[3].privkey ) testlib.next_block( **kw )
def scenario( wallets, **kw ): # 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 ) 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 ) # 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 ) # revoke it resp = testlib.blockstack_name_revoke( "foo.test", wallets[3].privkey ) testlib.next_block( **kw )
def scenario( wallets, **kw ): subsidy_wallet = wallets[5] print json.dumps( testlib.getrawtransaction( "28f78fbae22d2273341af231a2ac049d74958e1e6ce6ae622cd48d8f0fef591e", 1 ), indent=4 ) 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 ) # subsidized transactions... resp = testlib.blockstack_name_preorder( "foo.test", None, wallets[3].addr, subsidy_key=subsidy_wallet.privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) # (already subsidized...) send_subsidized( None, resp, **kw ) testlib.next_block( **kw ) resp = testlib.blockstack_name_register( "foo.test", None, wallets[3].addr, subsidy_key=subsidy_wallet.privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) # (already subsidized...) send_subsidized( None, resp, **kw ) testlib.next_block( **kw ) resp = testlib.blockstack_name_update( "foo.test", "11" * 20, None, user_public_key=wallets[3].pubkey_hex, subsidy_key=subsidy_wallet.privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) send_subsidized( wallets[3].privkey, resp, **kw ) testlib.next_block( **kw ) resp = testlib.blockstack_name_transfer( "foo.test", wallets[4].addr, True, None, user_public_key=wallets[3].pubkey_hex, subsidy_key=subsidy_wallet.privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) send_subsidized( wallets[3].privkey, resp, **kw ) testlib.next_block( **kw ) resp = testlib.blockstack_name_revoke( "foo.test", None, user_public_key=wallets[4].pubkey_hex, subsidy_key=subsidy_wallet.privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) send_subsidized( wallets[4].privkey, resp, **kw ) # advance a bit for i in xrange(0, 5): testlib.next_block( **kw )
def scenario(wallets, **kw): # 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) # import 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]] for i in xrange(0, len(names)): name = names[i] register_wallet = name_register_wallets[i] resp = testlib.blockstack_name_import(name, register_wallet.addr, str(9 - i) * 40, wallets[1].privkey) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) # namespace ready... 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) # 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 + 2) * 40, register_wallet.privkey) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) # update 3 names in the same block, again 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 # 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)
def scenario( wallets, **kw ): global fail_blocks 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 ) 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_revoke( "foo.test", wallets[3].privkey ) testlib.next_block( **kw ) # can't do anything with the name for another 10 blocks resp = testlib.blockstack_name_update( "foo.test", "11" * 20, wallets[3].privkey ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) testlib.expect_snv_fail_at( "foo.test", testlib.get_current_block(**kw)) # should fail resp = testlib.blockstack_name_transfer( "foo.test", wallets[4].addr, True, wallets[3].privkey, safety_checks=False ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) testlib.expect_snv_fail_at( "foo.test", testlib.get_current_block(**kw)) # should fail resp = testlib.blockstack_name_renew( "foo.test", wallets[3].privkey, safety_checks=False ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) testlib.expect_snv_fail_at( "foo.test", testlib.get_current_block(**kw)) # wait for it to expire... for i in xrange(0, 8 * NAMESPACE_LIFETIME_MULTIPLIER): testlib.next_block( **kw ) # verify that operations continue to fail (BUG in 0.13: THIS SUCCEEDS WHEN IT SHOULD FAIL) resp = testlib.blockstack_name_update( "foo.test", "11" * 20, wallets[3].privkey, safety_checks=False ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) fail_blocks.append( testlib.get_current_block( **kw ) ) testlib.expect_snv_fail_at( "foo.test", testlib.get_current_block(**kw)) # should fail resp = testlib.blockstack_name_transfer( "foo.test", wallets[4].addr, True, wallets[3].privkey, safety_checks=False ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) fail_blocks.append( testlib.get_current_block( **kw ) ) testlib.expect_snv_fail_at( "foo.test", testlib.get_current_block(**kw)) # should fail resp = testlib.blockstack_name_renew( "foo.test", wallets[3].privkey, safety_checks=False ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) fail_blocks.append( testlib.get_current_block( **kw ) ) testlib.expect_snv_fail_at( "foo.test", testlib.get_current_block(**kw)) # re-preorder... resp = testlib.blockstack_name_preorder( "foo.test", wallets[3].privkey, wallets[4].addr ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # re-register (different user) resp = testlib.blockstack_name_register( "foo.test", wallets[3].privkey, wallets[4].addr ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # warn the serialization checker that this changes behavior from 0.13 print "BLOCKSTACK_SERIALIZATION_CHANGE_BEHAVIOR" sys.stdout.flush()
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) resp = testlib.blockstack_name_import("foo.test", wallets[2].addr, "11" * 20, wallets[1].privkey) if 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) print "\nImport 25 names for %s" % wallets[3].addr # try to exceed quota (currently 25): order 25, and try to register a 26th for i in xrange(0, 25): resp = testlib.blockstack_name_import("foo%s.test" % i, wallets[3].addr, "22" * 20, wallets[1].privkey) if 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) print "\nImport 27 names for %s" % wallets[4].addr # try to exceed quota (currently 25): order 26, and try to update one of them (and try to transfer one too). for i in xrange(0, 27): resp = testlib.blockstack_name_import("bar%s.test" % i, wallets[4].addr, "33" * 20, wallets[1].privkey) if 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) testlib.blockstack_namespace_ready("test", wallets[1].privkey) testlib.next_block(**kw) print wallets[3].privkey resp = testlib.blockstack_name_preorder("foofail.test", wallets[3].privkey, wallets[1].addr) if 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) # should fail resp = testlib.blockstack_name_register("foofail.test", wallets[3].privkey, wallets[1].addr) if 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) # should succeed resp = testlib.blockstack_name_update("foo0.test", '55' * 20, wallets[3].privkey) if 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) resp = testlib.blockstack_name_preorder("barfail.test", wallets[4].privkey, wallets[2].addr) if 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) # should fail (exceeded quota) resp = testlib.blockstack_name_register("barfail.test", wallets[4].privkey, wallets[2].addr) if 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) # should fail (exceeded quota--have to revoke or give names away) resp = testlib.blockstack_name_update("bar0.test", '44' * 20, wallets[4].privkey) if 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) # should succeed (give a name away) resp = testlib.blockstack_name_transfer("bar0.test", wallets[1].addr, True, wallets[4].privkey) if 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) # should fail (exceeded quota--have to revoke or give names away) resp = testlib.blockstack_name_update("bar0.test", '44' * 20, wallets[4].privkey) if 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) # should succeed (revoke a name) resp = testlib.blockstack_name_revoke("bar2.test", wallets[4].privkey) if 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) # should succeed (now under quota) resp = testlib.blockstack_name_update("bar1.test", '66' * 20, wallets[4].privkey) if 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) testlib.expect_snv_fail("foofail.test") testlib.expect_snv_fail("barfail.test")
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, 2, 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("foo1.test", wallets[2].privkey, wallets[3].addr) testlib.blockstack_name_preorder("foo2.test", wallets[2].privkey, wallets[3].addr) testlib.blockstack_name_preorder("foo3.test", wallets[2].privkey, wallets[3].addr) testlib.next_block(**kw) testlib.blockstack_name_register("foo1.test", wallets[2].privkey, wallets[3].addr, zonefile_hash='11' * 20) testlib.blockstack_name_register("foo2.test", wallets[2].privkey, wallets[3].addr, zonefile_hash='22' * 20) testlib.blockstack_name_register("foo3.test", wallets[2].privkey, wallets[3].addr, zonefile_hash='33' * 20) testlib.next_block(**kw) def name_rec_equal(r1, r2): keys = set(r1.keys() + r2.keys()) for k in keys: if k in r1 and k in r2: if r1[k] != r2[k]: return False return True # dids for each of these names dids = [ 'did:stack:v0:{}-0'.format(wallets[3].addr), 'did:stack:v0:{}-1'.format(wallets[3].addr), 'did:stack:v0:{}-2'.format(wallets[3].addr) ] # whois for i in xrange(1, 4): name = 'foo{}.test'.format(i) res = testlib.blockstack_cli_whois(name) if 'error' in res: print res return False if not res.has_key('zonefile_hash') or res[ 'zonefile_hash'] != '{}{}'.format(i, i) * 20: print res return False if res['owner_address'] != wallets[3].addr: print res return False # DIDs for i in xrange(0, 3): name = 'foo{}.test'.format(i + 1) res = blockstack.lib.client.get_name_DID( name, hostport='http://localhost:{}'.format( blockstack.lib.config.RPC_SERVER_PORT)) if 'error' in res: print res return False if res != dids[i]: print 'DID mismatch: expected {}, got {}'.format(dids[i], res) return False res = blockstack.lib.client.get_name_record( name, hostport='http://localhost:{}'.format( blockstack.lib.client.RPC_SERVER_PORT)) if 'error' in res: print res return False name_rec = res res = blockstack.lib.client.get_DID_record( dids[i], hostport='http://localhost:{}'.format( blockstack.lib.client.RPC_SERVER_PORT)) if 'error' in res: print res return False did_rec = res if not name_rec_equal(name_rec, did_rec): print 'record mismatch' print json.dumps(name_rec, sort_keys=True) print json.dumps(did_rec, sort_keys=True) return False # do stuff with these names testlib.blockstack_name_update("foo1.test", "1b" * 20, wallets[3].privkey) testlib.blockstack_name_update("foo2.test", "2b" * 20, wallets[3].privkey) testlib.blockstack_name_update("foo3.test", "3b" * 20, wallets[3].privkey) testlib.blockstack_name_revoke("foo1.test", wallets[3].privkey) testlib.blockstack_name_transfer("foo2.test", wallets[4].addr, True, wallets[3].privkey) testlib.blockstack_name_transfer("foo3.test", wallets[4].addr, True, wallets[3].privkey) testlib.next_block(**kw) name_recs = { 'foo1.test': blockstack.lib.client.get_name_record( 'foo1.test', hostport='http://localhost:{}'.format( blockstack.lib.client.RPC_SERVER_PORT)), 'foo2.test': blockstack.lib.client.get_name_record( 'foo2.test', hostport='http://localhost:{}'.format( blockstack.lib.client.RPC_SERVER_PORT)), 'foo3.test': blockstack.lib.client.get_name_record( 'foo3.test', hostport='http://localhost:{}'.format( blockstack.lib.client.RPC_SERVER_PORT)), } assert name_recs['foo1.test']['revoked'] assert virtualchain.address_reencode(str( name_recs['foo2.test']['address'])) == virtualchain.address_reencode( str(wallets[4].addr)) assert virtualchain.address_reencode(str( name_recs['foo3.test']['address'])) == virtualchain.address_reencode( str(wallets[4].addr)) # expire. Reregister under the same owner testlib.next_block(**kw) testlib.next_block(**kw) testlib.next_block(**kw) testlib.next_block(**kw) testlib.next_block(**kw) testlib.blockstack_name_preorder("foo1.test", wallets[2].privkey, wallets[3].addr) testlib.blockstack_name_preorder("foo2.test", wallets[2].privkey, wallets[3].addr) testlib.blockstack_name_preorder("foo3.test", wallets[2].privkey, wallets[3].addr) testlib.next_block(**kw) testlib.blockstack_name_register("foo1.test", wallets[2].privkey, wallets[3].addr, zonefile_hash='1a' * 20) testlib.blockstack_name_register("foo2.test", wallets[2].privkey, wallets[3].addr, zonefile_hash='2a' * 20) testlib.blockstack_name_register("foo3.test", wallets[2].privkey, wallets[3].addr, zonefile_hash='3a' * 20) testlib.next_block(**kw) # whois for i in xrange(1, 4): name = 'foo{}.test'.format(i) res = testlib.blockstack_cli_whois(name) if 'error' in res: print res return False if not res.has_key('zonefile_hash' ) or res['zonefile_hash'] != '{}a'.format(i) * 20: print res return False if res['owner_address'] != wallets[3].addr: print res return False # dids for each of these names new_dids = [ 'did:stack:v0:{}-3'.format(wallets[3].addr), 'did:stack:v0:{}-4'.format(wallets[3].addr), 'did:stack:v0:{}-5'.format(wallets[3].addr) ] # new DIDs for i in xrange(0, 3): name = 'foo{}.test'.format(i + 1) res = blockstack.lib.client.get_name_DID( name, hostport='http://localhost:{}'.format( blockstack.lib.config.RPC_SERVER_PORT)) if 'error' in res: print res return False if res != new_dids[i]: print 'DID mismatch: expected {}, got {}'.format(new_dids[i], res) return False res = blockstack.lib.client.get_name_record( name, hostport='http://localhost:{}'.format( blockstack.lib.client.RPC_SERVER_PORT)) if 'error' in res: print res return False name_rec = res res = blockstack.lib.client.get_DID_record( new_dids[i], hostport='http://localhost:{}'.format( blockstack.lib.client.RPC_SERVER_PORT)) if 'error' in res: print res return False did_rec = res if not name_rec_equal(name_rec, did_rec): print 'record mismatch' print json.dumps(name_rec, sort_keys=True) print json.dumps(did_rec, sort_keys=True) return False # old DIDs for i in xrange(0, 3): name = 'foo{}.test'.format(i + 1) res = blockstack.lib.client.get_DID_record( dids[i], hostport='http://localhost:{}'.format( blockstack.lib.client.RPC_SERVER_PORT)) did_rec = res old_rec = name_recs[name] if old_rec.get('revoked') and 'error' not in did_rec: print 'revoked did is sitll valid: {}'.format(dids[i]) print did_rec return False elif not name_rec_equal(did_rec, old_rec): print 'old record mismatch' print json.dumps(did_rec, sort_keys=True) print json.dumps(old_rec, sort_keys=True) return False
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 ): # 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 ) # import 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]] # derive importer keys and do imports # NOTE: breaks consensus trace from 0.14.0 private_keychain = keychain.PrivateKeychain.from_private_key( wallets[1].privkey ) private_keys = [wallets[1].privkey] # NOTE: always start with the reveal key, then use children for i in xrange(0, len(names)-1): import_key = private_keychain.child(i).private_key() print "fund {} (child {})".format(import_key, i) res = testlib.send_funds( wallets[1].privkey, 100000000, virtualchain.BitcoinPrivateKey(import_key).public_key().address() ) if 'error' in res: print json.dumps(res, indent=4, sort_keys=True) return False testlib.next_block(**kw) private_keys.append(import_key) for i in xrange(0, len(names)): name = names[i] register_wallet = name_register_wallets[i] import_key = private_keys[i] resp = testlib.blockstack_name_import( name, register_wallet.addr, str(9 - i) * 40, import_key, safety_checks=False ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # namespace ready... 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 ) # 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 + 2) * 40, register_wallet.privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # update 3 names in the same block, again 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 # 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 )
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 ) 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 ) resp = testlib.blockstack_name_update( "foo.test", "00" * 20, wallets[3].privkey ) if 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block( **kw ) testlib.blockstack_name_revoke( "foo.test", wallets[3].privkey ) testlib.next_block( **kw ) # can't do anything with the name for another 10 blocks resp = testlib.blockstack_name_update( "foo.test", "11" * 20, wallets[3].privkey ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # should fail resp = testlib.blockstack_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 ) # should fail resp = testlib.blockstack_name_renew( "foo.test", wallets[3].privkey ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # wait for it to expire... for i in xrange(0, 8): testlib.next_block( **kw ) # verify that operations continue to fail resp = testlib.blockstack_name_update( "foo.test", "11" * 20, wallets[3].privkey ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # should fail resp = testlib.blockstack_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 ) # should fail resp = testlib.blockstack_name_renew( "foo.test", wallets[3].privkey ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # re-preorder... resp = testlib.blockstack_name_preorder( "foo.test", wallets[4].privkey, wallets[0].addr ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # re-register resp = testlib.blockstack_name_register( "foo.test", wallets[4].privkey, wallets[0].addr ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # re-update resp = testlib.blockstack_name_update( "foo.test", "11" * 20, wallets[0].privkey ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw )
def scenario(wallets, **kw): global renew_block testlib.blockstack_namespace_preorder("test", wallets[1].addr, wallets[0].privkey) testlib.next_block(**kw) testlib.blockstack_namespace_reveal( "test", wallets[1].addr, 4, 4, 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) whois = testlib.blockstack_cli_whois('foo.test') if 'error' in whois: print whois return False print json.dumps(whois, indent=4, sort_keys=True) # push to grace period testlib.next_block(**kw) testlib.next_block(**kw) testlib.next_block(**kw) # can't update res = testlib.blockstack_name_update("foo.test", '22' * 20, wallets[3].privkey) if 'error' not in res: print res return False res = testlib.blockstack_name_update("foo.test", '22' * 20, wallets[3].privkey, safety_checks=False, tx_fee=300 * 5) if 'error' in res: print res return False testlib.next_block(**kw) testlib.expect_snv_fail_at("foo.test", testlib.get_current_block(**kw)) # should not have gone through res = testlib.blockstack_cli_whois('foo.test') if 'error' in res: print res return False if res.has_key('zonefile_hash'): print res return False # can't transfer res = testlib.blockstack_name_transfer('foo.test', wallets[4].addr, True, wallets[3].privkey) if 'error' not in res: print res return False res = testlib.blockstack_name_transfer('foo.test', wallets[4].addr, True, wallets[3].privkey, safety_checks=False, tx_fee=300 * 5) if 'error' in res: print res return False testlib.next_block(**kw) testlib.expect_snv_fail_at("foo.test", testlib.get_current_block(**kw)) # should not have gone through res = testlib.blockstack_cli_whois('foo.test') if 'error' in res: print res return False if res['owner_address'] != wallets[3].addr: print res return False # can't revoke res = testlib.blockstack_name_revoke('foo.test', wallets[3].privkey) if 'error' not in res: print res return False res = testlib.blockstack_name_revoke('foo.test', wallets[3].privkey, safety_checks=False, tx_fee=300 * 5) if 'error' in res: print res return False testlib.next_block(**kw) testlib.expect_snv_fail_at("foo.test", testlib.get_current_block(**kw)) # should not have gone through res = testlib.blockstack_cli_whois('foo.test') if 'error' in res: print res return False # can renew res = testlib.blockstack_name_renew('foo.test', wallets[3].privkey) if 'error' in res: print res return False testlib.next_block(**kw) renew_block = testlib.get_current_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, 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) 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_revoke("foo.test", wallets[3].privkey) testlib.next_block(**kw) # can't do anything with the name for another 10 blocks resp = testlib.blockstack_name_update("foo.test", "11" * 20, wallets[3].privkey) if 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) # should fail resp = testlib.blockstack_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) # should fail resp = testlib.blockstack_name_renew("foo.test", wallets[3].privkey) if 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) # wait for it to expire... for i in xrange(0, 8): testlib.next_block(**kw) # verify that operations continue to fail resp = testlib.blockstack_name_update("foo.test", "11" * 20, wallets[3].privkey) if 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) # should fail resp = testlib.blockstack_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) # should fail resp = testlib.blockstack_name_renew("foo.test", wallets[3].privkey) if 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw)
def scenario(wallets, **kw): subsidy_wallet = wallets[5] print json.dumps(testlib.getrawtransaction( "28f78fbae22d2273341af231a2ac049d74958e1e6ce6ae622cd48d8f0fef591e", 1), indent=4) 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) # subsidized transactions... resp = testlib.blockstack_name_preorder("foo.test", None, wallets[3].addr, subsidy_key=subsidy_wallet.privkey) if debug or 'error' in resp: print json.dumps(resp, indent=4) # (already subsidized...) send_subsidized(None, resp, **kw) testlib.next_block(**kw) resp = testlib.blockstack_name_register("foo.test", None, wallets[3].addr, subsidy_key=subsidy_wallet.privkey) if debug or 'error' in resp: print json.dumps(resp, indent=4) # (already subsidized...) send_subsidized(None, resp, **kw) testlib.next_block(**kw) resp = testlib.blockstack_name_update( "foo.test", "11" * 20, None, user_public_key=wallets[3].pubkey_hex, subsidy_key=subsidy_wallet.privkey) if debug or 'error' in resp: print json.dumps(resp, indent=4) send_subsidized(wallets[3].privkey, resp, **kw) testlib.next_block(**kw) resp = testlib.blockstack_name_transfer( "foo.test", wallets[4].addr, True, None, user_public_key=wallets[3].pubkey_hex, subsidy_key=subsidy_wallet.privkey) if debug or 'error' in resp: print json.dumps(resp, indent=4) send_subsidized(wallets[3].privkey, resp, **kw) testlib.next_block(**kw) resp = testlib.blockstack_name_revoke( "foo.test", None, user_public_key=wallets[4].pubkey_hex, subsidy_key=subsidy_wallet.privkey) if debug or 'error' in resp: print json.dumps(resp, indent=4) send_subsidized(wallets[4].privkey, resp, **kw) # advance a bit for i in xrange(0, 5): 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 ) resp = testlib.blockstack_name_import( "foo.test", wallets[2].addr, "11" * 20, wallets[1].privkey ) if 'error' in resp: print json.dumps(resp, indent=4 ) testlib.next_block( **kw ) print "\nImport 25 names for %s" % wallets[3].addr # try to exceed quota (currently 25): order 25, and try to register a 26th for i in xrange(0, 25): resp = testlib.blockstack_name_import( "foo%s.test" % i, wallets[3].addr, "22" * 20, wallets[1].privkey ) if 'error' in resp: print json.dumps(resp, indent=4 ) testlib.next_block( **kw ) print "\nImport 27 names for %s" % wallets[4].addr # try to exceed quota (currently 25): order 26, and try to update one of them (and try to transfer one too). for i in xrange(0, 27): resp = testlib.blockstack_name_import( "bar%s.test" % i, wallets[4].addr, "33" * 20, wallets[1].privkey ) if 'error' in resp: print json.dumps(resp, indent=4 ) testlib.next_block( **kw ) testlib.blockstack_namespace_ready( "test", wallets[1].privkey ) testlib.next_block( **kw ) print wallets[3].privkey resp = testlib.blockstack_name_preorder( "foofail.test", wallets[3].privkey, wallets[1].addr ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # should fail resp = testlib.blockstack_name_register( "foofail.test",wallets[3].privkey, wallets[1].addr ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # should succeed resp = testlib.blockstack_name_update( "foo0.test", '55' * 20, wallets[3].privkey ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) resp = testlib.blockstack_name_preorder( "barfail.test", wallets[4].privkey, wallets[2].addr ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # should fail (exceeded quota) resp = testlib.blockstack_name_register( "barfail.test", wallets[4].privkey, wallets[2].addr ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # should fail (exceeded quota--have to revoke or give names away) resp = testlib.blockstack_name_update( "bar0.test", '44' * 20, wallets[4].privkey ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # should succeed (give a name away) resp = testlib.blockstack_name_transfer( "bar0.test", wallets[1].addr, True, wallets[4].privkey ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # should fail (exceeded quota--have to revoke or give names away) resp = testlib.blockstack_name_update( "bar0.test", '44' * 20, wallets[4].privkey ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # should succeed (revoke a name) resp = testlib.blockstack_name_revoke( "bar2.test", wallets[4].privkey ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # should succeed (now under quota) resp = testlib.blockstack_name_update( "bar1.test", '66' * 20, wallets[4].privkey ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) testlib.expect_snv_fail( "foofail.test" ) testlib.expect_snv_fail( "barfail.test" )
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) 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) resp = testlib.blockstack_name_update("foo.test", "00" * 20, wallets[3].privkey) if 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) testlib.blockstack_name_revoke("foo.test", wallets[3].privkey) testlib.next_block(**kw) # can't do anything with the name for another 10 blocks resp = testlib.blockstack_name_update("foo.test", "11" * 20, wallets[3].privkey, safety_checks=False) if 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) testlib.expect_snv_fail_at("foo.test", testlib.get_current_block(**kw)) # should fail resp = testlib.blockstack_name_transfer("foo.test", wallets[4].addr, True, wallets[3].privkey, safety_checks=False) if 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) testlib.expect_snv_fail_at("foo.test", testlib.get_current_block(**kw)) # should fail resp = testlib.blockstack_name_renew("foo.test", wallets[3].privkey, safety_checks=False) if 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) testlib.expect_snv_fail_at("foo.test", testlib.get_current_block(**kw)) # wait for it to expire... for i in xrange(0, 8 * NAMESPACE_LIFETIME_MULTIPLIER): testlib.next_block(**kw) # verify that operations continue to fail resp = testlib.blockstack_name_update("foo.test", "11" * 20, wallets[3].privkey, safety_checks=False) if 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) testlib.expect_snv_fail_at("foo.test", testlib.get_current_block(**kw)) # should fail resp = testlib.blockstack_name_transfer("foo.test", wallets[4].addr, True, wallets[3].privkey, safety_checks=False) if 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) testlib.expect_snv_fail_at("foo.test", testlib.get_current_block(**kw)) # should fail resp = testlib.blockstack_name_renew("foo.test", wallets[3].privkey, safety_checks=False) if 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) testlib.expect_snv_fail_at("foo.test", testlib.get_current_block(**kw)) # re-preorder... resp = testlib.blockstack_name_preorder("foo.test", wallets[4].privkey, wallets[0].addr, safety_checks=False) if 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) # re-register resp = testlib.blockstack_name_register("foo.test", wallets[4].privkey, wallets[0].addr, safety_checks=False) if 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) # re-update resp = testlib.blockstack_name_update("foo.test", "11" * 20, wallets[0].privkey, safety_checks=False) if 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw)
def scenario(wallets, **kw): global fail_blocks testlib.blockstack_namespace_preorder("test", wallets[1].addr, wallets[0].privkey) testlib.next_block(**kw) testlib.blockstack_namespace_reveal( "test", wallets[1].addr, 3, 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.blockstack_name_preorder("bar.test", wallets[2].privkey, wallets[3].addr) testlib.blockstack_name_preorder("baz.test", wallets[2].privkey, wallets[3].addr) testlib.next_block(**kw) testlib.blockstack_name_register("foo.test", wallets[2].privkey, wallets[3].addr) testlib.blockstack_name_register("bar.test", wallets[2].privkey, wallets[3].addr) testlib.blockstack_name_register("baz.test", wallets[2].privkey, wallets[3].addr) testlib.next_block(**kw) # dids for each of these names foo_did = 'did:stack:v0:{}-0'.format(wallets[3].addr) bar_did = 'did:stack:v0:{}-1'.format(wallets[3].addr) baz_did = 'did:stack:v0:{}-2'.format(wallets[3].addr) for did in [foo_did, bar_did, baz_did]: res = blockstack_client.proxy.get_DID_blockchain_record(did) if 'error' in res: print res return False if res['address'] != wallets[3].addr: print 'wrong address; expected {}'.format(wallets[3].addr) print json.dumps(res, indent=4, sort_keys=True) return False # revoke foo.test testlib.blockstack_name_revoke("foo.test", wallets[3].privkey) testlib.next_block(**kw) # wait for them all to expire... for i in xrange(0, 3): testlib.next_block(**kw) # re-preorder/reregister to different addresses testlib.blockstack_name_preorder("foo.test", wallets[4].privkey, wallets[0].addr) testlib.blockstack_name_preorder("bar.test", wallets[4].privkey, wallets[1].addr) testlib.blockstack_name_preorder("baz.test", wallets[4].privkey, wallets[2].addr) testlib.next_block(**kw) # re-register testlib.blockstack_name_register("foo.test", wallets[4].privkey, wallets[0].addr) testlib.blockstack_name_register("bar.test", wallets[4].privkey, wallets[1].addr) testlib.blockstack_name_register("baz.test", wallets[4].privkey, wallets[2].addr) testlib.next_block(**kw) # foo's DID should no longer resolve, since foo was revoked res = blockstack_client.proxy.get_DID_blockchain_record(foo_did) if 'error' not in res: print 'accidentally resolved {}'.format(foo_did) print res return False # non-revoked DIDs should resolve to the new addresses for did, addr in zip([bar_did, baz_did], [wallets[1].addr, wallets[2].addr]): res = blockstack_client.proxy.get_DID_blockchain_record(did) if 'error' in res: print res return False if res['address'] != addr: print 'wrong address post-reregister; expected {}'.format(addr) print json.dumps(res, indent=4, sort_keys=True) return False # dids for the new names foo2_did = 'did:stack:v0:{}-0'.format(wallets[0].addr) bar2_did = 'did:stack:v0:{}-0'.format(wallets[1].addr) baz2_did = 'did:stack:v0:{}-0'.format(wallets[2].addr) # new DIDs should all resolve to new addresses for did, addr in zip([foo2_did, bar2_did, baz2_did], [wallets[0].addr, wallets[1].addr, wallets[2].addr]): res = blockstack_client.proxy.get_DID_blockchain_record(did) if 'error' in res: print res return False if res['address'] != addr: print 'wrong address post-reregister: expected {}'.format(addr) print json.dumps(res, indent=4, sort_keys=True) return False # transfer all names back to wallets[3] testlib.blockstack_name_transfer("foo.test", wallets[3].addr, True, wallets[0].privkey) testlib.blockstack_name_transfer("bar.test", wallets[3].addr, True, wallets[1].privkey) testlib.blockstack_name_transfer("baz.test", wallets[3].addr, True, wallets[2].privkey) testlib.next_block(**kw) # all DIDs except for the original DID for foo.test should now resolve to wallets[3].addr for did in [bar_did, baz_did, foo2_did, bar2_did, baz2_did]: res = blockstack_client.proxy.get_DID_blockchain_record(did) if 'error' in res: print res return False if res['address'] != wallets[3].addr: print 'wrong address post-reregister: expected {}'.format( wallets[3].addr) print json.dumps(res, indent=4, sort_keys=True) return False # foo's original DID should not resolve res = blockstack_client.proxy.get_DID_blockchain_record(foo_did) if 'error' not in res: print 'accidentally resolved {}'.format(foo_did) print res return False
def scenario(wallets, **kw): global import_block global failed_blocks # 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, 2, 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) import_block = testlib.get_current_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) # wait for expiration (with multipler)... for i in xrange(0, 2 * NAMESPACE_LIFETIME_MULTIPLIER + 1): testlib.next_block(**kw) # verify that operations fail resp = testlib.blockstack_name_update("foo.test", "11" * 20, wallets[3].privkey, safety_checks=False) if 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) fail_blocks.append(testlib.get_current_block(**kw)) testlib.expect_snv_fail_at("foo.test", testlib.get_current_block(**kw)) # should fail resp = testlib.blockstack_name_transfer("foo.test", wallets[4].addr, True, wallets[3].privkey, safety_checks=False) if 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) fail_blocks.append(testlib.get_current_block(**kw)) testlib.expect_snv_fail_at("foo.test", testlib.get_current_block(**kw)) # should fail resp = testlib.blockstack_name_renew("foo.test", wallets[3].privkey, safety_checks=False) if 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) fail_blocks.append(testlib.get_current_block(**kw)) testlib.expect_snv_fail_at("foo.test", testlib.get_current_block(**kw)) # should fail resp = testlib.blockstack_name_revoke("foo.test", wallets[3].privkey, safety_checks=False) if 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) fail_blocks.append(testlib.get_current_block(**kw)) testlib.expect_snv_fail_at("foo.test", testlib.get_current_block(**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 ): # 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 ) # import 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]] for i in xrange(0, len(names)): name = names[i] register_wallet = name_register_wallets[i] resp = testlib.blockstack_name_import( name, register_wallet.addr, str(9 - i) * 40, wallets[1].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # namespace ready... 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 ) # 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 # 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 )
def scenario( wallets, **kw ): global fail_blocks 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 ) 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_revoke( "foo.test", wallets[3].privkey ) testlib.next_block( **kw ) # can't do anything with the name for another 10 blocks resp = testlib.blockstack_name_update( "foo.test", "11" * 20, wallets[3].privkey, safety_checks=False ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) testlib.expect_snv_fail_at( "foo.test", testlib.get_current_block(**kw)) # should fail resp = testlib.blockstack_name_transfer( "foo.test", wallets[4].addr, True, wallets[3].privkey, safety_checks=False ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) testlib.expect_snv_fail_at( "foo.test", testlib.get_current_block(**kw)) # should fail resp = testlib.blockstack_name_renew( "foo.test", wallets[3].privkey, safety_checks=False, tx_fee=10000*5 ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) testlib.expect_snv_fail_at( "foo.test", testlib.get_current_block(**kw)) # wait for it to expire... for i in xrange(0, 8 * NAMESPACE_LIFETIME_MULTIPLIER): testlib.next_block( **kw ) # verify that operations continue to fail (BUG in 0.13: THIS SUCCEEDS WHEN IT SHOULD FAIL) resp = testlib.blockstack_name_update( "foo.test", "11" * 20, wallets[3].privkey, safety_checks=False ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) fail_blocks.append( testlib.get_current_block( **kw ) ) testlib.expect_snv_fail_at( "foo.test", testlib.get_current_block(**kw)) # should fail resp = testlib.blockstack_name_transfer( "foo.test", wallets[4].addr, True, wallets[3].privkey, safety_checks=False ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) fail_blocks.append( testlib.get_current_block( **kw ) ) testlib.expect_snv_fail_at( "foo.test", testlib.get_current_block(**kw)) # should fail resp = testlib.blockstack_name_renew( "foo.test", wallets[3].privkey, safety_checks=False, tx_fee=10000*5 ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) fail_blocks.append( testlib.get_current_block( **kw ) ) testlib.expect_snv_fail_at( "foo.test", testlib.get_current_block(**kw)) # re-preorder... resp = testlib.blockstack_name_preorder( "foo.test", wallets[3].privkey, wallets[4].addr ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # re-register (different user) resp = testlib.blockstack_name_register( "foo.test", wallets[3].privkey, wallets[4].addr ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # warn the serialization checker that this changes behavior from 0.13 print "BLOCKSTACK_SERIALIZATION_CHANGE_BEHAVIOR" sys.stdout.flush()
def scenario(wallets, **kw): # 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, 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) # import 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]] # derive importer keys and do imports # NOTE: breaks consensus trace from 0.14.0 private_keychain = keychain.PrivateKeychain.from_private_key( wallets[1].privkey) private_keys = [ wallets[1].privkey ] # NOTE: always start with the reveal key, then use children for i in xrange(0, len(names) - 1): import_key = private_keychain.child(i).private_key() print "fund {} (child {})".format(import_key, i) res = testlib.send_funds( wallets[1].privkey, 100000000, virtualchain.BitcoinPrivateKey(import_key).public_key().address()) if 'error' in res: print json.dumps(res, indent=4, sort_keys=True) return False testlib.next_block(**kw) private_keys.append(import_key) for i in xrange(0, len(names)): name = names[i] register_wallet = name_register_wallets[i] import_key = private_keys[i] resp = testlib.blockstack_name_import(name, register_wallet.addr, str(9 - i) * 40, import_key) if 'error' in resp: print json.dumps(resp, indent=4) return False testlib.next_block(**kw) # namespace ready... 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) # 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 + 2) * 40, register_wallet.privkey) if 'error' in resp: print json.dumps(resp, indent=4) return False testlib.next_block(**kw) # update 3 names in the same block, again 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 'error' in resp: print json.dumps(resp, indent=4) return False 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 'error' in resp: print json.dumps(resp, indent=4) return False testlib.next_block(**kw) # exchange after transfer... tmp = name_register_wallets name_register_wallets = name_transfer_wallets name_transfer_wallets = tmp # 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 'error' in resp: print json.dumps(resp, indent=4) return False # iterate the blocks a few times for i in xrange(0, 5): testlib.next_block(**kw)
def scenario(wallets, **kw): testlib.disable_snv_checks() testlib.disable_did_checks() # make failed transactions resp = testlib.blockstack_namespace_preorder( "test2", wallets[1].addr, wallets[0].privkey, consensus_hash='00000000000000000000000000000000', safety_checks=False, expect_fail=True) testlib.next_block(**kw) test_failed_tx(resp['transaction_hash'], 'NAMESPACE_PREORDER') resp = testlib.blockstack_namespace_reveal( "test2", wallets[1].addr, 52595, 250, 4, [6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 10, 10, wallets[0].privkey, version_bits=blockstack.NAMESPACE_VERSION_PAY_WITH_STACKS, safety_checks=False, expect_fail=True) testlib.next_block(**kw) test_failed_tx(resp['transaction_hash'], 'NAMESPACE_REVEAL') resp = testlib.blockstack_namespace_ready("test2", wallets[1].privkey, safety_checks=False, expect_fail=True) testlib.next_block(**kw) test_failed_tx(resp['transaction_hash'], 'NAMESPACE_READY') # okay, go and actually create this namespace so we can preorder names 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, version_bits=blockstack.NAMESPACE_VERSION_PAY_WITH_STACKS) testlib.next_block(**kw) testlib.blockstack_namespace_ready("test", wallets[1].privkey) testlib.next_block(**kw) # start failing again resp = testlib.blockstack_name_preorder( "foo.test", wallets[2].privkey, wallets[3].addr, consensus_hash='00000000000000000000000000000000', safety_checks=False, expect_fail=True) testlib.next_block(**kw) test_failed_tx(resp['transaction_hash'], 'NAME_PREORDER') resp = testlib.blockstack_name_register("foo.test", wallets[2].privkey, wallets[3].addr, safety_checks=False, expect_fail=True) testlib.next_block(**kw) test_failed_tx(resp['transaction_hash'], 'NAME_REGISTRATION') resp = testlib.blockstack_name_update("foo.test", "11" * 20, wallets[3].privkey, safety_checks=False, expect_fail=True) testlib.next_block(**kw) test_failed_tx(resp['transaction_hash'], 'NAME_UPDATE') resp = testlib.blockstack_name_transfer("foo.test", wallets[0].addr, True, wallets[3].privkey, safety_checks=False, expect_fail=True) testlib.next_block(**kw) test_failed_tx(resp['transaction_hash'], 'NAME_TRANSFER') resp = testlib.blockstack_name_renew("foo.test", wallets[3].privkey, safety_checks=False, expect_fail=True) testlib.next_block(**kw) test_failed_tx(resp['transaction_hash'], 'NAME_REGISTRATION') resp = testlib.blockstack_name_revoke("foo.test", wallets[3].privkey, safety_checks=False, expect_fail=True) testlib.next_block(**kw) test_failed_tx(resp['transaction_hash'], 'NAME_REVOKE') resp = testlib.blockstack_send_tokens( wallets[0].addr, 'STACKS', 123, wallets[3].privkey, consensus_hash='11111111111111111111111111111111', safety_checks=False, expect_fail=True) testlib.next_block(**kw) test_failed_tx(resp['transaction_hash'], 'TOKEN_TRANSFER') resp = testlib.blockstack_announce("hello world", wallets[0].privkey, safety_checks=False, expect_fail=True) testlib.next_block(**kw) test_failed_tx(resp['transaction_hash'], 'ANNOUNCE')