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(sequencer): add unit tests for src/api_state_ext #890

Merged
merged 3 commits into from
Apr 5, 2024

Conversation

Lilyjjo
Copy link
Contributor

@Lilyjjo Lilyjjo commented Apr 1, 2024

Summary

Seventh set of state-ext unit tests. In total there are seven files which
need tests:

  • astria-sequencer/src/api_state_ext.rs (This PR)
  • astria-sequencer/src/state_ext.rs
  • astria-sequencer/src/accounts/state_ext.rs
  • astria-sequencer/src/asset/state_ext.rs
  • astria-sequencer/src/authority/state_ext.rs
  • astria-sequencer/src/bridge/state_ext.rs
  • astria-sequencer/src/ibc/state_ext.rs

This PR just tests the src/api_state_ext/state_ext.rs file.

Background

It is good to have unit tests to ensure that the database works as intended.

Changes

Unit tests for the functionality in the file src/api_state_ext/state_ext.rs were added.

Testing

:)

@github-actions github-actions bot added the sequencer pertaining to the astria-sequencer crate label Apr 1, 2024
Comment on lines +479 to +443
// create inner rollup id/tx data
let mut deposits = HashMap::new();
for _ in 0..2 {
Copy link
Collaborator

Choose a reason for hiding this comment

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

is this just adding 2 arbitrary deposit types?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I wanted to put rollup data in that could be read out. I can replace with normal non-deposit generated rollup transactions if you'd prefer.

Copy link
Collaborator

Choose a reason for hiding this comment

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

this is fine!

Copy link
Collaborator

@noot noot left a comment

Choose a reason for hiding this comment

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

looks good, main comment would be to use rand instead of the manual number generator for generating the test data - you can probably use all zeros/constant values for the test data except for the fields you need to vary (height, deposit info, etc)

@Lilyjjo Lilyjjo requested a review from noot April 3, 2024 19:02
// create inner rollup id/tx data
let mut deposits = HashMap::new();
for _ in 0..2 {
let rollup_id = RollupId::new([rng.gen(); 32]);
Copy link
Collaborator

Choose a reason for hiding this comment

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

just curious, can you do:

Suggested change
let rollup_id = RollupId::new([rng.gen(); 32]);
let rollup_id = RollupId::new(rng.gen());

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes you can! changed

Copy link
Collaborator

@noot noot left a comment

Choose a reason for hiding this comment

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

looks good!

@Lilyjjo Lilyjjo requested a review from Fraser999 as a code owner April 5, 2024 13:32
@Lilyjjo Lilyjjo force-pushed the lilyjjo/state-ext-unit-tests-7 branch from 275eff3 to 77cc50b Compare April 5, 2024 13:32
@Lilyjjo Lilyjjo enabled auto-merge April 5, 2024 13:32
@Lilyjjo Lilyjjo added this pull request to the merge queue Apr 5, 2024
Merged via the queue into main with commit 548a532 Apr 5, 2024
36 checks passed
@Lilyjjo Lilyjjo deleted the lilyjjo/state-ext-unit-tests-7 branch April 5, 2024 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sequencer pertaining to the astria-sequencer crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants