test_channels.py 文件源码

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

项目:two1-python 作者: 21dotco 项目源码 文件源码
def test_status_close_channel():
    """Test ability to get a channel's status and close it."""
    channel_server._db = DatabaseSQLite3(':memory:', db_dir='')
    test_client = _create_client_txs()

    # Test that channel close fails when no channel exists
    with pytest.raises(PaymentChannelNotFoundError):
        channel_server.close('fake', BAD_SIGNATURE)

    # Open the channel and make a payment
    deposit_txid = channel_server.open(test_client.deposit_tx, test_client.redeem_script)
    payment_txid = channel_server.receive_payment(deposit_txid, test_client.payment_tx)
    channel_server.redeem(payment_txid)

    # Test that channel close fails without a valid signature
    with pytest.raises(TransactionVerificationError):
        closed = channel_server.close(deposit_txid, BAD_SIGNATURE)

    # Test that channel close succeeds
    good_signature = codecs.encode(cust_wallet._private_key.sign(deposit_txid).to_der(), 'hex_codec')
    closed = channel_server.close(deposit_txid, good_signature)
    assert closed
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号