delvtech / hyperdrive-rs

Rust SDK for the Hyperdrive AMM.
https://docs.rs/crate/hyperdrive-math/latest
Apache License 2.0
2 stars 0 forks source link

fix `BlockOutOfRangeError` in fuzz tests #4

Open dpaiton opened 6 months ago

dpaiton commented 6 months ago

Two test occasionally fail with a BlockOutOfRangeError message.

long::open::tests::fuzz_calculate_spot_price_after_long

---- long::open::tests::fuzz_calculate_spot_price_after_long stdout ----
Error: (code: -32602, message: BlockOutOfRangeError: block height is 15 but requested was 16, data: None)

Location:
    /Users/dylan/code/delv/hyperdrive-rs/crates/test-utils/src/agent.rs:471:17

long::targeted::tests::test_calculate_targeted_long_with_budget

---- long::targeted::tests::test_calculate_targeted_long_with_budget stdout ----
Error: (code: -32602, message: BlockOutOfRangeError: block height is 16 but requested was 17, data: None)

Location:
    /Users/dylan/code/delv/hyperdrive-rs/crates/test-utils/src/agent.rs:943:13
dpaiton commented 6 months ago

The two cited line numbers are during initialize and hyperdrive.get_pool_info(), which is a wrappers function. Maybe this is an async issue?

jalextowle commented 5 months ago

Closing since I haven't seen this since fixing the nonce too low issue. We can re-open if we see it pop back up.

dpaiton commented 4 months ago

I found this issue again; I think it is happening between mint & approve in agent.fund(). Maybe we need to increase the sleep duration between these two calls?

Error: (code: -32602, message: BlockOutOfRangeError: block height is 114 but requested was 16, data: None)

Location:
    /Users/dylan/code/delv/hyperdrive-rs/crates/hyperdrive-test-utils/src/agent.rs:494:9

failures:
    long::open::tests::fuzz_sol_calculate_open_long
dpaiton commented 4 months ago

I was able to consistently reproduce this while working on #142 and then (hopefully) fixed it by adding a sleep after the base approval step in agent.fund()

dpaiton commented 4 months ago

Looks like the error is still happening on main: https://github.com/delvtech/hyperdrive-rs/actions/runs/9751500824/job/26913221206#step:5:862