Skip to content

Commit

Permalink
test: add coverage for parsing cryptographically invalid pubkeys
Browse files Browse the repository at this point in the history
  • Loading branch information
theStack committed Feb 9, 2024
1 parent c740b15 commit 98570fe
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion test/functional/wallet_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,9 +461,11 @@ def run_test(self):
# This will raise an exception for attempting to import a pubkey that isn't in hex
assert_raises_rpc_error(-5, 'Pubkey "not hex" must be a hex string', self.nodes[0].importpubkey, "not hex")

# This will raise an exception for importing a pubkey with invalid length
# This will raise exceptions for importing a pubkeys with invalid length / invalid coordinates
too_short_pubkey = "5361746f736869204e616b616d6f746f"
assert_raises_rpc_error(-5, f'Pubkey "{too_short_pubkey}" must have a length of either 33 or 65 bytes', self.nodes[0].importpubkey, too_short_pubkey)
not_on_curve_pubkey = bytes([4] + [0]*64).hex() # pubkey with coordinates (0,0) is not on curve
assert_raises_rpc_error(-5, f'Pubkey "{not_on_curve_pubkey}" must be cryptographically valid', self.nodes[0].importpubkey, not_on_curve_pubkey)

# Bech32m addresses cannot be imported into a legacy wallet
assert_raises_rpc_error(-5, "Bech32m addresses cannot be imported into legacy wallets", self.nodes[0].importaddress, "bcrt1p0xlxvlhemja6c4dqv22uapctqupfhlxm9h8z3k2e72q4k9hcz7vqc8gma6")
Expand Down

0 comments on commit 98570fe

Please sign in to comment.