Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Improve tests of adl_utils library. #476

Open
sparqet opened this issue Oct 4, 2023 · 5 comments
Open

test: Improve tests of adl_utils library. #476

sparqet opened this issue Oct 4, 2023 · 5 comments
Assignees
Labels
enhancement New feature or request testing

Comments

@sparqet
Copy link
Collaborator

sparqet commented Oct 4, 2023

Description

Implement and improve tests of adl_utils library.

File: test/adl/adl_utils.cairo.

Acceptance criteria

  • Unit tests (nominal and failure) are implemented and passing.
@sparqet sparqet added enhancement New feature or request testing labels Oct 4, 2023
@faytey
Copy link
Contributor

faytey commented Oct 6, 2023

Can I try working on this?

@sparqet
Copy link
Collaborator Author

sparqet commented Oct 7, 2023

Of course

@faytey
Copy link
Contributor

faytey commented Oct 27, 2023

Hello @sparqet i need some clarifications. I can't seem to figure out why this test fails and what it expects.

    // Setup
    let (caller_address, role_store, data_store, event_emitter, oracle) = setup_oracle_and_store();
    // TODO 
    // For testing "get_enabled_market",  "get_market_prices" and "is_pnl_factor_exceeded_direct" should be implmented
    let market = 'market'.try_into().unwrap();
    let is_long = true;
    let block_value = 1234_u64;
    adl_utils::set_latest_adl_block(data_store, market, is_long, block_value);

    let block_numbers = array![10_u64, 11_u64];
    adl_utils::update_adl_state(
        data_store, event_emitter, oracle, market, is_long, block_numbers.span()
    );

    teardown(data_store.contract_address);
}```
Here's the error code ```[FAIL] tests::adl::test_adl_utils::given_normal_conditions_when_update_adl_state_then_works

Failure data:
    original value: [679294546788681927074128974206947708677311959581332250879971221889508708], converted to a string: [block_no_smaller_than_required]

Tests: 0 passed, 1 failed, 0 skipped

Failures:

Sorry for the delay in starting the task, I had some emergencies to attend to. I'll await your response. Thanks

@sparqet
Copy link
Collaborator Author

sparqet commented Dec 1, 2023

Hello @faytey ! Sorry for my late reply, this last month has been very busy for me.
This test fails because you've set the latest_adl_block of the specific market at 1234, and when you call update_adl_state, you give an array of u64 with lower values than the block number you've set before for the same market

@faytey
Copy link
Contributor

faytey commented Dec 3, 2023

yes, i figured it and corrected it, which has been merged already, would you want me to work on another issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request testing
Projects
None yet
Development

No branches or pull requests

2 participants