From 01aa68309d75c61aacdc6b6f4b5c59ca6e5110b2 Mon Sep 17 00:00:00 2001 From: Aleksey Covacevice Date: Fri, 8 Oct 2021 16:21:11 -0300 Subject: [PATCH] Add a testcase for xpub derivation --- tests/test_from_xpublic_key.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/test_from_xpublic_key.py b/tests/test_from_xpublic_key.py index d8b9055..b022595 100644 --- a/tests/test_from_xpublic_key.py +++ b/tests/test_from_xpublic_key.py @@ -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__) @@ -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()