當前位置: 首頁>>代碼示例>>Python>>正文


Python Web3.toInt方法代碼示例

本文整理匯總了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
開發者ID:miohtama,項目名稱:web3.py,代碼行數:19,代碼來源:test_accounts.py

示例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
開發者ID:miohtama,項目名稱:web3.py,代碼行數:4,代碼來源:test_conversions.py

示例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
開發者ID:miohtama,項目名稱:web3.py,代碼行數:8,代碼來源:test_conversions.py


注:本文中的web3.Web3.toInt方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。