Skip to content

Commit

Permalink
chore: clean up and cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
dutterbutter committed Dec 19, 2024
1 parent d321cca commit 9c0e73d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 57 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions e2e-tests-rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

56 changes: 2 additions & 54 deletions e2e-tests-rust/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -580,58 +580,6 @@ async fn dump_state_on_run() -> anyhow::Result<()> {
Ok(())
}

#[tokio::test]
async fn dump_state_on_run() -> anyhow::Result<()> {
let temp_dir = TempDir::new("state-test").expect("failed creating temporary dir");
let dump_path = temp_dir.path().join("state_dump.json");

let dump_path_clone = dump_path.clone();
let provider = init_testing_provider(move |node| {
node
.path(get_node_binary_path())
.arg("--state-interval")
.arg("1")
.arg("--dump-state")
.arg(dump_path_clone.to_str().unwrap())
})
.await?;

provider.tx().finalize().await?;

// Allow some time for the state to be dumped
sleep(Duration::from_secs(2));

drop(provider);

assert!(
dump_path.exists(),
"State dump file should exist at {:?}",
dump_path
);

let dumped_data = fs::read_to_string(&dump_path)?;
let state: VersionedState = serde_json::from_str(&dumped_data)
.map_err(|e| anyhow::anyhow!("Failed to deserialize state: {}", e))?;

match state {
VersionedState::V1 { version: _, state } => {
assert!(
!state.blocks.is_empty(),
"state_dump.json should contain at least one block"
);
assert!(
!state.transactions.is_empty(),
"state_dump.json should contain at least one transaction"
);
},
VersionedState::Unknown { version } => {
panic!("Encountered unknown state version: {}", version);
}
}

Ok(())
}

#[tokio::test]
async fn dump_state_on_fork() -> anyhow::Result<()> {
let temp_dir = TempDir::new("state-fork-test").expect("failed creating temporary dir");
Expand All @@ -645,7 +593,7 @@ async fn dump_state_on_fork() -> anyhow::Result<()> {
.arg("1")
.arg("--dump-state")
.arg(dump_path_clone.to_str().unwrap())
.fork("mainnet")
.fork("sepolia-testnet")
})
.await?;

Expand Down Expand Up @@ -771,7 +719,7 @@ async fn load_state_on_fork() -> anyhow::Result<()> {
.arg("1")
.arg("--load-state")
.arg(dump_path_clone.to_str().unwrap())
.fork("mainnet")
.fork("sepolia-testnet")
})
.await?;

Expand Down

0 comments on commit 9c0e73d

Please sign in to comment.