def test_transform_cbor_to_dict_with_multiaddr(): addr1 = Multiaddr('/ip4/127.0.0.1/udp/1234') addr2 = Multiaddr('/ipfs/Qmafmh1Cw3H1bwdYpaaj5AbCW4LkYyUWaM7Nykpn5NZoYL') src = dumps({ 'data': 'hello world', 'size': 11, 'l1': Tag(LINK_TAG, addr1.to_bytes()), 'l2': Tag(LINK_TAG, addr2.to_bytes()), }, sort_keys=True) expected = { 'data': 'hello world', 'size': 11, 'l1': { '/': str(addr1), }, 'l2': { '/': str(addr2), } } assert unmarshal(src) == expected
def _multiaddr_to_bytes(maddr: Multiaddr) -> bytes: return maddr.to_bytes()