You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 20, 2023. It is now read-only.
if decoded_list.is_empty() || decoded_list.len() % 2 != 0{
809
806
debug!("Failed to decode ENR. List size is not a multiple of 2.");
810
807
returnErr(DecoderError::Custom("List not a multiple of two"));
811
808
}
812
809
813
-
let signature = decoded_list.remove(0);
814
-
let seq_bytes = decoded_list.remove(0);
810
+
let signature = decoded_list.remove(0).data()?;
811
+
let seq_bytes = decoded_list.remove(0).data()?;
815
812
816
813
if seq_bytes.len() > 8{
817
814
debug!("Failed to decode ENR. Sequence number is not a u64.");
@@ -826,16 +823,16 @@ impl<K: EnrKey> rlp::Decodable for Enr<K> {
826
823
letmut content = BTreeMap::new();
827
824
letmut prev:Option<String> = None;
828
825
for _ in0..decoded_list.len() / 2{
829
-
let key = decoded_list.remove(0);
830
-
let value = decoded_list.remove(0);
826
+
let key = decoded_list.remove(0).data()?;
827
+
let value = decoded_list.remove(0).data()?;
831
828
832
829
let key = String::from_utf8_lossy(&key);
833
830
// TODO: add tests for this error case
834
831
if prev.is_some() && prev >= Some(key.to_string()){
835
832
returnErr(DecoderError::Custom("Unsorted keys"));
836
833
}
837
834
prev = Some(key.to_string());
838
-
content.insert(key.to_string(), value);
835
+
content.insert(key.to_string(), value.into());
839
836
}
840
837
841
838
// verify we know the signature type
@@ -847,7 +844,7 @@ impl<K: EnrKey> rlp::Decodable for Enr<K> {
847
844
let enr = Self{
848
845
seq,
849
846
node_id,
850
-
signature,
847
+
signature: signature.into(),
851
848
content,
852
849
phantom:PhantomData,
853
850
};
@@ -941,6 +938,26 @@ mod tests {
941
938
assert!(enr.verify());
942
939
}
943
940
941
+
// the values in the content are rlp lists
942
+
#[test]
943
+
fntest_rlp_list_value(){
944
+
let text = "enr:-Je4QH0uN2HkMRmscUp6yvyTOPGtOg9U6lCxBFvCGynyystnDNRJbfz5GhXXY2lcu9tsghMxRiYHoznBwG46GQ7dfm0og2V0aMfGhMvbiDiAgmlkgnY0gmlwhA6hJmuJc2VjcDI1NmsxoQJBP4kg9GNBurV3uVXgR72u1n-XIABibUZLT1WvJLKwvIN0Y3CCdyeDdWRwgncn";
945
+
let signature = hex::decode("7d2e3761e43119ac714a7acafc9338f1ad3a0f54ea50b1045bc21b29f2cacb670cd4496dfcf91a15d763695cbbdb6c821331462607a339c1c06e3a190edd7e6d").unwrap();
0 commit comments