示例#1
0
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."
示例#2
0
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 = EthereumApi.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."
示例#3
0
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 = EthereumApi.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."
示例#4
0
def test_sign_message():
    """Test the signing function for the eth_crypto."""
    account = EthereumCrypto(PRIVATE_KEY_PATH)
    sign_bytes = account.sign_message('Hello')
    assert len(sign_bytes) > 0, "The len(signature) must not be 0"