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


Python rlp.sedes方法代碼示例

本文整理匯總了Python中rlp.sedes方法的典型用法代碼示例。如果您正苦於以下問題:Python rlp.sedes方法的具體用法?Python rlp.sedes怎麽用?Python rlp.sedes使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在rlp的用法示例。


在下文中一共展示了rlp.sedes方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: main

# 需要導入模塊: import rlp [as 別名]
# 或者: from rlp import sedes [as 別名]
def main(rounds=10000):
    st = time.time()
    d = do_test_serialize(mk_block(), rounds)
    elapsed = time.time() - st
    print('Block serializations / sec: %.2f' % (rounds / elapsed))

    st = time.time()
    d = do_test_deserialize(d, rounds)
    elapsed = time.time() - st
    print('Block deserializations / sec: %.2f' % (rounds / elapsed))

    st = time.time()
    d = do_test_serialize(mk_transaction(), rounds)
    elapsed = time.time() - st
    print('TX serializations / sec: %.2f' % (rounds / elapsed))

    st = time.time()
    d = do_test_deserialize(d, rounds, sedes=Transaction)
    elapsed = time.time() - st
    print('TX deserializations / sec: %.2f' % (rounds / elapsed)) 
開發者ID:ethereum,項目名稱:pyrlp,代碼行數:22,代碼來源:speed.py

示例2: gen_header

# 需要導入模塊: import rlp [as 別名]
# 或者: from rlp import sedes [as 別名]
def gen_header(testcases):
    header = f'''"""DO NOT MODIFY: Tests generated from `tests/` with {sys.argv[0]}"""
import unittest
from binascii import unhexlify
from manticore import ManticoreEVM, Plugin
from manticore.utils import config
'''

    if any("logs" in testcase for testcase in testcases.values()):
        body += """
import sha3
import rlp
from rlp.sedes import (
    CountableList,
    BigEndianInt,
    Binary,
)
class Log(rlp.Serializable):
    fields = [
        ('address', Binary.fixed_length(20, allow_empty=True)),
        ('topics', CountableList(BigEndianInt(32))),
        ('data', Binary())
    ]
"""

    header += """consts = config.get_group('core')
consts.mprocessing = consts.mprocessing.single
consts = config.get_group('evm')
consts.oog = 'pedantic'

class EVMTest(unittest.TestCase):
    # https://nose.readthedocs.io/en/latest/doc_tests/test_multiprocess/multiprocess.html#controlling-distribution
    _multiprocess_can_split_ = True
    # https://docs.python.org/3.7/library/unittest.html#unittest.TestCase.maxDiff
    maxDiff = None

"""
    return header 
開發者ID:trailofbits,項目名稱:manticore,代碼行數:40,代碼來源:make_VMTests.py

示例3: from_base_transaction

# 需要導入模塊: import rlp [as 別名]
# 或者: from rlp import sedes [as 別名]
def from_base_transaction(cls, transaction: SignedTransactionAPI) -> SignedTransactionAPI:
        return rlp.decode(rlp.encode(transaction), sedes=cls) 
開發者ID:ethereum,項目名稱:py-evm,代碼行數:4,代碼來源:transactions.py

示例4: test_evaluation_of_lazy_decode_with_list_sedes_and_invalid_value

# 需要導入模塊: import rlp [as 別名]
# 或者: from rlp import sedes [as 別名]
def test_evaluation_of_lazy_decode_with_list_sedes_and_invalid_value():
    sedes = CountableList(big_endian_int)
    value = [(), (1, 2), b'asdf', (3)]
    invalid_lazy = rlp.decode_lazy(rlp.encode(value), sedes)
    assert invalid_lazy[0] == value[0]
    assert invalid_lazy[1] == value[1]
    with pytest.raises(DeserializationError):
        invalid_lazy[2] 
開發者ID:ethereum,項目名稱:pyrlp,代碼行數:10,代碼來源:test_lazy.py

示例5: do_test_deserialize

# 需要導入模塊: import rlp [as 別名]
# 或者: from rlp import sedes [as 別名]
def do_test_deserialize(data, rounds=100, sedes=Block):
    for i in range(rounds):
        x = rlp.decode(data, sedes)
    return x 
開發者ID:ethereum,項目名稱:pyrlp,代碼行數:6,代碼來源:speed.py


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