Skip to content

Commit

Permalink
Update tests after changing minimum depth for public derivation.
Browse files Browse the repository at this point in the history
  • Loading branch information
ebellocchia committed Apr 11, 2020
1 parent 2425b78 commit 2646e16
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 26 deletions.
13 changes: 5 additions & 8 deletions tests/test_bip44.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,10 +329,10 @@
"ex_priv_5" : "xprvA47LQAPDXEkr9wwtUHNta4qWqiobTGKppzVy5JZVCszLdGTTQbuRxRMCJGqSdBg91M13Z2RTP2BKU5yDD41WFwZ7yavhhbCEs7cTnyvkxJV",
# Private key with depth 6 shall raise an exception
"ex_priv_6" : "xprvA69uJSR3uVgvYFM5AFabGnMuAvtdLrbm84CwEieMBbk5Kjk9ZGeYPF4AWuJ9EPBzC8pLn117Y6TFqgNKZ6EVKmoDxT4EjT1BaG3RhWL6wdF",
# Public key with depth 2 shall raise an exception
"ex_pub_2" : "xpub6AmukNpN4yyLgyzSysjU6JqqoYA1mVUvtinHYdBGPDppatJXHxT8CcDsmBo9n3yLBgrcw9z62ygt1siT9xai4UaJ2w4FPmY6kPCF96YN2cF",
# Public key with depth 3 shall raise an exception
"ex_pub_3" : "xpub6BosfCnifzxcFwrSzQiqu2DBVTshkCXacvNsWGYJVVhhawA7d4R5WSWGFNbi8Aw6ZRc1brxMyWMzG3DSSSSoekkudhUd9yLb6qx39T9nMdj",
# Public key with depth 4 is fine
"ex_pub_4" : "xpub6ELHKXNimKbxMCytPh7EdC2QXx46T9qLDJWGnTraz1H9kMMFdcduoU69wh9cxP12wDxqAAfbaESWGYt5rREsX1J8iR2TEunvzvddduAPYcY",
# Public key with depth 5 is fine
"ex_pub_5" : "xpub6Fbrwk4KhC8qnFVXTcR3wRsqiTGkedcSSZKyTqKaxXjFN6rZv3UJYZ4mQtjNYY3gCa181iCHSBWyWst2PFiXBKgLpFVSdcyLbHyAahin8pd",
# Public key with depth 6 shall raise an exception
Expand Down Expand Up @@ -422,9 +422,6 @@ def test_vector_from_exkey(self):
self.assertEqual(test["account"]["ex_pub"] , bip_obj_ctx.PublicKey())
self.assertEqual(test["account"]["ex_priv"], bip_obj_ctx.PrivateKey())

# It shall trigger an exception if created from account public key
self.assertRaises(Bip44DepthError, Bip44.FromExtendedKey, test["account"]["ex_pub"], test["coin"])

# Create from private change key
bip_obj_ctx = Bip44.FromExtendedKey(test["chain_ext"]["ex_priv"], test["coin"])
# Test external chain keys
Expand All @@ -433,7 +430,7 @@ def test_vector_from_exkey(self):
self.assertEqual(test["chain_ext"]["ex_pub"] , bip_obj_ctx.PublicKey())
self.assertEqual(test["chain_ext"]["ex_priv"], bip_obj_ctx.PrivateKey())

# Create from public change key is fine
# Create from public change key
bip_obj_ctx = Bip44.FromExtendedKey(test["chain_ext"]["ex_pub"], test["coin"])
self.assertTrue(bip_obj_ctx.IsPublicOnly())
self.assertTrue(bip_obj_ctx.IsChangeLevel())
Expand Down Expand Up @@ -467,9 +464,9 @@ def test_from_exkey_depth(self):
self.assertRaises(Bip44DepthError, Bip44.FromExtendedKey, test_data["ex_priv_6"], Bip44Coins.BITCOIN)

