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

Add tests for Genesis Executor and Tasks #91

Merged
merged 0 commits into from
Aug 2, 2022

Conversation

MitchTurner
Copy link

@MitchTurner MitchTurner commented Jun 8, 2022

Part of #84

This adds some test coverage for the Genesis Executor and the associated Tasks.

Probably isn't complete coverage, but sets a good precedence and subsequent tests will help give a fuller coverage as well.

I was forced to abandon the exec_many_with_returning as it's not supported with sqlite::memory:.

This PR also includes some refactoring as a result of the above change.

@MitchTurner
Copy link
Author

My prop tests have run into some intermittent failures. Trying to isolate. There's a good chance they are caused by the test framework, not the tested code.

@MitchTurner
Copy link
Author

Mainnet tests are all failing with the error

Exec("error returned from database: too many SQL variables")

@MitchTurner MitchTurner marked this pull request as ready for review June 11, 2022 06:20
@MitchTurner
Copy link
Author

@SebastienGllmt LMK if there is something I can do to help get this over the line, or if you think I should go a different direction with this. I know it's a little beefy, so I can think of ways to make it more bite-sized if that would help.

insert_active_models(db_tx, active_models).await?;
let mut all_models = Vec::new();
for tx_id in tx_ids {
let models = <entity::prelude::Address as EntityTrait>::find()
Copy link
Contributor

@SebastienGllmt SebastienGllmt Aug 1, 2022

Choose a reason for hiding this comment

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

This approach will be significantly slower than what we had before. We purposely batch as many things as possible in a single DB request because otherwise the DB overhead gets to be really big

I'm not sure what benefit you were trying to achieve by putting them in a tight for loop. Was this purely to get around using exec_many_with_returning? Probably not worth slowing down just to avoid using this function

Copy link
Author

Choose a reason for hiding this comment

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

IIRC, the reason I was trying to avoid exec_many_with_returning was so I could use an in-memory DB, and, with SeaORM, you can only do in-memory with SQLite, which doesn't support returning.

I generally prioritize testibility over performance--I'd rather be confident in my code than have it be fast and wrong. The best solution here would be to decouple Carp from SeaORM entirely, so you can just inject a mock db.

Copy link
Author

Choose a reason for hiding this comment

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

Are operations on db_tx the same as making a "DB request"? It's the lookups that had to be iterated over here (without returning) but if they are just looking at what's in the local DatabaseTransaction rather doing a "DB request" for each, I think that might be fine performance-wise.

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.

2 participants