Skip to content

Commit

Permalink
Add a testcase for xpub derivation
Browse files Browse the repository at this point in the history
  • Loading branch information
alecov committed Oct 8, 2021
1 parent b8ce968 commit 01aa683
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tests/test_from_xpublic_key.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import os

from hdwallet import HDWallet
from hdwallet.utils import generate_entropy

# Test Values
base_path: str = os.path.dirname(__file__)
Expand Down Expand Up @@ -81,3 +82,11 @@ def test_from_xpublic_key():
del dumps["xpublic_key_hex"]

assert hdwallet.dumps() == dumps

def test_derivation_from_xpublic_key():
hdwallet: HDWallet = HDWallet().from_entropy(generate_entropy())
wallet1: HDWallet = hdwallet.from_path("m/1'/2'/3'")
xpub: str = wallet1.xpublic_key()
wallet2: HDWallet = HDWallet().from_xpublic_key(xpub)
assert wallet1.xpublic_key() == wallet2.xpublic_key()
assert wallet1.from_path("m/1/2/3").xpublic_key() == wallet2.from_path("m/1/2/3").xpublic_key()

0 comments on commit 01aa683

Please sign in to comment.