Fix WakuPubSubTopic parsing

This commit is contained in:
Daniel Sanchez Quiros 2022-10-10 10:52:17 -05:00
parent 29c9cd9f6c
commit ed3fa3e0e8

View File

@ -395,7 +395,7 @@ impl FromStr for WakuPubSubTopic {
type Err = String;
fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
if let Ok((topic_name, encoding)) = scanf!(s, "/waku/v2/{}/{}", String, Encoding) {
if let Ok((topic_name, encoding)) = scanf!(s, "/waku/2/{}/{:/.+?/}", String, Encoding) {
Ok(WakuPubSubTopic {
topic_name,
encoding,
@ -487,3 +487,15 @@ where
})
.transpose()
}
#[cfg(test)]
mod tests {
use super::*;
use crate::WakuPubSubTopic;
use sscanf::scanf;
#[test]
fn parse_waku_topic() {
let s = "/waku/2/default-waku/proto";
let _: WakuPubSubTopic = s.parse().unwrap();
}
}