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

tests: remove near_actix_test_utils::run_actix_until_panic #4452

Merged
merged 3 commits into from
Jul 7, 2021

Conversation

mina86
Copy link
Contributor

@mina86 mina86 commented Jul 1, 2021

The way near_actix_test_utils::run_actix_until was written,
the expect_panic flag didn’t actually matter:

SET_PANIC_HOOK.call_once(|| {
    let default_hook = std::panic::take_hook();
    std::panic::set_hook(Box::new(move |info| {
        if !expect_panic {
            default_hook(info);
        }
        // ...
    }));
});

Since SET_PANIC_HOOK.call_once invokes the closure only once, the
value of expect_panic when that calls happen is the only one that
matters. In other words, the first run of run_actix_until function
decides what the value of expect_panic in the panic handler is.

Fortunately this didn’t actually matter. The only test which set the
flag to true – chunks_recovered_from_full_timeout_too_short – was
marked #[should_panic] and running the default panic hook didn’t
negatively influence the test.

As such, get rid of run_actix_until_panic and rename
run_actix_until_stop to simply be run_actix.

The way remove `near_actix_test_utils::run_actix_until` was written,
the expect_panic flag didn’t actually matter:

    SET_PANIC_HOOK.call_once(|| {
        let default_hook = std::panic::take_hook();
        std::panic::set_hook(Box::new(move |info| {
            if !expect_panic {
                default_hook(info);
            }
            // ...
        }));
    });

Since `SET_PANIC_HOOK.call_once` invokes the closure only once, the
value of expect_panic when that calls happen is the only one that
matters.  In other words, the first run of `run_actix_until` function
decides what the value of `expect_panic` in the panic handler is.

Fortunately this didn’t actually matter.  The only test which set the
flag to true – `chunks_recovered_from_full_timeout_too_short` – was
marked `#[should_panic]` and running the default panic hook didn’t
negatively influence the test.

As such, get rid of `run_actix_until_panic` and rename
`run_actix_until_stop` to simply be `run_actix`.

Issue: near#3266
@mina86
Copy link
Contributor Author

mina86 commented Jul 1, 2021

@miraclx

@mina86 mina86 enabled auto-merge (squash) July 2, 2021 03:05
Copy link
Contributor

@chefsale chefsale left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM updated to rebase onto master, as github automerge doesn't do it. @mina86 I would recommend to use the S-automerge label instead, as that bot also does automatocally rebase you PR.

@mina86 mina86 merged commit ff01c54 into near:master Jul 7, 2021
@mina86
Copy link
Contributor Author

mina86 commented Jul 7, 2021

I would recommend to use the S-automerge label instead, as that bot also does automatocally rebase you PR.

I suspected that is the case. Has been tested this with a few recent PRs. Thanks for confirming.

@mina86 mina86 deleted the tmp branch July 7, 2021 18:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants