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 * blockstack.lib.config.get_epoch_price_multiplier(
        703, "test", "BTC")
    current_price = blockstack.price_name("foo", namespace_rec, 703)

    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 = blockstack.get_epoch_price_multiplier(
        703, "test", "BTC")

    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 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", pybitcoin.make_pay_to_address_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 * blockstack.lib.config.get_epoch_price_multiplier( 266, "test" )
    current_price = blockstack.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 = blockstack.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