multiformats / rust-multiaddr

multiaddr implementation in rust
https://crates.io/crates/multiaddr
Other
86 stars 45 forks source link

`Multiaddr::from_bytes` panics on output of `to_bytes()`/`.as_slice()` #31

Closed gnunicorn closed 6 years ago

gnunicorn commented 6 years ago

Wanted to add parsing support for an external library, added a test, found that:

        let address: Multiaddr = "/ipv4/127.0.0.1".parse().unwrap();
        let wtf = Multiaddr::from_bytes(address.to_bytes()).unwrap();

panics. Same with as_slice().to_vec(). Is that expected behavior?

The docs don't really state/show how these APIs are supposed to be used, neither do any tests show that any output of the bytes*-functions of Multiaddr can be parsed by from_bytes...

gnunicorn commented 6 years ago

ignore me. The issue being that the protocol must be defined as ip4 not ipv4... typo. once again.