def test_sign_and_recover_message(): """Test the signing and the recovery function for the eth_crypto.""" account = EthereumCrypto(PRIVATE_KEY_PATH) sign_bytes = account.sign_message(message=b"hello") assert len(sign_bytes) > 0, "The len(signature) must not be 0" recovered_addr = account.recover_message(message=b"hello", signature=sign_bytes) assert recovered_addr == account.address, "Failed to recover the correct address."
def test_sign_and_recover_message(): """Test the signing and the recovery function for the eth_crypto.""" account = EthereumCrypto(ETHEREUM_PRIVATE_KEY_PATH) sign_bytes = account.sign_message(message=b"hello") assert len(sign_bytes) > 0, "The len(signature) must not be 0" recovered_addresses = account.recover_message(message=b"hello", signature=sign_bytes) assert len( recovered_addresses) == 1, "Wrong number of addresses recovered." assert (recovered_addresses[0] == account.address ), "Failed to recover the correct address."
def test_sign_and_recover_message_deprecated(): """Test the signing and the recovery function for the eth_crypto.""" account = EthereumCrypto(ETHEREUM_PRIVATE_KEY_PATH) message = b"hello" message_hash = hashlib.sha256(message).digest() sign_bytes = account.sign_message(message=message_hash, is_deprecated_mode=True) assert len(sign_bytes) > 0, "The len(signature) must not be 0" recovered_addresses = account.recover_message(message=message_hash, signature=sign_bytes, is_deprecated_mode=True) assert len( recovered_addresses) == 1, "Wrong number of addresses recovered." assert (recovered_addresses[0] == account.address ), "Failed to recover the correct address."