Skip to content

Commit

Permalink
Add test for abort on tag
Browse files Browse the repository at this point in the history
  • Loading branch information
3alpha committed Jul 9, 2024
1 parent 4e34912 commit 448b013
Showing 1 changed file with 30 additions and 2 deletions.
32 changes: 30 additions & 2 deletions crates/starknet-devnet/tests/test_abort_blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pub mod common;
mod abort_blocks_tests {
use serde_json::json;
use server::api::json_rpc::error::ApiError;
use starknet_rs_core::types::{BlockId, FieldElement};
use starknet_rs_core::types::{BlockId, BlockTag, FieldElement};
use starknet_types::rpc::transaction_receipt::FeeUnit;

use crate::common::background_devnet::BackgroundDevnet;
Expand Down Expand Up @@ -97,7 +97,7 @@ mod abort_blocks_tests {
}

#[tokio::test]
async fn abort_latest_block() {
async fn abort_latest_block_with_hash() {
let devnet =
BackgroundDevnet::spawn_with_additional_args(&["--state-archive-capacity", "full"])
.await
Expand Down Expand Up @@ -296,4 +296,32 @@ mod abort_blocks_tests {

abort_blocks_error(&fork_devnet, &BlockId::Hash(fork_block_hash)).await;
}

#[tokio::test]
async fn abort_latest_blocks() {
let devnet =
BackgroundDevnet::spawn_with_additional_args(&["--state-archive-capacity", "full"])
.await
.expect("Could not start Devnet");

for _ in 0..3 {
devnet.create_block().await.unwrap();
}
for _ in 0..3 {
abort_blocks(&devnet, &BlockId::Tag(BlockTag::Latest)).await;
}
abort_blocks_error(&devnet, &BlockId::Tag(BlockTag::Latest)).await; // Rolled back to genesis block, should not be possible to abort
}
#[tokio::test]
async fn abort_pending_block() {
let devnet =
BackgroundDevnet::spawn_with_additional_args(&["--state-archive-capacity", "full"])
.await
.expect("Could not start Devnet");

for _ in 0..3 {
devnet.create_block().await.unwrap();
}
abort_blocks_error(&devnet, &BlockId::Tag(BlockTag::Pending)).await; // Pending block is genesis block so not possible to abort
}
}

0 comments on commit 448b013

Please sign in to comment.