diff --git a/bin/citrea/src/test_rpc.rs b/bin/citrea/src/test_rpc.rs index 1289a7ad8..e556fddf9 100644 --- a/bin/citrea/src/test_rpc.rs +++ b/bin/citrea/src/test_rpc.rs @@ -288,9 +288,9 @@ fn test_get_batches() { let expected = jsonrpc_result!([{ "hash":"0xf85fe0cb36fdaeca571c896ed476b49bb3c8eff00d935293a8967e1e9a62071e", "tx_range":{"start":3,"end":263}, - "txs": batch2_tx_receipts().into_iter().map(|tx_receipt| format!("0x{}", hex::encode(tx_receipt.tx_hash) )).collect::>(), - + "txs": batch2_tx_receipts().into_iter().map(|tx_receipt| hex::encode(tx_receipt.tx_hash) ).collect::>(), }]); + regular_test_helper(payload, &expected); let payload = jsonrpc_req!("ledger_getBatches", [[2]]); @@ -316,7 +316,7 @@ fn test_get_batches() { fn test_get_soft_batch() { // Get the first soft batch by number let payload = jsonrpc_req!("ledger_getSoftBatchByNumber", [1]); - let expected = jsonrpc_result!({"da_slot_height":0,"da_slot_hash":"0000000000000000000000000000000000000000000000000000000000000000","da_slot_txs_commitment":"0101010101010101010101010101010101010101010101010101010101010101","hash":"b5515a80204963f7db40e98af11aedb49a394b1c7e3d8b5b7a33346b8627444f","txs":["0x74783120626f6479", "0x74783220626f6479"],"pre_state_root":"","post_state_root":"","soft_confirmation_signature":"","pub_key":"","l1_fee_rate":0}); + let expected = jsonrpc_result!({"da_slot_height":0,"da_slot_hash":"0000000000000000000000000000000000000000000000000000000000000000","da_slot_txs_commitment":"0101010101010101010101010101010101010101010101010101010101010101","hash":"b5515a80204963f7db40e98af11aedb49a394b1c7e3d8b5b7a33346b8627444f","txs":["74783120626f6479", "74783220626f6479"],"pre_state_root":"","post_state_root":"","soft_confirmation_signature":"","pub_key":"","l1_fee_rate":0}); regular_test_helper(payload, &expected); // Get the first soft batch by hash @@ -330,12 +330,7 @@ fn test_get_soft_batch() { let payload = jsonrpc_req!("ledger_getSoftBatchByNumber", [2]); let txs = batch2_tx_receipts() .into_iter() - .map(|tx_receipt| { - format!( - "0x{}", - tx_receipt.body_to_save.unwrap().encode_hex::() - ) - }) + .map(|tx_receipt| tx_receipt.body_to_save.unwrap().encode_hex::()) .collect::>(); let expected = jsonrpc_result!( {"da_slot_height":1,"da_slot_hash":"0202020202020202020202020202020202020202020202020202020202020202","da_slot_txs_commitment":"0303030303030303030303030303030303030303030303030303030303030303","hash":"f85fe0cb36fdaeca571c896ed476b49bb3c8eff00d935293a8967e1e9a62071e","txs": txs, "pre_state_root":"","post_state_root":"","soft_confirmation_signature":"","pub_key":"","l1_fee_rate":0} @@ -354,15 +349,10 @@ fn test_get_soft_batch() { let txs = batch2_tx_receipts() .into_iter() - .map(|tx_receipt| { - format!( - "0x{}", - tx_receipt.body_to_save.unwrap().encode_hex::() - ) - }) + .map(|tx_receipt| tx_receipt.body_to_save.unwrap().encode_hex::()) .collect::>(); let expected = jsonrpc_result!( - [{"da_slot_height":0,"da_slot_hash":"0000000000000000000000000000000000000000000000000000000000000000","da_slot_txs_commitment":"0101010101010101010101010101010101010101010101010101010101010101","hash":"b5515a80204963f7db40e98af11aedb49a394b1c7e3d8b5b7a33346b8627444f","txs":["0x74783120626f6479", "0x74783220626f6479"],"pre_state_root":"","post_state_root":"","soft_confirmation_signature":"","pub_key":"","l1_fee_rate":0},{"da_slot_height":1,"da_slot_hash":"0202020202020202020202020202020202020202020202020202020202020202","da_slot_txs_commitment":"0303030303030303030303030303030303030303030303030303030303030303","hash":"f85fe0cb36fdaeca571c896ed476b49bb3c8eff00d935293a8967e1e9a62071e","txs": txs, "pre_state_root":"","post_state_root":"","soft_confirmation_signature":"","pub_key":"","l1_fee_rate":0} + [{"da_slot_height":0,"da_slot_hash":"0000000000000000000000000000000000000000000000000000000000000000","da_slot_txs_commitment":"0101010101010101010101010101010101010101010101010101010101010101","hash":"b5515a80204963f7db40e98af11aedb49a394b1c7e3d8b5b7a33346b8627444f","txs":["74783120626f6479", "74783220626f6479"],"pre_state_root":"","post_state_root":"","soft_confirmation_signature":"","pub_key":"","l1_fee_rate":0},{"da_slot_height":1,"da_slot_hash":"0202020202020202020202020202020202020202020202020202020202020202","da_slot_txs_commitment":"0303030303030303030303030303030303030303030303030303030303030303","hash":"f85fe0cb36fdaeca571c896ed476b49bb3c8eff00d935293a8967e1e9a62071e","txs": txs, "pre_state_root":"","post_state_root":"","soft_confirmation_signature":"","pub_key":"","l1_fee_rate":0} ] ); regular_test_helper(payload, &expected); @@ -553,7 +543,7 @@ proptest!( let batch_hash = hex::encode(curr_batch.batch_hash); let _batch_receipt= 0; let tx_hashes: Vec = curr_batch.tx_receipts.iter().map(|tx| { - format!("0x{}", hex::encode(tx.tx_hash)) + hex::encode(tx.tx_hash) }).collect(); let full_txs = curr_batch.tx_receipts.iter().enumerate().map(|(tx_id, tx)| full_tx_json(curr_tx_num + tx_id, tx, &tx_id_to_event_range) diff --git a/crates/sovereign-sdk/rollup-interface/src/node/rpc/mod.rs b/crates/sovereign-sdk/rollup-interface/src/node/rpc/mod.rs index 765512421..fc85ac86e 100644 --- a/crates/sovereign-sdk/rollup-interface/src/node/rpc/mod.rs +++ b/crates/sovereign-sdk/rollup-interface/src/node/rpc/mod.rs @@ -250,7 +250,7 @@ pub struct TxResponse { #[serde(untagged)] pub enum ItemOrHash { /// The hex encoded hash of the requested item. - Hash(#[serde(with = "utils::rpc_hex")] [u8; 32]), + Hash(#[serde(with = "hex::serde")] [u8; 32]), /// The full item body. Full(T), }