test_transaction_signature_validation.py 文件源码

python
阅读 31 收藏 0 点赞 0 评论 0

项目:py-evm 作者: ethereum 项目源码 文件源码
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']
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号