-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add shamir recovery invitation to invite_list tests
- Loading branch information
Showing
2 changed files
with
150 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -92,4 +92,75 @@ pub fn rep_ok() { | |
let data2 = authenticated_cmds::invite_list::Rep::load(&raw2).unwrap(); | ||
|
||
p_assert_eq!(data2, expected); | ||
|
||
// Generated from Parsec 3.1.1-a.0+dev | ||
// Content: | ||
// status: 'ok' | ||
// invitations: [ | ||
// { | ||
// type: 'USER', | ||
// claimer_email: '[email protected]', | ||
// created_on: ext(1, 946774800000000) i.e. 2000-01-02T02:00:00Z, | ||
// status: 'IDLE', | ||
// token: 0xd864b93ded264aae9ae583fd3d40c45a, | ||
// }, | ||
// { | ||
// type: 'DEVICE', | ||
// created_on: ext(1, 946774800000000) i.e. 2000-01-02T02:00:00Z, | ||
// status: 'IDLE', | ||
// token: 0xd864b93ded264aae9ae583fd3d40c45a, | ||
// }, | ||
// { | ||
// type: 'SHAMIR_RECOVERY', | ||
// claimer_user_id: ext(2, 0xa11cec00100000000000000000000000), | ||
// created_on: ext(1, 946774800000000) i.e. 2000-01-02T02:00:00Z, | ||
// status: 'IDLE', | ||
// token: 0xd864b93ded264aae9ae583fd3d40c45a, | ||
// }, | ||
// ] | ||
let raw: &[u8] = hex!( | ||
"82a6737461747573a26f6bab696e7669746174696f6e739385a474797065a455534552" | ||
"ad636c61696d65725f656d61696cb1616c696365406578616d706c652e636f6daa6372" | ||
"65617465645f6f6ed70100035d162fa2e400a6737461747573a449444c45a5746f6b65" | ||
"6ec410d864b93ded264aae9ae583fd3d40c45a84a474797065a6444556494345aa6372" | ||
"65617465645f6f6ed70100035d162fa2e400a6737461747573a449444c45a5746f6b65" | ||
"6ec410d864b93ded264aae9ae583fd3d40c45a85a474797065af5348414d49525f5245" | ||
"434f56455259af636c61696d65725f757365725f6964d802a11cec0010000000000000" | ||
"0000000000aa637265617465645f6f6ed70100035d162fa2e400a6737461747573a449" | ||
"444c45a5746f6b656ec410d864b93ded264aae9ae583fd3d40c45a" | ||
) | ||
.as_ref(); | ||
|
||
let expected = authenticated_cmds::invite_list::Rep::Ok { | ||
invitations: vec![ | ||
authenticated_cmds::invite_list::InviteListItem::User { | ||
token: InvitationToken::from_hex("d864b93ded264aae9ae583fd3d40c45a").unwrap(), | ||
created_on: "2000-1-2T01:00:00Z".parse().unwrap(), | ||
claimer_email: "[email protected]".to_owned(), | ||
status: InvitationStatus::Idle, | ||
}, | ||
authenticated_cmds::invite_list::InviteListItem::Device { | ||
token: InvitationToken::from_hex("d864b93ded264aae9ae583fd3d40c45a").unwrap(), | ||
created_on: "2000-1-2T01:00:00Z".parse().unwrap(), | ||
status: InvitationStatus::Idle, | ||
}, | ||
authenticated_cmds::invite_list::InviteListItem::ShamirRecovery { | ||
token: InvitationToken::from_hex("d864b93ded264aae9ae583fd3d40c45a").unwrap(), | ||
created_on: "2000-1-2T01:00:00Z".parse().unwrap(), | ||
claimer_user_id: "alice".parse().unwrap(), | ||
status: InvitationStatus::Idle, | ||
}, | ||
], | ||
}; | ||
|
||
let data = authenticated_cmds::invite_list::Rep::load(raw).unwrap(); | ||
println!("***expected: {:?}", expected.dump().unwrap()); | ||
p_assert_eq!(data, expected); | ||
|
||
// Also test serialization round trip | ||
let raw2 = data.dump().unwrap(); | ||
|
||
let data2 = authenticated_cmds::invite_list::Rep::load(&raw2).unwrap(); | ||
|
||
p_assert_eq!(data2, expected); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters