本文整理汇总了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