def test_newchain_account_sign(acct, message, key, expected_bytes,
                               expected_hash, v, r, s, signature):
    msghash = defunct_hash_message(text=message)
    assert msghash == expected_hash
    signed = acct.signHash(msghash, private_key=key)
    assert signed.messageHash == expected_hash
    assert signed.v == v
    assert signed.r == r
    assert signed.s == s
    assert signed.signature == signature

    account = acct.privateKeyToAccount(key)
    msghash = defunct_hash_message(text=message)
    assert account.signHash(msghash) == signed
def test_eth_account_recover_message(acct):
    v, r, s = (
        28,
        '0xe6ca9bba58c88611fad66a6ce8f996908195593807c4b38bd528d2cff09d4eb3',
        '0x3e5bfbbf4d3e39b1a2fd816a7680c19ebebaf3a141b239934ad43cb33fcec8ce',
    )
    message = "I♥SF"
    message_hash = defunct_hash_message(text=message)
    from_account = acct.recoverHash(message_hash, vrs=(v, r, s))
    assert from_account == '0x5ce9454909639D2D17A3F753ce7d93fa0b9aB12E'
def test_newchain_account_hash_message_hexstr(acct, message, expected):
    assert defunct_hash_message(hexstr=message) == expected
def test_newchain_account_hash_message_text(message, expected):
    assert defunct_hash_message(text=message) == expected