Enforce that ProtocolId is a string (#6953)

* Enforce that ProtocolId is a string

* Fix test
This commit is contained in:
Pierre Krieger
2020-08-26 14:27:30 +02:00
committed by GitHub
parent 8856be80bc
commit 1bd6082cf7
14 changed files with 61 additions and 57 deletions
@@ -156,13 +156,13 @@ impl Config {
pub fn set_protocol(&mut self, id: &ProtocolId) -> &mut Self {
let mut vl = Vec::new();
vl.extend_from_slice(b"/");
vl.extend_from_slice(id.as_bytes());
vl.extend_from_slice(id.as_ref().as_bytes());
vl.extend_from_slice(b"/light/2");
self.light_protocol = vl.into();
let mut vb = Vec::new();
vb.extend_from_slice(b"/");
vb.extend_from_slice(id.as_bytes());
vb.extend_from_slice(id.as_ref().as_bytes());
vb.extend_from_slice(b"/sync/2");
self.block_protocol = vb.into();
@@ -1447,7 +1447,7 @@ mod tests {
}
fn make_config() -> super::Config {
super::Config::new(&ProtocolId::from(&b"foo"[..]))
super::Config::new(&ProtocolId::from("foo"))
}
fn dummy_header() -> sp_test_primitives::Header {