def test_unmarshalling_with_table(): for item in table: unmarshaller = Unmarshaller() unmarshaller.feed(bytes.fromhex(item['data'])) try: unmarshaller.unmarshall() except Exception as e: print('message failed to unmarshall:') print(json_dump(item['message'])) raise e message = Message(**item['message']) body = [] for i, type_ in enumerate(message.signature_tree.types): body.append(replace_variants(type_, message.body[i])) message.body = body for attr in [ 'body', 'signature', 'message_type', 'destination', 'path', 'interface', 'member', 'flags', 'serial' ]: assert getattr(unmarshaller.message, attr) == getattr(message, attr), f'attr doesnt match: {attr}'
def test_marshalling_with_table(): for item in table: message = Message(**item['message']) body = [] for i, type_ in enumerate(message.signature_tree.types): body.append(replace_variants(type_, message.body[i])) message.body = body buf = message._marshall() data = bytes.fromhex(item['data']) if buf != data: print('message:') print(json_dump(item['message'])) print('') print('mine:') print_buf(bytes(buf)) print('') print('theirs:') print_buf(data) assert buf == data