Skip to content

Commit

Permalink
Fix CI (#196)
Browse files Browse the repository at this point in the history
* chore: fix Clippy warnings

* test: don't match on specific panic

Recent Rust versions (>=1.73.0) changed the wording when using `assert_eq!()`.
This made a test fail, as it was targeted at a specific message. As this
message could change any time (as it's not under our control), just remove
that exact matching, and just match on any panic.

Closes #195.
  • Loading branch information
vmx authored Jan 9, 2024
1 parent 63104f3 commit 300e7e5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
9 changes: 6 additions & 3 deletions core/src/codec.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! `Ipld` codecs.
use alloc::{format, string::String, vec::Vec};
use core::convert::TryFrom;
use alloc::{string::String, vec::Vec};
use core::{convert::TryFrom, fmt::Write as _};

use crate::cid::Cid;
use crate::error::{Result, UnsupportedCodec};
Expand Down Expand Up @@ -85,7 +85,10 @@ where
Ipld: Decode<C> + Encode<C>,
{
fn hex(bytes: &[u8]) -> String {
bytes.iter().map(|byte| format!("{:02x}", byte)).collect()
bytes.iter().fold(String::new(), |mut output, byte| {
let _ = write!(output, "{byte:02x}");
output
})
}
let mut bytes = Vec::new();
data.encode(c, &mut bytes).unwrap();
Expand Down
2 changes: 1 addition & 1 deletion core/tests/serde_deserialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ fn ipld_deserialize_link() {
}

#[test]
#[should_panic(expected = "assertion failed")]
#[should_panic]
fn ipld_deserialize_link_not_as_bytes() {
let cid = Cid::try_from("bafkreie74tgmnxqwojhtumgh5dzfj46gi4mynlfr7dmm7duwzyvnpw7h7m").unwrap();
let ipld = Ipld::Link(cid);
Expand Down
3 changes: 1 addition & 2 deletions dag-cbor/tests/serde_interop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ impl Arbitrary for ValueArb {
.into_iter()
.map(|x| {
let slf = Self(x);
let shrunk = slf.shrink().map(|x| x.0).collect::<Vec<_>>();
shrunk
slf.shrink().map(|x| x.0).collect::<Vec<_>>()
})
.map(Value::Array)
.map(Self),
Expand Down

0 comments on commit 300e7e5

Please sign in to comment.