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;
36
36
37
37
use lightning_types:: features:: NodeFeatures ;
38
38
39
+ use core:: fmt;
40
+
39
41
use crate :: blinded_path:: message:: DNSResolverContext ;
40
42
use crate :: io;
41
43
#[ cfg( feature = "dnssec" ) ]
@@ -287,6 +289,12 @@ impl Readable for HumanReadableName {
287
289
}
288
290
}
289
291
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
+
290
298
#[ cfg( feature = "dnssec" ) ]
291
299
struct PendingResolution {
292
300
start_height : u32 ,
@@ -473,3 +481,24 @@ impl OMNameResolver {
473
481
None
474
482
}
475
483
}
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