-
Notifications
You must be signed in to change notification settings - Fork 122
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 unit test for method ExternalKey.PubKey #1284
Conversation
Need a BIP86 xpub and master fingerprint. I don't think it's possible with https://iancoleman.io/bip39/ ? |
We can get a real BIP86 xpub set from the chantools itest:
But we need for mainnet also. Not just regtest. |
Pull Request Test Coverage Report for Build 12809434712Details
💛 - Coveralls |
The base branch has not been merged yet. To avoid merging this PR prematurely, I will keep it in draft status. However, @ziggie1984, it is ready for review. |
Note also this comment from starius (from #1286):
|
e61d638
to
c0c6795
Compare
c425baf
to
94d8eba
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🎉
asset/asset_test.go
Outdated
testCases := []struct { | ||
name string | ||
externalKey ExternalKey | ||
expectError bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: seems like there's no need for this bool
, we can just expect an error if the expectedError
is not empty.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using the expectError
bool flag we can specify that we expect an error without having to specify the error message. So I see it as optionality that we might as well keep. Let me know if you feel strongly about this and I can change as you suggest.
t.Run(tc.name, func(tt *testing.T) { | ||
pubKey, err := tc.externalKey.PubKey() | ||
|
||
if tc.expectError { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: if tx.expectedError != ""
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice not to have to specify the error message IMO, #1284 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, tho I would say this change is so low level it almost feels it should be put into its own package, at least the taproot key generation tests.
c0c6795
to
5299e8b
Compare
94d8eba
to
f5d4327
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lgtm ✔️
-- pending comments by @bhandras
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tho I would say this change is so low level it almost feels it should be put into its own package
Would agree with this. This PR should be to the btcutil
repo. It adds more tests to routines defined in the hdkeychain
package.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🍐
Moved to draft to avoid accidental merging before cold-group-key branch is merged. |
5299e8b
to
49c2141
Compare
Needs rebase. |
49c2141
to
c4a9222
Compare
@ffranr shouldn't we just merge this, since it goes into the |
c4a9222
to
b801f9f
Compare
At this point, |
b801f9f
to
5ca4168
Compare
Changed the base branch to |
This commit introduces a comprehensive unit test for the `PubKey` method of the `ExternalKey` struct. The test covers various scenarios, including valid and invalid derivation paths, ensuring the method's correctness and error handling.
Added more derivation paths and corresponding public keys, check in the test that the values returned by the method match to expected values. Also added tpub (testnet xpub). To run "chantools derivekey" with xpubs, use PR lightninglabs/chantools#179
f5d4327
to
cba1ca7
Compare
This PR introduces a comprehensive unit test for the
PubKey
method of theExternalKey
struct. The test covers various scenarios, including valid and invalid derivation paths, ensuring the method's correctness and error handling.Notes for Reviewers
This PR depends on #1272 . This PR should be merged after #1272 has been merged. I will keep in draft until #1272 is merged.