本文整理汇总了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))
示例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
示例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)
示例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]
示例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