# Public key with depth 3 shall raise exception
self.assertRaises(Bip44DepthError, Bip44.FromExtendedKey, test_data["ex_pub_3"], Bip44Coins.BITCOIN)
self.assertRaises(Bip44DepthError, Bip44.FromExtendedKey, test_data["ex_pub_2"], Bip44Coins.BITCOIN)
# Public key with depth 4 or 5 shall not raise exception
Bip44.FromExtendedKey(test_data["ex_pub_4"], Bip44Coins.BITCOIN)
Bip44.FromExtendedKey(test_data["ex_pub_3"], Bip44Coins.BITCOIN)
Bip44.FromExtendedKey(test_data["ex_pub_5"], Bip44Coins.BITCOIN)
# Public key with depth 6 shall raise exception
self.assertRaises(Bip44DepthError, Bip44.FromExtendedKey, test_data["ex_pub_6"], Bip44Coins.BITCOIN)
Expand Down
15 changes: 6 additions & 9 deletions tests/test_bip49.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,10 +293,10 @@
"ex_priv_5" : "yprvANXJmbMRf4r2NVPx9K5sDCnhND9fjZqWtBthvRJrN2XCU7H9KJmMLP2LnsgLbhdoaNcD89Fw7zktymVkW6eVcX9MKHpeAkEd94Hm9nWKWVw",
# Private key with depth 6 shall raise an exception
"ex_priv_6" : "yprvAQyUkCuvz2wzk4dUqEyQFXe4sUeEkCSnmz13PAxrNQZrorMkkAw8yVaBcQU3MUp17y9NSYn1ugT6QdETtS85GCsxUi33EVk1EynV37De7V5",
# Public key with depth 3 shall raise an exception
# Public key with depth 2 shall raise an exception
"ex_pub_2" : "ypub6VVTyCM8KkwKjEfeUaygfZCPb3Xxx7DfhCFRndbDREZfWkQg5Q5p3pHMDCoiTfPKwejRBnbhr4SocDthWYoJv4VU1Xfje7FE7sERi3CsDRt",
# Public key with depth 3 is fine
"ex_pub_3" : "ypub6Ww3ibxVfGzLrAH1PNcjyAWenMTbbAosGNB6VvmSEgytSER9azLDWCxoJwW7Ke7icmizBMXrzBx9979FfaHxHcrArf3zbeJJJUZPf663zsP",
# Public key with depth 4 is fine
"ex_pub_4" : "ypub6Ynvx7RLNYgWzFGM8aeU43hFNjTh7u5Grrup7Ryu2nKZ1Y8FWKaJZXiUrkJSnMmGVNBoVH1DNDtQ32tR4YFDRSpSUXjjvsiMnCvoPHVWXJP",
# Public key with depth 5 is fine
"ex_pub_5" : "ypub6bWfB6tKVSQKayURFLcsaLjRvEzA92ZNFQpJioiTvN4BLucHrr5btBLpeBDjuV2mGb2wXWL1taoBNWf9xNgjHrPWkhSxxfrDGiciopL6N6E",
# Public key with depth 6 shall raise an exception
Expand Down Expand Up @@ -396,9 +396,6 @@ def test_vector_from_exkey(self):
self.assertEqual(test["account"]["ex_pub"] , bip_obj_ctx.PublicKey())
self.assertEqual(test["account"]["ex_priv"], bip_obj_ctx.PrivateKey())

# It shall trigger an exception if created from account public key
self.assertRaises(Bip44DepthError, Bip49.FromExtendedKey, test["account"]["ex_pub"], test["coin"])

# Create from private change key
bip_obj_ctx = Bip49.FromExtendedKey(test["chain_ext"]["ex_priv"], test["coin"])
# Test external chain keys
Expand All @@ -407,7 +404,7 @@ def test_vector_from_exkey(self):
self.assertEqual(test["chain_ext"]["ex_pub"] , bip_obj_ctx.PublicKey())
self.assertEqual(test["chain_ext"]["ex_priv"], bip_obj_ctx.PrivateKey())

# Create from public change key is fine
# Create from public change key
bip_obj_ctx = Bip49.FromExtendedKey(test["chain_ext"]["ex_pub"], test["coin"])
self.assertTrue(bip_obj_ctx.IsPublicOnly())
self.assertTrue(bip_obj_ctx.IsChangeLevel())
Expand Down Expand Up @@ -441,9 +438,9 @@ def test_from_exkey_depth(self):
self.assertRaises(Bip44DepthError, Bip49.FromExtendedKey, test_data["ex_priv_6"], Bip44Coins.BITCOIN)

