From e4d127bd9168cc441f6fb64d682c1e173058ad05 Mon Sep 17 00:00:00 2001 From: Riccardo Casatta Date: Thu, 19 Oct 2023 22:04:19 +0200 Subject: [PATCH 1/2] serde roundtrip with ciborium fails --- Cargo.toml | 1 + src/transaction.rs | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 38bf4fa2..80350c9c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -37,6 +37,7 @@ serde_test = "1.0.19" serde_json = "1.0" serde_cbor = "0.8" # older than latest version to support 1.41.1 bincode = "1.3" +ciborium = "0.2.1" [[example]] name = "pset_blind_coinjoin" diff --git a/src/transaction.rs b/src/transaction.rs index 6196aa9d..acde2f8e 100644 --- a/src/transaction.rs +++ b/src/transaction.rs @@ -1610,6 +1610,26 @@ mod tests { assert!(tx.all_fees().is_empty()); } + #[cfg(feature = "serde")] + #[test] + fn serde_roundtrip() { + let tx: Transaction = hex_deserialize!( + "0200000001086f9e8271d7ead1c5660784418a470cc6303dd80dcf33f5588df43ea6bad928410000000000ffffffff738af5bc0624f55864239466e076866e5b3e418fa9809dce1ee0b4e34300de7100000000171600145bda74ffebca58db8ea8f317a539a45a57166141ffffffff73ef431f9c9d0585641f63ecd15929cd74cdff756c47b3ba254bd00881b0ef060000000000ffffffff7b26e64ab777fb5ae56bb4708f6bc56ee4d8fe6e0184a8a67a01f038a93509a704000000171600140960b655b9bb51aef337e2498c58f0a47c1f9a4bffffffff82ef57c29a9aa637fc3054e929a1e73231d1e15fce13b974f875ed196e26ffed0300000017160014a0e0cefc7a8c3b97f67b079c17c7c64de57589beffffffff86a9c935b87ad662e2feb23a386a9d8ecea319d1c8759dc3a50536de75f797ef0000000000ffffffff9c4e4de1f6ec306d17f4393dd8590d2f61364b438af1b8366e0100d3fd069014000000001716001498c94cb9237a8313fd60d86cbb4167eddf9cc9b9ffffffffa1c02902430fe950238376ede26f5766ad0184f72cab0c7e66b7b7dbf0e404fc0000000000ffffffff030a620a0309dcf8fefc53250a41abbf4186494221713b4f3d0c3886ef575cacf58d080c1a1fbaf5b3168afc3a8b2bd3ae952bc300ddf8020606c0f24e887714e5d52b02e93865fd4995e765fc2111d5fdae77c16ff9e6784b348396ce4c3b02fa9b304217a9142c152830b7acf303f7f0b27ce0b47a9802a4f600870a794791a38cf02920fb8d5e22e8d805ffee82d04c922667a380e6dbfe4298f1a708f39fd14834b95c7e2cdafd60d4e1e31fa1419f2a5f51dddd68c3f2f0efbdf73402bd8063172947f1a3a92b7c346ce4a28d57577ffb86942c092bd352c235217f5d17a914a895ef53b57d1168bd9f56982ef33027775aa94d87016d521c38ec1ea15734ae22b7c46064412829c0d0579f0a713d1c04ede979026f01000000000000016000000000000000000247304402203db0b95e6e09183f08f17a77eba0549ed1e9087d590dd9d3371b4b18e5c2932102204c565ed3f04ebdf9db3c8fdf1af863e442477f770515cb3fb0b6c3acf33de411012102b10f20ad160efdc792f03c909717d10a80e098b9b1ac600c2b2f6f9d19e27cf50000000247304402202313001cec4f2e7e7d18e4f1fa23d3092723ca9e07b7be172e86ddd26a8499a50220108756330b1bde0dd541babe989ad3febae4a4bd2856786bacfa9fc34d207e51012103a36210d4a670f7a277edfe71df447b6dac39a3e275e8a9e961e45959aba02f9100000002473044022033156e0317cdefc5bce93122ad2f7ec69f0a9875179d33f8e887b3b74efe5124022075986f45abdb0e267c61aa7725deebfddb6f99f3bbf4d60961935189d3dde0b3012102f7fcc494eb24a221fccd1c7b4381468dc08deef9cc412df3720e23488c64c32b00000002473044022068df73b3360667ddb3e132deb574cc82163a925f75a7fbee91f8a11b674d9838022042b435a1e42cbcb7b0d51c8c2598abe7a0d1778387b92bc14103a2d73619daef01210204e6a24ebf255d5f062f8a8690d40e6ee5b8dc2acdf20f518d0465b27a2a3b950000000247304402204c05628daca33ffee68ecb51f3a25c5bc5eeb7efab6edac9d39b4efefb49787a02205191581b1ac7fe805f27523ef19e96814f84f1610120ef814b0e4fe227b160cd01210277e91b35687135a996cd3c01a66b444a782456556582c2b8a0386612f531a8e10000000247304402204cbf298bb31bdfc29f21dfdce63e97c6a2528011567b625dc76f1786c759185902206cd0e3bca92840272ae2c4380ffa00a8e926018fc08172bdb6e7526c120637ff01210265c62c103050de23fad51a971dfd98de3960fbdf24a4cd63047f9f8222eb9d500000000247304402202a1286a4c20766b8970bfa195ad08f74da598c855c45d9639c62b401bcc1fa9f022021a78894856223eb99cdabf43df5891eb20ed794f3b37d7302e060757e6469ee012103f3cf6a2e655dc7ab5b52a3892db0aee27d9b0b6ee0fc4dbd0d9db8a01a34511e00000002473044022030bd7a28d37f4a614f336f37f5f1dca56afc06f313beee9ba2ce1d21ac2a20a3022065e3fa8be35f487c81e1c264310d111bb89216e2741aee9d0914a28f5279f61d01210278af95eaa25d7c13a4db4551ed56e1eda91aaf6dc3c477aa284d3d97e72610ee008308008a580ce8344ba5c6a9a7c105ca176eca7faaddfb7b2638a2dd71f9031efe85daa1ccf08b72503054baf6496f367f94eaa7149fca894c334e57e15ba95fa86094413c3a3b380e086c7609364ee16bf1cd9b626ca862de9d3b64261f8c85a7772ee5bf4d8199ef801cbaaecea61f18a44159903e8cb188d5b34e0d4e7cf6a1aebff9fd4e1060330000000000000001767e13001e118c504995cbb072ca916332636a56419acf56071705af3203ae259860467d2020b81333c0b33c658c13573774615ec5a34d48ee0ecadaaa3f3d6d0d463102c63b4df9fef8d6ef2b291a5f5a32a435cf8a1a1826fb8b91b1ab4aa6405cd10b09dcf603b39baf2366f23438ed32107a629c7c9e2cf6f3b39bc759e8fb81cc8d664d6a334fbd43bde3e8d584fb11df9a5f7ecd87e87d377141aac4f1d568a1227359e8677cc5b1df02675e3f5ccaf2a63b6d2cae464185bb012fef1ae6fbb4abe613252cb5bd57cccebe73a20bb3fa578a9b2dfb9cae0dca2912f433c59054c25a3e5f04ed63dc15687f89fec5d4e4ed84b9f10373f3d780488d99061fcfd12be20142279ed527e2f5281c1601ad4d11337fc05ee97b36ab8b676794bf7b3255bd5630835a51c786a6c4609ed836e933de8c63effc0b23cbafd886b157953fce3c8cc55a261a575bda42e5c9faae383fec77b3740ac0c52bb99a9e41f9c49f5407dc8e5d84fad359a6c922e035e0f1a906f7c27f98ec2d450d706a41d16b7536d446733d5f0bca4313f1b7a8d01d257dd5d840d33b0080655a9b30a7803f5e63ed798184a50ecccd2141497db8085d1860b9e6466a3c6e5c11829e63162dca6554610fd2dd2ad6336150ebc1ad9bf77d960fcf49ff93063b810c86615e5255264db2708f3d2d0d5a5212f6ef6859d3c6b3f06e5852475e96316de2dbb0560060376ae6d613ed8cb3c6b02b2f83a532c2178640cd9f839acfb0783f60627fa7c05af2a8a17e826b59ff7d489b43da50bda9b51097c224840fbbe3267f6dd3487a0e990a58f7101597c0b68f6a13be8127a1fc8a90d3012fd9f820fd11d5fdbf41634606ff54bffbf1eb7996d157354709b823cbe12d7bdad59edb0227812156036f21e1b9d232d7c7f859dd9c716f7358d8c27b3a40d26dc10d1d994b967bce3794242d27ec6547e3e3e5d72cb36b924732413f63efbde4a98e6abb5d71694cca16954c0d621e1efe8203e0551add5369385c6d17f34b4e35a328817c7709a3164a27a6b707308b1cc86ebba746c43f944c31c9f0c0c82d1c179480b3415ffb6f68a9365fefda3a357aa0cece86f410ace18ff4ddfeb634432d1d507cff5f0043b7fbbe6d14118ee7c7fd9b3792a192c5910dfb7cb732673868cd81b726f5e314d59749fa9858f18d2b556d456a6a665b5f239c19ecf41b61ed7fe458b8beb074ba985e6d297e35fb5da7da7f71df15df62a1e01c09a3c0a4231f54170dde42538e854a765c11c1be6a3df8aa6d78286adb771c6832d10ecb430b2c2b9169c5a0381337188616319bc71057f2522e9fdf8b3ba29705139abc14ea9c49fec1564b5b98838be9883b777d7d620aed09de6e8c19e71e3957e16a36d4cc64f47d357302d466622f018c826d6bbf3c4517c5e3620504263d93aa148e2bccb645b82fb722ac2c27471bab0d26b9ad4a26afb0bf3e65d064b7d890f82e052076b206499bf8ec723658d2ad8f66b6f410860542d29e0f5c05c959542e7b6004528b199eb4c7744e8a8e55eb7cb7db5b1661781bd620778b3f3a8ebc3b32d30b64e54a64fd2861f2adcfe187fb0d8d7367bc908edc8dbdfcec1bcfda3b4da8a9d4997d491df34e7afa035e5dc198f63aa749c349a4349a577123a3e533b159075868afccb8fb1b2c907cfa8743a095f3e7e93280ab9a1af5c07fe3403081585d8efdf025c9a1b54e8fc52a2316effd029a94edc446f123403fd80d907c8ef30ee085544de2d5ede30ea8a0e352b11ddc5140b0350ae66df9913a3f8fa0fb8f4f3f45d307bf24ec6b0fde9d0b4563d15c1c09bba91373d7d539445f326b1ebd21489eb8c436295dfd0fe6959652d354c0eef5436301bc8abe4e405768f2ab1fcf52404ce813cb13fa17e4338a66b83ab332f3e6a6dd7a931b718cde100120449e8a5a59847b188b387b6b6694f826e6b09208d1a4871a13914f81283684c2e2147860fdcc1129cccc3bed26a5977a9c5fd726221390beb384525f25d5d95345bce0b229f8d4a4f8b6080450c22025fa50fdff8c92c24a8aea1b3434514997a7d8a364721b237be9edfbdaa4c1f93e4f93feddbe52887fd61aa84e3c858c8da7dc76e3831a3b9cb68f20a5899516b7a6fa4b6ccaa7670d8fc7b6a8bbffd938c06e1945dd435f7329b7d8456515445998f3fd52a7f0b6758a4b35759476aea7b3d9a4e2797bd02df3c30d3aaf0344af4534406e2d0cc9e16df45cf0174ebc0d58ae4af38a41dbe6eed92ec121ce5a59ab3bec47e9e8caeea802047dcd586cb672416fe7064215a8df90655e58e6ec23e29766de0cca7298cc8144dbdc09112c0073c9e14b72c95ecd34e25f4a3e9c8b17f6cd167f4a0757653e29e41f22b28d85bb25dba58e232957181c320787fbd6e6a1cd87bb9889a765f94de030246e7f21fe21d3dad04c7350e974c4ab4d43bd9b417355b1234f80fc73c8a7ecdbb15ce7284afe9b10746cc6b37aa21efa4a8042e9a8a67760147bbd99efec54a2941d50ba385c1b31df4a6be3bb711a03a1f6e1fa67a801d1555517f10be37ff77482d09dca9a8fcb596eb2b92fbd39590e12038b64bfe1e6ee014c68597f82639dc9391dd67eea1e8c65f1f1f795dc77765b04f6924d4779fdb109aeba3ec00ece0730af14c7e06f4203b27362007ab36e9a042c0c7cdcdcb8feed5befbd5b852164c4a5fa403bb6bebef58c8b8924a5de3ee1f37cb259e622570af96aa2c95d15e5af12563a30fb53a46e00ae6c673b7a71770e54165552fa251042cfe03e4fe8859e1442ae6abef39f74afb2244300c61a7ec81be04d48c6b777fb3e3dec3480710e056911f50194f0e166a70dc41d50e7077a5bed9eeacccb02cdec88246fdce2bebdd294176bd39b1688a93423cbd1e0f711e9b2902bd413235fcaa8417fe40ddf4e0d070862779100d07a054cddd128b224f683f0b00e4b7542b3ec33a428e24c13072165a8054195afa76396adc89784c62b2450c81a0fad0a3baaa91dc8fafe1e7d0f07070ce5f1d11955fa105183fdf279b697207c580533c7d15b9e38bd1cea7ec4e400d9c1f0af564cbb2e865bdd327671bfe79314faf317735944eae51dd097e79006c195f6ead2592e146918d06800f08810b7ad2b543b68941ada5bb3bf612b22db0b67526eb924774a3815597489083cfa951070ce223c1289c93bfdf0d918742887c733503553ed2619fc5aee86ca1d321c994094c65bc570123d0319d2579b047e7be60928863af177d7caf72d131ed054fdbe973b671e34975e2839baae3d351a2a8374275ed3f0e07c6dc0d9762fcfe3152d4cc519108a5d94b71ca4c5508e75f582b4a15b1dc6461e887eec23dfc6a0dc9aa6672b57612ed1ccec280555cbf06a2999619579dcc9286e16417716f758c3a26690732e49e93bf6a3f033b06eec5618313fd4eabec1fc811499e5234fa07cb229adf71a9f013fd23ae5f88e05e0f0480dcc31ecc56b882233a7d49c439f4c17f6eb64f14bbf42fd16e37dccaac07c4df9919d7520b1c9c956bdc171ed256055920513ab4efe5bcef254e9ac95299d919f84074c7b96c5dd866b4f47261317d70f2f2908db900aa03659c688fbfedc3039cf80a74f0c66bfee03e60220267d095969b6abceedb8ade7acdd66ab8dd1e15c9ca424c742c8e165ac47885dc21b72869269ca0c4bdd0ae40e3f2c9ad1ff7497de1b612569483390935eb2d91f5b94ad10e3be7b3389973c588cb3997351b1670913d6ccb77f2e6b4f6337b572754f1759edd624d5d726bd80a19fceb81ab552a797fe847455080449c1dc1e09bd167d1b0385a6e17281807d6a39d7b38d21808414ff4bdb02382e77559c94c52c9a7aed9bc16dc10fbf1da7f0d10002c07de56bb2da933c22bcfc7564c6417a467f2840d63033c6a6cdc58b7091d3f6e5381dc62b4c7097e78968162f42f3f8087c38bb9af4c61ced2030d5b9d50dc2cc3f116b0df90628369979293db2621f65bd5364bba9cc725aa474fe6c4a6bfeb598584f10bdc3e4b3cd09a828a184248d2e2d2c3eb6cf1a39139c814b5d8b68cf845273c355c8b92809032f285fdb080e1f99dbe9ac33a1d70d5b9c07a772f09fdf3ade550628f3d41e1c16a66d1639377776d8f765254cd2685a0f3b00ad0b79643fa23340f1510e21cb185a2cfb260e75316d07160707ea63fa0836b05507aafb623db7426bfe6ec6a334ad70517983b852432d0c4fbf7fc1d0f55901e028877d66a812c1e6a097e824182a56155a5cd443657937c30136c4900d909326fdddb063ee4267eafb952fe81f6d43dee5a0c753f49c8eea011bdb6c11b29e5810422ef44635bb19cdece0ee835f89082bb9a82d097cf75cf04fb8098ee5fd2fcc17e17669d3585fb5b60bcd6dac57ac338fdd8b9bbe032d0e22d7eb6be3cc425e65ffaf3b2ab60b82555913b60eb2ff22cbc17a6b8e67573f20216f526adfceb6151434e5d3e3efc1d49e97023060992f8bff99d1cb71555bbf3064a8a61cf250fd2397d836b47c2202afee72a39cdbe30b9dc570584b5696fc09d6f82d15d4dcc61a7f53321d3ecbca35be9d350c92fb4ddb2e24802b7c40e4cab46daf4a43da7976cd0365272b8df7ecaadad0ceb52802d32b6f1411a77f4cf664508ad264ef565b4fe5cf12a1db44398a6bf23215f8ee8204dc0935f2dde737d5950491420a13636632812a426938a0900c90c774a7cf8c887353c1b47e688eb131ee025c0463f7390c810ccc832d2355a7f64305dd7d9cd5286387a28b1f18ae126ff16ee86da08de77dcf0cf5b871d6b09877a30e94159b77de543cb862e24e0b2a8d844ea5aee4493b2dd12288ea47720fec24469f147681d02ae36443fa96eba2f1e5b14d0ceba32fa5c68e0b7754eb064e72b24b5d0874cf36409514083da7e893d1bbaa558309bf6db72c8b4ea950d267987474ef1363a5a62a8ae8f34e07192e6e962fb5cd8246107ced7fba0170f3b9824d0f43c5eab660940d53f1ee9528530339f7901ee3df5c57757d89bb9a444d17a56a2e76dd9264ae84f16d53152f163949c7ad238785c597f71805b8584d9cf4326ded392c4228ec657bf9126fbef27eaa08e5de09de8122014bf24871278fece05a5b106ddac1b5fddf7f2f6a760d732f972c8be7d26fae8e3929ff846f56f882bf9024382983973a5d6ff0cdbc889db9615429df1a150716e7ad4eabda5282e31b67fd6418caa984c005ca83c4dc62956b3e6ff434bbb80b380af2b990c81b6e1a93ec03f4b471845426c8afd3251c31815842898d88b7fdb526f37c60a5980391f76b5bf40a52f8b6f948eb5c5564a377b356e5967f1a44f1f3a864556ade6bc9c2bbc9749d301f1bc4f365aa845bb7c50536bc9afd4d829269f24f1ebfb762eef1b43837871f97f027e52697fa071d00da7615ef7055a5cf2c5e3e296885bfb49034c1264c3537ffdbdc1a4dec8628fe0da727b794f18e5bb0970cd49ed742ac348df47f62a07cfaadedc8916112a4f99f022b38d9af722b8c401a0604f8f18e843d959523554448eda48ddcdf78b885b7d9850bf13e28e4f9223ed028d310eb9379b7e7d441739897bbc05f09c7e3afcf398cf8f8c311f9ea8e8b203a738a56048d1292c5ac2a7e773a787472b41f3bb939b66448e4a49ecc0d358c33bb41ed2e4f7e511f9ffe1f02a41bee9e630693f1198030ab81900c539f09e106fcc6644378fc02c04312a637b8ed08d475a6920b69c4916dc26f67c7db6f0522d2c91cbc236afb0eb4bf61d2e6e67c04657275d049ff243752ff24b041b672f728f33fba16ed536c2673e929b1fee1e815891e8eee6c873183f9c335333d20595db4b27c27799054398d5dbc9e91206768fc8308005284ede21dc5211c224deb9d674b24848ff7f32b396d64f97f45edc0ba34df92596bba3d4286598440d9c3da88334b99690ba1d7b4f196ffdfde9676f65da69e3efa2f6e8af8071dd9c4b2a0919afd226d4e671a0cbcb7b24218d524e18804159ea82f38bf423cd54ab9526c4d72a424ac26839f8cd925b08a09d069188bfed5c6fd4e1060330000000000000001a19ab4012b1d59c5792ab465dfe892792aa3679cd9e055e7191e185deded2670497823addafc19a7504d65345272688af70fe577ec095235a5c52203ff8cead131c3eb9e5958ea159d254a0185ef59968b00dc7097637b8182cd59680c4fbc93d8c1aa5eb45978b37047354f9f1c3ad69e6bc91d5aa78ad93f27a78c16c8340b15975f7509774daa4c9ff6c6d9aeb943e8cea50b9c485dbfa32f2150d90598d29b0c9b22202445dfac28eb3b4a08d5d2b1b3528569bbac3081582f1d2113c1ed29f993286293a8506a0b458b60867d75da00e3f0a99aa9f14ae4b82dbdc4b59160faa872344c02c245a4e3036ba0ff378631b4bb0d293f187e8eedcbae496987b01b56aa2bc4f35486157f1ac45367b86b360b570d6bacad94972ae771e719f1e05d53e85f7c33f51c72aed1a9332d681c07a8cdaa04a209a2dac766aa0bbe53fea3f3a3e723bdadcc85d9b123afdcaad8875a29ed366acc58789b3337c942970f3a44f1d076017e6dd9f378c35893f291b1336705f4252472039c8b9ee6e12f583db41a9349a80596c93c03c4ca5a54a6e234bdeb97808d7c39b67f6e13875e3ce26af45a5fac809debb707276f5fb51b238437433c4c1f34f86054b458077b839570533c5124b388cba02418cd370aeccd275dce3c790e1e9f9a74af4861fb062205b6043d3e6950e18fb7cfa18cdcb45fc9e028c8feebe1d6c6d250b1cfdc06053a605f8df637df5bf764a06584675963c074af2d62e532ff025172d6a635aa21d79ac102998598074b496cfdd6107a359542a09778f8ec7518582e93aaa3fadf3c51e678dffad2f3e3646316d82b9315a029e6a4671dbbe08fa3499a79d2246d008957013198da7079366320321418efc80e2ce4811b616a35339637cba1eee71178a3aa26da2f1eacf111496e9d422d71713ba60fc96b7d2cbf3fb1182f219cc97d2de2a4fc02906fc1b7336d42a22f1209b80820901c80c86dc496a7093190e1dee87a121b08556d3844f578e739fd0d93fe4251f030f604cdf8ac0f0d2a63b740cbed32f4e384b97b1071cd08778260e0b997e3e7de0815eba12ef7a96d513a2ec2a9ad37b84b55513ae6da79f7a1f4e0dac29fcb7196bdefd91912cf6405818806c2c2ce53f8ab1aa695337bd164d7f9ee0316ed421a10a6b753fd9c0b65c2a5babe2fbbb15804e8e9bc1c4dba7f51500d8494906e8cb92e2979f28473fd92c0d1536513413661453250de8126dbc570fb86a13942388d7f2f628163c8bc67962037d84df41c54c4ff76130de82f828fa31811662cbdbf1b2691be0a5466ae788df6a5a88d491e4cedecf8086ab9224aa88cde0af2c8562c62f863d0b2de55174e376cfb38508728c4711c0d53e7c22c200bef0746f6c4dcc331c6b75aa6cfafe039a6ebbdc70f6a3d8e169e5128921d3c099c75233076ab79b20fe1a90514d21787aa00f558b3a5d4f996de1d65ad403e0efaf49a6dbc5c05d629450687f49ebb379abfa9942487bd5ed4d436140ba348e711d2c58c71139e90ea7b3e883ba6dd9bce769a4fafed8e2faf503e0a58212c0a8fd5ae3b7e36b9ee36320278bca613f09b96075c1aaea96938df4ee522391af99c8a07f878afeb7481b8a42d52a4507d112b24a03d911acf0e60fababdc94021575761403ba41cd281f624e19c2125cf7bdf104ebd8a81cd5406f8cf2c4e3fdda678e30cecd06c1fda8329f8c8333681aa13b43d02b3c2a8ba02386ec2d27e32ce9c511601d9d6ddd22b90a0a0b4a354599dcd78607f921d6e2e727a2e0a73b4d0e4568d0e28c4ae1e5ee404ae0fd58469132407989c0c588e1d69a5020a1ba1b35f1b49844611003a2244ca647e085358582ce9e104cf96eb7d9a687dd32c33d3288b10696c1fb7382805510beeb954c45d64cb862851706320311d0ba10be34f6ecd9570aed6a5888101a2c8ae4dda3203258519fc4ec776af9d9121a4abf2c2db6c42dea33be271461046aa66fe2d43f6ff4f49c52066997ab77aa4fe6ffb845b81982ee07621e6566bfeaa317e070900517f41dfad8db3014f8b736ff1ef030b29a71393a0b4ca1d25eace95954f686742ac0a7e907e8caf125334f439f2c9d015a75cb5ac466465bbb82a2960f00829fbe374c710f4c965aff48ecf6d8d378370ac3980a72f58db0b71c33d9e8dd7a72c9188fdfd70a1f9d83e57a2aa7ac39ccb88d5807ed4e6b851fd6c45c2e80c8e600a783966d5f8ff0408d83b5d727936072e5929ac8ba49ebaf57cc7d315343497e75b37452e6483195fbb6cea7ef766f1761110f151ed4d8704fa3b747b35f46dbc8f120e9ca1620dfb28b6cb847f01d3fdb02a835ffc8aa5b7cc10bfd2839e5c1f41eba655b0f03aa40bffd5cdd2b0b46c0b4e0d5ce224d45133e17259c555dd3c3e85d86cce56d164e969fc3b4ce82ba0c51bceeffbcb3aeb7865b99688c9ab9f80f585d8ad438f4e7fa68776a645b88f7853e61712dd92003421ea51b850e926b64cae391667dd94f537853cc1063539c35199206f9f249bebfc8b8c09d51546a26e1cd603d53bb3fbca20c8be065b3cb7b35e7af30d16d29463bc5084fb1709e50b67a2c33c966d651f74bf2c1ae69463d9d0e2a901ae4fa75cf6a8745f200de05d0e1833f2d9d862b3f74cada7497bb39b91ea2537141a831df4fcbc74f28c23baab397d0fb22c489b68dddbe92f092a4aa7e1afb3b0d72dc0c83bd093f1540e172f469d6ba3a2c0b4154b6b4f0e40dceaa60c37e4499ef6d00c837c590f4552a140c03df6094dab0383b2aa384c98820fa322d1d3493c053543ed33a499bdd6f6ee5856fe4b61f068769af2669e8353c027e14c10cc83076cefedd448c399a9844b344b28fe51cab4915c1f2c5df338c324e44f92cb94cbed4da364375912e54c2bb81eeb524d384b2061595bcc14b5b33cf6e483bbb3b711e524c2a3a5fec33cbfdde43517691c8dc7ca6bd47121c696d98a4d6426e6600ed3add2c7ac3debc59813c412aa6e853a91e9e6db11f50e27dfb8bfb72ad6d82c308ff36390d554c9ab7f39436a96b5cbf5e262946953cc6914421d84956041290ec2afe929446376af06d7c4890f76ad5b93feb32c95643e9ffafec0b0d6dbe122fc8c3e71deeb35c86b790b3bbf2ca5d5916a1736624c30d0c256d7f0ceb8ea4e791cae50dbe5a6a77cf32a647ab22283038e127d511c431dbfb5f39f5b5a72a791dd948a4446d038e3b8249a17ff90aaf70c0af28e468e28ad139c638ab7675c61612d712958164cd0b2c6d580c5ed69974d85d1e10b88422f54f5853e9fe0115f603934107e917fc45c6b14ed09fad2f1a716e6283c1902dc74a20c507a67303af0c8a6ad4a25a890b61163dcd42be8689bc1659c0e1effb5ed9ecf05b183015816df5b91bc293aeb4dc155aee4e2e51c2edd52b807ed5c960b610bb7003a7e3a97703f483038167201fb0c56b77da80237eb5efad251c4f919bdf83ec27c1de62738b5257f8414bb74157430da138b3a2b35fc564ade0f0f42f09d681a2b607254dcdbb116e160fec3ecfc68369e358ccecd70ab390ff4bbe8b0c1d71562a153a3f92758dac8ddae135a0e1177d8c6b9cce900111af2306e0fa6cc18a9e935f178ca9c4035d5e0232af560a90efe02a3d6e91e52d3a397516fe2a44b15560ea0d83ad4a172567d469ed0a96c6ae0c51b5e92056001a707e117799485fd1e0a7e48970ead66b12a280288dce39252180a075bd81764a95c649f502ab915548bd9f845c0d67013b6e90be6edfecbc41f42f77fc90a5809d4401a9085c6ef6bbfdc5673eb1d8c7059cefe292722d452c2e5359ede723d49df7322bc8e306ecf4c19f82cf135f2a71cc3f2f1ed620a20b26aca6346a0da59cab7a52675ced3634d72e63f8f1652ae9c95f469db7ec92682166bfb8d386495cea71815913d895203075bbf60d5e302c5d6a2e0cb4ec21524e42c37c7b2e0cedd32d117a03acb3b576a0feb95f6819dff8197bffd5b6038a1549854d12c16a092195ac40d3ec01e9f80dc12c75eeefe299af1c3e81911aa94e97133cf06dce65be786d2e8834e4bb25e9b2c055bd89a969df596172a67b22c5ca443185c3c6dd433d540541f0ffa7ec5a3c1894ad3db114fc387f3aaecd690415d82dd5cc8dcc857e9e2227360bfc1bbdff2f6146f102972d77e5b85faa22042f9ffd134f7e0cfd8cb86e61427ea32b882a9a8393c20b2d919e3e5f92a35b732a2dbcede88a9fef0a6cbcea4b22e7e4c3a1052982986fdac2b5479acd13f08cc50fec3e48698db5fb346ba3000bc653a810e5dfb6a7443228abe2d8dbf916f0ba077d7ebb8f2eb6008b830d71b700c07ac8bd847987eec4247a4a9ac730377fe7b7e74cdc94fd4cf7266be4389f8881bb5ca6f9f1f84f6b190da149454be9eb2c1b0343ab8e9f2fdfa27c52296f0ae854dab523e2b078b29e1dbc81564d355a6a9b6011ba4817247fc900e4f6e7b236a7d61875ec1331ad58f53f838c12252563d08b36df12b17b7dd10f331b7e8fe1ef873b2ff0bf6bcbaea833ebefcc7258f76b46f6df3aae3a3548f3eddce05a3ee064caf7630be02d9ba75b94af243859e3c25037d58956a2428d1f535cc3cb2ee750b829fac184948ba3fd2b90f7de30e421388650f5312e964a3f254d6046726397e3a47a6baec0c3183dc707e3dd17f5c8fea185f6c14aa55c1749d5a5243922db45f022c5fdf5bc68749fab9ce2156965805827fb65571ec97299e57efd76525c3768608bfb4d9a7a45df9d491f0075b53bfec396374941cb8f07890574aa4ae26bb78a1b9c6f74687b7421e14e4d75b1623cda50d3b88fe804449b2db24a8d61312edc228d8a616cd84a8ccbb5da2b85b44950c63407cb6c2efc263574885dedb584feec44d675fa9c9bd23b24d91a2429b8f6b42a049f35fb052444b56a362ed836930ec93c134a21ba5657634aea139844de364ed3f88b26aa8dd4f0d0421a6b38db2af4b8cc77bfc8234c93cefbf87e5e0c935b3760f1ef1b58e68bcc931b44df1a803089cdadcb07641291831e4e8ba7a53ab0ae8e5ca6cc6c8af39d8c007d37e4b1585ef1f868d82533fd1fe378c1e5170cd273ca628c869dd8c2eb550e0faa69df6abf33143e80634a66e1e3ff2580ec3b0a1170a1d2daffca38f957c4f8f19a572d1f123cffe4bc40af5b8ed107ee8d897d5ba5f5242ecd6fe9cc53dc932d8754aaad6109c1697e61456f81f77f4dcdcf7df54dd98639756d24fdcfb2b72f9ebfb013985bc22bc959d17d8d536137ebc0c3f05a585c90604a3de432488ec8d184ca78f8f185ff653b94bacf77574c381da992c1581c9372f8ca76503019983d4ad65cdcc4d545c3cf73be2f7748fd1e57b45ca7ebac7f81671ec50074724f432ca5cd7dec8d599b614d06319adab05ec37ae0ae59260b0d18289ef468444ec62ed3e4a6a9193660ccce9de80a00e5edd9678c78b03ab996111c7ae8f4861fc48fa305a44fa47e65585c6748a0d134fd13472dcc0762aa8c5b38b765fdef981858bb2232ef4de40b4448961ae54a128f7bc119a5d0e848c5e42e07fd5ea06c179cb0a3bf3b986c0727cf3a1e2e329e5ee5d92721d13c50b683bc08823e33b9fe8270f75764f1f57dc4afbc7f576e1793344a2da513db5e77be4213af76fa1f277f2762268e132b18ce00e292a6a0982965029ff7b87b9a322fd7a56ff0056d3de271c5ebd573128e0ab00de67ca5124b4f7ce2854027a17bbb8d2e67300aef7adea61611c13fb0572f3d8df1db8d9fafad41cc7b75c7b36997fe0bc79eb07d617fe7ca3c78609c9ff2ab583f860c5a7ac3150af4a6fcc87deefbe5c368ae164d6fa890cd92096a82a12c1c849a2cd8c304e134450811e814e100000" + ); + + let bytes = serde_cbor::to_vec(&tx).unwrap(); + let tx_back: Transaction = serde_cbor::from_slice(&bytes[..]).unwrap(); + let bytes_again = serde_cbor::to_vec(&tx_back).unwrap(); + assert_eq!(bytes, bytes_again); + + let mut cib_bytes = Vec::new(); + ciborium::ser::into_writer(&tx, &mut cib_bytes).unwrap(); + let cib_tx_back: Transaction = ciborium::from_reader(&cib_bytes[..]).unwrap(); + let mut cib_bytes_again = Vec::new(); + ciborium::ser::into_writer(&cib_tx_back, &mut cib_bytes_again).unwrap(); + assert_eq!(cib_bytes, cib_bytes_again); + } + #[test] fn pegin() { // Pegin tx from Liquid integration tests From 45bd2bf274a7ed44da1d8fa65e80749d2f188db7 Mon Sep 17 00:00:00 2001 From: Riccardo Casatta Date: Fri, 20 Oct 2023 08:17:46 +0200 Subject: [PATCH 2/2] test: isolate bug on RangeProof deser --- src/transaction.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/transaction.rs b/src/transaction.rs index acde2f8e..4f53504e 100644 --- a/src/transaction.rs +++ b/src/transaction.rs @@ -1610,6 +1610,25 @@ mod tests { assert!(tx.all_fees().is_empty()); } + #[test] + fn rangeproof_roundtrip() { + let rangeproof_hex = "60330000000000000001767e13001e118c504995cbb072ca916332636a56419acf56071705af3203ae259860467d2020b81333c0b33c658c13573774615ec5a34d48ee0ecadaaa3f3d6d0d463102c63b4df9fef8d6ef2b291a5f5a32a435cf8a1a1826fb8b91b1ab4aa6405cd10b09dcf603b39baf2366f23438ed32107a629c7c9e2cf6f3b39bc759e8fb81cc8d664d6a334fbd43bde3e8d584fb11df9a5f7ecd87e87d377141aac4f1d568a1227359e8677cc5b1df02675e3f5ccaf2a63b6d2cae464185bb012fef1ae6fbb4abe613252cb5bd57cccebe73a20bb3fa578a9b2dfb9cae0dca2912f433c59054c25a3e5f04ed63dc15687f89fec5d4e4ed84b9f10373f3d780488d99061fcfd12be20142279ed527e2f5281c1601ad4d11337fc05ee97b36ab8b676794bf7b3255bd5630835a51c786a6c4609ed836e933de8c63effc0b23cbafd886b157953fce3c8cc55a261a575bda42e5c9faae383fec77b3740ac0c52bb99a9e41f9c49f5407dc8e5d84fad359a6c922e035e0f1a906f7c27f98ec2d450d706a41d16b7536d446733d5f0bca4313f1b7a8d01d257dd5d840d33b0080655a9b30a7803f5e63ed798184a50ecccd2141497db8085d1860b9e6466a3c6e5c11829e63162dca6554610fd2dd2ad6336150ebc1ad9bf77d960fcf49ff93063b810c86615e5255264db2708f3d2d0d5a5212f6ef6859d3c6b3f06e5852475e96316de2dbb0560060376ae6d613ed8cb3c6b02b2f83a532c2178640cd9f839acfb0783f60627fa7c05af2a8a17e826b59ff7d489b43da50bda9b51097c224840fbbe3267f6dd3487a0e990a58f7101597c0b68f6a13be8127a1fc8a90d3012fd9f820fd11d5fdbf41634606ff54bffbf1eb7996d157354709b823cbe12d7bdad59edb0227812156036f21e1b9d232d7c7f859dd9c716f7358d8c27b3a40d26dc10d1d994b967bce3794242d27ec6547e3e3e5d72cb36b924732413f63efbde4a98e6abb5d71694cca16954c0d621e1efe8203e0551add5369385c6d17f34b4e35a328817c7709a3164a27a6b707308b1cc86ebba746c43f944c31c9f0c0c82d1c179480b3415ffb6f68a9365fefda3a357aa0cece86f410ace18ff4ddfeb634432d1d507cff5f0043b7fbbe6d14118ee7c7fd9b3792a192c5910dfb7cb732673868cd81b726f5e314d59749fa9858f18d2b556d456a6a665b5f239c19ecf41b61ed7fe458b8beb074ba985e6d297e35fb5da7da7f71df15df62a1e01c09a3c0a4231f54170dde42538e854a765c11c1be6a3df8aa6d78286adb771c6832d10ecb430b2c2b9169c5a0381337188616319bc71057f2522e9fdf8b3ba29705139abc14ea9c49fec1564b5b98838be9883b777d7d620aed09de6e8c19e71e3957e16a36d4cc64f47d357302d466622f018c826d6bbf3c4517c5e3620504263d93aa148e2bccb645b82fb722ac2c27471bab0d26b9ad4a26afb0bf3e65d064b7d890f82e052076b206499bf8ec723658d2ad8f66b6f410860542d29e0f5c05c959542e7b6004528b199eb4c7744e8a8e55eb7cb7db5b1661781bd620778b3f3a8ebc3b32d30b64e54a64fd2861f2adcfe187fb0d8d7367bc908edc8dbdfcec1bcfda3b4da8a9d4997d491df34e7afa035e5dc198f63aa749c349a4349a577123a3e533b159075868afccb8fb1b2c907cfa8743a095f3e7e93280ab9a1af5c07fe3403081585d8efdf025c9a1b54e8fc52a2316effd029a94edc446f123403fd80d907c8ef30ee085544de2d5ede30ea8a0e352b11ddc5140b0350ae66df9913a3f8fa0fb8f4f3f45d307bf24ec6b0fde9d0b4563d15c1c09bba91373d7d539445f326b1ebd21489eb8c436295dfd0fe6959652d354c0eef5436301bc8abe4e405768f2ab1fcf52404ce813cb13fa17e4338a66b83ab332f3e6a6dd7a931b718cde100120449e8a5a59847b188b387b6b6694f826e6b09208d1a4871a13914f81283684c2e2147860fdcc1129cccc3bed26a5977a9c5fd726221390beb384525f25d5d95345bce0b229f8d4a4f8b6080450c22025fa50fdff8c92c24a8aea1b3434514997a7d8a364721b237be9edfbdaa4c1f93e4f93feddbe52887fd61aa84e3c858c8da7dc76e3831a3b9cb68f20a5899516b7a6fa4b6ccaa7670d8fc7b6a8bbffd938c06e1945dd435f7329b7d8456515445998f3fd52a7f0b6758a4b35759476aea7b3d9a4e2797bd02df3c30d3aaf0344af4534406e2d0cc9e16df45cf0174ebc0d58ae4af38a41dbe6eed92ec121ce5a59ab3bec47e9e8caeea802047dcd586cb672416fe7064215a8df90655e58e6ec23e29766de0cca7298cc8144dbdc09112c0073c9e14b72c95ecd34e25f4a3e9c8b17f6cd167f4a0757653e29e41f22b28d85bb25dba58e232957181c320787fbd6e6a1cd87bb9889a765f94de030246e7f21fe21d3dad04c7350e974c4ab4d43bd9b417355b1234f80fc73c8a7ecdbb15ce7284afe9b10746cc6b37aa21efa4a8042e9a8a67760147bbd99efec54a2941d50ba385c1b31df4a6be3bb711a03a1f6e1fa67a801d1555517f10be37ff77482d09dca9a8fcb596eb2b92fbd39590e12038b64bfe1e6ee014c68597f82639dc9391dd67eea1e8c65f1f1f795dc77765b04f6924d4779fdb109aeba3ec00ece0730af14c7e06f4203b27362007ab36e9a042c0c7cdcdcb8feed5befbd5b852164c4a5fa403bb6bebef58c8b8924a5de3ee1f37cb259e622570af96aa2c95d15e5af12563a30fb53a46e00ae6c673b7a71770e54165552fa251042cfe03e4fe8859e1442ae6abef39f74afb2244300c61a7ec81be04d48c6b777fb3e3dec3480710e056911f50194f0e166a70dc41d50e7077a5bed9eeacccb02cdec88246fdce2bebdd294176bd39b1688a93423cbd1e0f711e9b2902bd413235fcaa8417fe40ddf4e0d070862779100d07a054cddd128b224f683f0b00e4b7542b3ec33a428e24c13072165a8054195afa76396adc89784c62b2450c81a0fad0a3baaa91dc8fafe1e7d0f07070ce5f1d11955fa105183fdf279b697207c580533c7d15b9e38bd1cea7ec4e400d9c1f0af564cbb2e865bdd327671bfe79314faf317735944eae51dd097e79006c195f6ead2592e146918d06800f08810b7ad2b543b68941ada5bb3bf612b22db0b67526eb924774a3815597489083cfa951070ce223c1289c93bfdf0d918742887c733503553ed2619fc5aee86ca1d321c994094c65bc570123d0319d2579b047e7be60928863af177d7caf72d131ed054fdbe973b671e34975e2839baae3d351a2a8374275ed3f0e07c6dc0d9762fcfe3152d4cc519108a5d94b71ca4c5508e75f582b4a15b1dc6461e887eec23dfc6a0dc9aa6672b57612ed1ccec280555cbf06a2999619579dcc9286e16417716f758c3a26690732e49e93bf6a3f033b06eec5618313fd4eabec1fc811499e5234fa07cb229adf71a9f013fd23ae5f88e05e0f0480dcc31ecc56b882233a7d49c439f4c17f6eb64f14bbf42fd16e37dccaac07c4df9919d7520b1c9c956bdc171ed256055920513ab4efe5bcef254e9ac95299d919f84074c7b96c5dd866b4f47261317d70f2f2908db900aa03659c688fbfedc3039cf80a74f0c66bfee03e60220267d095969b6abceedb8ade7acdd66ab8dd1e15c9ca424c742c8e165ac47885dc21b72869269ca0c4bdd0ae40e3f2c9ad1ff7497de1b612569483390935eb2d91f5b94ad10e3be7b3389973c588cb3997351b1670913d6ccb77f2e6b4f6337b572754f1759edd624d5d726bd80a19fceb81ab552a797fe847455080449c1dc1e09bd167d1b0385a6e17281807d6a39d7b38d21808414ff4bdb02382e77559c94c52c9a7aed9bc16dc10fbf1da7f0d10002c07de56bb2da933c22bcfc7564c6417a467f2840d63033c6a6cdc58b7091d3f6e5381dc62b4c7097e78968162f42f3f8087c38bb9af4c61ced2030d5b9d50dc2cc3f116b0df90628369979293db2621f65bd5364bba9cc725aa474fe6c4a6bfeb598584f10bdc3e4b3cd09a828a184248d2e2d2c3eb6cf1a39139c814b5d8b68cf845273c355c8b92809032f285fdb080e1f99dbe9ac33a1d70d5b9c07a772f09fdf3ade550628f3d41e1c16a66d1639377776d8f765254cd2685a0f3b00ad0b79643fa23340f1510e21cb185a2cfb260e75316d07160707ea63fa0836b05507aafb623db7426bfe6ec6a334ad70517983b852432d0c4fbf7fc1d0f55901e028877d66a812c1e6a097e824182a56155a5cd443657937c30136c4900d909326fdddb063ee4267eafb952fe81f6d43dee5a0c753f49c8eea011bdb6c11b29e5810422ef44635bb19cdece0ee835f89082bb9a82d097cf75cf04fb8098ee5fd2fcc17e17669d3585fb5b60bcd6dac57ac338fdd8b9bbe032d0e22d7eb6be3cc425e65ffaf3b2ab60b82555913b60eb2ff22cbc17a6b8e67573f20216f526adfceb6151434e5d3e3efc1d49e97023060992f8bff99d1cb71555bbf3064a8a61cf250fd2397d836b47c2202afee72a39cdbe30b9dc570584b5696fc09d6f82d15d4dcc61a7f53321d3ecbca35be9d350c92fb4ddb2e24802b7c40e4cab46daf4a43da7976cd0365272b8df7ecaadad0ceb52802d32b6f1411a77f4cf664508ad264ef565b4fe5cf12a1db44398a6bf23215f8ee8204dc0935f2dde737d5950491420a13636632812a426938a0900c90c774a7cf8c887353c1b47e688eb131ee025c0463f7390c810ccc832d2355a7f64305dd7d9cd5286387a28b1f18ae126ff16ee86da08de77dcf0cf5b871d6b09877a30e94159b77de543cb862e24e0b2a8d844ea5aee4493b2dd12288ea47720fec24469f147681d02ae36443fa96eba2f1e5b14d0ceba32fa5c68e0b7754eb064e72b24b5d0874cf36409514083da7e893d1bbaa558309bf6db72c8b4ea950d267987474ef1363a5a62a8ae8f34e07192e6e962fb5cd8246107ced7fba0170f3b9824d0f43c5eab660940d53f1ee9528530339f7901ee3df5c57757d89bb9a444d17a56a2e76dd9264ae84f16d53152f163949c7ad238785c597f71805b8584d9cf4326ded392c4228ec657bf9126fbef27eaa08e5de09de8122014bf24871278fece05a5b106ddac1b5fddf7f2f6a760d732f972c8be7d26fae8e3929ff846f56f882bf9024382983973a5d6ff0cdbc889db9615429df1a150716e7ad4eabda5282e31b67fd6418caa984c005ca83c4dc62956b3e6ff434bbb80b380af2b990c81b6e1a93ec03f4b471845426c8afd3251c31815842898d88b7fdb526f37c60a5980391f76b5bf40a52f8b6f948eb5c5564a377b356e5967f1a44f1f3a864556ade6bc9c2bbc9749d301f1bc4f365aa845bb7c50536bc9afd4d829269f24f1ebfb762eef1b43837871f97f027e52697fa071d00da7615ef7055a5cf2c5e3e296885bfb49034c1264c3537ffdbdc1a4dec8628fe0da727b794f18e5bb0970cd49ed742ac348df47f62a07cfaadedc8916112a4f99f022b38d9af722b8c401a0604f8f18e843d959523554448eda48ddcdf78b885b7d9850bf13e28e4f9223ed028d310eb9379b7e7d441739897bbc05f09c7e3afcf398cf8f8c311f9ea8e8b203a738a56048d1292c5ac2a7e773a787472b41f3bb939b66448e4a49ecc0d358c33bb41ed2e4f7e511f9ffe1f02a41bee9e630693f1198030ab81900c539f09e106fcc6644378fc02c04312a637b8ed08d475a6920b69c4916dc26f67c7db6f0522d2c91cbc236afb0eb4bf61d2e6e67c04657275d049ff243752ff24b041b672f728f33fba16ed536c2673e929b1fee1e815891e8eee6c873183f9c335333d20595db4b27c27799054398d5dbc9e91206768fc"; + let rangeproof_bytes = Vec::::from_hex(&rangeproof_hex).unwrap(); + let rangeproof = RangeProof::from_slice(&rangeproof_bytes[..]).unwrap(); + + // serde_cbor works ok + let bytes = serde_cbor::to_vec(&rangeproof).unwrap(); + let rangeproof_back: RangeProof = serde_cbor::from_slice(&bytes[..]).unwrap(); + let bytes_again = serde_cbor::to_vec(&rangeproof_back).unwrap(); + assert_eq!(bytes, bytes_again); + + // ciborium does not + let mut bytes_cib = vec![]; + ciborium::ser::into_writer(&rangeproof, &mut bytes_cib).unwrap(); + assert_eq!(bytes_cib, bytes, "ciborium/serde_cbor don't serialize the same"); + let _: RangeProof = ciborium::from_reader(&bytes_cib[..]).unwrap(); // Semantic(None, "invalid type: bytes, expected bytes") + } + #[cfg(feature = "serde")] #[test] fn serde_roundtrip() {