def test_eth_account_sign_transaction_from_eth_test(acct, transaction_info): expected_raw_txn = transaction_info['signed'] key = transaction_info['key'] transaction = dissoc(transaction_info, 'signed', 'key', 'unsigned') # validate r, in order to validate the transaction hash # There is some ambiguity about whether `r` will always be deterministically # generated from the transaction hash and private key, mostly due to code # author's ignorance. The example test fixtures and implementations seem to agree, so far. # See ecdsa_raw_sign() in /eth_keys/backends/native/ecdsa.py signed = acct.signTransaction(transaction, key) assert signed.r == Web3.toInt(hexstr=expected_raw_txn[-130:-66]) # confirm that signed transaction can be recovered to the sender expected_sender = acct.privateKeyToAccount(key).address assert acct.recoverTransaction(signed.rawTransaction) == expected_sender
def test_to_int_hexstr(val, expected): assert Web3.toInt(hexstr=val) == expected
def test_to_int_text(val, expected): if isinstance(expected, type): with pytest.raises(expected): Web3.toInt(text=val) else: assert Web3.toInt(text=val) == expected