# -*- coding: utf-8 -*- from raiden.encoding.format import Field, namedbuffer from raiden.encoding.encoders import integer # pylint: disable=invalid-name byte = Field('byte', 1, 'B', None) hugeint = Field('huge', 100, '100s', integer(0, 2**(8 * 100))) SingleByte = namedbuffer('SingleByte', [byte]) HugeInt = namedbuffer('HugeInt', [hugeint]) def test_byte(): data = bytearray(1) # zero initialized packed_data = SingleByte(data) assert packed_data.byte == b'\x00' packed_data.byte = b'\x01' assert packed_data.byte == b'\x01' def test_decoder_int(): data = bytearray(100) packed_data = HugeInt(data) assert packed_data.huge == 0 packed_data.huge = 1 assert packed_data.huge == 1
secret = make_field('secret', 32, '32s') echo = make_field('echo', 32, '32s') transferred_amount = make_field('transferred_amount', 32, '32s', integer(0, UINT256_MAX)) amount = make_field('amount', 32, '32s', integer(0, UINT256_MAX)) fee = make_field('fee', 32, '32s', integer(0, UINT256_MAX)) optional_locksroot = make_field('locksroot', 32, '32s', optional_bytes()) optional_secret = make_field('secret', 32, '32s', optional_bytes()) signature = make_field('signature', 65, '65s') Ack = namedbuffer( 'ack', [ cmdid(ACK), # [0:1] pad(3), # [1:4] sender, echo, ]) Ping = namedbuffer( 'ping', [ cmdid(PING), # [0:1] pad(3), # [1:4] nonce, # [4:12] signature, # [12:77] ]) SecretRequest = namedbuffer( 'secret_request',
secret = make_field('secret', 32, '32s') echo = make_field('echo', 32, '32s') transfered_amount = make_field('transfered_amount', 32, '32s', integer(0, BYTE**32)) amount = make_field('amount', 32, '32s', integer(0, BYTE**32)) fee = make_field('fee', 32, '32s', integer(0, BYTE**32)) optional_locksroot = make_field('locksroot', 32, '32s', optional_bytes()) optional_secret = make_field('secret', 32, '32s', optional_bytes()) signature = make_field('signature', 65, '65s') Ack = namedbuffer( 'ack', [ cmdid(ACK), # [0:1] pad(3), # [1:4] sender, echo, ]) Ping = namedbuffer( 'ping', [ cmdid(PING), # [0:1] pad(3), # [1:4] nonce, # [4:12] signature, # [12:77] ]) LocksrootRejected = namedbuffer( 'locksroot_rejected',
locked_amount = make_field('locked_amount', 32, '32s', integer(0, UINT256_MAX)) amount = make_field('amount', 32, '32s', integer(0, UINT256_MAX)) reward_amount = make_field('reward_amount', 32, '32s', integer(0, UINT256_MAX)) fee = make_field('fee', 32, '32s', integer(0, UINT256_MAX)) reveal_timeout = make_field('reveal_timeout', 32, '32s', integer(0, UINT256_MAX)) signature = make_field('signature', 65, '65s') non_closing_signature = make_field('non_closing_signature', 65, '65s') reward_proof_signature = make_field('reward_proof_signature', 65, '65s') Processed = namedbuffer( 'processed', [ cmdid(PROCESSED), pad(3), message_identifier, signature, ], ) Delivered = namedbuffer( 'delivered', [ cmdid(DELIVERED), pad(3), delivered_message_identifier, signature, ], )
# -*- coding: utf-8 -*- from raiden.encoding.format import Field, namedbuffer from raiden.encoding.encoders import integer # pylint: disable=invalid-name byte = Field('byte', 1, 'B', None) hugeint = Field('huge', 100, '100s', integer(0, 2 ** (8 * 100))) SingleByte = namedbuffer('SingleByte', [byte]) HugeInt = namedbuffer('HugeInt', [hugeint]) def test_byte(): data = bytearray(1) # zero initialized packed_data = SingleByte(data) assert packed_data.byte == b'\x00' packed_data.byte = b'\x01' assert packed_data.byte == b'\x01' def test_decoder_int(): data = bytearray(100) packed_data = HugeInt(data) assert packed_data.huge == 0 packed_data.huge = 1 assert packed_data.huge == 1
import pytest from raiden.encoding.encoders import integer from raiden.encoding.format import Field, namedbuffer # pylint: disable=invalid-name byte = Field("byte", 1, "B", None) hugeint = Field("huge", 100, "100s", integer(0, 2**(8 * 100))) SingleByte = namedbuffer("SingleByte", [byte]) HugeInt = namedbuffer("HugeInt", [hugeint]) def test_byte(): data = bytearray(1) # zero initialized packed_data = SingleByte(data) assert packed_data.byte == b"\x00" packed_data.byte = b"\x01" assert packed_data.byte == b"\x01" def test_decoder_int(): data = bytearray(100) packed_data = HugeInt(data) assert packed_data.huge == 0 packed_data.huge = 1 assert packed_data.huge == 1
lnd_string = make_field('lnd_string', 200, '200s') cross_type = make_field('cross_type', 1, '1s', integer(0, UINT64_MAX)) CrossLockedTransfer = namedbuffer('crosslockedtransfer', [ cmdid(CROSSLOCKEDTRANSFER), pad(3), nonce, chain_id, message_identifier, payment_identifier, expiration, token_network_address, token, channel, recipient, target, initiator, locksroot, secrethash, transferred_amount, locked_amount, amount, fee, cross_id, lnd_string, locked_transfer_signature, signature, ]) AcceptCross = namedbuffer('acceptcross', [ cmdid(ACCEPTCROSS),
locksroot = make_field('locksroot', 32, '32s') secrethash = make_field('secrethash', 32, '32s') secret = make_field('secret', 32, '32s') transferred_amount = make_field('transferred_amount', 32, '32s', integer(0, UINT256_MAX)) locked_amount = make_field('locked_amount', 32, '32s', integer(0, UINT256_MAX)) amount = make_field('amount', 32, '32s', integer(0, UINT256_MAX)) fee = make_field('fee', 32, '32s', integer(0, UINT256_MAX)) signature = make_field('signature', 65, '65s') Processed = namedbuffer( 'processed', [ cmdid(PROCESSED), pad(3), message_identifier, signature, ], ) Delivered = namedbuffer( 'delivered', [ cmdid(DELIVERED), pad(3), delivered_message_identifier, signature, ], )
locksroot = make_field('locksroot', 32, '32s') secrethash = make_field('secrethash', 32, '32s') secret = make_field('secret', 32, '32s') transferred_amount = make_field('transferred_amount', 32, '32s', integer(0, UINT256_MAX)) amount = make_field('amount', 32, '32s', integer(0, UINT256_MAX)) fee = make_field('fee', 32, '32s', integer(0, UINT256_MAX)) optional_secret = make_field('secret', 32, '32s', optional_bytes()) signature = make_field('signature', 65, '65s') Processed = namedbuffer( 'processed', [ cmdid(PROCESSED), pad(3), sender, processed_message_identifier, ] ) Ping = namedbuffer( 'ping', [ cmdid(PING), pad(3), nonce, signature, ] )
secret = make_field('secret', 32, '32s') echo = make_field('echo', 32, '32s') transferred_amount = make_field('transferred_amount', 32, '32s', integer(0, BYTE**32)) amount = make_field('amount', 32, '32s', integer(0, BYTE**32)) fee = make_field('fee', 32, '32s', integer(0, BYTE**32)) optional_locksroot = make_field('locksroot', 32, '32s', optional_bytes()) optional_secret = make_field('secret', 32, '32s', optional_bytes()) signature = make_field('signature', 65, '65s') Ack = namedbuffer( 'ack', [ cmdid(ACK), # [0:1] pad(3), # [1:4] sender, echo, ]) Ping = namedbuffer( 'ping', [ cmdid(PING), # [0:1] pad(3), # [1:4] nonce, # [4:12] signature, # [12:77] ]) SecretRequest = namedbuffer( 'secret_request',
secret = make_field('secret', 32, '32s') echo = make_field('echo', 32, '32s') transferred_amount = make_field('transferred_amount', 32, '32s', integer(0, BYTE ** 32)) amount = make_field('amount', 32, '32s', integer(0, BYTE ** 32)) fee = make_field('fee', 32, '32s', integer(0, BYTE ** 32)) optional_locksroot = make_field('locksroot', 32, '32s', optional_bytes()) optional_secret = make_field('secret', 32, '32s', optional_bytes()) signature = make_field('signature', 65, '65s') Ack = namedbuffer( 'ack', [ cmdid(ACK), # [0:1] pad(3), # [1:4] sender, echo, ] ) Ping = namedbuffer( 'ping', [ cmdid(PING), # [0:1] pad(3), # [1:4] nonce, # [4:12] signature, # [12:77] ] )
hashlock = make_field('hashlock', 32, '32s') secret = make_field('secret', 32, '32s') echo = make_field('echo', 32, '32s') transferred_amount = make_field('transferred_amount', 32, '32s', integer(0, UINT256_MAX)) amount = make_field('amount', 32, '32s', integer(0, UINT256_MAX)) fee = make_field('fee', 32, '32s', integer(0, UINT256_MAX)) optional_secret = make_field('secret', 32, '32s', optional_bytes()) signature = make_field('signature', 65, '65s') Ack = namedbuffer( 'ack', [ cmdid(ACK), # [0:1] pad(3), # [1:4] sender, echo, ] ) Ping = namedbuffer( 'ping', [ cmdid(PING), # [0:1] pad(3), # [1:4] nonce, # [4:12] signature, # [12:77] ] )
amount = make_field("amount", 32, "32s", integer(0, UINT256_MAX)) reward_amount = make_field("reward_amount", 32, "32s", integer(0, UINT256_MAX)) fee = make_field("fee", 32, "32s", integer(0, UINT256_MAX)) reveal_timeout = make_field("reveal_timeout", 32, "32s", integer(0, UINT256_MAX)) updating_capacity = make_field("updating_capacity", 32, "32s", integer(0, UINT256_MAX)) other_capacity = make_field("other_capacity", 32, "32s", integer(0, UINT256_MAX)) signature = make_field("signature", 65, "65s") non_closing_signature = make_field("non_closing_signature", 65, "65s") reward_proof_signature = make_field("reward_proof_signature", 65, "65s") Processed = namedbuffer( "processed", [cmdid(PROCESSED), pad(3), message_identifier, signature]) Delivered = namedbuffer( "delivered", [cmdid(DELIVERED), pad(3), delivered_message_identifier, signature]) Ping = namedbuffer( "ping", [cmdid(PING), pad(3), nonce, current_protocol_version, signature]) Pong = namedbuffer("pong", [cmdid(PONG), pad(3), nonce, signature]) SecretRequest = namedbuffer( "secret_request",
secret = make_field('secret', 32, '32s') echo = make_field('echo', 32, '32s') transfered_amount = make_field('transfered_amount', 32, '32s', integer(0, BYTE**32)) amount = make_field('amount', 32, '32s', integer(0, BYTE**32)) fee = make_field('fee', 32, '32s', integer(0, BYTE**32)) optional_locksroot = make_field('locksroot', 32, '32s', optional_bytes()) optional_secret = make_field('secret', 32, '32s', optional_bytes()) signature = make_field('signature', 65, '65s') Ack = namedbuffer( 'ack', [ cmdid(ACK), # [0:1] pad(3), # [1:4] sender, echo, ]) Ping = namedbuffer( 'ping', [ cmdid(PING), # [0:1] pad(3), # [1:4] nonce, # [4:12] signature, # [12:77] ]) # FIXME: we need to know the type of each arg # Reject = Message('reject', [cmdid(REJECTED), pad(3), echo, erroid, args])
secret = make_field('secret', 32, '32s') echo = make_field('echo', 32, '32s') balance = make_field('balance', 32, '32s', integer(0, BYTE ** 32)) amount = make_field('amount', 32, '32s', integer(0, BYTE ** 32)) fee = make_field('fee', 32, '32s', integer(0, BYTE ** 32)) optional_locksroot = make_field('locksroot', 32, '32s', optional_bytes()) optional_secret = make_field('secret', 32, '32s', optional_bytes()) signature = make_field('signature', 65, '65s') Ack = namedbuffer( 'ack', [ cmdid(ACK), # [0:1] pad(3), # [1:4] sender, echo, ] ) Ping = namedbuffer( 'ping', [ cmdid(PING), # [0:1] pad(3), # [1:4] nonce, # [4:12] signature, # [12:77] ] )