def test_unsigned_to_eip155_signed_transaction(txn_fixture, transaction_class):
if txn_fixture['chainId'] is None:
pytest.skip('No chain id for EIP155 signing')
elif not hasattr(transaction_class, 'chain_id'):
pytest.skip('Transaction class is not chain aware')
key = keys.PrivateKey(decode_hex(txn_fixture['key']))
unsigned_txn = transaction_class.create_unsigned_transaction(
nonce=txn_fixture['nonce'],
gas_price=txn_fixture['gasPrice'],
gas=txn_fixture['gas'],
to=(
to_canonical_address(txn_fixture['to'])
if txn_fixture['to']
else b''
),
value=txn_fixture['value'],
data=decode_hex(txn_fixture['data']),
)
signed_txn = unsigned_txn.as_signed_transaction(key, chain_id=txn_fixture['chainId'])
assert is_same_address(signed_txn.sender, key.public_key.to_canonical_address())
assert signed_txn.chain_id == txn_fixture['chainId']
test_transaction_signature_validation.py 文件源码
python
阅读 31
收藏 0
点赞 0
评论 0
评论列表
文章目录