Skip to content

Commit

Permalink
post rebase fix
Browse files Browse the repository at this point in the history
  • Loading branch information
momoshell committed Dec 1, 2023
1 parent fb385c2 commit b173adc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 224 deletions.
218 changes: 0 additions & 218 deletions src/network/mod.rs

This file was deleted.

13 changes: 7 additions & 6 deletions src/network/p2p/event_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ enum DHTKey {
}

impl TryFrom<RecordKey> for DHTKey {
type Error = anyhow::Error;
type Error = color_eyre::Report;

fn try_from(key: RecordKey) -> std::result::Result<Self, Self::Error> {
match *String::from_utf8(key.to_vec())?
Expand All @@ -98,7 +98,7 @@ impl TryFrom<RecordKey> for DHTKey {
{
[block_num, row_num] => Ok(DHTKey::Row(block_num, row_num)),
[block_num, row_num, col_num] => Ok(DHTKey::Cell(block_num, row_num, col_num)),
_ => Err(anyhow::anyhow!("Invalid DHT key")),
_ => Err(eyre!("Invalid DHT key")),
}
}
}
Expand Down Expand Up @@ -579,6 +579,7 @@ impl EventLoop {
#[cfg(test)]
mod tests {
use crate::network::p2p::event_loop::DHTKey;
use color_eyre::Result;
use libp2p::kad::RecordKey;

#[test]
Expand All @@ -589,10 +590,10 @@ mod tests {
let cell_key: DHTKey = RecordKey::new(&"3:2:1").try_into().unwrap();
assert_eq!(cell_key, DHTKey::Cell(3, 2, 1));

let result: anyhow::Result<DHTKey> = RecordKey::new(&"1:2:4:3").try_into();
result.unwrap_err();
let result: Result<DHTKey> = RecordKey::new(&"1:2:4:3").try_into();
_ = result.unwrap_err();

let result: anyhow::Result<DHTKey> = RecordKey::new(&"123").try_into();
result.unwrap_err();
let result: Result<DHTKey> = RecordKey::new(&"123").try_into();
_ = result.unwrap_err();
}
}

0 comments on commit b173adc

Please sign in to comment.