Add complete login test case
This commit is contained in:
parent
d82e145f50
commit
9ce3918ff5
@ -211,6 +211,7 @@ fn test_pairing() {
|
||||
|
||||
#[wasm_bindgen_test]
|
||||
fn test_first_login() {
|
||||
reset_device().unwrap();
|
||||
setup();
|
||||
debug!("==============================================\nStarting test_first_login\n==============================================");
|
||||
|
||||
@ -295,37 +296,78 @@ fn test_first_login() {
|
||||
|
||||
#[wasm_bindgen_test]
|
||||
fn test_login() {
|
||||
reset_device().unwrap();
|
||||
setup();
|
||||
debug!("==============================================\nStarting test_login\n==============================================");
|
||||
|
||||
// ======================= Alice
|
||||
restore_device(ALICE_LOGGED_DEVICE.to_owned()).unwrap();
|
||||
|
||||
debug!("Alice sends a login transaction to Bob, which creates a new key for him");
|
||||
let login_tx = create_login_transaction(1).unwrap();
|
||||
let alice_login_tx = create_login_transaction(1).unwrap();
|
||||
let alice_login_cipher = AnkNetworkMsg::new(
|
||||
sdk_common::network::AnkFlag::Cipher,
|
||||
&alice_login_tx.new_network_msg.ciphertext.unwrap(),
|
||||
);
|
||||
|
||||
let get_outputs_result = get_outputs().unwrap();
|
||||
|
||||
let alice_outputs: HashMap<OutPoint, OwnedOutput> = get_outputs_result.into_serde().unwrap();
|
||||
|
||||
let login_tweak_data = helper_get_tweak_data(
|
||||
&login_tx.transaction,
|
||||
let alice_login_tweak_data = helper_get_tweak_data(
|
||||
&alice_login_tx.transaction,
|
||||
alice_outputs
|
||||
);
|
||||
|
||||
helper_parse_transaction(&login_tx.transaction, &login_tweak_data);
|
||||
debug!("Parsing Alice login transaction");
|
||||
helper_parse_transaction(&alice_login_tx.transaction, &alice_login_tweak_data);
|
||||
|
||||
let alice_device = dump_device().unwrap();
|
||||
let alice_cache = dump_message_cache().unwrap();
|
||||
|
||||
// ============================== Bob
|
||||
reset_device().unwrap();
|
||||
restore_device(BOB_LOGGED_DEVICE.to_owned()).unwrap();
|
||||
|
||||
helper_parse_transaction(&login_tx.transaction, &login_tweak_data);
|
||||
debug!("Bob finds out the login demand from Alice");
|
||||
helper_parse_transaction(&alice_login_tx.transaction, &alice_login_tweak_data);
|
||||
let alice_login_msg = helper_parse_ank_msg(alice_login_cipher.to_string());
|
||||
|
||||
// Bob must confirm that he agrees to log in
|
||||
|
||||
// Boutons "login" ou "Refuser"
|
||||
// At this point Bob can fire up the revokation output if the login demand is illegitimate
|
||||
// revoke_paired_device(1).unwrap();
|
||||
// OR she must answer with a login transaction to Alice
|
||||
create_login_transaction(1).unwrap();
|
||||
// OR it must answer with a login transaction to Alice
|
||||
let bob_login_tx = create_login_transaction(1).unwrap();
|
||||
let bob_login_cipher = AnkNetworkMsg::new(
|
||||
sdk_common::network::AnkFlag::Cipher,
|
||||
&bob_login_tx.new_network_msg.ciphertext.unwrap(),
|
||||
);
|
||||
|
||||
let get_outputs_result = get_outputs().unwrap();
|
||||
|
||||
let bob_outputs: HashMap<OutPoint, OwnedOutput> = get_outputs_result.into_serde().unwrap();
|
||||
|
||||
let bob_login_tweak_data = helper_get_tweak_data(&bob_login_tx.transaction, bob_outputs);
|
||||
|
||||
debug!("Bob parses his own login transaction");
|
||||
helper_parse_transaction(&bob_login_tx.transaction, &bob_login_tweak_data);
|
||||
|
||||
login(alice_login_msg.id, alice_login_tx.transaction.clone()).unwrap();
|
||||
|
||||
// =================== Alice
|
||||
|
||||
reset_device().unwrap();
|
||||
restore_device(alice_device).unwrap();
|
||||
set_message_cache(alice_cache).unwrap();
|
||||
|
||||
helper_parse_transaction(&bob_login_tx.transaction, &bob_login_tweak_data);
|
||||
let bob_login_msg = helper_parse_ank_msg(bob_login_cipher.to_string());
|
||||
|
||||
assert!(bob_login_msg.status == CachedMessageStatus::Login);
|
||||
|
||||
login(bob_login_msg.id, alice_login_tx.transaction).unwrap();
|
||||
}
|
||||
|
||||
// #[wasm_bindgen_test]
|
||||
|
Loading…
x
Reference in New Issue
Block a user