def check(state_engine): global first_name_block # not revealed, but ready ns = state_engine.get_namespace_reveal("test") if ns is not None: return False ns = state_engine.get_namespace("test") if ns is None: return False if ns['namespace_id'] != 'test': return False # not preordered for i in xrange(0, len(wallets)): preorder = state_engine.get_name_preorder( "foo.test", virtualchain.make_payment_script(wallets[i].addr), wallets[(i + 1) % 5].addr) if preorder is not None: print "preordered" return False # registered name_rec = state_engine.get_name("foo.test") if name_rec is None: print "no name" return False # renewed (12 blocks later, starting from renewal time) if name_rec['last_renewed'] - 12 != name_rec['first_registered']: print name_rec['last_renewed'] print name_rec['first_registered'] return False namespace_rec = state_engine.get_namespace("test") if namespace_rec is None: print "missing namespace" return False # renewal fee should have been name_cost * epoch_cost_multiplier # make sure we have both the original and new prices original_price = 6400000 historic_name_rec = state_engine.get_name_at("foo.test", first_name_block) if historic_name_rec is None or len(historic_name_rec) == 0: print "missing historic name rec at %s" % first_name_rec return False historic_name_rec = historic_name_rec[0] if abs(original_price - historic_name_rec['op_fee']) >= 10e-8: print "historic op fee mismatch: original price = %s, historic fee = %s" % ( original_price, historic_name_rec['op_fee']) return False current_fee = original_price * ysi.lib.config.get_epoch_price_multiplier( 266, "test") current_price = ysi.price_name("foo", namespace_rec, 266) if abs(current_price - current_fee) >= 10e-8: print "current op fee mismatch: original price = %s, historic price = %s" % ( current_price, current_fee) return False epoch_cost_multiplier = ysi.get_epoch_price_multiplier(266, "test") if abs(original_price * epoch_cost_multiplier - current_price) >= 10e-8: print "epoch cost failure: original_price = %s, multiplier = %s, current price = %s" % ( original_price, epoch_cost_multiplier, current_price) return False return True
def check(state_engine): global zonefile_hash, new_expire_block # 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 # registered name_rec = state_engine.get_name("foo.test") if name_rec is None: print "name does not exist" return False # owned by owner_address = wallets[3].addr if name_rec['address'] != owner_address or name_rec[ 'sender'] != virtualchain.make_payment_script(owner_address): print "sender is wrong" return False # value hash if name_rec['value_hash'] != zonefile_hash: print "wrong zonefile hash: %s != %s" % (name_rec['value_hash'], zonefile_hash) return False # replicated? zonefile = testlib.ysi_get_zonefile(zonefile_hash) if 'error' in zonefile: print "zonefile error: %s" % zonefile['error'] return False # right hash? if ysi_client.hash_zonefile(zonefile) != zonefile_hash: print "wrong zonefile: %s != %s" % (ysi_client.hash_zonefile(zonefile), zonefile_hash) return False # all queues are drained queue_info = testlib.ysi_client_queue_state() if len(queue_info) > 0: print "Still in queue:\n%s" % json.dumps( queue_info, indent=4, sort_keys=True) return False # final balance is correct? name_fee = ysi_server.price_name("foo", ns, new_expire_block) preorder_dust_fees = 3 * DEFAULT_DUST_FEE + DEFAULT_OP_RETURN_FEE register_dust_fees = 4 * DEFAULT_DUST_FEE + DEFAULT_OP_RETURN_FEE renewal_dust_fees = 3 * DEFAULT_DUST_FEE + DEFAULT_OP_RETURN_FEE total_fee = name_fee * 2 + preorder_dust_fees + register_dust_fees + renewal_dust_fees payment_address = wallets[2].addr # TODO: check return True