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

[bug-fix] Set the sync time in populate test db. #717

Closed
wants to merge 1 commit into from

Conversation

rajarshimaitra
Copy link
Contributor

@rajarshimaitra rajarshimaitra commented Aug 14, 2022

Description

After recent changes in balance calculation, the get_funded_wallet test function will not show any balance because we are not setting the sync_time in the populate_test_db macro..

Our existing tests are not failing, because even if the balance is shown zero, it will still be able to produce transactions. But its causing test failure in downstream bdk-reserves crate where the balances are required to assert scenarios.

Notes to the reviewers

This will be replayed in #624 too, as this function is being refactored there.. For now opening it as separate PR for quick merge.

Checklists

All Submissions:

  • I've signed all my commits
  • I followed the contribution guidelines
  • I ran cargo fmt and cargo clippy before committing

Bugfixes:

  • I've added tests to reproduce the issue which are now passing

This allows to retrieve the right wallet balance. Or else it will just
assume the wallet db is never synced.

Add a test to confirm behavior.
@rajarshimaitra
Copy link
Contributor Author

rajarshimaitra commented Aug 14, 2022

This is becoming a more intrusive change than I previously thought.. There are test cases thats working on the assumption that sync height is never set, even when populate_test_db is taking in current height as Some(100).. Also the current populate_test_db cannot handle None values without further changes..

I am trying next to replay the fix on top of #624.. I think that will reduce the review effort, as all these functions are refactored there anyway.. And its not a major bug, so can wait for sometime, if the fix isn't just few lines anymore..

More suggestions welcome in the mean time..

Idea: The other way of fixing this bug is, do not check for sync time at get_balance(), just give a balance back if there's unspent outputs, which I think what was the case pre v0.21.

@rajarshimaitra
Copy link
Contributor Author

Closing this in favor of #624 where the full fix is included..

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.

1 participant