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.next_block( **kw ) testlib.ysi_namespace_ready( "test", wallets[1].privkey ) testlib.next_block( **kw ) # expire it for i in xrange(0, 4): testlib.next_block(**kw) whois = testlib.ysi_cli_whois('foo.test') if 'error' not in whois: print whois return False 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']) res = testlib.ysi_name_preorder( "foo.test", wallets[2].privkey, wallets[4].addr ) if 'error' in res: print res return False testlib.next_block( **kw ) res = testlib.ysi_name_register( "foo.test", wallets[2].privkey, wallets[4].addr, zonefile_hash='22' * 20 ) 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: print 'address {} did not get credited'.format(namespace_rec['address']) print '{} != {} + {}'.format(new_namespace_balance, namespace_balance, name_cost) return False if name_rec['value_hash'] != '22' * 20: print 'wrong value hash' return False
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 # should fail (safety checks stop it) resp = testlib.ysi_name_register('foo.test', wallets[2].privkey, wallets[3].addr, zonefile_hash='22' * 20) if 'error' not in resp: print resp return False # should succeed in being sent, but will be rejected resp = testlib.ysi_name_register('foo.test', wallets[2].privkey, wallets[3].addr, zonefile_hash='22' * 20, safety_checks=False, tx_fee=300 * 5) if 'error' in resp: print resp return False testlib.next_block(**kw) # 693 testlib.expect_snv_fail_at("foo.test", testlib.get_current_block(**kw)) # must NOT be registered resp = testlib.ysi_cli_whois('foo.test') if 'error' not in resp: print resp return False # epoch 3 now active. # try again, and it should succeed resp = testlib.ysi_name_register('foo.test', wallets[2].privkey, wallets[3].addr, zonefile_hash='22' * 20) if 'error' in resp: print resp return False testlib.next_block(**kw) # 694
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("foo1.test", wallets[2].privkey, wallets[3].addr) testlib.ysi_name_preorder("foo2.test", wallets[2].privkey, wallets[3].addr) testlib.ysi_name_preorder("foo3.test", wallets[2].privkey, wallets[3].addr) testlib.next_block(**kw) testlib.ysi_name_register("foo1.test", wallets[2].privkey, wallets[3].addr, zonefile_hash='11' * 20) testlib.ysi_name_register("foo2.test", wallets[2].privkey, wallets[3].addr, zonefile_hash='22' * 20) testlib.ysi_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.ysi_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
def check(state_engine): # not revealed, but ready ns = state_engine.get_namespace_reveal("test") if ns is not None: print "namespace reveal exists" return False ns = state_engine.get_namespace("test") if ns is None: print "no namespace" return False if ns['namespace_id'] != 'test': print "wrong namespace" return False # not preordered preorder = state_engine.get_name_preorder( "foo.test", virtualchain.make_payment_script(wallets[2].addr), wallets[3].addr) if preorder is not None: print "preorder exists" return False # registered name_rec = state_engine.get_name("foo.test") if name_rec is None: print "name does not exist" return False # owned by if name_rec['address'] != wallets[3].addr or name_rec[ 'sender'] != virtualchain.make_payment_script(wallets[3].addr): print "sender is wrong" return False # renewed res = testlib.ysi_cli_whois('foo.test') if 'error' in res: print res return False if res['block_renewed_at'] != renew_block: print 'wrong renew block: expected {}'.format(renew_block) print res return False return True
def scenario( wallets, **kw ): global preorder_info, register_info, update_info, balance_before, balance_after, names_owned_before, names_owned_after, whois, blockchain_record, deposit_info, price_info global blockchain_history, zonefile_info, all_names_info, namespace_names_info, wallet_info, lookup_info, update_history, zonefile_history, names_info 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 ) wallet = testlib.ysi_client_initialize_wallet( "0123456789abcdef", wallets[2].privkey, wallets[3].privkey, wallets[4].privkey ) balance_before = testlib.ysi_cli_balance() deposit_info = testlib.ysi_cli_deposit() price_info = testlib.ysi_cli_price( "foo.test", password="******" ) wallet_info = testlib.ysi_cli_wallet( "0123456789abcdef" ) resp = testlib.ysi_cli_register( "foo.test", "0123456789abcdef" ) if 'error' in resp: print >> sys.stderr, json.dumps(resp, indent=4, sort_keys=True) return False # wait for the preorder to get confirmed for i in xrange(0, 5): testlib.next_block( **kw ) # queued? preorder_info = testlib.ysi_cli_info() names_owned_before = testlib.ysi_cli_get_names_owned_by_address( wallets[3].addr ) for i in xrange(0, 7): testlib.next_block( **kw ) # wait for the poller to pick it up print >> sys.stderr, "Waiting 10 seconds for the backend to submit the register" time.sleep(10) # wait for the register to get confirmed for i in xrange(0, 5): testlib.next_block( **kw ) # registered? register_info = testlib.ysi_cli_info() names_info = testlib.ysi_cli_names() for i in xrange(0, 7): testlib.next_block( **kw ) print >> sys.stderr, "Waiting 10 seconds for the backend to acknowledge registration" time.sleep(10) # wait for update to get confirmed for i in xrange(0, 5): testlib.next_block( **kw ) update_info = testlib.ysi_cli_info() names_owned_after = testlib.ysi_cli_get_names_owned_by_address( wallets[3].addr ) whois = testlib.ysi_cli_whois( "foo.test" ) for i in xrange(0, 7): testlib.next_block( **kw ) print >> sys.stderr, "Waiting 10 seconds for the backend to acknowledge update" time.sleep(10) # put some immutable data put_immutable_info = testlib.ysi_cli_put_immutable( "foo.test", "hello_world", '{"hello": "world"}' ) if 'error' in put_immutable_info: print "put_immutable failed" print json.dumps(put_immutable_info, indent=4, sort_keys=True) return False # wait for update to be confirmed for i in xrange(0, 12): testlib.next_block( **kw ) print >> sys.stderr, "Waiting 10 seconds for backend to acknowledge put-immutable update" time.sleep(10) balance_after = testlib.ysi_cli_balance() blockchain_history = testlib.ysi_cli_get_name_blockchain_history( "foo.test" ) zonefile_info = testlib.ysi_cli_get_name_zonefile( "foo.test", json=False ) all_names_info = testlib.ysi_cli_get_all_names(0) namespace_names_info = testlib.ysi_cli_get_names_in_namespace("test", 0) lookup_info = testlib.ysi_cli_lookup( "foo.test" ) update_history = testlib.ysi_cli_list_update_history( "foo.test" ) zonefile_history = testlib.ysi_cli_list_zonefile_history( "foo.test" ) blockchain_record = testlib.ysi_cli_get_name_blockchain_record( "foo.test" )
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 # 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 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 3 should be active) 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 # 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.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) # end of 693 (new epoch) 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 ): 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 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 # should go through resp = testlib.ysi_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 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 testlib.next_block(**kw) # end of 693; begin epoch 2 # begin epoch 2 # should go through, but be rejected resp = testlib.ysi_name_register("foo.test", wallets[1].privkey, wallets[2].addr, safety_checks=False, tx_fee=500*5) if 'error' in resp: print resp 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 if whois['owner_address'] != wallets[3].addr: print 'accidentally registered' print json.dumps(whois) return False testlib.next_block(**kw) # 694 testlib.expect_snv_fail_at( "foo.test", testlib.get_current_block(**kw)) # should go through, but be rejected resp = testlib.ysi_name_register("foo.test", wallets[1].privkey, wallets[2].addr, safety_checks=False, tx_fee=500*5) if 'error' in resp: print resp 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 if whois['owner_address'] != wallets[3].addr: print 'accidentally registered' print json.dumps(whois) 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.expect_snv_fail_at( "foo.test", testlib.get_current_block(**kw)) 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 if whois['owner_address'] != wallets[3].addr: print 'accidentally registered' print json.dumps(whois) return False # should go through, but be rejected resp = testlib.ysi_name_register("foo.test", wallets[1].privkey, wallets[2].addr, safety_checks=False, tx_fee=500*5) if 'error' in resp: print resp return False testlib.next_block(**kw) # end of 696 testlib.expect_snv_fail_at( "foo.test", testlib.get_current_block(**kw)) 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 if whois['owner_address'] != wallets[3].addr: print 'accidentally registered' print json.dumps(whois) return False last_transaction_height = whois['last_transaction_height'] # should go through, but be rejected resp = testlib.ysi_name_register("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 testlib.expect_snv_fail_at( "foo.test", testlib.get_current_block(**kw)) whois = testlib.ysi_cli_whois('foo.test') if 'error' in whois: print whois if whois['owner_address'] != wallets[3].addr: print 'accidentally registered' print json.dumps(whois) return False resp = testlib.ysi_name_register("foo.test", wallets[1].privkey, wallets[2].addr) if 'error' not in resp: print resp return False # should go through, but be rejected resp = testlib.ysi_name_register("foo.test", wallets[1].privkey, wallets[2].addr, 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.ysi_cli_whois('foo.test') if 'error' in whois: print whois return False if whois['owner_address'] != wallets[3].addr: print 'accidentally registered' print json.dumps(whois) return False if whois['last_transaction_height'] != last_transaction_height: print 'accidentally registered' return False resp = testlib.ysi_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.ysi_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.ysi_cli_whois('foo.test') if 'error' in whois: print whois return False if whois['owner_address'] != wallets[3].addr: print 'accidentally registered' print json.dumps(whois) return False if whois['last_transaction_height'] != last_transaction_height: print 'accidentally registered' return False resp = testlib.ysi_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.ysi_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 # should go through, and be acccepted resp = testlib.ysi_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 testlib.next_block(**kw) # 700 testlib.expect_snv_fail_at( "foo.test", testlib.get_current_block(**kw)) whois = testlib.ysi_cli_whois('foo.test') if 'error' in whois: print whois return False if whois['owner_address'] != wallets[3].addr: print 'accidentally registered' print json.dumps(whois) return False if whois['last_transaction_height'] != last_transaction_height: print 'accidentally registered' return False # should fail resp = testlib.ysi_name_register("foo.test", wallets[3].privkey, wallets[0].addr, zonefile_hash='44' * 20) if 'error' not in resp: print resp return False # should go through, but be rejected resp = testlib.ysi_name_register("foo.test", wallets[3].privkey, wallets[0].addr, zonefile_hash='44' * 20, safety_checks=False, tx_fee=500*5) 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.ysi_cli_whois('foo.test') if 'error' not in whois: print whois return False # should go through, and be rejected (expired preorder) resp = testlib.ysi_name_register("foo.test", wallets[1].privkey, wallets[2].addr, zonefile_hash='44' * 20) 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.ysi_cli_whois('foo.test') if 'error' not in whois: print whois return False # should go through, and be accepted resp = testlib.ysi_name_register("foo.test", wallets[3].privkey, wallets[0].addr, zonefile_hash='33' * 20) 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['owner_address'] != wallets[0].addr: print 'accidentally registered foo.test to {}'.format(whois['owner_address']) 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) 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, 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) 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 # should send to null burn address res = testlib.ysi_name_preorder("foo2.test", wallets[2].privkey, wallets[3].addr) if 'error' in res: print res return False # preorder should send to the null burn address now. # try forcing it to the namespace burn address, to verify that it fails res = testlib.ysi_name_preorder("foo_fail.test", wallets[2].privkey, wallets[3].addr, burn_addr=namespace_rec['address']) if 'error' not in res: print res return False res = testlib.ysi_name_preorder("foo_fail.test", wallets[2].privkey, wallets[3].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 rejected res = testlib.ysi_name_register("foo_fail.test", wallets[2].privkey, wallets[3].addr) if 'error' in res: print res return False # should be accepted res = testlib.ysi_name_register("foo2.test", wallets[2].privkey, wallets[3].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 != name_cost + 5500: print 'address {} got credited after fee capture period'.format( namespace_rec['address']) print '{} != {} + {}'.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): 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): 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) # 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 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 3 should be active) 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 # 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.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) # end of 693 (new epoch) 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 # expire it again (block 694-698) for i in xrange(0, 4): testlib.next_block(**kw) lookup = testlib.ysi_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.ysi_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.ysi_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.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 if whois['owner_address'] != wallets[4].addr: print 'wrong owner; expected {}'.format(wallets[4].addr) print whois return False
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): 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): 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): 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 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 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 testlib.next_block(**kw) # end of 693; begin epoch 2 # begin epoch 2 testlib.next_block(**kw) # 694 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) testlib.next_block(**kw) # end of 696 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 # safety checks should NOT allow the preorder to go through resp = testlib.ysi_name_preorder('foo.test', wallets[3].privkey, wallets[4].addr) if 'error' not in resp: print resp return False # begin epoch 3 (grace period) testlib.next_block(**kw) # end of 697 # safety checks should NOT allow the preorder to go through resp = testlib.ysi_name_preorder('foo.test', wallets[3].privkey, wallets[4].addr) if 'error' not in resp: print resp return False testlib.next_block(**kw) # 698 # safety checks should NOT allow the preorder to go through resp = testlib.ysi_name_preorder('foo.test', wallets[3].privkey, wallets[4].addr) if 'error' not in resp: print resp return False testlib.next_block(**kw) # 699 # safety checks should NOT allow the preorder to go through resp = testlib.ysi_name_preorder('foo.test', wallets[3].privkey, wallets[4].addr) if 'error' not in resp: print resp return False testlib.next_block(**kw) # 700 # safety checks should NOT allow the preorder to go through resp = testlib.ysi_name_preorder('foo.test', wallets[3].privkey, wallets[4].addr) if 'error' not in resp: print resp return False testlib.next_block(**kw) # end of 701 # safety checks SHOULD allow the preorder to go through (will be incorporated into block 702) resp = testlib.ysi_name_preorder('foo.test', wallets[3].privkey, wallets[4].addr) if 'error' in resp: print resp return False testlib.next_block(**kw) # 702 resp = testlib.ysi_name_register("foo.test", wallets[3].privkey, wallets[4].addr, zonefile_hash='33' * 20) if 'error' in resp: print resp return False testlib.next_block(**kw) # 703