From da40e8ef5a43a364b3e189e9e094293b17da35a4 Mon Sep 17 00:00:00 2001 From: kiseln <3428059+kiseln@users.noreply.github.com> Date: Wed, 20 Mar 2024 20:23:27 +0700 Subject: [PATCH] Add more tests for proof generator --- eth2near/utilities/src/eth_proof_generator.rs | 97 ++++++++++++++++--- 1 file changed, 85 insertions(+), 12 deletions(-) diff --git a/eth2near/utilities/src/eth_proof_generator.rs b/eth2near/utilities/src/eth_proof_generator.rs index dec07e30..fb2f2521 100644 --- a/eth2near/utilities/src/eth_proof_generator.rs +++ b/eth2near/utilities/src/eth_proof_generator.rs @@ -30,20 +30,23 @@ pub fn get_proof_for_event(tx_hash: &str, log_index: u64, node_url: &str,) -> Re let block_header = client.get_block_by_number(receipt.block_number)?; let block_receipts = client.get_block_receipts(receipt.block_number)?; - let trie = build_receipt_trie(&block_receipts)?; + let mut trie = build_receipt_trie(&block_receipts)?; + trie.root()?; let receipt_key = rlp::encode(&receipt.transaction_index); let proof = trie.get_proof(&receipt_key)?; let mut log_data: Option> = None; - for log in &receipt.logs { + let mut log_index_in_receipt = 0; + for (i, log) in receipt.logs.iter().enumerate() { if log.log_index == log_index { log_data = Some(encode_log(log)); + log_index_in_receipt = i as u64; } } Ok(Proof { - log_index, + log_index: log_index_in_receipt, log_entry_data: log_data.ok_or("Log not found")?, receipt_index: receipt.transaction_index, receipt_data: encode_receipt(&receipt), @@ -151,20 +154,90 @@ fn encode_header(header: &BlockHeader) -> Vec { pub mod tests { use super::*; use hasher::Hasher; + const RPC_URL: &'static str = "https://eth.llamarpc.com"; #[test] - fn generate_proof() { - const RPC_URL: &'static str = "https://eth.llamarpc.com"; - const TX_HASH: &'static str = "0x9298954a9db8026ca28bce4d71ffb7ba0aac70e91f0667ffb7398c67e60b84fa"; - let proof = get_proof_for_event(TX_HASH, 377, RPC_URL).unwrap(); + fn generate_proof_pre_shapella() { + let tx_hash = "0xc4a6c5cde1d243b26b013f805f71f6de91536f66c993abfee746f373203b68cc"; + let proof = get_proof_for_event(tx_hash, 251, RPC_URL).unwrap(); + + let expected_log_index = 0; + let expected_receipt_index = 167; + let expected_header = "f61633d948772c98982af9df989c5cb9b9a8f5ed1a8411d57feb794013941de5"; + let expected_receipt = "02f902c70183f2d2d4b9010000000000000000000000000000000000000000000000000000000000000000000800010000000000000002000100000000000000000000000000000000000000000200000000000008000008000000000000000000000000000000004000000000000000000000000000000000000000000000000000010000000010000000000000000000000000000000000000000200000000010000000000000000000000000000000000200080000000200000000000000000000000000000004000000000000002000000000000000000000000000000000000080000000000000000000000000000000000000000000200000004000000000000000000000000000000f901bcf89b94a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48f863a0ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa0000000000000000000000000ef013a60f765f34b0fd7c5aaf83b9c65bb10a9afa000000000000000000000000023ddd3e3692d1861ed57ede224608875809e127fa0000000000000000000000000000000000000000000000000000000174876e800f9011c9423ddd3e3692d1861ed57ede224608875809e127ff863a0dd85dc56b5b4da387bf69c28ec19b1d66e793e0d51b567882fa31dc50bbd32c5a0000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48a0000000000000000000000000ef013a60f765f34b0fd7c5aaf83b9c65bb10a9afb8a0000000000000000000000000000000000000000000000000000000174876e8000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000002f6175726f72613a343332456231663237333036363241443141393739314564333443423244424466373030313535350000000000000000000000000000000000"; + let expected_log = "f89b94a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48f863a0ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa0000000000000000000000000ef013a60f765f34b0fd7c5aaf83b9c65bb10a9afa000000000000000000000000023ddd3e3692d1861ed57ede224608875809e127fa0000000000000000000000000000000000000000000000000000000174876e800"; + let expected_proof = [ + "f90131a0967c44262dfeff60c2af9aba0bece5cb031e5072f2978bcf7fb18360abad1d3ca0ebdf9d8b1746ad2d585fa5c657348250fa92fa0586d6c89ab40c186115bebc17a0feffed8388da8e4f4936717c660a42f34b93cce4583d0944198c27e043779f56a06f970da48b1447fb56f88d27d9b0d4ea8cf30a6e83b507734fd96e3a42c17f24a0748ff314a3f88b77e11ef6c7f716f58ac498ae3b3264d6b2e0bdb6c91030df1fa05f6b3f1d31dc2f30322199b97af434c1c40891648515c0c483c2518f981a10b1a06dfe85601a2d49321453acf4edeab412bdb950fc65b2337b042aa7972d4925eea01eb88ec9349d5f61858f5a14b90456b78fb3bb0121d90df936d9765a05e78031a047c4fa8e5283c0dbeae2e4b9e6250008551b02d2edce1dd87bf9ace4d687604b8080808080808080", + "f851a08aa8e40f2823eb01a484cf576f2582137280289ca54eb3da743a36203ba963d0a023bad42a2491d2b478b82ff7e2d1b2beb569981a23c4376be21d1436c12d920a808080808080808080808080808080", + "f8918080808080808080a0918f290dbb902b8bf23c852bd82c945a37d4d5d015e9e9485616f3fa6e12aabca092b063303221d5c76f441ae788fa44597bd71cf03d0c944993ce8428c5a661fda0a7fc9b765f5a541c286acb44fe3ccffd32c1585da784b88d9bd800d933e69826a0ea9675894b751d28c53159f2582481df16925392fef0a81e1a2baa2d9e08190b8080808080", + "f90211a0abc02bfbddd2313e525124b626275a08e4d5437c837a114b11bd56a9421d04aaa0e71d7c39496e26fa67b5cc364a49e2e5701c8b5edbd5c58afc716e92ca9cc8f9a0cdec4707b811edbf0c81db09631c5a18dbfbda66d4793358257e5ec5c8993234a01356b944c23504dc1aa148f1a46d5e3c3f1b990a88b8ade4767d84aa7d4ca79fa06f883de36996ebd0b395f114e96a468c1aeaa287ca4f10e01648b0d60515a111a02ccaea122ce8542fd7ff9e02cec311f8d1b8ab7a0d949074e8f621765c58588ba01aeeca3be1c4e8e2581ed016d74442677645c0b423bb34e919ccf14009cbc92ba03bc2b368375a4de99317a01c548c6e564966cb317c3b4ba20c5cb0b181ac7c6ca04350da6c4a50dbb535c72bcd4632a5b94c15c709e2df6cd91269ce0faacd46c4a0743908223350d40bdb093c331dc0fbabe066f46440fdcf474f28acc48162c67da052aeea371b09dfe541719470a63a1fb12708c72eaa575bf723fea692a48b9d77a0aefd559fe69cb9163a4c3aa562e80beb3199afa446c449f048a38be05bc5fa00a05a373afc917a53eea199c158f7daea520dcc4d5b76c6cf87bb823b962f6cb506a0eb119ea50817395bd79be6e6fa748d64dc9ded81c63c6d61474210ab0003be7da0e4c36dd93a40a90993f083829469e0718aaf510e8eedf9ed5a7d8fdd4af92643a0aa1c5c12d65fdf25f74354991185dccecefb1e5813531ce8c9fdd2b2c7494a3c80", + "f902cf20b902cb02f902c70183f2d2d4b9010000000000000000000000000000000000000000000000000000000000000000000800010000000000000002000100000000000000000000000000000000000000000200000000000008000008000000000000000000000000000000004000000000000000000000000000000000000000000000000000010000000010000000000000000000000000000000000000000200000000010000000000000000000000000000000000200080000000200000000000000000000000000000004000000000000002000000000000000000000000000000000000080000000000000000000000000000000000000000000200000004000000000000000000000000000000f901bcf89b94a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48f863a0ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa0000000000000000000000000ef013a60f765f34b0fd7c5aaf83b9c65bb10a9afa000000000000000000000000023ddd3e3692d1861ed57ede224608875809e127fa0000000000000000000000000000000000000000000000000000000174876e800f9011c9423ddd3e3692d1861ed57ede224608875809e127ff863a0dd85dc56b5b4da387bf69c28ec19b1d66e793e0d51b567882fa31dc50bbd32c5a0000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48a0000000000000000000000000ef013a60f765f34b0fd7c5aaf83b9c65bb10a9afb8a0000000000000000000000000000000000000000000000000000000174876e8000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000002f6175726f72613a343332456231663237333036363241443141393739314564333443423244424466373030313535350000000000000000000000000000000000" + ]; + + let hasher = HasherKeccak::new(); + assert_eq!(hasher.digest(&proof.header_data), hex::decode(expected_header).unwrap()); + + assert_eq!(proof.log_index, expected_log_index); + assert_eq!(proof.receipt_index, expected_receipt_index); + assert_eq!(proof.receipt_data, hex::decode(expected_receipt).unwrap()); + assert_eq!(proof.log_entry_data, hex::decode(expected_log).unwrap()); + assert_eq!(proof.proof.len(), expected_proof.len()); + assert!(proof.proof.into_iter().eq(expected_proof.iter().map(|x| hex::decode(x).unwrap()))); + } - const EXPECTED_HEADER: &'static str = "14ffc7718ede2f244f3abcdf513cade51d60a50bfd503a10079b5b540af5dee0"; + #[test] + fn generate_proof_post_shapella() { + let tx_hash = "0xd6ae351d6946f98c4b63589e2154db668e703e8c09fbd4e5c6807b5d356453c3"; + let proof = get_proof_for_event(tx_hash, 172, RPC_URL).unwrap(); + + let expected_log_index = 0; + let expected_receipt_index = 54; + let expected_header = "d02357b89842839d7c736f5b9899a6a2f469c7c1c35ec574c76b087006653456"; + let expected_receipt = "02f902c701837036edb9010000000000000000000000000000000000000000000000000000200000000000000800010000000000000002000100000000000000000000000000000000000000000000000000000008000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000010000000000000000000000000000000000000000200000000010000000000000000000000000000000000200080000000200000000000000000000000000000004000000000000002000000000000000000000000000000000000080000000000000000000000000000000000000000000200000004000000000002000000000000000000f901bcf89b94a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48f863a0ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa000000000000000000000000090b0a46b1c02bd137ca1410772eff1c231f07fe2a000000000000000000000000023ddd3e3692d1861ed57ede224608875809e127fa00000000000000000000000000000000000000000000000000000000014dc9380f9011c9423ddd3e3692d1861ed57ede224608875809e127ff863a0dd85dc56b5b4da387bf69c28ec19b1d66e793e0d51b567882fa31dc50bbd32c5a0000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48a000000000000000000000000090b0a46b1c02bd137ca1410772eff1c231f07fe2b8a00000000000000000000000000000000000000000000000000000000014dc93800000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000002f6175726f72613a316339396663333736353537366635613641353544353341653431423936434239373141393432350000000000000000000000000000000000"; + let expected_log = "f89b94a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48f863a0ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa000000000000000000000000090b0a46b1c02bd137ca1410772eff1c231f07fe2a000000000000000000000000023ddd3e3692d1861ed57ede224608875809e127fa00000000000000000000000000000000000000000000000000000000014dc9380"; + let expected_proof = [ + "f90111a09e0259b98fa182a95c48a8dacc2692badd7c29f71bc3e0d9d73dbf9d07e9611ba0ba6c9f95a62c8f2b828d4160e01162934297442c7cefea304908609de9fbd075a0993a2a24f0772d90700a7ad8f133ab1b7963defa359ad9826eb963f6168cfb60a0c31053f554e06e64bdddc105051dd2210d396514cd6edcc9aa55767e7652825ba05e2a24f235c03c6b6320a1d62e0e6d646349da863767ecf10126e6b4aacf274fa0e0c4a45d2ecd16a37af707062a5bec9f6657fcfe14ddb692215bdd6a26600617a0e53fe123d45561809c69c532b39d90e7eb0b6d7a74d09a259cbb41a29b12081480a044cf8e4f60cf97fb129824b1b37c04e82251da90b5e8fb9b3998cc3519e159798080808080808080", + "f90211a0d4de7e86f5e6eba4a08c89925937986e201e6f286b7123fb5700354df9167b7ba07b3389484104ebb32e6959db5ed3cddcdb2d1ce0c2b41ce5dc4ce2553e808f84a0e7344755384ea053c57c5546c1516a356c8cab5fe926a5a3eb3fe6721671001da0b9312cb00a3723a9a80598ab13d730430c686e9f2b14e669f41d87f36ede87b2a06069a92ac34df54f389475c9b92fea2b92bc73e92bffa14cb5c085469e884398a03f6262719ad775eef95b991f24aa63370892d4d0ef8dbaeba19f681e2cba2b5aa0071ab0cc93209db0be2343111f91ba35a180e0a453f23660aed462fce5daf551a0bfd7126fa52bb94255b9b7613a5a0b8bdb1f01443de5da83ce1839a0fe9d6e3ba02384631620ba5abce1a52e7347bff8c3727a56390bd7bc57c7d1386508cb1672a06ed35b57e37f3a08788866524b8a2d0089ec3fb308f34dea583324afd57e476aa05af302b741e36f6c630f423ff8d40be2fdeb4fb517eb62782ae6955c986ce21fa0b16f820757bb0bd971bdba9371540c09528d2818a6ab196ca6cbb3919d5097bda027b6b7c488fd95227a11f4c62d1d138341fd242f558de9bba659f99f543edd18a06f83a49cb804e10ee72d2cbd844b0fb6145eb5ca2f3bcd0c4d37fd357f2404d8a0b9f13ed67f0b534b781693633d36bde8f6127aa4cae31659475910a08a2956f4a0dcc805b1d26db82e140bf5de19cb39b95e7590a52e13cd83a65471cb95f456fd80", + "f902cf20b902cb02f902c701837036edb9010000000000000000000000000000000000000000000000000000200000000000000800010000000000000002000100000000000000000000000000000000000000000000000000000008000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000010000000000000000000000000000000000000000200000000010000000000000000000000000000000000200080000000200000000000000000000000000000004000000000000002000000000000000000000000000000000000080000000000000000000000000000000000000000000200000004000000000002000000000000000000f901bcf89b94a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48f863a0ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa000000000000000000000000090b0a46b1c02bd137ca1410772eff1c231f07fe2a000000000000000000000000023ddd3e3692d1861ed57ede224608875809e127fa00000000000000000000000000000000000000000000000000000000014dc9380f9011c9423ddd3e3692d1861ed57ede224608875809e127ff863a0dd85dc56b5b4da387bf69c28ec19b1d66e793e0d51b567882fa31dc50bbd32c5a0000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48a000000000000000000000000090b0a46b1c02bd137ca1410772eff1c231f07fe2b8a00000000000000000000000000000000000000000000000000000000014dc93800000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000002f6175726f72613a316339396663333736353537366635613641353544353341653431423936434239373141393432350000000000000000000000000000000000", + ]; let hasher = HasherKeccak::new(); + assert_eq!(hasher.digest(&proof.header_data), hex::decode(expected_header).unwrap()); + + assert_eq!(proof.log_index, expected_log_index); + assert_eq!(proof.receipt_index, expected_receipt_index); + assert_eq!(proof.receipt_data, hex::decode(expected_receipt).unwrap()); + assert_eq!(proof.log_entry_data, hex::decode(expected_log).unwrap()); + assert_eq!(proof.proof.len(), expected_proof.len()); + assert!(proof.proof.into_iter().eq(expected_proof.iter().map(|x| hex::decode(x).unwrap()))); + } + + #[test] + fn generate_proof_post_dencun() { + let tx_hash = "0x42639810a1238a76ca947b848f5b88a854ac36471d1c4f6a15631393790f89af"; + let proof = get_proof_for_event(tx_hash, 360, RPC_URL).unwrap(); + + let expected_log_index = 0; + let expected_receipt_index = 212; + let expected_header = "0a02eb4a373b45367457c1e162c728cae7e68beaf0914b259b10ed033e95bdcc"; + let expected_receipt = "02f902a60183cee136b9010000000000000020000000000000000000000000000000000000000000000000000800010000000000000008000100000040000000000000000000000000000000000000000000000000000008004000000000000000000000000000000000000000000000000000000000000000000200000000000000010000000010000000000000010000000000000000000000000000000000000004000000000000000000000000000000000080000000200000000000000000000000000000004000000000000002000000000000000000000000000000000000080000210000000000000000000000000000000000000200000000000000000000000000000000000000f9019bf89b94438e48ed4ce6beecf503d43b9dbd3c30d516e7fdf863a0ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa00000000000000000000000006889de313803839ce3e15996a86167f639b4a634a000000000000000000000000023ddd3e3692d1861ed57ede224608875809e127fa000000000000000000000000000000000000000000000001a2738b6f81a2e0130f8fc9423ddd3e3692d1861ed57ede224608875809e127ff863a0dd85dc56b5b4da387bf69c28ec19b1d66e793e0d51b567882fa31dc50bbd32c5a0000000000000000000000000438e48ed4ce6beecf503d43b9dbd3c30d516e7fda00000000000000000000000006889de313803839ce3e15996a86167f639b4a634b88000000000000000000000000000000000000000000000001a2738b6f81a2e01300000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000b74696d626c652e6e656172000000000000000000000000000000000000000000"; + let expected_log = "f89b94438e48ed4ce6beecf503d43b9dbd3c30d516e7fdf863a0ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa00000000000000000000000006889de313803839ce3e15996a86167f639b4a634a000000000000000000000000023ddd3e3692d1861ed57ede224608875809e127fa000000000000000000000000000000000000000000000001a2738b6f81a2e0130"; + let expected_proof = [ + "f90131a0ea31efc223a1f91c0211cc8216c96d841a4c6aa9e706b1c80f4556473766c835a0a0d053a80857fe23752abc931238dfb519c600ec2c89740a8c0027f2452691dba07211c9aec8f2476236ff4ae404ea0a4d86a3b69aef1d7d68b4525b695d6937c3a066ff6c2bdfbec1a598afe01a4c8cb5342f09dc23e126af6161fc8b66a29258b4a02b1c9c12e45087ab52a964dac390a2b297b279839a14d73e6039ff4136efe176a0c5d3039faed9aefe6b036979ee41e741a6d1a1ffb280d245eefac5646ff0e5b4a0de9817fcc57347a50f1c3bf6bc0af45514a1e17b349d6b3a893acdfc45ad0a70a0bd3ac3599d9a58447c23c89c2ba279fa00a11c13c5e181012d50e012ef845f77a026ce9a58a9d343be345947cd441816397a516ad88e7211170a856d8ce164a14b8080808080808080", + "f851a0776031d2861aa23cb9bd323e49ac2b831658c311c35413899369ea8d558af735a08b9654ecaae433ee01704bb66b4877076a1f8e40b92ba31cadfb9dc06f858c15808080808080808080808080808080", + "f8f18080808080808080a07a49b3a8c05d073eb6d6d11c5c4fdc4505acb5a36c9cbc590929aad029ffc719a099264b31f39abaef84c246bbac4a72dc8bcf5d935c775a8d6c356234d0226061a042f9385fe9d42d8764f8e69b30cae57bcff98c77dc5431d7cc21d10905abcd1ca08a3023498e1067ee67f3caa5a290502efcb05549dd9b0814023e6e1448288467a06e40e4f27b3a0ed5de67c684369aa12610652e6399d002edb5443394f64db861a069631286f3eddfa8ef89eec490348240bc8690b874db62dde1690206dff758b2a0cebfcf4bb26fdcd28a9a42ec0da1e287a0cb41d9bb40ca4879d1cccaf23309998080", + "f90211a0c36f6abaee0178f644673e7d81132cdb139a9bd0bacf0d9719803242b54ef4d3a001a13437394f2ec24ec6a62baf5ef685dc617948314cf6cb7cb237dd759ba7afa0723df3efb2a08ca7156749e43c789cc92001953180a0e51935b3db6eb9c189b2a0d9929bc3195b7cb531249cfcccb0d7d56243a3af67be40d8a89a1ee287a2deeaa0641a7b318fd965ea4d1eb0686909dcd7898b491bb632eeb1ebad2bcc828f4017a0908899d902b0d7d459bba5e19767fc3373764fc6290de12d6588b4e90694aadfa0c6bdef3e0259812cbb979859c0e6a5e2bf980be306d5ed709ae373f0953449cca00993685867da25fb8ac53d636b9630a20297cdabf6e45bc003770dc335742d99a0c8b548c83f65e60afe207d499697f7b377be59c73183f0507862bc739be2348ba0cb4bc9bafef0aec55cd9ff83bc459d162e9f3701b784e2af2a768bc8b3dceeb9a066f522fef288d829e8e49738af851f7aef120dda1f6a1b934c24f96f52684ff2a0117847f1836bf5f354706fce391a183f4b69a55c6e64e820d69c4f5ee35e703da0548eb3f38b406cd35381c28b8a78028d48fe63db72f4a595893adc579b566295a0228c5276786aad75391a7b42d96df14b4494723fc1b096e07bc73e6bfaebc00ea01ae3c79fc12a94557c83e2668c89ec273b0fec08ad6b66e758cde410f121d340a06009085a2fc2a80ee20e8846c9320e28fd7ecf2c519fb8b5559fa30c750ebe8b80", + "f902ae20b902aa02f902a60183cee136b9010000000000000020000000000000000000000000000000000000000000000000000800010000000000000008000100000040000000000000000000000000000000000000000000000000000008004000000000000000000000000000000000000000000000000000000000000000000200000000000000010000000010000000000000010000000000000000000000000000000000000004000000000000000000000000000000000080000000200000000000000000000000000000004000000000000002000000000000000000000000000000000000080000210000000000000000000000000000000000000200000000000000000000000000000000000000f9019bf89b94438e48ed4ce6beecf503d43b9dbd3c30d516e7fdf863a0ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa00000000000000000000000006889de313803839ce3e15996a86167f639b4a634a000000000000000000000000023ddd3e3692d1861ed57ede224608875809e127fa000000000000000000000000000000000000000000000001a2738b6f81a2e0130f8fc9423ddd3e3692d1861ed57ede224608875809e127ff863a0dd85dc56b5b4da387bf69c28ec19b1d66e793e0d51b567882fa31dc50bbd32c5a0000000000000000000000000438e48ed4ce6beecf503d43b9dbd3c30d516e7fda00000000000000000000000006889de313803839ce3e15996a86167f639b4a634b88000000000000000000000000000000000000000000000001a2738b6f81a2e01300000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000b74696d626c652e6e656172000000000000000000000000000000000000000000" + ]; - println!("Header {:x?}", hasher.digest(&proof.header_data)); - println!("Proof {:x?}", &proof.proof); - - assert_eq!(hasher.digest(&proof.header_data), hex::decode(EXPECTED_HEADER).unwrap()); + let hasher = HasherKeccak::new(); + assert_eq!(hasher.digest(&proof.header_data), hex::decode(expected_header).unwrap()); + + assert_eq!(proof.log_index, expected_log_index); + assert_eq!(proof.receipt_index, expected_receipt_index); + assert_eq!(proof.receipt_data, hex::decode(expected_receipt).unwrap()); + assert_eq!(proof.log_entry_data, hex::decode(expected_log).unwrap()); + assert_eq!(proof.proof.len(), expected_proof.len()); + assert!(proof.proof.into_iter().eq(expected_proof.iter().map(|x| hex::decode(x).unwrap()))); } }