File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed
lightning/src/onion_message Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -36,6 +36,8 @@ use dnssec_prover::rr::Name;
3636
3737use lightning_types:: features:: NodeFeatures ;
3838
39+ use core:: fmt;
40+
3941use crate :: blinded_path:: message:: DNSResolverContext ;
4042use crate :: io;
4143#[ cfg( feature = "dnssec" ) ]
@@ -287,6 +289,12 @@ impl Readable for HumanReadableName {
287289 }
288290}
289291
292+ impl fmt:: Display for HumanReadableName {
293+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
294+ write ! ( f, "₿{}@{}" , self . user( ) , self . domain( ) )
295+ }
296+ }
297+
290298#[ cfg( feature = "dnssec" ) ]
291299struct PendingResolution {
292300 start_height : u32 ,
@@ -473,3 +481,24 @@ impl OMNameResolver {
473481 None
474482 }
475483}
484+
485+ #[ cfg( test) ]
486+ mod tests {
487+ use super :: HumanReadableName ;
488+
489+ #[ test]
490+ fn test_hrn_display_format ( ) {
491+ let user = "user" ;
492+ let domain = "example.com" ;
493+ let hrn = HumanReadableName :: new ( user, domain)
494+ . expect ( "Failed to create HumanReadableName for user" ) ;
495+
496+ // Assert that the formatted string matches the expected output
497+ let expected_display = format ! ( "₿{}@{}" , user, domain) ;
498+ assert_eq ! (
499+ format!( "{}" , hrn) ,
500+ expected_display,
501+ "HumanReadableName display format mismatch"
502+ ) ;
503+ }
504+ }
You can’t perform that action at this time.
0 commit comments