Update pairing test
This commit is contained in:
parent
359312574f
commit
d6f2202627
@ -125,7 +125,7 @@ fn test_pairing() {
|
|||||||
])
|
])
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let initial_session_privkey = [0u8; 32];
|
let initial_session_privkey = [0u8; 32]; // In reality we would generate a random new key here
|
||||||
let initial_session_pubkey = [0u8; 32];
|
let initial_session_pubkey = [0u8; 32];
|
||||||
|
|
||||||
let pairing_init_state = json!({
|
let pairing_init_state = json!({
|
||||||
@ -229,6 +229,20 @@ fn test_pairing() {
|
|||||||
|
|
||||||
// Alice simply shoots back the return value in the ws
|
// Alice simply shoots back the return value in the ws
|
||||||
let bob_received_pcd = alice_parsed_confirm.ciphers_to_send[0].clone();
|
let bob_received_pcd = alice_parsed_confirm.ciphers_to_send[0].clone();
|
||||||
|
let commit_msg = alice_parsed_confirm.commit_to_send.unwrap();
|
||||||
|
|
||||||
|
// Take the relevant state out of the process
|
||||||
|
let relevant_process = alice_process_cache.get(&commit_msg.init_tx).unwrap();
|
||||||
|
|
||||||
|
let concurrent_states = relevant_process.get_latest_concurrent_states().unwrap();
|
||||||
|
let relevant_state = concurrent_states.into_iter().find(|s| s.pcd_commitment == commit_msg.pcd_commitment).unwrap();
|
||||||
|
|
||||||
|
// Alice can also sign her response and send it to Bob
|
||||||
|
let alice_response = create_response_message(commit_msg.init_tx, relevant_state.pcd_commitment.to_string(), true).unwrap();
|
||||||
|
|
||||||
|
let (outpoint, updated_process) = alice_response.updated_process.unwrap();
|
||||||
|
|
||||||
|
alice_process_cache.insert(outpoint, updated_process);
|
||||||
|
|
||||||
// ======================= Bob
|
// ======================= Bob
|
||||||
reset_device().unwrap();
|
reset_device().unwrap();
|
||||||
@ -307,12 +321,15 @@ fn test_pairing() {
|
|||||||
updated_process,
|
updated_process,
|
||||||
);
|
);
|
||||||
|
|
||||||
// We also send an update to the other members
|
|
||||||
|
|
||||||
debug!("Bob pairs device with Alice");
|
debug!("Bob pairs device with Alice");
|
||||||
pair_device(root_outpoint, proposal_members).unwrap();
|
pair_device(root_outpoint, proposal_members).unwrap();
|
||||||
|
|
||||||
// To make the pairing effective, alice and bob must now creates a new transaction where they both control one output
|
// We can also check alice response
|
||||||
|
let parsed_alice_response = parse_cipher(alice_response.ciphers_to_send[0].clone()).unwrap();
|
||||||
|
|
||||||
|
debug!("parsed_alice_response: {:#?}", parsed_alice_response.updated_process.unwrap());
|
||||||
|
|
||||||
|
// Since we have enough validation we can send it directly to relay for commitment
|
||||||
|
|
||||||
// login();
|
// login();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user