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 ) testlib.next_block( **kw ) # renew again resp = testlib.blockstack_name_renew( "foo.test", wallets[3].privkey ) 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) testlib.blockstack_name_update("foo.test", "11" * 20, wallets[3].privkey) testlib.next_block(**kw) testlib.blockstack_name_renew("foo.test", wallets[3].privkey) testlib.next_block(**kw)
def scenario( wallets, **kw ): testlib.blockstack_namespace_preorder( "test", wallets[1].addr, wallets[0].privkey ) testlib.next_block( **kw ) # 689 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 ) # 690 testlib.blockstack_namespace_ready( "test", wallets[1].privkey ) testlib.next_block( **kw ) # 691 testlib.blockstack_name_preorder( "foo.test", wallets[2].privkey, wallets[3].addr ) testlib.next_block( **kw ) # 692 testlib.blockstack_name_register( "foo.test", wallets[2].privkey, wallets[3].addr ) testlib.next_block( **kw ) # 693 whois = testlib.blockstack_cli_whois("foo.test") if 'error' in whois: print whois return False # should fail (safety checks stop it) resp = testlib.blockstack_name_renew( "foo.test", wallets[3].privkey, zonefile_hash='22' * 20, recipient_addr=wallets[0].addr ) if 'error' not in resp: print resp return False # should succeed in being sent resp = testlib.blockstack_name_renew( "foo.test", wallets[3].privkey, zonefile_hash='22' * 20, recipient_addr=wallets[0].addr, safety_checks=False, tx_fee=10000 * 5 ) if 'error' in resp: print resp return False # should fail to get accepted testlib.expect_snv_fail_at( "foo.test", testlib.get_current_block(**kw)) testlib.next_block( **kw ) # 694 # should NOT have been renewed whois2 = testlib.blockstack_cli_whois('foo.test') if 'error' in whois: print whois return False if whois2['block_renewed_at'] != whois['block_renewed_at']: print 'accidentally renewed' print whois print whois2 return False # activate epoch 3 testlib.next_block( **kw ) # 695 # should succeed resp = testlib.blockstack_name_renew( "foo.test", wallets[3].privkey, zonefile_hash='22' * 20, recipient_addr=wallets[0].addr ) if 'error' in resp: print resp return False testlib.next_block( **kw ) # 696
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, 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.blockstack_name_register("foo.test", wallets[2].privkey, wallets[3].addr) # will be rejected testlib.blockstack_name_renew("foo.test", wallets[3].privkey, safety_checks=False, tx_fee=30000) testlib.next_block(**kw) renew_block = testlib.get_current_block(**kw) testlib.expect_snv_fail_at('foo.test', renew_block)
def scenario( wallets, **kw ): global pk, pk2 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.lib.config.NAMESPACE_VERSION_PAY_TO_CREATOR) testlib.next_block( **kw ) testlib.blockstack_namespace_ready( "test", wallets[1].privkey ) testlib.next_block( **kw ) # pay for a name in a v1 namespace with Stacks addr = virtualchain.address_reencode(virtualchain.get_privkey_address(pk)) addr2 = virtualchain.address_reencode(virtualchain.get_privkey_address(pk2)) # calculate the cost of doing so namespace = testlib.get_state_engine().get_namespace('test') stacks_price = blockstack.lib.scripts.price_name_stacks('foo', namespace, testlib.get_current_block(**kw)) btc_price = blockstack.lib.scripts.price_name('foo', namespace, testlib.get_current_block(**kw)) print '' print 'price of {} in Stacks is {}'.format('foo.test', stacks_price) print 'price of {} in BTC is {}'.format('foo.test', btc_price) print '' testlib.blockstack_send_tokens(addr, "STACKS", stacks_price + 2, wallets[0].privkey) testlib.blockstack_send_tokens(addr2, "STACKS", stacks_price + 1, wallets[0].privkey) testlib.send_funds(wallets[0].privkey, 3*btc_price, addr) testlib.send_funds(wallets[0].privkey, 3*btc_price, addr2) testlib.next_block(**kw) # preorder/register using Stacks testlib.blockstack_name_preorder( "foo.test", pk, addr2) testlib.blockstack_name_preorder( "bar.test", pk2, addr) testlib.next_block( **kw ) testlib.blockstack_name_register( "foo.test", pk, addr2 ) testlib.blockstack_name_register( "bar.test", pk2, addr ) testlib.next_block( **kw ) testlib.next_block( **kw ) testlib.next_block( **kw ) testlib.next_block( **kw ) # end of pay to namespace creator # renew using more stacks than we have (should fail) # bar.test should succeed testlib.blockstack_name_renew('foo.test', pk2, price={'units': 'STACKS', 'amount': stacks_price + 2}, expect_fail=True, safety_checks=False) testlib.blockstack_name_renew('bar.test', pk, price={'units': 'STACKS', 'amount': stacks_price + 1}) 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) resp = testlib.blockstack_name_preorder("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("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) # 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) testlib.next_block(**kw) # renew again resp = testlib.blockstack_name_renew("foo.test", wallets[3].privkey) if 'error' in resp: print json.dumps(resp, indent=4) sys.exit(1) testlib.next_block(**kw)
def scenario( wallets, **kw ): global 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() # 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 ) 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 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 ): testlib.blockstack_namespace_preorder( "test", wallets[1].addr, wallets[0].privkey ) testlib.next_block( **kw ) testlib.blockstack_namespace_reveal( "test", wallets[1].addr, 11, 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 ) # next epoch takes effect... testlib.next_block( **kw ) # wait for a bit more (namespace lifetime should have 2x'ed) 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 ) 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.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 ) # has to be the same key that registered... resp = testlib.blockstack_name_renew( "foo.test", wallets[4].privkey, safety_checks=False, tx_fee=10000*5 ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) testlib.next_block( **kw )
def do_interleaving( name, namerecs, order ): # order should be a string of "u", "t", and "r" order = list(order) for i in xrange(0, len(order)): op = order[i] if op == 'r': # renew print "\nrenew '%s' with %s\n" % (name, pybitcoin.make_pay_to_address_script( namerecs[name][0].addr )) resp = testlib.blockstack_name_renew( name, namerecs[name][0].privkey, register_addr=namerecs[name][0].addr ) if 'error' in resp: print json.dumps( resp, indent=4 ) elif op == 'u': # update resp = testlib.blockstack_name_update( name, ("%s%s" % (i, i)) * 20, namerecs[name][0].privkey ) if 'error' in resp: print json.dumps( resp, indent=4 ) elif op == 't': # transfer and exchange wallets print "\ntransfer '%s' from %s to %s" % (name, pybitcoin.make_pay_to_address_script( namerecs[name][0].addr ), pybitcoin.make_pay_to_address_script( namerecs[name][1].addr )) resp = testlib.blockstack_name_transfer( name, namerecs[name][1].addr, True, namerecs[name][0].privkey ) if 'error' in resp: print json.dumps( resp, indent=4 ) tmp = namerecs[name][0] namerecs[name][0] = namerecs[name][1] namerecs[name][1] = tmp
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, 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 * NAMESPACE_LIFETIME_MULTIPLIER - 4): 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) testlib.next_block(**kw) # transfer 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) testlib.next_block(**kw) # update resp = testlib.blockstack_name_update("foo.test", "22" * 20, wallets[4].privkey) if 'error' in resp: 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_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_renew("foo.test", 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[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, 2, 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=2) 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.blockstack_namespace_ready( "test", wallets[1].privkey ) testlib.next_block( **kw ) namespace_rec = testlib.blockstack_cli_get_namespace_blockchain_record("test") if 'error' in namespace_rec: print namespace_rec return False namespace_balance = testlib.get_balance(namespace_rec['address']) testlib.blockstack_name_renew("foo.test", wallets[3].privkey) testlib.next_block(**kw) new_namespace_balance = testlib.get_balance(namespace_rec['address']) name_rec = testlib.get_name_blockchain_record('foo.test') name_cost = name_rec['op_fee'] if new_namespace_balance - namespace_balance != name_cost: print 'address {} did not get credited'.format(namespace_rec['address']) print '{} != {} + {}'.format(new_namespace_balance, namespace_balance, name_cost) return False testlib.blockstack_name_renew("foo.test", wallets[3].privkey, recipient_addr=wallets[4].addr, zonefile_hash='22' * 20) testlib.next_block(**kw) new_namespace_balance = testlib.get_balance(namespace_rec['address']) name_rec = testlib.get_name_blockchain_record('foo.test') name_cost = name_rec['op_fee'] if new_namespace_balance - namespace_balance != 2*name_cost: print 'address {} did not get credited'.format(namespace_rec['address']) print '{} != {} + {}'.format(new_namespace_balance, namespace_balance, 2*name_cost) return False
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 ): testlib.blockstack_namespace_preorder( "test", wallets[1].addr, wallets[0].privkey ) testlib.next_block( **kw ) testlib.blockstack_namespace_reveal( "test", wallets[1].addr, 4, 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 ) # preorder, register, update, expire (twice; should fail the second time) for i in xrange(2, 4): resp = testlib.blockstack_name_preorder( "foo.test", wallets[i].privkey, wallets[(i+1)%11].addr ) if 'error' in resp: print json.dumps( resp, indent=4 ) 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 ) if i == 3: testlib.expect_snv_fail_at( "foo.test", testlib.get_current_block(**kw)) testlib.next_block( **kw ) resp = testlib.blockstack_name_update( "foo.test", ("%02x" % i) * 20, wallets[(i+1)%11].privkey ) 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)) testlib.next_block( **kw ) resp = testlib.blockstack_name_transfer( "foo.test", wallets[i].addr, True, wallets[(i+1)%11].privkey ) 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)) testlib.next_block( **kw ) resp = testlib.blockstack_name_renew( "foo.test", wallets[i].privkey ) 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)) if i == 3: break testlib.next_block( **kw )
def scenario( wallets, **kw ): global pk, pk2 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 ) # pay for a name in a v1 namespace with Stacks addr = virtualchain.address_reencode(virtualchain.get_privkey_address(pk)) addr2 = virtualchain.address_reencode(virtualchain.get_privkey_address(pk2)) # calculate the cost of doing so namespace = testlib.get_state_engine().get_namespace('test') stacks_price = blockstack.lib.scripts.price_name_stacks('foo', namespace, testlib.get_current_block(**kw)) btc_price = blockstack.lib.scripts.price_name('foo', namespace, testlib.get_current_block(**kw)) print '' print 'price of {} in Stacks is {}'.format('foo.test', stacks_price) print 'price of {} in BTC is {}'.format('foo.test', btc_price) print '' testlib.blockstack_send_tokens(addr, "STACKS", stacks_price + 1, wallets[0].privkey) testlib.blockstack_send_tokens(addr2, "STACKS", stacks_price + 1, wallets[0].privkey) testlib.send_funds(wallets[0].privkey, 2*btc_price, addr) testlib.send_funds(wallets[0].privkey, 2*btc_price, addr2) testlib.next_block(**kw) # preorder/register using Stacks testlib.blockstack_name_preorder( "foo.test", pk, addr2, price={'units': 'STACKS', 'amount': stacks_price + 1}) testlib.next_block( **kw ) testlib.blockstack_name_register( "foo.test", pk, addr2 ) testlib.next_block( **kw ) # renew using Stacks testlib.blockstack_name_renew('foo.test', pk2, price={'units': 'STACKS', 'amount': stacks_price + 1}) 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 ) testlib.next_block( **kw ) resp = testlib.blockstack_name_renew( "foo.test", wallets[3].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) 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 ) testlib.next_block( **kw ) 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 ) 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) 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) if 'error' in resp: print json.dumps(resp) testlib.next_block(**kw) resp = testlib.blockstack_name_renew("foo.test", wallets[3].privkey) if 'error' in resp: print json.dumps(resp) 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) testlib.next_block(**kw) # try both addresses (should both fail) resp = testlib.blockstack_name_revoke("foo.test", wallets[4].privkey) if 'error' in resp: print json.dumps(resp) testlib.next_block(**kw) resp = testlib.blockstack_name_revoke("foo.test", wallets[3].privkey) if 'error' in resp: print json.dumps(resp)
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 ): # 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 * NAMESPACE_LIFETIME_MULTIPLIER - 4): 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 ) testlib.next_block( **kw ) # transfer 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 ) testlib.next_block( **kw ) # update resp = testlib.blockstack_name_update( "foo.test", "22" * 20, wallets[4].privkey ) if '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 ) testlib.blockstack_name_update( "foo.test", "11" * 20, wallets[3].privkey ) testlib.next_block( **kw ) testlib.blockstack_name_renew( "foo.test", wallets[3].privkey ) 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, 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 ) # 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 ) if 'error' in resp: print json.dumps( resp, indent=4 ) 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 ) resp = testlib.blockstack_name_update( "foo.test", ("%02x" % i) * 20, wallets[(i+1)%11].privkey ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) resp = testlib.blockstack_name_transfer( "foo.test", wallets[i].addr, True, wallets[(i+1)%11].privkey ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) resp = testlib.blockstack_name_renew( "foo.test", wallets[i].privkey ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) testlib.next_block( **kw ) testlib.next_block( **kw ) if i == 10: break testlib.next_block( **kw )
def do_interleaving(name, namerecs, order): # order should be a string of "u", "t", and "r" order = list(order) for i in xrange(0, len(order)): op = order[i] if op == 'r': # renew print "\nrenew '%s' with %s\n" % ( name, pybitcoin.make_pay_to_address_script(namerecs[name][0].addr)) resp = testlib.blockstack_name_renew( name, namerecs[name][0].privkey, register_addr=namerecs[name][0].addr, safety_checks=False) if 'error' in resp: print json.dumps(resp, indent=4) elif op == 'u': # update resp = testlib.blockstack_name_update(name, ("%s%s" % (i, i)) * 20, namerecs[name][0].privkey, safety_checks=False) if 'error' in resp: print json.dumps(resp, indent=4) elif op == 't': # transfer and exchange wallets print "\ntransfer '%s' from %s to %s" % ( name, pybitcoin.make_pay_to_address_script(namerecs[name][0].addr), pybitcoin.make_pay_to_address_script(namerecs[name][1].addr)) resp = testlib.blockstack_name_transfer(name, namerecs[name][1].addr, True, namerecs[name][0].privkey, safety_checks=False) if 'error' in resp: print json.dumps(resp, indent=4) tmp = namerecs[name][0] namerecs[name][0] = namerecs[name][1] namerecs[name][1] = tmp
def scenario(wallets, **kw): global first_name_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, 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) first_name_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 a bit... for i in xrange(0, 10): testlib.next_block(**kw) # renew; expect different fee resp = testlib.blockstack_name_renew("foo.test", wallets[3].privkey) if 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) testlib.next_block(**kw)
def scenario( wallets, **kw ): global first_name_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, 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 ) first_name_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 a bit... for i in xrange(0, 10): testlib.next_block( **kw ) # renew; expect different fee resp = testlib.blockstack_name_renew( "foo.test", wallets[3].privkey ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) testlib.next_block( **kw )
def scenario( wallets, **kw ): global first_name_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 ) # end of 689 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 'error' in resp: print json.dumps( resp, indent=4 ) return False testlib.next_block( **kw ) # 690 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 ) # 691 first_name_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 ) # end of 692 (epoch 3 should be active) whois = testlib.blockstack_cli_whois('foo.test') if 'error' in whois: print 'failed to whois foo.test' print json.dumps(whois, indent=4) return False # epoch 3 should be active... if whois['expire_block'] != testlib.get_current_block(**kw) + 4: print 'wrong expire block (should be 4 away)' print whois return False resp = testlib.blockstack_name_renew( 'foo.test', wallets[3].privkey, zonefile_hash='22'*20, recipient_addr=wallets[2].addr) if 'error' in resp: print resp return False testlib.next_block(**kw) # end of 693 (new epoch) whois = testlib.blockstack_cli_whois('foo.test') if 'error' in whois: print whois return False if whois['expire_block'] != testlib.get_current_block(**kw) + 4: print 'expire block: {}'.format(whois['expire_block']) print 'current block + 4: {}'.format(testlib.get_current_block(**kw) + 4) return False if whois['renewal_deadline'] != testlib.get_current_block(**kw) + 9: print 'renewal deadline: {}'.format(whois['renewal_deadline']) print 'current block + 9: {}'.format(testlib.get_current_block(**kw) + 9) return False # expire it again (block 694-698) for i in xrange(0, 4): testlib.next_block(**kw) lookup = testlib.blockstack_cli_lookup('foo.test') if 'error' not in lookup: print lookup return False if 'name is expired' not in lookup['error'].lower(): print lookup return False whois = testlib.blockstack_cli_whois('foo.test') if 'error' in whois: print whois return False if whois['expire_block'] != testlib.get_current_block(**kw): print 'expire block: {}'.format(whois['expire_block']) print 'current block: {}'.format(testlib.get_current_block(**kw)) return False if whois['renewal_deadline'] != testlib.get_current_block(**kw) + 5: print 'renewal deadline: {}'.format(whois['renewal_deadline']) print 'current block + 4: {}'.format(testlib.get_current_block(**kw) + 5) return False # renew resp = testlib.blockstack_name_renew( 'foo.test', wallets[2].privkey, zonefile_hash='33'*20, recipient_addr=wallets[4].addr) if 'error' in resp: print resp return False testlib.next_block(**kw) # 699 whois = testlib.blockstack_cli_whois('foo.test') if 'error' in whois: print whois return False if whois['expire_block'] != testlib.get_current_block(**kw) + 4: print 'expire block: {}'.format(whois['expire_block']) print 'current block + 4: {}'.format(testlib.get_current_block(**kw) + 4) return False if whois['renewal_deadline'] != testlib.get_current_block(**kw) + 9: print 'renewal deadline: {}'.format(whois['renewal_deadline']) print 'current block + 9: {}'.format(testlib.get_current_block(**kw) + 9) return False if whois['owner_address'] != wallets[4].addr: print 'wrong owner; expected {}'.format(wallets[4].addr) print whois return False
def scenario(wallets, **kw): print '\nactivating segwit\n' virtualchain.set_features("segwit", True) print '\nsegwit state: {}\n'.format(virtualchain.get_features('segwit')) testlib.blockstack_namespace_preorder("test", wallets[1].addr, wallets[5].privkey) testlib.blockstack_namespace_preorder("mult", wallets[2].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[5].privkey) testlib.blockstack_namespace_reveal( "mult", wallets[2].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=2) testlib.next_block(**kw) private_keychain = keychain.PrivateKeychain.from_private_key( wallets[2].privkey) private_keys = [ wallets[2].privkey ] # NOTE: always start with the reveal key, then use children for i in xrange(0, 4): 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) # should succeed resp = testlib.blockstack_name_import("foo.mult", wallets[2].addr, '00' * 20, private_keys[0]) if 'error' in resp: print json.dumps(resp, indent=4, sort_keys=True) return False testlib.next_block(**kw) # should succeed resp = testlib.blockstack_name_import("bar.mult", wallets[3].addr, "11" * 20, private_keys[1]) if 'error' in resp: print json.dumps(resp, indent=4, sort_keys=True) return False # should succeed resp = testlib.blockstack_name_import("baz.mult", wallets[4].addr, "22" * 20, private_keys[2]) if 'error' in resp: print json.dumps(resp, indent=4, sort_keys=True) return False # should succeed resp = testlib.blockstack_name_import("goo.mult", wallets[5].addr, "33" * 20, private_keys[3]) if 'error' in resp: print json.dumps(resp, indent=4, sort_keys=True) return False testlib.next_block(**kw) testlib.blockstack_namespace_ready("test", wallets[1].privkey) testlib.blockstack_namespace_ready("mult", wallets[2].privkey) testlib.next_block(**kw) namespace_balance = testlib.get_balance(wallets[0].addr) # get prices hello_cost = testlib.blockstack_get_name_cost('hello.mult') world_cost = testlib.blockstack_get_name_cost('world.mult') foo_cost = testlib.blockstack_get_name_cost('foo.mult') # register/renew res = testlib.blockstack_name_preorder("hello.mult", wallets[1].privkey, wallets[2].addr) if 'error' in res: print res return False res = testlib.blockstack_name_preorder('world.mult', wallets[6].privkey, wallets[7].addr, wallet=wallets[7]) if 'error' in res: print res return False res = testlib.blockstack_name_renew('foo.mult', wallets[2].privkey) if 'error' in res: print res return False testlib.next_block(**kw) new_namespace_balance = testlib.get_balance(wallets[0].addr) if new_namespace_balance != namespace_balance + hello_cost + world_cost + foo_cost: print 'wrong balance' print new_namespace_balance print namespace_balance print hello_cost print foo_cost return False res = testlib.blockstack_name_register("hello.mult", wallets[1].privkey, wallets[2].addr) if 'error' in res: print res return False res = testlib.blockstack_name_register('world.mult', wallets[6].privkey, wallets[7].addr, wallet=wallets[7], zonefile_hash='44' * 20) if 'error' in res: print res return False testlib.next_block(**kw)
def scenario( wallets, **kw ): global first_name_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 ) # end of 689 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 'error' in resp: print json.dumps( resp, indent=4 ) return False testlib.next_block( **kw ) # 690 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 ) # 691 first_name_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 ) # end of 692 whois = testlib.blockstack_cli_whois('foo.test') if 'error' in whois: print 'failed to whois foo.test' print json.dumps(whois, indent=4) return False # this should be the second-to-last block if whois['expire_block'] != testlib.get_current_block(**kw) + 2: print 'wrong expire block (expect 2 more)' print whois return False testlib.next_block(**kw) # end of 693; begin epoch 2 # begin epoch 2 testlib.next_block(**kw) # 694 whois = testlib.blockstack_cli_whois('foo.test') if 'error' in whois: print 'failed to whois foo.test' print json.dumps(whois, indent=4) return False # this should be the last block if whois['expire_block'] != testlib.get_current_block(**kw) + 2: print 'wrong expire block (expect 2 more)' print whois return False if whois['renewal_deadline'] != testlib.get_current_block(**kw) + 2: print 'wrong renewal block (expect 2 more)' print whois return False print whois testlib.next_block(**kw) # 695 (epoch 3 begins) testlib.next_block(**kw) # end of 696 whois = testlib.blockstack_cli_whois('foo.test') if 'error' in whois: print whois return False # this should be the expire block if whois['expire_block'] != testlib.get_current_block(**kw): print 'wrong expire block (now at {})'.format(testlib.get_current_block(**kw)) print whois return False # should now be a grace period if whois['renewal_deadline'] != testlib.get_current_block(**kw) + 5: print 'wrong renewal block (now at {})'.format(testlib.get_current_block(**kw)) print whois return False last_transaction_height = whois['last_transaction_height'] # should go through resp = testlib.blockstack_name_preorder('foo.test', wallets[3].privkey, wallets[0].addr, safety_checks=False, tx_fee=500*5) if 'error' in resp: print resp return False # should go through resp = testlib.blockstack_name_preorder('foo.test', wallets[1].privkey, wallets[2].addr, safety_checks=False, tx_fee=500*5) if 'error' in resp: print resp return False # begin epoch 3 (grace period) testlib.next_block(**kw) # end of 697 resp = testlib.blockstack_name_register("foo.test", wallets[1].privkey, wallets[2].addr, zonefile_hash='44' * 20) if 'error' not in resp: print resp return False # should go through, but be rejected resp = testlib.blockstack_name_register("foo.test", wallets[1].privkey, wallets[2].addr, zonefile_hash='44' * 20, safety_checks=False, tx_fee=500*5) if 'error' in resp: print resp return False testlib.next_block(**kw) # 698 testlib.expect_snv_fail_at( "foo.test", testlib.get_current_block(**kw)) # should NOT have gone through whois = testlib.blockstack_cli_whois('foo.test') if 'error' in whois: print whois return False if whois['last_transaction_height'] != last_transaction_height: print 'accidentally registered' return False resp = testlib.blockstack_name_register("foo.test", wallets[1].privkey, wallets[2].addr, zonefile_hash='44' * 20) if 'error' not in resp: print resp return False # should go through, but be rejected resp = testlib.blockstack_name_register("foo.test", wallets[1].privkey, wallets[2].addr, zonefile_hash='44' * 20, safety_checks=False, tx_fee=500*5) if 'error' in resp: print resp return False testlib.next_block(**kw) # 699 testlib.expect_snv_fail_at( "foo.test", testlib.get_current_block(**kw)) whois = testlib.blockstack_cli_whois('foo.test') if 'error' in whois: print whois return False if whois['last_transaction_height'] != last_transaction_height: print 'accidentally registered' return False resp = testlib.blockstack_name_register("foo.test", wallets[1].privkey, wallets[2].addr, zonefile_hash='44' * 20) if 'error' not in resp: print resp return False # should go through, but be rejected resp = testlib.blockstack_name_register("foo.test", wallets[1].privkey, wallets[2].addr, zonefile_hash='44' * 20, safety_checks=False, tx_fee=500*5) if 'error' in resp: print resp return False testlib.next_block(**kw) # 700 testlib.expect_snv_fail_at( "foo.test", testlib.get_current_block(**kw)) whois = testlib.blockstack_cli_whois('foo.test') if 'error' in whois: print whois return False if whois['last_transaction_height'] != last_transaction_height: print 'accidentally registered' return False resp = testlib.blockstack_name_register("foo.test", wallets[1].privkey, wallets[2].addr, zonefile_hash='44' * 20) if 'error' not in resp: print resp return False # should go through, but be rejected resp = testlib.blockstack_name_register("foo.test", wallets[1].privkey, wallets[2].addr, zonefile_hash='44' * 20, safety_checks=False, tx_fee=500*5) if 'error' in resp: print resp return False # renew/xfer/update resp = testlib.blockstack_name_renew('foo.test', wallets[3].privkey, zonefile_hash='33'*20, recipient_addr=wallets[0].addr) if 'error' in resp: print resp return False testlib.next_block(**kw) # end of 701 (end of grace period) testlib.expect_snv_fail_at( "foo.test", testlib.get_current_block(**kw)) whois = testlib.blockstack_cli_whois('foo.test') if 'error' in whois: print whois return False resp = testlib.blockstack_name_register("foo.test", wallets[1].privkey, wallets[2].addr, zonefile_hash='44' * 20) if 'error' not in resp: print resp return False # should go through, and be rejected (even though preordered) resp = testlib.blockstack_name_register("foo.test", wallets[1].privkey, wallets[2].addr, zonefile_hash='44' * 20, safety_checks=False, tx_fee=500*5) if 'error' in resp: print resp return False testlib.next_block(**kw) # 702 (name can be registered again) testlib.expect_snv_fail_at( "foo.test", testlib.get_current_block(**kw)) whois = testlib.blockstack_cli_whois('foo.test') if 'error' in whois: print whois return False if whois['owner_address'] != wallets[0].addr: print 'accidentally registered foo.test to {}'.format(wallets[0].addr) return False if whois['zonefile_hash'] != '33' * 20: print 'wrong zonefile hash' print whois return False
def scenario(wallets, **kw): # should fail testlib.blockstack_namespace_preorder("test_fail", wallets[1].addr, wallets[0].privkey, safety_checks=False, price={ 'units': 'STACKS', 'amount': 0 }) testlib.next_block(**kw) testlib.blockstack_namespace_reveal( "test_fail", 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.expect_snv_fail_at('test_fail', testlib.get_current_block(**kw)) # should succeed testlib.blockstack_namespace_preorder("test", wallets[1].addr, wallets[3].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[3].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) # should fail (empty balance) testlib.blockstack_name_preorder('foo_fail.test', wallets[0].privkey, wallets[3].addr, safety_checks=False, expect_fail=True) testlib.next_block(**kw) testlib.blockstack_name_register('foo_fail.test', wallets[0].privkey, wallets[3].addr, safety_checks=False) testlib.next_block(**kw) testlib.expect_snv_fail_at('foo_fail.test', testlib.get_current_block(**kw)) # should succeed 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) # deplete balance balance = json.loads(testlib.nodejs_cli('balance', wallets[2].addr)) testlib.blockstack_send_tokens(wallets[0].addr, 'STACKS', int(balance['STACKS']), wallets[2].privkey) balance = json.loads(testlib.nodejs_cli('balance', wallets[3].addr)) testlib.blockstack_send_tokens(wallets[0].addr, 'STACKS', int(balance['STACKS']), wallets[3].privkey) testlib.next_block(**kw) # should fail--not enough funds testlib.blockstack_name_renew("foo.test", wallets[3].privkey, expect_fail=True) testlib.next_block(**kw) testlib.expect_snv_fail_at('foo.test', testlib.get_current_block(**kw)) # should fail--not enough funds testlib.blockstack_name_preorder("baz.test", wallets[2].privkey, wallets[3].addr, expect_fail=True, safety_checks=False) testlib.next_block(**kw) testlib.expect_snv_fail_at('baz.test', testlib.get_current_block(**kw)) testlib.blockstack_name_register("baz.test", wallets[2].privkey, wallets[3].addr, safety_checks=False) testlib.next_block(**kw) testlib.expect_snv_fail_at('baz.test', testlib.get_current_block(**kw))
def scenario( wallets, **kw ): 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 ) # should get rejected 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 ) # should get rejected (NOTE: the underlying mock utxo provider doesn't handle double-spends!) 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 ) # should get accepted 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 ) # should get rejected (but only because the namespace isn't revealed until the block goes through) 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_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 ) # should get rejected resp = testlib.blockstack_name_register( "foo.test", wallets[2].privkey, wallets[3].addr ) if 'error' in resp: print json.dumps( resp, indent=4 ) # should get rejected (NOTE: the underlying mock utxo provider doesn't handle double-spends!) resp = testlib.blockstack_name_register( "foo.test", wallets[2].privkey, wallets[3].addr ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # should succeed resp = testlib.blockstack_name_register( "foo.test", wallets[2].privkey, wallets[3].addr ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # (this should succeed) resp = testlib.blockstack_name_update( "foo.test", "11" * 20, wallets[3].privkey ) if 'error' in resp: print json.dumps( resp, indent=4 ) # (this should also succeed) 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 ) # (this should succeed) resp = testlib.blockstack_name_renew( "foo.test", wallets[4].privkey ) if 'error' in resp: print json.dumps( resp, indent=4 ) # (this should also succeed) resp = testlib.blockstack_name_update( "foo.test", "22" * 20, wallets[4].privkey ) if 'error' in resp: print json.dumps( resp, indent=4 ) # (this should succeed) resp = testlib.blockstack_name_transfer( "foo.test", wallets[3].addr, True, wallets[4].privkey ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # lots of updates for i in xrange(0, 9): resp = testlib.blockstack_name_update( "foo.test", ("%s%s" % (i,i)) * 20, wallets[3].privkey ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # transfer loop for i in xrange(0, 5): #resp = testlib.blockstack_name_transfer( "foo.test", wallets[3].addr, True, wallets[4].privkey ) resp = testlib.blockstack_name_transfer( "foo.test", wallets[4].addr, True, wallets[3].privkey ) if 'error' in resp: print json.dumps( resp, indent=4 ) resp = testlib.blockstack_name_transfer( "foo.test", wallets[3].addr, True, wallets[4].privkey ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # update/transfer/update/transfer for i in xrange(0, 5): resp = testlib.blockstack_name_transfer("foo.test", wallets[4].addr, True, wallets[3].privkey ) if 'error' in resp: print json.dumps( resp, indent=4 ) resp = testlib.blockstack_name_update("foo.test", "aa" * 20, wallets[4].privkey ) if 'error' in resp: print json.dumps( resp, indent=4 ) resp = testlib.blockstack_name_transfer("foo.test", wallets[3].addr, True, wallets[4].privkey ) if 'error' in resp: print json.dumps( resp, indent=4 ) resp = testlib.blockstack_name_update("foo.test", "bb" * 20, wallets[3].privkey ) if '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 ): 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 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 ): 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( "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 ) # 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 # renew/tranfer/update for i in xrange(1, 4): name = 'foo{}.test'.format(i) resp = testlib.blockstack_name_renew( name, wallets[3].privkey, zonefile_hash='{}a'.format(i) * 20, recipient_addr=wallets[0].addr ) if 'error' in resp: print resp return False 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[0].addr: print res 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) 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 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 ): resp = testlib.blockstack_namespace_preorder( "test", wallets[1].addr, wallets[0].privkey, safety_checks=False ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # should get rejected 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, safety_checks=False ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) # should get rejected (NOTE: the underlying mock utxo provider doesn't handle double-spends!) 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, safety_checks=False ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # should get accepted 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, safety_checks=False ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) # should get rejected (but only because the namespace isn't revealed until the block goes through) resp = testlib.blockstack_namespace_ready( "test", wallets[1].privkey, safety_checks=False ) 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, safety_checks=False ) 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, safety_checks=False ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # should get rejected resp = testlib.blockstack_name_register( "foo.test", wallets[2].privkey, wallets[3].addr, safety_checks=False ) if 'error' in resp: print json.dumps( resp, indent=4 ) # should get rejected (NOTE: the underlying mock utxo provider doesn't handle double-spends!) resp = testlib.blockstack_name_register( "foo.test", wallets[2].privkey, wallets[3].addr, safety_checks=False ) if 'error' in resp: print json.dumps( resp, indent=4 ) # don't SNV-check these testlib.expect_snv_fail_at( "foo.test", testlib.get_current_block( **kw )+1 ) testlib.next_block( **kw ) # should succeed resp = testlib.blockstack_name_register( "foo.test", wallets[2].privkey, wallets[3].addr, safety_checks=False ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # (this should succeed) 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 ) # (this should also succeed) 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 ) # (this should succeed) resp = testlib.blockstack_name_renew( "foo.test", wallets[4].privkey, safety_checks=False ) if 'error' in resp: print json.dumps( resp, indent=4 ) # (this should also succeed) resp = testlib.blockstack_name_update( "foo.test", "22" * 20, wallets[4].privkey, safety_checks=False ) if 'error' in resp: print json.dumps( resp, indent=4 ) # (this should succeed) resp = testlib.blockstack_name_transfer( "foo.test", wallets[3].addr, True, wallets[4].privkey, safety_checks=False ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # lots of updates for i in xrange(0, 9): resp = testlib.blockstack_name_update( "foo.test", ("%s%s" % (i,i)) * 20, wallets[3].privkey, safety_checks=False ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # transfer loop for i in xrange(0, 5): #resp = testlib.blockstack_name_transfer( "foo.test", wallets[3].addr, True, wallets[4].privkey ) 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 ) resp = testlib.blockstack_name_transfer( "foo.test", wallets[3].addr, True, wallets[4].privkey, safety_checks=False ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # update/transfer/update/transfer for i in xrange(0, 5): 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 ) resp = testlib.blockstack_name_update("foo.test", "aa" * 20, wallets[4].privkey, safety_checks=False ) if 'error' in resp: print json.dumps( resp, indent=4 ) resp = testlib.blockstack_name_transfer("foo.test", wallets[3].addr, True, wallets[4].privkey, safety_checks=False ) if 'error' in resp: print json.dumps( resp, indent=4 ) resp = testlib.blockstack_name_update("foo.test", "bb" * 20, wallets[3].privkey, safety_checks=False ) 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 ): 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, version_bits=2) testlib.next_block(**kw) testlib.blockstack_namespace_ready("test", wallets[1].privkey) testlib.next_block(**kw) namespace_rec = testlib.blockstack_cli_get_namespace_blockchain_record( "test") if 'error' in namespace_rec: print namespace_rec return False namespace_balance = testlib.get_balance(namespace_rec['address']) 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) # renew/xfer/update res = testlib.blockstack_name_renew("foo.test", wallets[3].privkey, zonefile_hash="22" * 20, recipient_addr=wallets[4].addr) if 'error' in res: print res return False testlib.next_block(**kw) # renew/update res = testlib.blockstack_name_renew("foo.test", wallets[4].privkey, zonefile_hash="33" * 20) if 'error' in res: print res return False testlib.next_block(**kw) # renew/xfer res = testlib.blockstack_name_renew("foo.test", wallets[4].privkey, recipient_addr=wallets[1].addr) if 'error' in res: print res return False testlib.next_block(**kw) # renew res = testlib.blockstack_name_renew("foo.test", wallets[1].privkey) if 'error' in res: print res return False testlib.next_block(**kw) new_namespace_balance = testlib.get_balance(namespace_rec['address']) name_rec = testlib.get_name_blockchain_record('foo.test') name_cost = name_rec['op_fee'] if new_namespace_balance - namespace_balance != name_cost * 5: print 'address {} did not get credited'.format( namespace_rec['address']) print '{} != {} + {}'.format(new_namespace_balance, namespace_balance, name_cost * 5) return False
def scenario(wallets, **kw): global first_name_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) # end of 689 # 4-block lifetime in practice 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 'error' in resp: print json.dumps(resp, indent=4) return False testlib.next_block(**kw) # 690 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) # 691 first_name_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) # end of 692. epoch 2 activates now whois = testlib.blockstack_cli_whois('foo.test') if 'error' in whois: print 'failed to whois foo.test' print json.dumps(whois, indent=4) return False # this should be the second-to-last block if whois['expire_block'] != testlib.get_current_block(**kw) + 2: print 'wrong expire block (now: {})'.format( testlib.get_current_block(**kw)) print whois return False print whois testlib.next_block(**kw) # end of 693 whois = testlib.blockstack_cli_whois('foo.test') if 'error' in whois: print 'failed to whois foo.test' print json.dumps(whois, indent=4) return False # we should have 3 more block to go now. if whois['expire_block'] != testlib.get_current_block(**kw) + 3: print 'wrong expire block (should be 3 blocks away from {})'.format( testlib.get_current_block(**kw)) print whois return False print whois 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) # end of 694, begin epoch 3 whois = testlib.blockstack_cli_whois('foo.test') if 'error' in whois: print 'failed to whois foo.test' print json.dumps(whois, indent=4) return False # we should have 2 more blocks to go now. if whois['expire_block'] != testlib.get_current_block(**kw) + 2: print 'wrong expire block' print whois return False if whois['renewal_deadline'] != testlib.get_current_block(**kw) + 2: print 'wrong renewal deadline' print whois return False print whois testlib.next_block(**kw) # end of 695 whois = testlib.blockstack_cli_whois('foo.test') if 'error' in whois: print 'failed to whois foo.test' print json.dumps(whois, indent=4) return False # we should have 1 more blocks to go now. if whois['expire_block'] != testlib.get_current_block(**kw) + 1: print 'wrong expire block' print whois return False if whois['renewal_deadline'] != testlib.get_current_block(**kw) + 6: print 'wrong renewal deadline' print whois return False print whois testlib.next_block(**kw) # end of 696. Name should be expired # update should be impossible, since we're now in the renewal period resp = testlib.blockstack_name_update('foo.test', '66' * 20, wallets[4].privkey, expect_fail=True) if 'error' not in resp: print resp return False # renew should work resp = testlib.blockstack_name_renew('foo.test', wallets[4].privkey, zonefile_hash='22' * 20, recipient_addr=wallets[2].addr) if 'error' in resp: print resp return False testlib.next_block(**kw) # end of 697 whois = testlib.blockstack_cli_whois('foo.test') if 'error' in whois: print whois return False print whois if whois['expire_block'] != testlib.get_current_block(**kw) + 4: print 'expire block: {}'.format(whois['expire_block']) print 'current block + 4: {}'.format( testlib.get_current_block(**kw) + 4) return False if whois['renewal_deadline'] != testlib.get_current_block(**kw) + 9: print 'renewal deadline: {}'.format(whois['renewal_deadline']) print 'current block + 9: {}'.format( testlib.get_current_block(**kw) + 9) 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 first_name_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) # 689 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 'error' in resp: print json.dumps(resp, indent=4) return False testlib.next_block(**kw) # 690 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) # 691 first_name_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) # 692 testlib.next_block(**kw) # end of 693 whois = testlib.blockstack_cli_whois('foo.test') if 'error' in whois: print 'failed to whois foo.test' print json.dumps(whois, indent=4) return False # this should be the penultimate block if whois['expire_block'] != testlib.get_current_block(**kw) + 1: print 'wrong expire block (got {}, expected {})'.format( whois['expire_block'], testlib.get_current_block(**kw)) print whois return False resp = testlib.blockstack_name_renew('foo.test', wallets[3].privkey) if 'error' in resp: print json.dumps(resp, indent=4) return False testlib.next_block(**kw) # end of 694 (epoch 2 is now active) testlib.next_block(**kw) # 695 whois = testlib.blockstack_cli_whois('foo.test') if 'error' in whois: print whois return False if whois['expire_block'] != testlib.get_current_block(**kw) + 3: print 'wrong expire block: {} != {} + 3'.format( whois['expire_block'], testlib.get_current_block(**kw)) return False testlib.next_block(**kw) # end of 696 (epoch 3 is now active) whois = testlib.blockstack_cli_whois('foo.test') if 'error' in whois: print whois return False if whois['expire_block'] != testlib.get_current_block(**kw) + 2: print 'wrong expire block: {} != {} + 2'.format( whois['expire_block'], testlib.get_current_block(**kw)) return False testlib.next_block(**kw) # 697 whois = testlib.blockstack_cli_whois('foo.test') if 'error' in whois: print whois return False if whois['expire_block'] != testlib.get_current_block(**kw) + 1: print 'wrong expire block: {} != {} + 1'.format( whois['expire_block'], testlib.get_current_block(**kw)) return False testlib.next_block(**kw) # 698 if whois['expire_block'] != testlib.get_current_block(**kw): print 'wrong expire block: {} != {}'.format( whois['expire_block'], testlib.get_current_block(**kw)) return False testlib.next_block(**kw) # end of 699 (expired now) testlib.next_block(**kw) # 700 testlib.next_block(**kw) # 701 testlib.next_block(**kw) # 702 resp = testlib.blockstack_name_renew('foo.test', wallets[3].privkey, zonefile_hash='22' * 20, recipient_addr=wallets[2].addr) if 'error' in resp: print resp return False testlib.next_block(**kw) # 703 whois = testlib.blockstack_cli_whois('foo.test') if 'error' in whois: print whois return False if whois['expire_block'] != testlib.get_current_block(**kw) + 4: print 'expire block: {}'.format(whois['expire_block']) print 'current block + 4: {}'.format( testlib.get_current_block(**kw) + 4) return False if whois['renewal_deadline'] != testlib.get_current_block(**kw) + 9: print 'renewal deadline: {}'.format(whois['renewal_deadline']) print 'current block + 9: {}'.format( testlib.get_current_block(**kw) + 9) return False
def scenario( wallets, **kw ): global update_blocks, transfer_blocks, update_hashes, transfer_recipients, renew_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 ) # preorder, register, update, expire (multiple times) for i in xrange(2, 5): resp = testlib.blockstack_name_preorder( "foo.test", wallets[i].privkey, wallets[(i+1)%11].addr, safety_checks=False ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) resp = testlib.blockstack_name_register( "foo.test", wallets[i].privkey, wallets[(i+1)%11].addr, safety_checks=False ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) resp = testlib.blockstack_name_update( "foo.test", ("%02x" % i) * 20, wallets[(i+1)%11].privkey, safety_checks=False ) 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 ) resp = testlib.blockstack_name_transfer( "foo.test", wallets[i].addr, True, wallets[(i+1)%11].privkey, safety_checks=False ) 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 ) resp = testlib.blockstack_name_renew( "foo.test", wallets[i].privkey, safety_checks=False ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) renew_blocks.append( testlib.get_current_block( **kw ) ) # wait for name to expire for j in xrange(0, 2 * NAMESPACE_LIFETIME_MULTIPLIER - 1 ): testlib.next_block( **kw ) if i == 4: break testlib.next_block( **kw )