Exemplo n.º 1
0
def test_payment_sent_getters():
    payment_preimage = PaymentPreimage(get_random_bytes(32))
    event = Event.payment_sent(payment_preimage)

    assert event.payment_preimage == payment_preimage

    # Check no other getters are available
    local_attributes = ["payment_preimage"]
    check_not_available_getters(event, local_attributes, all_attributes)
Exemplo n.º 2
0
def test_commitment_tx_broadcasted_getters():
    outpoint = OutPoint.from_bytes(get_random_bytes(34))
    event = MonitorEvent.commitment_tx_broadcasted(outpoint)

    assert event.type == "CommitmentTxBroadcasted"
    assert event.outpoint == outpoint

    # Check no other getters are available
    check_not_available_getters(event, ["outpoint"], all_attributes)
Exemplo n.º 3
0
def test_htlc_event_getters(htlc_update_data):
    htlc_update = HTLCUpdate.from_bytes(htlc_update_data)
    event = MonitorEvent.htlc_event(htlc_update)

    assert event.type == "HTLCEvent"
    assert event.htlc_update.serialize() == htlc_update_data

    # Check no other getters are available
    check_not_available_getters(event, ["htlc_update"], all_attributes)
Exemplo n.º 4
0
def test_funding_broadcasting_safe_getters():
    outpoint = OutPoint.from_bytes(get_random_bytes(34))
    user_channel_id = get_random_int(8)
    event = Event.funding_broadcasting_safe(outpoint, user_channel_id)

    assert event.funding_txo == outpoint
    assert event.user_channel_id == user_channel_id

    # Check no other getters are available
    local_attributes = ["funding_txo", "user_channel_id"]
    check_not_available_getters(event, local_attributes, all_attributes)
Exemplo n.º 5
0
def test_payment_failed_getters():
    payment_hash = PaymentHash(get_random_bytes(32))
    rejected_by_dest = True
    event = Event.payment_failed(payment_hash, rejected_by_dest)

    assert event.payment_hash == payment_hash
    assert event.rejected_by_dest == rejected_by_dest

    # Check no other getters are available
    local_attributes = ["payment_hash", "rejected_by_dest"]
    check_not_available_getters(event, local_attributes, all_attributes)
Exemplo n.º 6
0
def test_static_output_getters():
    outpoint = OutPoint.from_bytes(get_random_bytes(34))
    txout = TxOut(get_random_int(8), Script(get_random_bytes(30)))
    descriptor = SpendableOutputDescriptor.static_output(outpoint, txout)

    assert descriptor.outpoint == outpoint
    assert descriptor.output == txout

    # Check no other getters are available
    local_attributes = ["outpoint", "output"]

    check_not_available_getters(descriptor, local_attributes, all_attributes)
Exemplo n.º 7
0
def test_payment_received_getters():
    payment_hash = PaymentHash(get_random_bytes(32))
    payment_secret = None
    amt = get_random_int(8)
    event = Event.payment_received(payment_hash, payment_secret, amt)

    assert event.payment_hash == payment_hash
    assert event.payment_secret == payment_secret
    assert event.amt == amt

    # Check no other getters are available
    local_attributes = ["payment_hash", "payment_secret", "amt"]
    check_not_available_getters(event, local_attributes, all_attributes)
Exemplo n.º 8
0
def test_pending_htlcs_forwardable():
    secs = get_random_int(8)
    nanos = get_random_int(4)

    # Make sure nanos does not go all the way to seconds
    while nanos > 100000000:
        secs = +1
        nanos -= 100000000

    event = Event.pending_htlcs_forwardable(secs, nanos)
    assert event.time_forwardable == (secs, nanos)

    # Check no other getters are available
    local_attributes = ["time_forwardable"]
    check_not_available_getters(event, local_attributes, all_attributes)
Exemplo n.º 9
0
def test_static_output_counterparty_payment_getters():
    outpoint = OutPoint.from_bytes(get_random_bytes(34))
    txout = TxOut(get_random_int(8), Script(get_random_bytes(30)))
    key_derivation_params = (get_random_int(8), get_random_int(8))
    descriptor = SpendableOutputDescriptor.static_output_counterparty_payment(
        outpoint, txout, key_derivation_params)

    assert descriptor.outpoint == outpoint
    assert descriptor.output == txout
    assert descriptor.key_derivation_params == key_derivation_params

    # Check no other getters are available
    local_attributes = ["outpoint", "output", "key_derivation_params"]

    check_not_available_getters(descriptor, local_attributes, all_attributes)
Exemplo n.º 10
0
def test_funding_generation_ready_getters():
    temporary_channel_id = get_random_bytes(32)
    channel_value_satoshis = 42
    output_script = Script(get_random_bytes(50))
    user_channel_id = get_random_int(8)
    event = Event.funding_generation_ready(temporary_channel_id,
                                           channel_value_satoshis,
                                           output_script, user_channel_id)

    assert event.temporary_channel_id == temporary_channel_id
    assert event.channel_value_satoshis == channel_value_satoshis
    assert event.output_script == output_script
    assert event.user_channel_id == user_channel_id

    # Check no other getters are available
    local_attributes = [
        "temporary_channel_id", "channel_value_satoshis", "output_script",
        "user_channel_id"
    ]
    check_not_available_getters(event, local_attributes, all_attributes)