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 coverage #418

Merged
merged 106 commits into from
Oct 3, 2023
Merged

test: improve coverage #418

merged 106 commits into from
Oct 3, 2023

Conversation

MicaiahReid
Copy link
Contributor

@MicaiahReid MicaiahReid commented Sep 18, 2023

Fixes some bugs found along the way


Checklist

  • All tests pass
  • Tests added in this PR (if applicable)
    Test coverage before: 47.07%
    Test coverage after: 63.30%

### Description

Improves how we handle a restart of `chainhook service` while predicates
are scanning/streaming. Here are the cases we now handle:
1. Predicates that were in `scanning` status when Chainhook was
terminated will resume scanning starting from their
`last_evaluated_block_height`. *Note: because we only save predicate
status every 10 scans, we could end up re-emiting matches on a resetart*
2. Predicates that were in `new` status when Chainhook was terminated
will start scanning at the predicate's `start_block`
3. Predicates that were in `streaming` status will _return_ to a
`scanning` status, starting at `last_evaluated_block_height` to catch up
on the missed blocks. Note, the `number_of_blocks_to_scan` is set to 0
for this temporary catch-up, as it's difficult to compute the number of
remaining blocks in the context of this change
4. If predicates were passed in at startup, we also register those to
begin scanning, which previously didn't happen
5. We now allow passing in a predicate at startup _and_ registering
additional predicates with the predicate registration server. This means
that if you use the same startup predicate repeatedly, it will already
be saved in redis and _not_ be reloaded.

Fixes: #298, fixes #390, fixes #402, fixes #403


---

### Checklist

- [x] All tests pass
- [ ] Tests added in this PR (if applicable)
@MicaiahReid MicaiahReid marked this pull request as ready for review September 22, 2023 19:37
@@ -43,11 +45,36 @@ pub struct LimitsConfigFile {

#[derive(Deserialize, Debug, Clone)]
pub struct NetworkConfigFile {
pub mode: String,
pub mode: NetworkConfigMode,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This fixes a bug when you run chainhook config new --devnet, then try to use that config, Chainhook would panic.

@MicaiahReid
Copy link
Contributor Author

@lgalabru I did remove a fair amount of code that (as far as I could tell) was not used. Can you verify for me that this is okay? Here are the files:

Copy link
Contributor

@lgalabru lgalabru left a comment

Choose a reason for hiding this comment

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

This PR is looking great, thank you @MicaiahReid!

@MicaiahReid MicaiahReid merged commit 1e606ed into develop Oct 3, 2023
1 check passed
@MicaiahReid MicaiahReid deleted the improve-test-coverage branch October 3, 2023 16:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants