File tree Expand file tree Collapse file tree 5 files changed +42
-11
lines changed Expand file tree Collapse file tree 5 files changed +42
-11
lines changed Original file line number Diff line number Diff line change @@ -51,11 +51,8 @@ async fn tower_newbie() -> anyhow::Result<()> {
5151
5252 val_app_cfg. maybe_add_profile ( p) ?;
5353
54- let mut alice_sender = Sender :: from_app_cfg (
55- & val_app_cfg,
56- Some ( alice. child_0_owner . account . to_hex_literal ( ) ) ,
57- )
58- . await ?;
54+ let mut alice_sender =
55+ Sender :: from_app_cfg ( & val_app_cfg, Some ( alice. child_0_owner . account . to_string ( ) ) ) . await ?;
5956
6057 assert ! ( alice_acct == & alice_sender. local_account. address( ) ) ;
6158
Original file line number Diff line number Diff line change @@ -39,11 +39,8 @@ async fn sender_back_and_forth() -> anyhow::Result<()> {
3939 val_app_cfg. maybe_add_profile ( p) ?;
4040
4141 // also checking we can get a Sender type with a second profile
42- let mut alice_sender = Sender :: from_app_cfg (
43- & val_app_cfg,
44- Some ( alice. child_0_owner . account . to_hex_literal ( ) ) ,
45- )
46- . await ?;
42+ let mut alice_sender =
43+ Sender :: from_app_cfg ( & val_app_cfg, Some ( alice. child_0_owner . account . to_string ( ) ) ) . await ?;
4744
4845 assert ! ( alice_acct == & alice_sender. local_account. address( ) ) ;
4946
Original file line number Diff line number Diff line change @@ -33,3 +33,6 @@ serde_yaml = { workspace = true }
3333tokio = { workspace = true }
3434toml = { workspace = true }
3535url = { workspace = true }
36+
37+ [dev-dependencies ]
38+ diem-temppath = { workspace = true }
Original file line number Diff line number Diff line change @@ -202,7 +202,7 @@ impl AppCfg {
202202
203203 if let Some ( n) = nickname {
204204 let found = self . user_profiles . iter ( ) . enumerate ( ) . find_map ( |( i, e) | {
205- if e. nickname . contains ( & n) || e. account . to_hex_literal ( ) . contains ( & n) {
205+ if e. nickname . contains ( & n) || e. account . to_string ( ) . contains ( & n) {
206206 Some ( i)
207207 } else {
208208 None
@@ -622,6 +622,39 @@ async fn test_create() {
622622 a. save_file ( ) . unwrap ( ) ;
623623}
624624
625+ #[ tokio:: test]
626+ async fn test_init ( ) {
627+ use diem_temppath:: TempPath ;
628+ let d = TempPath :: new ( ) ;
629+ let a = AuthenticationKey :: from_str (
630+ "8603ba96e87b810cebbec1a0fd7ea06285f9eb352a3eabde992a5594fe80af40" ,
631+ )
632+ . unwrap ( ) ;
633+
634+ let b = AuthenticationKey :: from_str (
635+ "052dea65ac80cd4b2b1318a9420dc1568819882769346d9acffdc0d731504c66" ,
636+ )
637+ . unwrap ( ) ;
638+
639+ let mut app_cfg: AppCfg = AppCfg :: init_app_configs (
640+ a,
641+ a. derived_address ( ) ,
642+ Some ( d. path ( ) . to_owned ( ) ) ,
643+ None ,
644+ None ,
645+ )
646+ . unwrap ( ) ;
647+
648+ app_cfg
649+ . maybe_add_profile ( Profile :: new ( b, b. derived_address ( ) ) )
650+ . unwrap ( ) ;
651+ assert ! ( app_cfg. user_profiles. len( ) > 1 ) ;
652+ let p = app_cfg
653+ . get_profile ( Some ( "052dea65ac80" . to_string ( ) ) )
654+ . unwrap ( ) ;
655+ assert ! ( p. auth_key == b) ;
656+ }
657+
625658#[ test]
626659fn read_write ( ) {
627660 let raw_yaml = r"
You can’t perform that action at this time.
0 commit comments