def scenario(wallets, **kw): testlib.ysi_namespace_preorder("test", wallets[1].addr, wallets[0].privkey) testlib.next_block(**kw) testlib.ysi_namespace_reveal( "test", wallets[1].addr, 52595, 250, 4, [6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 10, 10, wallets[0].privkey) testlib.next_block(**kw) testlib.ysi_namespace_ready("test", wallets[1].privkey) testlib.next_block(**kw) testlib.ysi_name_preorder("foo.test", wallets[2].privkey, wallets[3].addr) testlib.next_block(**kw) testlib.ysi_name_register("foo.test", wallets[2].privkey, wallets[3].addr) testlib.next_block(**kw) testlib.ysi_name_update("foo.test", "11" * 20, wallets[3].privkey) testlib.next_block(**kw) testlib.ysi_name_renew("foo.test", wallets[3].privkey) testlib.next_block(**kw)
def scenario(wallets, **kw): testlib.ysi_namespace_preorder("test", wallets[1].addr, wallets[0].privkey) testlib.next_block(**kw) testlib.ysi_namespace_reveal( "test", wallets[1].addr, 52595, 250, 4, [6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 10, 10, wallets[0].privkey) testlib.next_block(**kw) testlib.ysi_namespace_ready("test", wallets[1].privkey) testlib.next_block(**kw) testlib.ysi_name_preorder("foo.test", wallets[2].privkey, wallets[3].addr) testlib.next_block(**kw) testlib.ysi_name_register("foo.test", wallets[2].privkey, wallets[3].addr) testlib.next_block(**kw) # wait for a bit... for i in xrange(0, 10): testlib.next_block(**kw) # has to be the same key that registered... resp = testlib.ysi_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 scenario(wallets, **kw): testlib.ysi_namespace_preorder("test", wallets[1].addr, wallets[0].privkey) testlib.next_block(**kw) testlib.ysi_namespace_reveal( "test", wallets[1].addr, 52595, 250, 4, [6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 10, 10, wallets[0].privkey) testlib.next_block(**kw) testlib.ysi_namespace_ready("test", wallets[1].privkey) testlib.next_block(**kw) testlib.ysi_name_preorder("foo.test", wallets[2].privkey, wallets[3].addr) testlib.next_block(**kw) testlib.ysi_name_register("foo.test", wallets[2].privkey, wallets[3].addr) testlib.next_block(**kw) # wait for a bit... for i in xrange(0, 10): testlib.next_block(**kw) resp = testlib.ysi_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.ysi_namespace_preorder( "test", wallets[1].addr, wallets[0].privkey ) testlib.next_block( **kw ) testlib.ysi_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.ysi_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.ysi_namespace_ready( "test", wallets[1].privkey ) testlib.next_block( **kw ) namespace_rec = testlib.ysi_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.ysi_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.ysi_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 update_block # make a test namespace resp = testlib.ysi_namespace_preorder( "test", wallets[1].addr, wallets[0].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) resp = testlib.ysi_namespace_reveal( "test", wallets[1].addr, 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.ysi_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.ysi_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.ysi_name_renew( "foo.test", wallets[3].privkey ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # update resp = testlib.ysi_name_update( "foo.test", "22" * 20, wallets[3].privkey ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) update_block = testlib.get_current_block( **kw ) # expire for i in xrange(0, 6 * NAMESPACE_LIFETIME_MULTIPLIER): testlib.next_block( **kw ) # re-register testlib.ysi_name_preorder( "foo.test", wallets[7].privkey, wallets[8].addr ) testlib.next_block( **kw ) testlib.ysi_name_register( "foo.test", wallets[7].privkey, wallets[8].addr ) testlib.next_block( **kw )
def scenario(wallets, **kw): global debug resp = testlib.ysi_namespace_preorder("test", wallets[1].addr, wallets[0].privkey) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) resp = testlib.ysi_namespace_reveal( "test", wallets[1].addr, 52595, 250, 4, [6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 10, 10, wallets[0].privkey) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) resp = testlib.ysi_namespace_ready("test", wallets[1].privkey) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) resp = testlib.ysi_name_preorder("foo.test", wallets[2].privkey, wallets[3].addr) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) resp = testlib.ysi_name_register("foo.test", wallets[2].privkey, wallets[3].addr) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) resp = testlib.ysi_name_transfer("foo.test", wallets[4].addr, True, wallets[3].privkey) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) resp = testlib.ysi_name_renew("foo.test", wallets[4].privkey) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) resp = testlib.ysi_name_update("foo.test", "11" * 20, wallets[4].privkey) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw)
def scenario(wallets, **kw): # make a test namespace resp = testlib.ysi_namespace_preorder("test", wallets[1].addr, wallets[0].privkey) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) resp = testlib.ysi_namespace_reveal( "test", wallets[1].addr, 52595, 250, 4, [6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 10, 10, wallets[0].privkey) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) resp = testlib.ysi_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.ysi_namespace_ready("test", wallets[1].privkey) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) resp = testlib.ysi_name_update("foo.test", "22" * 20, wallets[3].privkey) if 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) resp = testlib.ysi_name_transfer("foo.test", wallets[4].addr, True, wallets[3].privkey) if 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) # wait for a bit... for i in xrange(0, 10): testlib.next_block(**kw) resp = testlib.ysi_name_renew("foo.test", wallets[4].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.ysi_namespace_preorder("test", wallets[1].addr, wallets[0].privkey) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) resp = testlib.ysi_namespace_reveal( "test", wallets[1].addr, 52595, 250, 4, [6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 10, 10, wallets[0].privkey) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) resp = testlib.ysi_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.ysi_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.ysi_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 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, virtualchain.make_payment_script(namerecs[name][0].addr)) resp = testlib.ysi_name_renew(name, namerecs[name][0].privkey, safety_checks=False, tx_fee=10000 * 5) if 'error' in resp: print json.dumps(resp, indent=4) elif op == 'u': # update resp = testlib.ysi_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, virtualchain.make_payment_script(namerecs[name][0].addr), virtualchain.make_payment_script(namerecs[name][1].addr)) resp = testlib.ysi_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): testlib.ysi_namespace_preorder("test", wallets[1].addr, wallets[0].privkey) testlib.next_block(**kw) testlib.ysi_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.ysi_namespace_ready("test", wallets[1].privkey) testlib.next_block(**kw) testlib.ysi_name_preorder("foo.test", wallets[2].privkey, wallets[3].addr) testlib.next_block(**kw) testlib.ysi_name_register("foo.test", wallets[2].privkey, wallets[3].addr) testlib.next_block(**kw) # 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.ysi_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.ysi_namespace_preorder("test", wallets[1].addr, wallets[0].privkey) testlib.next_block(**kw) testlib.ysi_namespace_reveal( "test", wallets[1].addr, 52595, 250, 4, [6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 10, 10, wallets[0].privkey, version_bits=2) testlib.next_block(**kw) resp = testlib.ysi_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) testlib.ysi_namespace_ready("test", wallets[1].privkey) testlib.next_block(**kw) namespace_rec = testlib.ysi_cli_get_namespace_blockchain_record("test") if 'error' in namespace_rec: print namespace_rec return False namespace_balance = testlib.get_balance(namespace_rec['address']) burn_balance = testlib.get_balance( ysi_client.constants.BLOCKSTACK_BURN_ADDRESS) # should send to namespace burn address res = testlib.ysi_name_renew('foo.test', wallets[3].privkey) if 'error' in res: print res return False testlib.next_block(**kw) # should send to namespace burn address res = testlib.ysi_name_renew('foo.test', wallets[3].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 != 2 * name_cost: print 'address {} did not get credited'.format( namespace_rec['address']) print '{} != {} + {}'.format(new_namespace_balance, namespace_balance, name_cost) return False # should be rejected if not burned res = testlib.ysi_name_renew('foo.test', wallets[3].privkey, burn_addr=namespace_rec['address']) if 'error' not in res: print res return False res = testlib.ysi_name_renew('foo.test', wallets[3].privkey, burn_addr=namespace_rec['address'], safety_checks=False, tx_fee=10000 * 5) if 'error' in res: print res return False testlib.next_block(**kw) # should have been rejected name_rec_2 = testlib.get_name_blockchain_record('foo.test') if name_rec_2['last_renewed'] != name_rec['last_renewed']: print 'accidentally renewed' return False # renew, but correctly (with proper burn address) res = testlib.ysi_name_renew('foo.test', wallets[3].privkey) if 'error' in res: print res return False testlib.next_block(**kw) name_rec_2 = testlib.get_name_blockchain_record('foo.test') if name_rec_2['last_renewed'] <= name_rec['last_renewed']: print 'did not renew' return False # must have burned new_burn_balance = testlib.get_balance( ysi_client.constants.BLOCKSTACK_BURN_ADDRESS) if new_burn_balance - name_cost != burn_balance: print 'did not burn fee' print '{} != {} + {}'.format(new_burn_balance, burn_balance, name_cost) return False
def scenario(wallets, **kw): global fail_blocks testlib.ysi_namespace_preorder("test", wallets[1].addr, wallets[0].privkey) testlib.next_block(**kw) testlib.ysi_namespace_reveal( "test", wallets[1].addr, 10, 250, 4, [6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 10, 10, wallets[0].privkey) testlib.next_block(**kw) testlib.ysi_namespace_ready("test", wallets[1].privkey) testlib.next_block(**kw) testlib.ysi_name_preorder("foo.test", wallets[2].privkey, wallets[3].addr) testlib.next_block(**kw) testlib.ysi_name_register("foo.test", wallets[2].privkey, wallets[3].addr) testlib.next_block(**kw) testlib.ysi_name_revoke("foo.test", wallets[3].privkey) testlib.next_block(**kw) # can't do anything with the name for another 10 blocks resp = testlib.ysi_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.ysi_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.ysi_name_renew("foo.test", wallets[3].privkey, safety_checks=False, tx_fee=10000 * 5) if 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) testlib.expect_snv_fail_at("foo.test", testlib.get_current_block(**kw)) # wait for it to expire... for i in xrange(0, 8 * NAMESPACE_LIFETIME_MULTIPLIER): testlib.next_block(**kw) # verify that operations continue to fail (BUG in 0.13: THIS SUCCEEDS WHEN IT SHOULD FAIL) resp = testlib.ysi_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.ysi_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.ysi_name_renew("foo.test", wallets[3].privkey, safety_checks=False, tx_fee=10000 * 5) if 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) fail_blocks.append(testlib.get_current_block(**kw)) testlib.expect_snv_fail_at("foo.test", testlib.get_current_block(**kw)) # re-preorder... resp = testlib.ysi_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.ysi_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.ysi_namespace_preorder("test", wallets[1].addr, wallets[0].privkey) testlib.next_block(**kw) testlib.ysi_namespace_reveal( "test", wallets[1].addr, 10, 250, 4, [6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 10, 10, wallets[0].privkey) testlib.next_block(**kw) testlib.ysi_namespace_ready("test", wallets[1].privkey) testlib.next_block(**kw) testlib.ysi_name_preorder("foo.test", wallets[2].privkey, wallets[3].addr) testlib.next_block(**kw) testlib.ysi_name_register("foo.test", wallets[2].privkey, wallets[3].addr) testlib.next_block(**kw) resp = testlib.ysi_name_update("foo.test", "00" * 20, wallets[3].privkey) if 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) testlib.ysi_name_revoke("foo.test", wallets[3].privkey) testlib.next_block(**kw) # can't do anything with the name for another 10 blocks resp = testlib.ysi_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.ysi_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.ysi_name_renew("foo.test", wallets[3].privkey, safety_checks=False, tx_fee=10000 * 5) if 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) testlib.expect_snv_fail_at("foo.test", testlib.get_current_block(**kw)) # wait for it to expire... for i in xrange(0, 8 * NAMESPACE_LIFETIME_MULTIPLIER): testlib.next_block(**kw) # verify that operations continue to fail resp = testlib.ysi_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.ysi_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.ysi_name_renew("foo.test", wallets[3].privkey, safety_checks=False, tx_fee=10000 * 5) if 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) testlib.expect_snv_fail_at("foo.test", testlib.get_current_block(**kw)) # re-preorder... resp = testlib.ysi_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.ysi_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.ysi_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): testlib.ysi_namespace_preorder("test", wallets[1].addr, wallets[0].privkey) testlib.next_block(**kw) testlib.ysi_namespace_reveal( "test", wallets[1].addr, 3, 250, 4, [6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 10, 10, wallets[0].privkey) testlib.next_block(**kw) testlib.ysi_namespace_ready("test", wallets[1].privkey) testlib.next_block(**kw) testlib.ysi_name_preorder("foo.test", wallets[2].privkey, wallets[3].addr) testlib.next_block(**kw) testlib.ysi_name_register("foo.test", wallets[2].privkey, wallets[3].addr) testlib.next_block(**kw) # wait for a bit... for i in xrange(0, 2): testlib.next_block(**kw) # name must still exist name_rec = testlib.ysi_cli_whois('foo.test') if 'error' in name_rec: print name_rec return False if name_rec['owner_address'] != wallets[3].addr: print name_rec print 'wrong addr' return False # must still be renewable resp = testlib.ysi_name_renew("foo.test", wallets[3].privkey) if 'error' in resp: print json.dumps(resp, indent=4) return False # wait for a bit... for i in xrange(0, 5): testlib.next_block(**kw) # must be gone name_rec = testlib.ysi_cli_whois('foo.test') if 'error' not in name_rec: print name_rec return False # re-register under different address testlib.ysi_name_preorder("foo.test", wallets[3].privkey, wallets[2].addr) testlib.next_block(**kw) testlib.ysi_name_register("foo.test", wallets[3].privkey, wallets[2].addr) testlib.next_block(**kw) # wait for a bit... for i in xrange(0, 2): testlib.next_block(**kw) # name must still exist name_rec = testlib.ysi_cli_whois('foo.test') if 'error' in name_rec: print name_rec return False if name_rec['owner_address'] != wallets[2].addr: print name_rec print 'wrong addr' return False # must still be renewable resp = testlib.ysi_name_renew("foo.test", wallets[2].privkey) if 'error' in resp: print json.dumps(resp, indent=4) return False testlib.next_block(**kw) testlib.next_block(**kw)
def scenario(wallets, **kw): testlib.ysi_namespace_preorder("test", wallets[1].addr, wallets[0].privkey) testlib.next_block(**kw) testlib.ysi_namespace_reveal( "test", wallets[1].addr, 52595, 250, 4, [6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 10, 10, wallets[0].privkey) testlib.next_block(**kw) testlib.ysi_namespace_ready("test", wallets[1].privkey) testlib.next_block(**kw) resp = testlib.ysi_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.ysi_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.ysi_name_renew("foo.test", wallets[3].privkey, safety_checks=False, tx_fee=10000 * 5) 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.ysi_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.ysi_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.ysi_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): global fail_blocks testlib.ysi_namespace_preorder("test", wallets[1].addr, wallets[0].privkey) testlib.next_block(**kw) testlib.ysi_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.ysi_namespace_ready("test", wallets[1].privkey) testlib.next_block(**kw) testlib.ysi_name_preorder("foo.test", wallets[2].privkey, wallets[3].addr) testlib.next_block(**kw) testlib.ysi_name_register("foo.test", wallets[2].privkey, wallets[3].addr) testlib.next_block(**kw) # 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.ysi_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.ysi_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.ysi_name_renew("foo.test", wallets[3].privkey, safety_checks=False, tx_fee=10000 * 5) if 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) fail_blocks.append(testlib.get_current_block(**kw)) testlib.expect_snv_fail_at("foo.test", testlib.get_current_block(**kw)) # should fail resp = testlib.ysi_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): # make a test namespace resp = testlib.ysi_namespace_preorder("test", wallets[1].addr, wallets[0].privkey) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) resp = testlib.ysi_namespace_reveal( "test", wallets[1].addr, 52595, 250, 4, [6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 10, 10, wallets[0].privkey) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) resp = testlib.ysi_namespace_ready("test", wallets[1].privkey) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) # 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]] for i in xrange(0, len(names)): name = names[i] preorder_wallet = name_preorder_wallets[i] register_wallet = name_register_wallets[i] resp = testlib.ysi_name_preorder(name, preorder_wallet.privkey, register_wallet.addr) if debug or 'error' in resp: print json.dumps(resp, indent=4) 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.ysi_name_register(name, preorder_wallet.privkey, register_wallet.addr) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) # update 3 names in the same block for i in xrange(0, len(names)): name = names[i] register_wallet = name_register_wallets[i] resp = testlib.ysi_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.ysi_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.ysi_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.ysi_name_revoke(name, register_wallet.privkey) if debug or 'error' in resp: print json.dumps(resp, indent=4) # iterate the blocks a few times for i in xrange(0, 5): testlib.next_block(**kw)
def scenario(wallets, **kw): resp = testlib.ysi_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.ysi_namespace_reveal( "test", wallets[1].addr, 52595, 250, 4, [6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 10, 10, wallets[0].privkey, 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.ysi_namespace_reveal( "test", wallets[1].addr, 52595, 250, 4, [6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 10, 10, wallets[0].privkey, safety_checks=False) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) testlib.expect_snv_fail_at('test', testlib.get_current_block(**kw)) # should get accepted resp = testlib.ysi_namespace_reveal( "test", wallets[1].addr, 52595, 250, 4, [6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 10, 10, wallets[0].privkey, 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.ysi_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) testlib.expect_snv_fail_at('test', testlib.get_current_block(**kw)) resp = testlib.ysi_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.ysi_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.ysi_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.ysi_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.ysi_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.ysi_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.ysi_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.ysi_name_renew("foo.test", wallets[4].privkey, safety_checks=False, tx_fee=10000 * 5) if 'error' in resp: print json.dumps(resp, indent=4) # (this should also succeed) resp = testlib.ysi_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.ysi_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.ysi_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.ysi_name_transfer( "foo.test", wallets[3].addr, True, wallets[4].privkey ) resp = testlib.ysi_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.ysi_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.ysi_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.ysi_name_update("foo.test", "aa" * 20, wallets[4].privkey, safety_checks=False) if 'error' in resp: print json.dumps(resp, indent=4) resp = testlib.ysi_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.ysi_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 renew_block testlib.ysi_namespace_preorder("test", wallets[1].addr, wallets[0].privkey) testlib.next_block(**kw) testlib.ysi_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.ysi_namespace_ready("test", wallets[1].privkey) testlib.next_block(**kw) testlib.ysi_name_preorder("foo.test", wallets[2].privkey, wallets[3].addr) testlib.next_block(**kw) testlib.ysi_name_register("foo.test", wallets[2].privkey, wallets[3].addr) testlib.next_block(**kw) whois = testlib.ysi_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.ysi_name_update("foo.test", '22' * 20, wallets[3].privkey) if 'error' not in res: print res return False res = testlib.ysi_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.ysi_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.ysi_name_transfer('foo.test', wallets[4].addr, True, wallets[3].privkey) if 'error' not in res: print res return False res = testlib.ysi_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.ysi_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.ysi_name_revoke('foo.test', wallets[3].privkey) if 'error' not in res: print res return False res = testlib.ysi_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.ysi_cli_whois('foo.test') if 'error' in res: print res return False # can renew res = testlib.ysi_name_renew('foo.test', wallets[3].privkey) if 'error' in res: print res return False testlib.next_block(**kw) renew_block = testlib.get_current_block(**kw)
def scenario(wallets, **kw): testlib.ysi_namespace_preorder("test", wallets[1].addr, wallets[0].privkey) testlib.next_block(**kw) testlib.ysi_namespace_reveal( "test", wallets[1].addr, 52595, 250, 4, [6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 10, 10, wallets[0].privkey, version_bits=2) testlib.next_block(**kw) testlib.ysi_namespace_ready("test", wallets[1].privkey) testlib.next_block(**kw) namespace_rec = testlib.ysi_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.ysi_name_preorder("foo.test", wallets[2].privkey, wallets[3].addr) testlib.next_block(**kw) testlib.ysi_name_register("foo.test", wallets[2].privkey, wallets[3].addr) testlib.next_block(**kw) # renew/xfer/update res = testlib.ysi_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.ysi_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.ysi_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.ysi_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): testlib.ysi_namespace_preorder("test", wallets[1].addr, wallets[0].privkey) testlib.next_block(**kw) testlib.ysi_namespace_reveal( "test", wallets[1].addr, 3, 250, 4, [6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 10, 10, wallets[0].privkey, version_bits=2) testlib.next_block(**kw) testlib.ysi_namespace_ready("test", wallets[1].privkey) testlib.next_block(**kw) namespace_rec = testlib.ysi_cli_get_namespace_blockchain_record("test") if 'error' in namespace_rec: print namespace_rec return False namespace_balance = testlib.get_balance(namespace_rec['address']) burn_balance = testlib.get_balance( ysi_client.constants.BLOCKSTACK_BURN_ADDRESS) res = testlib.ysi_name_preorder("foo.test", wallets[2].privkey, wallets[3].addr) if 'error' in res: print res return False testlib.next_block(**kw) res = testlib.ysi_name_register("foo.test", wallets[2].privkey, wallets[3].addr) if 'error' in res: print res return False testlib.next_block(**kw) testlib.next_block(**kw) testlib.next_block(**kw) testlib.next_block(**kw) testlib.next_block(**kw) # expired res = testlib.ysi_name_preorder("foo.test", wallets[3].privkey, wallets[4].addr) if 'error' in res: print res return False testlib.next_block(**kw) res = testlib.ysi_name_register("foo.test", wallets[3].privkey, wallets[4].addr) if 'error' in res: print res return False testlib.next_block(**kw) testlib.next_block(**kw) res = testlib.ysi_name_renew("foo.test", wallets[4].privkey) if 'error' in res: print res return False testlib.next_block(**kw) testlib.next_block(**kw) testlib.next_block(**kw) testlib.next_block(**kw) testlib.next_block(**kw) # expired res = testlib.ysi_name_preorder("foo.test", wallets[2].privkey, wallets[3].addr) if 'error' in res: print res return False testlib.next_block(**kw) res = testlib.ysi_name_register("foo.test", wallets[2].privkey, wallets[3].addr) 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'] testlib.next_block(**kw) testlib.next_block(**kw) testlib.next_block(**kw) testlib.next_block(**kw) # expired if new_namespace_balance - namespace_balance != 4 * name_cost: print 'address {} did not get credited'.format( namespace_rec['address']) print '{} != {} + 4*{}'.format(new_namespace_balance, namespace_balance, name_cost) return False # preorder should send to the null burn address now. res = testlib.ysi_name_preorder("foo2.test", wallets[4].privkey, wallets[0].addr) if 'error' in res: print res return False # try forcing it to the namespace burn address, to verify that it fails res = testlib.ysi_name_preorder("foo_fail.test", wallets[4].privkey, wallets[0].addr, burn_addr=namespace_rec['address']) if 'error' not in res: print res return False res = testlib.ysi_name_preorder("foo_fail.test", wallets[4].privkey, wallets[0].addr, burn_addr=namespace_rec['address'], safety_checks=False, tx_fee=10000 * 5) if 'error' in res: print res return False testlib.next_block(**kw) # should be accepted res = testlib.ysi_name_register("foo2.test", wallets[4].privkey, wallets[0].addr) if 'error' in res: print res return False # should be rejected res = testlib.ysi_name_register("foo_fail.test", wallets[4].privkey, wallets[0].addr) if 'error' in res: print res return False testlib.next_block(**kw) # should have been rejected due to wrong burn address whois = testlib.ysi_cli_whois('foo_fail.test') if 'error' not in whois: print whois return False new_burn_balance = testlib.get_balance( ysi_client.constants.BLOCKSTACK_BURN_ADDRESS) new_namespace_balance = testlib.get_balance(namespace_rec['address']) name_rec_2 = testlib.get_name_blockchain_record('foo2.test') name_cost_2 = name_rec_2['op_fee'] # namespace should NOT have gotten the fee for foo_fail. It should only have gotten it for foo.test if new_namespace_balance - namespace_balance != 4 * name_cost + 3 * 5500: print 'address {} got credited after fee capture period'.format( namespace_rec['address']) print '{} != {} + 4*{}'.format(new_namespace_balance, namespace_balance, name_cost) return False # burn address should have received the fee for the second name if new_burn_balance - name_cost_2 != burn_balance: print 'null burn address did not get credited' print '{} != {} + {}'.format(new_burn_balance, burn_balance, name_cost_2) return False
def scenario(wallets, **kw): testlib.ysi_namespace_preorder("test", wallets[1].addr, wallets[0].privkey) testlib.next_block(**kw) testlib.ysi_namespace_reveal( "test", wallets[1].addr, 52595, 250, 4, [6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 10, 10, wallets[0].privkey) testlib.next_block(**kw) testlib.ysi_namespace_ready("test", wallets[1].privkey) testlib.next_block(**kw) testlib.ysi_name_preorder("foo.test", wallets[2].privkey, wallets[3].addr) testlib.next_block(**kw) testlib.ysi_name_register("foo.test", wallets[2].privkey, wallets[3].addr) testlib.next_block(**kw) # renew resp = testlib.ysi_name_renew("foo.test", wallets[3].privkey) if 'error' in resp: print json.dumps(resp, indent=4) return False testlib.next_block(**kw) # whois res = testlib.ysi_cli_whois('foo.test') if 'error' in res: print res return False if res.has_key('zonefile_hash'): print res return False if res['owner_address'] != wallets[3].addr: print res return False # transfer resp = testlib.ysi_name_transfer('foo.test', wallets[4].addr, True, wallets[3].privkey) if 'error' in resp: print resp return False testlib.next_block(**kw) # whois res = testlib.ysi_cli_whois('foo.test') if 'error' in res: print res return False if res.has_key('zonefile_hash'): print res return False if res['owner_address'] != wallets[4].addr: print res return False # renew/update resp = testlib.ysi_name_renew("foo.test", wallets[4].privkey, zonefile_hash='11' * 20) if 'error' in resp: print json.dumps(resp, indent=4) return False testlib.next_block(**kw) # whois res = testlib.ysi_cli_whois('foo.test') if 'error' in res: print res return False if not res.has_key('zonefile_hash') or res['zonefile_hash'] != '11' * 20: print res return False if res['owner_address'] != wallets[4].addr: print res return False # transfer resp = testlib.ysi_name_transfer('foo.test', wallets[1].addr, True, wallets[4].privkey) if 'error' in resp: print json.dumps(resp, indent=4) return False testlib.next_block(**kw) # whois res = testlib.ysi_cli_whois('foo.test') if 'error' in res: print res return False if not res.has_key('zonefile_hash') or res['zonefile_hash'] != '11' * 20: print res return False if res['owner_address'] != wallets[1].addr: print res return False # renew/update/transfer resp = testlib.ysi_name_renew("foo.test", wallets[1].privkey, zonefile_hash='22' * 20, recipient_addr=wallets[0].addr) if 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) # whois res = testlib.ysi_cli_whois('foo.test') if 'error' in res: print res return False if not res.has_key('zonefile_hash') or res['zonefile_hash'] != '22' * 20: print res return False if res['owner_address'] != wallets[0].addr: print res return False # transfer resp = testlib.ysi_name_transfer('foo.test', wallets[2].addr, True, wallets[0].privkey) if 'error' in resp: print json.dumps(resp, indent=4) return False testlib.next_block(**kw) # whois res = testlib.ysi_cli_whois('foo.test') if 'error' in res: print res return False if not res.has_key('zonefile_hash') or res['zonefile_hash'] != '22' * 20: print res return False if res['owner_address'] != wallets[2].addr: print res return False # renew/transfer resp = testlib.ysi_name_renew("foo.test", wallets[2].privkey, recipient_addr=wallets[1].addr) if 'error' in resp: print json.dumps(resp, indent=4) return False testlib.next_block(**kw) # whois res = testlib.ysi_cli_whois('foo.test') if 'error' in res: print res return False if not res.has_key('zonefile_hash') or res['zonefile_hash'] != '22' * 20: print res return False if res['owner_address'] != wallets[1].addr: print res return False
def scenario(wallets, **kw): global first_name_block test_proxy = testlib.make_proxy() # make a test namespace resp = testlib.ysi_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.ysi_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 # make a zonefile and a profile driver_urls = ysi_client.storage.make_mutable_data_urls( 'foo.test', use_only=['dht', 'disk']) zonefile = ysi_client.zonefile.make_empty_zonefile('foo.test', wallets[4].pubkey_hex, urls=driver_urls) zonefile_txt = ysi_zones.make_zone_file(zonefile, origin='foo.test', ttl=4200) # make a new keyfile as well user_profile = ysi_client.user.make_empty_user_profile() ''' res = ysi_client.key_file.make_initial_key_file(user_profile, wallets[3].privkey) if 'error' in res: print res return res keyfile_txt = res['key_file'] ''' zonefile_hash = ysi_client.get_zonefile_data_hash(zonefile_txt) resp = testlib.ysi_name_import("foo.test", wallets[3].addr, zonefile_hash, wallets[1].privkey) if 'error' in resp: print json.dumps(resp, indent=4) return False testlib.next_block(**kw) # 691 # broadcast zonefile res = testlib.ysi_cli_sync_zonefile('foo.test', zonefile_string=zonefile_txt) if 'error' in res: print res return False ''' # upload keyfile res = ysi_client.key_file.key_file_put('foo.test', keyfile_txt) if 'error' in res: print res return False ''' rc = ysi_client.profile.put_profile('foo.test', user_profile, blockchain_id='foo.test', user_data_privkey=wallets[4].privkey, user_zonefile=zonefile, proxy=test_proxy) if not rc: print 'failed to put profile' return False # try lookup res = testlib.ysi_cli_lookup('foo.test') if 'error' in res: print res return False first_name_block = testlib.get_current_block(**kw) resp = testlib.ysi_namespace_ready("test", wallets[1].privkey) if 'error' in resp: print json.dumps(resp, indent=4) return False # try lookup res = testlib.ysi_cli_lookup('foo.test') if 'error' in res: print res return False testlib.next_block(**kw) # end of 692 whois = testlib.ysi_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 # try lookup res = testlib.ysi_cli_lookup('foo.test') if 'error' in res: print res return False testlib.next_block(**kw) # end of 693; begin epoch 2 # begin epoch 2 # try lookup res = testlib.ysi_cli_lookup('foo.test') if 'error' in res: print res return False testlib.next_block(**kw) # 694 # try lookup res = testlib.ysi_cli_lookup('foo.test') if 'error' in res: print res return False whois = testlib.ysi_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) # try lookup res = testlib.ysi_cli_lookup('foo.test') if 'error' in res: print res return False testlib.next_block(**kw) # end of 696 # try lookup (should fail) res = testlib.ysi_cli_lookup('foo.test') if 'error' not in res: print res return False if 'expired' not in res['error']: print res return False whois = testlib.ysi_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'] # begin epoch 3 (grace period) testlib.next_block(**kw) # end of 697 # try lookup (should fail) res = testlib.ysi_cli_lookup('foo.test') if 'error' not in res: print res return False if 'expired' not in res['error']: print res return False testlib.next_block(**kw) # 698 # try lookup (should fail) res = testlib.ysi_cli_lookup('foo.test') if 'error' not in res: print res return False if 'expired' not in res['error']: print res return False testlib.next_block(**kw) # 699 # try lookup (should fail) res = testlib.ysi_cli_lookup('foo.test') if 'error' not in res: print res return False if 'expired' not in res['error']: print res return False testlib.next_block(**kw) # 700 # try lookup (should fail) res = testlib.ysi_cli_lookup('foo.test') if 'error' not in res: print res return False if 'expired' not in res['error']: print res return False # make a zonefile and a profile driver_urls = ysi_client.storage.make_mutable_data_urls( 'foo.test', use_only=['dht', 'disk']) new_zonefile = ysi_client.zonefile.make_empty_zonefile( 'foo.test', wallets[4].pubkey_hex, urls=driver_urls) new_zonefile_txt = ysi_zones.make_zone_file(new_zonefile, origin='foo.test', ttl=4200) # make a new keyfile as well new_user_profile = ysi_client.user.make_empty_user_profile() new_user_profile['new_user'] = True ''' res = ysi_client.key_file.make_initial_key_file(new_user_profile, wallets[0].privkey) if 'error' in res: print res return res new_keyfile_txt = res['key_file'] ''' new_zonefile_hash = ysi_client.get_zonefile_data_hash(new_zonefile_txt) rc = ysi_client.profile.put_profile('foo.test', new_user_profile, blockchain_id='foo.test', user_data_privkey=wallets[4].privkey, user_zonefile=new_zonefile, proxy=test_proxy) if not rc: print 'failed to put profile' return False # renew/xfer/update resp = testlib.ysi_name_renew('foo.test', wallets[3].privkey, zonefile_hash=new_zonefile_hash, recipient_addr=wallets[0].addr) if 'error' in resp: print resp return False testlib.next_block(**kw) # end of 701 (end of grace period) # try lookup (should succeed again) res = testlib.ysi_cli_lookup('foo.test') if 'error' in res: print res return False if res['zonefile'] != new_zonefile_txt: print 'wrong zonefile' print new_zonefile_txt print res return False testlib.next_block(**kw) # 702 (name can be registered again)
def scenario( wallets, **kw ): testlib.ysi_namespace_preorder( "test", wallets[1].addr, wallets[0].privkey ) testlib.next_block( **kw ) # 689 testlib.ysi_namespace_reveal( "test", wallets[1].addr, 52595, 250, 4, [6,5,4,3,2,1,0,0,0,0,0,0,0,0,0,0], 10, 10, wallets[0].privkey ) testlib.next_block( **kw ) # 690 testlib.ysi_namespace_ready( "test", wallets[1].privkey ) testlib.next_block( **kw ) # 691 testlib.ysi_name_preorder( "foo.test", wallets[2].privkey, wallets[3].addr ) testlib.next_block( **kw ) # 692 testlib.ysi_name_register( "foo.test", wallets[2].privkey, wallets[3].addr ) testlib.next_block( **kw ) # 693 whois = testlib.ysi_cli_whois("foo.test") if 'error' in whois: print whois return False # should fail (safety checks stop it) resp = testlib.ysi_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.ysi_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.ysi_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.ysi_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 # should succeed resp = testlib.ysi_name_renew( "foo.test", wallets[0].privkey, zonefile_hash='33' * 20, recipient_addr=wallets[1].addr ) if 'error' in resp: print resp return False testlib.next_block( **kw ) # 697
def scenario(wallets, **kw): test_proxy = testlib.make_proxy() ysi_client.set_default_proxy(test_proxy) testlib.ysi_namespace_preorder("test", wallets[1].addr, wallets[0].privkey) testlib.next_block(**kw) # 689 testlib.ysi_namespace_reveal( "test", wallets[1].addr, 52595, 250, 4, [6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 10, 10, wallets[0].privkey) testlib.next_block(**kw) # 690 testlib.ysi_namespace_ready("test", wallets[1].privkey) testlib.next_block(**kw) # 691 testlib.ysi_name_preorder("foo.test", wallets[2].privkey, wallets[3].addr) testlib.next_block(**kw) # 692 testlib.ysi_name_register("foo.test", wallets[2].privkey, wallets[3].addr) testlib.next_block(**kw) # 693 names = ['f' + 'o' * i + '.test' for i in xrange(0, 32)] names_novowel = ['f' + 'j' * i + '.test' for i in xrange(0, 32)] names_nonalpha = ['f' + '1' * i + '.test' for i in xrange(0, 32)] namespaces = ['b' * i for i in xrange(1, 20)] name_costs = {} namespace_costs = {} for n in names + names_novowel + names_nonalpha: name_cost_info = test_proxy.get_name_cost(n) price_satoshis = name_cost_info['satoshis'] name_costs[n] = price_satoshis for ns in namespaces: namespace_cost_info = test_proxy.get_namespace_cost(ns) namespace_price_satoshis = namespace_cost_info['satoshis'] namespace_costs[ns] = namespace_price_satoshis # activate epoch 3 testlib.next_block(**kw) # 694 new_name_costs = {} new_namespace_costs = {} for n in names + names_novowel + names_nonalpha: name_cost_info = test_proxy.get_name_cost(n) price_satoshis = name_cost_info['satoshis'] new_name_costs[n] = price_satoshis for ns in namespaces: namespace_cost_info = test_proxy.get_namespace_cost(ns) namespace_price_satoshis = namespace_cost_info['satoshis'] new_namespace_costs[ns] = namespace_price_satoshis for n in names + names_novowel + names_nonalpha: if new_name_costs[n] * 10 != name_costs[n]: print 'wrong name cost change for {}: {} * 10 != {}'.format( n, new_name_costs[n], name_costs[n]) return False for ns in namespaces: if new_namespace_costs[ns] * 10 != namespace_costs[ns]: print 'wrong namespace cost change for {}: {} * 10 != {}'.format( ns, new_name_costs[ns], name_costs[ns]) return False # should succeed resp = testlib.ysi_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) # 695
def scenario(wallets, **kw): global debug, consensus, small_unspents res = check_utxo_consumption( "test", wallets[0], wallets[1], wallets[2], ['namespace_preorder', 'namespace_reveal', 'namespace_ready'], wallets[1].addr, **kw) if 'error' in res: return False expected_utxo_count = res['expected_utxo_count'] # do the preorder resp = testlib.ysi_namespace_preorder("test", wallets[1].addr, wallets[0].privkey) if debug or 'error' in resp: print simplejson.dumps(resp, indent=4) testlib.next_block(**kw) # verify that all the small UTXOs are NOT consumed bitcoind = testlib.connect_bitcoind() bitcoind.ping() txdata = bitcoind.getrawtransaction(resp['transaction_hash'], 1) if len(txdata['vin']) != 1: print simplejson.dumps(txdata, indent=4) print "wrong number of inputs: {} != 1".format(len(txdata['vin'])) return False if spent_small_transaction(resp['transaction_hash']): return False # finish ordering the namespace resp = testlib.ysi_namespace_reveal( "test", wallets[1].addr, 52595, 250, 4, [6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 10, 10, wallets[0].privkey) if debug or 'error' in resp: print simplejson.dumps(resp, indent=4) if spent_small_transaction(resp['transaction_hash']): return False testlib.next_block(**kw) resp = testlib.ysi_namespace_ready("test", wallets[1].privkey) if debug or 'error' in resp: print simplejson.dumps(resp, indent=4) if spent_small_transaction(resp['transaction_hash']): return False testlib.next_block(**kw) res = check_utxo_consumption( "foo.test", wallets[2], wallets[3], wallets[4], ['preorder', 'register', 'update', 'transfer'], wallets[4].addr, **kw) if 'error' in res: return False expected_utxo_count = res['expected_utxo_count'] resp = testlib.ysi_name_preorder("foo.test", wallets[2].privkey, wallets[3].addr) if debug or 'error' in resp: print simplejson.dumps(resp, indent=4) if spent_small_transaction(resp['transaction_hash']): return False testlib.next_block(**kw) # verify that all the small UTXOs are NOT consumed bitcoind = testlib.connect_bitcoind() bitcoind.ping() txdata = bitcoind.getrawtransaction(resp['transaction_hash'], 1) if len(txdata['vin']) != 1: print simplejson.dumps(txdata, indent=4) print "wrong number of inputs: {} != {}".format( len(txdata['vin']), expected_utxo_count) return False # proceed to register resp = testlib.ysi_name_register("foo.test", wallets[2].privkey, wallets[3].addr) if debug or 'error' in resp: print simplejson.dumps(resp, indent=4) if spent_small_transaction(resp['transaction_hash']): return False testlib.next_block(**kw) # verify that all the UTXOs are consumed bitcoind = testlib.connect_bitcoind() bitcoind.ping() txdata = bitcoind.getrawtransaction(resp['transaction_hash'], 1) if len(txdata['vin']) != 1: print simplejson.dumps(txdata, indent=4) print "wrong number of inputs: {} != {}".format( len(txdata['vin']), expected_utxo_count) return False # make a few small UTXOs for the preorder payment addr for i in xrange(0, 3): res = testlib.send_funds(wallets[1].privkey, 10000, testlib.get_default_payment_wallet().addr) if 'error' in res: print simplejson.dumps(res, indent=4, sort_keys=True) return False testlib.next_block(**kw) small_unspents.append(res['transaction_hash']) utxos = testlib.get_utxos(testlib.get_default_payment_wallet().addr) assert len(utxos) > 3 resp = testlib.ysi_name_update("foo.test", "11" * 20, wallets[3].privkey) if debug or 'error' in resp: print simplejson.dumps(resp, indent=4) if spent_small_transaction(resp['transaction_hash']): return False consensus = testlib.get_consensus_at(testlib.get_current_block(**kw), **kw) testlib.next_block(**kw) # inspect the transaction: only 3 UTXOs should have been consumed (2 owner UTXOs and 1 payment UTXO) txdata = testlib.connect_bitcoind().getrawtransaction( resp['transaction_hash'], 1) if len(txdata['vin']) != 3: print simplejson.dumps(txdata, indent=4) print "too many inputs" return False # make a few more small UTXOs for the preorder payment addr for i in xrange(0, 3): res = testlib.send_funds(wallets[1].privkey, 10000, testlib.get_default_payment_wallet().addr) if 'error' in res: print simplejson.dumps(res, indent=4, sort_keys=True) return False testlib.next_block(**kw) small_unspents.append(res['transaction_hash']) utxos = testlib.get_utxos(testlib.get_default_payment_wallet().addr) assert len(utxos) > 3 resp = testlib.ysi_name_transfer("foo.test", wallets[4].addr, True, wallets[3].privkey) if debug or 'error' in resp: print simplejson.dumps(resp, indent=4) # inspect the transaction: only 2 UTXOs should have been consumed (1 owner UTXO and 1 payment UTXO) txdata = testlib.connect_bitcoind().getrawtransaction( resp['transaction_hash'], 1) if len(txdata['vin']) != 2: print simplejson.dumps(txdata, indent=4) print "too many inputs" return False if spent_small_transaction(resp['transaction_hash']): return False testlib.next_block(**kw) # make a few more small UTXOs for the preorder payment addr for i in xrange(0, 3): res = testlib.send_funds(wallets[1].privkey, 10000, testlib.get_default_payment_wallet().addr) if 'error' in res: print simplejson.dumps(res, indent=4, sort_keys=True) return False testlib.next_block(**kw) small_unspents.append(res['transaction_hash']) utxos = testlib.get_utxos(testlib.get_default_payment_wallet().addr) assert len(utxos) > 3 resp = testlib.ysi_name_renew("foo.test", wallets[4].privkey) if debug or 'error' in resp: print simplejson.dumps(resp, indent=4) # inspect the transaction: only 3 UTXOs should have been consumed (2 owner UTXO and 1 payment UTXO) # NOTE: produces two UTXOs: an "owner" utxo and the change for the owner address txdata = testlib.connect_bitcoind().getrawtransaction( resp['transaction_hash'], 1) if len(txdata['vin']) != 3: print simplejson.dumps(txdata, indent=4) print "too many inputs" return False if spent_small_transaction(resp['transaction_hash']): return False testlib.next_block(**kw) # make a few more small UTXOs for the preorder payment addr for i in xrange(0, 3): res = testlib.send_funds(wallets[1].privkey, 10000, testlib.get_default_payment_wallet().addr) if 'error' in res: print simplejson.dumps(res, indent=4, sort_keys=True) return False testlib.next_block(**kw) small_unspents.append(res['transaction_hash']) utxos = testlib.get_utxos(testlib.get_default_payment_wallet().addr) assert len(utxos) > 3 resp = testlib.ysi_name_revoke("foo.test", wallets[4].privkey) if debug or 'error' in resp: print simplejson.dumps(resp, indent=4) # inspect the transaction: only 3 UTXOs should have been consumed (2 owner UTXO and 1 payment UTXO) txdata = testlib.connect_bitcoind().getrawtransaction( resp['transaction_hash'], 1) if len(txdata['vin']) != 3: print simplejson.dumps(txdata, indent=4) print "too many inputs" return False if spent_small_transaction(resp['transaction_hash']): return False testlib.next_block(**kw) '''
def scenario(wallets, **kw): global first_name_block # make a test namespace resp = testlib.ysi_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.ysi_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.ysi_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.ysi_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.ysi_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.ysi_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.ysi_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.ysi_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.ysi_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.ysi_name_update('foo.test', '66' * 20, wallets[4].privkey) if 'error' not in resp: print resp return False # renew should work resp = testlib.ysi_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.ysi_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 first_name_block # make a test namespace resp = testlib.ysi_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.ysi_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.ysi_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.ysi_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.ysi_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.ysi_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.ysi_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.ysi_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.ysi_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.ysi_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.ysi_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): testlib.ysi_namespace_preorder("test", wallets[1].addr, wallets[0].privkey) testlib.next_block(**kw) testlib.ysi_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.ysi_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.ysi_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.ysi_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) if i == 3: testlib.expect_snv_fail_at("foo.test", testlib.get_current_block(**kw)) testlib.next_block(**kw) resp = testlib.ysi_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) if i == 3: testlib.expect_snv_fail_at("foo.test", testlib.get_current_block(**kw)) testlib.next_block(**kw) resp = testlib.ysi_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) if i == 3: testlib.expect_snv_fail_at("foo.test", testlib.get_current_block(**kw)) testlib.next_block(**kw) resp = testlib.ysi_name_renew("foo.test", wallets[i].privkey, safety_checks=False, tx_fee=10000 * 5) 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): print '\nactivating segwit\n' virtualchain.set_features("segwit", True) print '\nsegwit state: {}\n'.format(virtualchain.get_features('segwit')) testlib.ysi_namespace_preorder("test", wallets[1].addr, wallets[5].privkey) testlib.ysi_namespace_preorder("mult", wallets[2].addr, wallets[0].privkey) testlib.next_block(**kw) testlib.ysi_namespace_reveal( "test", wallets[1].addr, 52595, 250, 4, [6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 10, 10, wallets[5].privkey) testlib.ysi_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.ysi_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.ysi_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.ysi_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.ysi_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.ysi_namespace_ready("test", wallets[1].privkey) testlib.ysi_namespace_ready("mult", wallets[2].privkey) testlib.next_block(**kw) namespace_balance = testlib.get_balance(wallets[0].addr) # get prices hello_cost = testlib.ysi_get_name_cost('hello.mult') world_cost = testlib.ysi_get_name_cost('world.mult') foo_cost = testlib.ysi_get_name_cost('foo.mult') # register/renew res = testlib.ysi_name_preorder("hello.mult", wallets[1].privkey, wallets[2].addr) if 'error' in res: print res return False res = testlib.ysi_name_preorder('world.mult', wallets[6].privkey, wallets[7].addr, wallet=wallets[7]) if 'error' in res: print res return False res = testlib.ysi_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.ysi_name_register("hello.mult", wallets[1].privkey, wallets[2].addr) if 'error' in res: print res return False res = testlib.ysi_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)