Skip to content

Commit

Permalink
Esad/fix tests (#1113)
Browse files Browse the repository at this point in the history
* fix getters_succeed

* bump proof wait time because it takes a lng time on bitcoin

* try again on ci

* fix test asserts and increase wait time for sequencer block production

* adjust LedgerGetCommitmentsTest one more time
  • Loading branch information
eyusufatik authored Sep 5, 2024
1 parent ad4e3ba commit c58de2f
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 18 deletions.
2 changes: 1 addition & 1 deletion bin/citrea/tests/all_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ mod test_helpers;

const DEFAULT_MIN_SOFT_CONFIRMATIONS_PER_COMMITMENT: u64 = 1000;
const DEFAULT_DEPOSIT_MEMPOOL_FETCH_LIMIT: usize = 10;
const DEFAULT_PROOF_WAIT_DURATION: u64 = 300; // 5 minutes
const DEFAULT_PROOF_WAIT_DURATION: u64 = 600; // 10 minutes
const TEST_DATA_GENESIS_PATH: &str = "../../resources/test-data/integration-tests";
11 changes: 6 additions & 5 deletions bin/citrea/tests/bitcoin_e2e/tests/sequencer_commitments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,10 @@ impl TestCase for LedgerGetCommitmentsTest {
sequencer.client.send_publish_batch_request().await;
}

da.generate(1, None).await?;
// disable this since it's the only difference from other tests??
// da.generate(1, None).await?;

sequencer.client.send_publish_batch_request().await;
// sequencer.client.send_publish_batch_request().await;

// Wait for blob tx to hit the mempool
da.wait_mempool_len(1, None).await?;
Expand All @@ -132,7 +133,7 @@ impl TestCase for LedgerGetCommitmentsTest {
da.generate(FINALITY_DEPTH + 1, None).await?;

full_node
.wait_for_l2_height(MIN_SOFT_CONF_PER_COMMITMENT + 1, None)
.wait_for_l2_height(MIN_SOFT_CONF_PER_COMMITMENT, None)
.await;

let finalized_height = da.get_finalized_height().await?;
Expand All @@ -150,13 +151,13 @@ impl TestCase for LedgerGetCommitmentsTest {

let hash = da.get_block_hash(finalized_height).await?;

let commitments_hash = full_node
let commitments_node = full_node
.client
.ledger_get_sequencer_commitments_on_slot_by_hash(hash.as_raw_hash().to_byte_array())
.await
.unwrap()
.unwrap();
assert_eq!(commitments_hash, commitments);
assert_eq!(commitments_node, commitments);
Ok(())
}
}
Expand Down
4 changes: 2 additions & 2 deletions bin/citrea/tests/e2e/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ async fn test_all_flow() {
assert_eq!(commitments_hash, commitments);

let prover_proof = prover_node_test_client
.ledger_get_proof_by_slot_height(3)
.ledger_get_proofs_by_slot_height(3)
.await[0]
.clone();

Expand Down Expand Up @@ -295,7 +295,7 @@ async fn test_all_flow() {
assert_eq!(commitments.len(), 1);

let prover_proof_data = prover_node_test_client
.ledger_get_proof_by_slot_height(5)
.ledger_get_proofs_by_slot_height(5)
.await[0]
.clone();

Expand Down
2 changes: 1 addition & 1 deletion bin/citrea/tests/e2e/proving.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ async fn full_node_verify_proof_and_store() {
assert_eq!(commitments_hash, commitments);

let prover_proof = prover_node_test_client
.ledger_get_proof_by_slot_height(3)
.ledger_get_proofs_by_slot_height(3)
.await[0]
.clone();

Expand Down
4 changes: 2 additions & 2 deletions bin/citrea/tests/e2e/sequencer_behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ async fn test_sequencer_commitment_threshold() {
.unwrap();
}
seq_test_client.send_publish_batch_request().await;
wait_for_l2_block(&seq_test_client, i, Some(Duration::from_secs(10))).await;
wait_for_l2_block(&seq_test_client, i, None).await;
}

wait_for_l2_block(&seq_test_client, 11, Some(Duration::from_secs(60))).await;
Expand All @@ -205,7 +205,7 @@ async fn test_sequencer_commitment_threshold() {
.unwrap();
}
seq_test_client.send_publish_batch_request().await;
wait_for_l2_block(&seq_test_client, i, Some(Duration::from_secs(10))).await;
wait_for_l2_block(&seq_test_client, i, None).await;
}

wait_for_l2_block(&seq_test_client, 21, Some(Duration::from_secs(60))).await;
Expand Down
2 changes: 1 addition & 1 deletion bin/citrea/tests/test_client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ impl TestClient {
.map_err(|e| e.into())
}

pub(crate) async fn ledger_get_proof_by_slot_height(&self, height: u64) -> Vec<ProofResponse> {
pub(crate) async fn ledger_get_proofs_by_slot_height(&self, height: u64) -> Vec<ProofResponse> {
self.http_client
.request("ledger_getProofsBySlotHeight", rpc_params![height])
.await
Expand Down
8 changes: 4 additions & 4 deletions crates/sovereign-sdk/full-node/sov-ledger-rpc/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ pub trait Rpc {
) -> RpcResult<Option<Vec<SequencerCommitmentResponse>>>;

/// Gets proof by slot height.
#[method(name = "getProofBySlotHeight")]
async fn get_proof_by_slot_height(&self, height: u64) -> RpcResult<Option<ProofResponse>>;
#[method(name = "getProofsBySlotHeight")]
async fn get_proofs_by_slot_height(&self, height: u64) -> RpcResult<Option<ProofResponse>>;

/// Gets proof by slot hash.
#[method(name = "getProofBySlotHash")]
async fn get_proof_by_slot_hash(&self, hash: [u8; 32]) -> RpcResult<Option<ProofResponse>>;
#[method(name = "getProofsBySlotHash")]
async fn get_proofs_by_slot_hash(&self, hash: [u8; 32]) -> RpcResult<Option<ProofResponse>>;

/// Gets the height pf most recent committed soft confirmation.
#[method(name = "getHeadSoftConfirmation")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ where
.map_err(|e| to_jsonrpsee_error_object(LEDGER_RPC_ERROR, e))
})?;

rpc.register_blocking_method("ledger_getProofBySlotHash", move |params, ledger, _| {
rpc.register_blocking_method("ledger_getProofsBySlotHash", move |params, ledger, _| {
// Returns proof on DA slot with given height
let hash: [u8; 32] = params.one()?;
let height = ledger
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ async fn getters_succeed() {
.await
.unwrap();

rpc_client.get_proof_by_slot_hash([0; 32]).await.unwrap();
rpc_client.get_proofs_by_slot_height(0).await.unwrap();

rpc_client.get_proofs_by_slot_hash([0; 32]).await.unwrap();

rpc_client
.get_head_soft_confirmation_height()
Expand Down

0 comments on commit c58de2f

Please sign in to comment.