本文整理匯總了Python中web3.Web3.toInt方法的典型用法代碼示例。如果您正苦於以下問題:Python Web3.toInt方法的具體用法?Python Web3.toInt怎麽用?Python Web3.toInt使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類web3.Web3
的用法示例。
在下文中一共展示了Web3.toInt方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_eth_account_sign_transaction_from_eth_test
# 需要導入模塊: from web3 import Web3 [as 別名]
# 或者: from web3.Web3 import toInt [as 別名]
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
示例2: test_to_int_hexstr
# 需要導入模塊: from web3 import Web3 [as 別名]
# 或者: from web3.Web3 import toInt [as 別名]
def test_to_int_hexstr(val, expected):
assert Web3.toInt(hexstr=val) == expected
示例3: test_to_int_text
# 需要導入模塊: from web3 import Web3 [as 別名]
# 或者: from web3.Web3 import toInt [as 別名]
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