@@ -17,8 +17,8 @@ use crate::storage::registry::schemas::{RegistryMetadata, TipInfo};
1717struct FakeState {
1818 events : HashMap < String , Vec < Event > > ,
1919 key_states : HashMap < String , KeyState > ,
20- attestations : HashMap < DeviceDID , Attestation > ,
21- attestation_history : HashMap < DeviceDID , Vec < Attestation > > ,
20+ attestations : HashMap < CanonicalDid , Attestation > ,
21+ attestation_history : HashMap < CanonicalDid , Vec < Attestation > > ,
2222 org_members : HashMap < ( String , String ) , Attestation > ,
2323}
2424
@@ -205,7 +205,10 @@ impl RegistryBackend for FakeRegistryBackend {
205205
206206 fn load_attestation ( & self , did : & DeviceDID ) -> Result < Option < Attestation > , RegistryError > {
207207 let state = self . state . lock ( ) . unwrap ( ) ;
208- Ok ( state. attestations . get ( did) . cloned ( ) )
208+ #[ allow( clippy:: disallowed_methods) ]
209+ // INVARIANT: did.as_str() is a valid DID string from DeviceDID
210+ let canonical = CanonicalDid :: new_unchecked ( did. as_str ( ) ) ;
211+ Ok ( state. attestations . get ( & canonical) . cloned ( ) )
209212 }
210213
211214 fn visit_attestation_history (
@@ -214,7 +217,10 @@ impl RegistryBackend for FakeRegistryBackend {
214217 visitor : & mut dyn FnMut ( & Attestation ) -> ControlFlow < ( ) > ,
215218 ) -> Result < ( ) , RegistryError > {
216219 let state = self . state . lock ( ) . unwrap ( ) ;
217- if let Some ( history) = state. attestation_history . get ( did) {
220+ #[ allow( clippy:: disallowed_methods) ]
221+ // INVARIANT: did.as_str() is a valid DID string from DeviceDID
222+ let canonical = CanonicalDid :: new_unchecked ( did. as_str ( ) ) ;
223+ if let Some ( history) = state. attestation_history . get ( & canonical) {
218224 for att in history {
219225 if visitor ( att) . is_break ( ) {
220226 break ;
@@ -229,8 +235,10 @@ impl RegistryBackend for FakeRegistryBackend {
229235 visitor : & mut dyn FnMut ( & DeviceDID ) -> ControlFlow < ( ) > ,
230236 ) -> Result < ( ) , RegistryError > {
231237 let state = self . state . lock ( ) . unwrap ( ) ;
232- for did in state. attestations . keys ( ) {
233- if visitor ( did) . is_break ( ) {
238+ for canonical_did in state. attestations . keys ( ) {
239+ if let Ok ( device_did) = DeviceDID :: parse ( canonical_did. as_str ( ) )
240+ && visitor ( & device_did) . is_break ( )
241+ {
234242 break ;
235243 }
236244 }
0 commit comments