Skip to content

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

Closed
rajarshimaitra wants to merge 1 commit into
bitcoindevkit:masterfrom
rajarshimaitra:bug-fix
Closed

[bug-fix] Set the sync time in populate test db.#717
rajarshimaitra wants to merge 1 commit into
bitcoindevkit:masterfrom
rajarshimaitra:bug-fix

Conversation

@rajarshimaitra

@rajarshimaitra rajarshimaitra commented Aug 14, 2022

Copy link
Copy Markdown
Contributor

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

rajarshimaitra commented Aug 14, 2022

Copy link
Copy Markdown
Contributor Author

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
Copy Markdown
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