def run_test():

    conn_obj = DummyConnectionObj()
    end_a = PartnerEndpoint(conn_obj)
    end_b = PartnerEndpoint(conn_obj)

    ctx_a = create_context(end_a)
    ctx_b = create_context(end_b)
    num_var_a = ctx_a.global_store.get_var_if_exists(
        end_a.end_global_number_var_name)
    num_var_b = ctx_b.global_store.get_var_if_exists(
        end_b.end_global_number_var_name)            


    # perform write locally
    a_val = 3920
    write_event = end_a._act_event_map.create_root_event()
    num_var_a.set_val(write_event,a_val)
    
    # send sequence message to the other side to perform write there.
    # block until call completes
    ctx_a.hide_partner_call(
        end_a,write_event,'test_partner',True)

    # actually try to commit write event
    write_event.begin_first_phase_commit()

    # check that both values were updated
    read_event_a = end_a._act_event_map.create_root_event()
    if num_var_a.get_val(read_event_a) != a_val:
        print '\nWrite did not go through on A\n'
        return False

    read_event_a.begin_first_phase_commit()

    read_event_b = end_b._act_event_map.create_root_event()
    if num_var_b.get_val(read_event_b) != B_VAL:
        print '\nWrite did not go through on B\n'
        return False
    read_event_b.begin_first_phase_commit()

    return True
def run_test():
    conn_obj = DummyConnectionObj()
    end_a = PartnerEndpoint(conn_obj)
    end_b = PartnerEndpoint(conn_obj)

    ctx_a = create_context(end_a)
    # load a sequence variable into ctx_a

    ctx_a.sequence_local_store.add_var(
        SEQ_LOC_VAR_NAME,
        # True means that it's peered
        SingleThreadedLockedMapVariable(Waldo._host_uuid,True,{}))
    
    # send sequence message to the other side to perform write there.
    # block until call completes
    write_event = end_a._act_event_map.create_root_event()

    map_var = ctx_a.sequence_local_store.get_var_if_exists(
        SEQ_LOC_VAR_NAME)

    map_var.get_val(write_event).add_key(write_event,KEY_A,VAL_A)
        
    ctx_a.hide_partner_call(
        end_a,write_event,'test_partner_write',True)

    # check that sequence local value was updated
    map_var = ctx_a.sequence_local_store.get_var_if_exists(
        SEQ_LOC_VAR_NAME)

    if failed_on_partner:
        print '\nPartner could not read correct data in sequence\n'
        return False


    tmp = map_var.get_val(write_event).get_val_on_key(write_event,KEY_A)
    if map_var.get_val(write_event).get_val_on_key(write_event,KEY_A) != VAL_B:
        print '\nDid not incorporate other side changes on key a\n'
        return False

    if map_var.get_val(write_event).get_val_on_key(write_event,KEY_B) != VAL_B:
        print '\nDid not incorporate other side changes on key b\n'
        return False    
    

    # actually try to commit write event
    write_event.begin_first_phase_commit()
    return True
def run_test():
    conn_obj = DummyConnectionObj()
    end_a = PartnerEndpoint(conn_obj)
    end_b = PartnerEndpoint(conn_obj)

    ctx_a = create_context(end_a)
    # load a sequence variable into ctx_a

    ctx_a.sequence_local_store.add_var(
        SEQ_LOC_VAR_NAME,
        # True means that it's peered
        SingleThreadedLockedNumberVariable(Waldo._host_uuid,True,100))
    
    # send sequence message to the other side to perform write there.
    # block until call completes
    write_event = end_a._act_event_map.create_root_event()


    num_var = ctx_a.sequence_local_store.get_var_if_exists(
        SEQ_LOC_VAR_NAME)
    
    ctx_a.hide_partner_call(
        end_a,write_event,'test_partner_write',True)

    # check that sequence local value was updated
    num_var = ctx_a.sequence_local_store.get_var_if_exists(
        SEQ_LOC_VAR_NAME)

    gotten_val = num_var.get_val(write_event)

    
    if num_var.get_val(write_event) != B_VAL:
        print '\nRead incorrect value from num_var.\n'
        return False

    # actually try to commit write event
    write_event.begin_first_phase_commit()
    return True