Update to latest sdk_common
This commit is contained in:
parent
2788159c4d
commit
25bbc64e6a
@ -3,7 +3,6 @@ use std::str::FromStr;
|
|||||||
use anyhow::{Error, Result};
|
use anyhow::{Error, Result};
|
||||||
|
|
||||||
use hex::FromHex;
|
use hex::FromHex;
|
||||||
use sdk_common::pcd::Pcd;
|
|
||||||
use sdk_common::silentpayments::create_transaction;
|
use sdk_common::silentpayments::create_transaction;
|
||||||
use sdk_common::sp_client::spclient::Recipient;
|
use sdk_common::sp_client::spclient::Recipient;
|
||||||
use sdk_common::network::CommitMessage;
|
use sdk_common::network::CommitMessage;
|
||||||
@ -64,14 +63,15 @@ fn handle_initial_transaction(tx: Transaction, commit_msg: &CommitMessage) -> Re
|
|||||||
// return Err(Error::msg("Role commitment mismatch"));
|
// return Err(Error::msg("Role commitment mismatch"));
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// Create the initial process state
|
let mut new_process = Process::new(root_commitment);
|
||||||
let empty_state = ProcessState {
|
let init_state = ProcessState {
|
||||||
commited_in: root_commitment,
|
commited_in: root_commitment,
|
||||||
|
encrypted_pcd: roles_only_map,
|
||||||
|
pcd_commitment: commit_msg.pcd_commitment.clone(),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
let mut init_state = empty_state.clone();
|
|
||||||
init_state.encrypted_pcd = roles_only_map;
|
new_process.insert_concurrent_state(init_state)?;
|
||||||
init_state.pcd_commitment = commit_msg.pcd_commitment.clone();
|
|
||||||
|
|
||||||
// Cache the process
|
// Cache the process
|
||||||
let mut commitments = CACHEDPROCESSES
|
let mut commitments = CACHEDPROCESSES
|
||||||
@ -80,7 +80,7 @@ fn handle_initial_transaction(tx: Transaction, commit_msg: &CommitMessage) -> Re
|
|||||||
.lock_anyhow()?;
|
.lock_anyhow()?;
|
||||||
commitments.insert(
|
commitments.insert(
|
||||||
root_commitment,
|
root_commitment,
|
||||||
Process::new(vec![init_state, empty_state], vec![]),
|
new_process,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Add to frozen UTXOs
|
// Add to frozen UTXOs
|
||||||
@ -217,7 +217,7 @@ mod tests {
|
|||||||
use mockall::predicate::*;
|
use mockall::predicate::*;
|
||||||
use mockall::mock;
|
use mockall::mock;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::sync::{Mutex, Arc};
|
use std::sync::Mutex;
|
||||||
use bitcoincore_rpc::bitcoin::*;
|
use bitcoincore_rpc::bitcoin::*;
|
||||||
use crate::daemon::RpcCall;
|
use crate::daemon::RpcCall;
|
||||||
use std::sync::OnceLock;
|
use std::sync::OnceLock;
|
||||||
@ -429,11 +429,7 @@ mod tests {
|
|||||||
let roles = commit_msg.roles.clone();
|
let roles = commit_msg.roles.clone();
|
||||||
let pcd_commitment = commit_msg.pcd_commitment.clone();
|
let pcd_commitment = commit_msg.pcd_commitment.clone();
|
||||||
|
|
||||||
let empty_state = ProcessState {
|
let process = Process::new(init_commitment);
|
||||||
commited_in: init_commitment,
|
|
||||||
..Default::default()
|
|
||||||
};
|
|
||||||
let process = Process::new(vec![empty_state.clone()], vec![]);
|
|
||||||
CACHEDPROCESSES.get().unwrap().lock().unwrap().insert(init_commitment, process);
|
CACHEDPROCESSES.get().unwrap().lock().unwrap().insert(init_commitment, process);
|
||||||
|
|
||||||
let result = handle_commit_request(commit_msg);
|
let result = handle_commit_request(commit_msg);
|
||||||
@ -455,6 +451,10 @@ mod tests {
|
|||||||
encrypted_pcd: Value::Object(roles_map),
|
encrypted_pcd: Value::Object(roles_map),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
let empty_state = ProcessState {
|
||||||
|
commited_in: init_commitment,
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
let target = vec![&empty_state, &new_state];
|
let target = vec![&empty_state, &new_state];
|
||||||
|
|
||||||
assert_eq!(concurrent_states, target);
|
assert_eq!(concurrent_states, target);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user