# Public key with depth 3 shall raise exception
self.assertRaises(Bip44DepthError, Bip49.FromExtendedKey, test_data["ex_pub_3"], Bip44Coins.BITCOIN)
self.assertRaises(Bip44DepthError, Bip49.FromExtendedKey, test_data["ex_pub_2"], Bip44Coins.BITCOIN)
# Public key with depth 4 or 5 shall not raise exception
Bip49.FromExtendedKey(test_data["ex_pub_4"], Bip44Coins.BITCOIN)
Bip49.FromExtendedKey(test_data["ex_pub_3"], Bip44Coins.BITCOIN)
Bip49.FromExtendedKey(test_data["ex_pub_5"], Bip44Coins.BITCOIN)
# Public key with depth 6 shall raise exception
self.assertRaises(Bip44DepthError, Bip49.FromExtendedKey, test_data["ex_pub_6"], Bip44Coins.BITCOIN)
Expand Down
15 changes: 6 additions & 9 deletions tests/test_bip84.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,10 @@
"ex_priv_5" : "zprvAgXNdrVSkvLM5GpuHWL9EoqfiXCvpL8DufMAbQiyFa1RTqmqs9PMdR7dHXCqYMZnmVReq6KSPwysULotdZYhYry6BejgKdtNrEnKx91CGBP",
# Private key with depth 6 shall raise an exception
"ex_priv_6" : "zprvAjPYgsh8YN3eo99YLw2mPCHbu3aeGiBsotM7nYANpFss5oHg7P9a6VcVC6K5WdWf3ids32M54srqqiizzNWzUGmEWW5snNEBJopzRUTHtQD",
# Public key with depth 3 shall raise an exception
# Public key with depth 2 shall raise an exception
"ex_pub_2" : "zpub6pNAXMNU74t5ERmvhYL68oqmkaRKPPFucgE6Vrd7Q11N712u3EFZ3X18MY9LsL48ySz5fTaetHhpft2bsPDtxK97HnnKkzR2ES2qB69sCPf",
# Public key with depth 3 is fine
"ex_pub_3" : "zpub6rFR7y4Q2AijBEqTUquhVz398htDFrtymD9xYYfG1m4wAcvPhXNfE3EfH1r1ADqtfSdVCToUG868RvUUkgDKf31mGDtKsAYz2oz2AGutZYs",
# Public key with depth 4 is fine
"ex_pub_4" : "zpub6u4KbU8TSgNuZSxzv7HaGq5Tk361gMHdZxnM4UYuwzg5CMLcNytzhobitV4Zq6vWtWHpG9QijsigkxAzXvQWyLRfLq1L7VxPP1tky1hPfD4",
# Public key with depth 5 is fine
"ex_pub_5" : "zpub6uWj3N2LbHteHkuNPXs9bwnQGZ3RDnr5GtGmPo8aouYQLe6zQghcBDS78p221mbYb5eVgviZ2mEkdgMvLfSmvzsSe6nMYVaALaL6rZ9pTbq",
# Public key with depth 6 shall raise an exception
Expand Down Expand Up @@ -232,9 +232,6 @@ def test_vector_from_exkey(self):
self.assertEqual(test["account"]["ex_pub"] , bip_obj_ctx.PublicKey())
self.assertEqual(test["account"]["ex_priv"], bip_obj_ctx.PrivateKey())

# It shall trigger an exception if created from account public key
self.assertRaises(Bip44DepthError, Bip84.FromExtendedKey, test["account"]["ex_pub"], test["coin"])

# Create from private change key
bip_obj_ctx = Bip84.FromExtendedKey(test["chain_ext"]["ex_priv"], test["coin"])
# Test external chain keys
Expand All @@ -243,7 +240,7 @@ def test_vector_from_exkey(self):
self.assertEqual(test["chain_ext"]["ex_pub"] , bip_obj_ctx.PublicKey())
self.assertEqual(test["chain_ext"]["ex_priv"], bip_obj_ctx.PrivateKey())

# Create from public change key is fine
# Create from public change key
bip_obj_ctx = Bip84.FromExtendedKey(test["chain_ext"]["ex_pub"], test["coin"])
self.assertTrue(bip_obj_ctx.IsPublicOnly())
self.assertTrue(bip_obj_ctx.IsChangeLevel())
Expand Down Expand Up @@ -277,9 +274,9 @@ def test_from_exkey_depth(self):
self.assertRaises(Bip44DepthError, Bip84.FromExtendedKey, test_data["ex_priv_6"], Bip44Coins.BITCOIN)

# Public key with depth 3 shall raise exception
self.assertRaises(Bip44DepthError, Bip84.FromExtendedKey, test_data["ex_pub_3"], Bip44Coins.BITCOIN)
self.assertRaises(Bip44DepthError, Bip84.FromExtendedKey, test_data["ex_pub_2"], Bip44Coins.BITCOIN)
# Public key with depth 4 or 5 shall not raise exception
Bip84.FromExtendedKey(test_data["ex_pub_4"], Bip44Coins.BITCOIN)
Bip84.FromExtendedKey(test_data["ex_pub_3"], Bip44Coins.BITCOIN)
Bip84.FromExtendedKey(test_data["ex_pub_5"], Bip44Coins.BITCOIN)
# Public key with depth 6 shall raise exception
self.assertRaises(Bip44DepthError, Bip84.FromExtendedKey, test_data["ex_pub_6"], Bip44Coins.BITCOIN)
Expand Down

0 comments on commit 2646e16

Please sign in to comment.