Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rakanalh committed Apr 6, 2024
1 parent 44a3213 commit 33b5af7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 18 deletions.
24 changes: 7 additions & 17 deletions bin/citrea/src/test_rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<Vec<_>>(),

"txs": batch2_tx_receipts().into_iter().map(|tx_receipt| hex::encode(tx_receipt.tx_hash) ).collect::<Vec<_>>(),
}]);

regular_test_helper(payload, &expected);

let payload = jsonrpc_req!("ledger_getBatches", [[2]]);
Expand All @@ -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
Expand All @@ -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::<String>()
)
})
.map(|tx_receipt| tx_receipt.body_to_save.unwrap().encode_hex::<String>())
.collect::<Vec<String>>();
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}
Expand All @@ -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::<String>()
)
})
.map(|tx_receipt| tx_receipt.body_to_save.unwrap().encode_hex::<String>())
.collect::<Vec<String>>();
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);
Expand Down Expand Up @@ -553,7 +543,7 @@ proptest!(
let batch_hash = hex::encode(curr_batch.batch_hash);
let _batch_receipt= 0;
let tx_hashes: Vec<String> = 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)
Expand Down
2 changes: 1 addition & 1 deletion crates/sovereign-sdk/rollup-interface/src/node/rpc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ pub struct TxResponse<Tx> {
#[serde(untagged)]
pub enum ItemOrHash<T> {
/// 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),
}
Expand Down

0 comments on commit 33b5af7

Please sign in to comment.