Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(opt8n): Handle opt8n Errors #52

Merged
merged 1 commit into from
Jul 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions bin/opt8n/src/opt8n.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,11 @@ impl Opt8n {
output_file: PathBuf,
genesis: Option<PathBuf>,
) -> Result<Self> {
let genesis = genesis.as_ref().map(|path| {
serde_json::from_reader(File::open(path).expect("TODO: handle error Invalid path"))
.expect("TODO: handle error Invalid genesis")
});
let genesis = if let Some(genesis) = genesis.as_ref() {
serde_json::from_reader(File::open(genesis)?)?
} else {
None
};

let node_config = node_config
.unwrap_or_default()
Expand Down Expand Up @@ -106,7 +107,7 @@ impl Opt8n {
// Mine the block and generate the execution fixture
opt8n.mine_block().await;

let block = new_blocks.next().await.expect("TODO: handle error");
let block = new_blocks.next().await.ok_or(eyre!("No new block"))?;
if let Some(block) = opt8n.eth_api.backend.get_block_by_hash(block.hash) {
opt8n.generate_execution_fixture(block).await?;
}
Expand Down Expand Up @@ -147,7 +148,7 @@ impl Opt8n {
.eth_api
.txpool_content()
.await
.expect("TODO: handle error")
.expect("Failed to get txpool content")
.pending
.len();

Expand Down Expand Up @@ -207,7 +208,7 @@ impl Opt8n {
self.node_handle.http_provider(),
BlockId::from(block.header.number - 1),
)
.expect("Could not create AlloyDB"),
.ok_or_else(|| eyre!("Failed to create AlloyDB"))?,
);

let block_env = BlockEnv {
Expand Down