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 testutils and test-wallet features #412

Closed
wants to merge 2 commits into from

Conversation

notmandatory
Copy link
Member

Description

This PR creates two new feature flags, testutils to enable the testutils module, and test-wallet to enable the now exposed wallet::get_funded_wallet() function. Exposing the wallet::get_funded_wallet() function and moving the Wallet::network() function are needed to make testing easier for supporting projects like bdk-reserves without including this functionality in non-test builds.

Notes to the reviewers

All doctests should work with the new testutils feature without having this module exposed for non-test builds.

Checklists

All Submissions:

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

New Features:

  • I've added tests for the new feature
  • I've added docs for the new feature
  • I've updated CHANGELOG.md

Bugfixes:

  • This pull request breaks the existing API
  • I've added tests to reproduce the issue which are now passing
  • I'm linking the issue being fixed by this PR

@notmandatory
Copy link
Member Author

@LLFourn I found another way here to add the testutils feature back in using bdk as it's own dev dependency. Too hacky? seem to work for doc tests and I don't see any down sides.

@LLFourn
Copy link
Contributor

LLFourn commented Jul 29, 2021

@notmandatory 🤯 . Did you get that idea from somewhere? can we not just add testutils as a default feature I guess then it will be available during doctests I guess?

@notmandatory
Copy link
Member Author

It probably would work as a default feature but then anyone using BDK as a normal dependency would need to set no-default features or end with the unwanted 'testutils'. I ran across this in a old rustc bug where adding a crate as a test dep of itself used to panicked the compiler. But issue got fixed and seems to be supported.

@notmandatory
Copy link
Member Author

This is the issue comment that gave me the idea:

rust-lang/cargo#2911 (comment)

@LLFourn
Copy link
Contributor

LLFourn commented Jul 30, 2021

They seem to say it doesn't work in that the hack enables it for non-dev as well: rust-lang/cargo#2911 (comment)

In rust you only pay for what you use so there is no real harm in not having it under a feature flag or as a default feature flag. My personal preference is to leave without and wait until rust-lang/rust#67295 and rust-lang/cargo#2911 are fixed.

@notmandatory
Copy link
Member Author

Ok ya I read through a few more related issues and looks like this is a hack that will soon not be supported and as you said probably isn't doing what I think it is.

Closing this PR.

@notmandatory notmandatory deleted the test_features branch September 16, 2021 20:14
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.

3 participants