mirror of
https://github.com/logos-blockchain/lssa.git
synced 2026-08-25 06:41:13 +00:00
fix: lints fix
This commit is contained in:
@@ -54,7 +54,7 @@ mod tests {
|
||||
let mut store = NodeAccountsStore::new();
|
||||
|
||||
let account = create_sample_account(100);
|
||||
let account_addr = account.address.clone();
|
||||
let account_addr = account.address;
|
||||
|
||||
store.register_account(account);
|
||||
|
||||
@@ -68,7 +68,7 @@ mod tests {
|
||||
let mut store = NodeAccountsStore::new();
|
||||
|
||||
let account = create_sample_account(100);
|
||||
let account_addr = account.address.clone();
|
||||
let account_addr = account.address;
|
||||
store.register_account(account);
|
||||
|
||||
assert_eq!(store.accounts.len(), 1);
|
||||
@@ -94,8 +94,8 @@ mod tests {
|
||||
let account1 = create_sample_account(100);
|
||||
let account2 = create_sample_account(200);
|
||||
|
||||
let address_1 = account1.address.clone();
|
||||
let address_2 = account2.address.clone();
|
||||
let address_1 = account1.address;
|
||||
let address_2 = account2.address;
|
||||
|
||||
store.register_account(account1);
|
||||
store.register_account(account2);
|
||||
|
||||
@@ -145,8 +145,8 @@ mod tests {
|
||||
|
||||
fn create_sample_block(block_id: u64, prev_block_id: u64) -> Block {
|
||||
Block {
|
||||
block_id: block_id,
|
||||
prev_block_id: prev_block_id,
|
||||
block_id,
|
||||
prev_block_id,
|
||||
prev_block_hash: [0; 32],
|
||||
hash: [1; 32],
|
||||
transactions: vec![],
|
||||
@@ -211,7 +211,7 @@ mod tests {
|
||||
|
||||
// The genesis block should be available on reload
|
||||
let result = node_store.get_block_at_id(0);
|
||||
assert!(!result.is_err());
|
||||
assert!(result.is_ok());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -80,7 +80,7 @@ impl NodeChainStore {
|
||||
|
||||
Ok((
|
||||
Self {
|
||||
acc_map: From::from(acc_map),
|
||||
acc_map,
|
||||
block_store,
|
||||
nullifier_store,
|
||||
utxo_commitments_store,
|
||||
@@ -324,8 +324,8 @@ mod tests {
|
||||
|
||||
fn create_sample_block(block_id: u64, prev_block_id: u64) -> Block {
|
||||
Block {
|
||||
block_id: block_id,
|
||||
prev_block_id: prev_block_id,
|
||||
block_id,
|
||||
prev_block_id,
|
||||
prev_block_hash: [0; 32],
|
||||
hash: [1; 32],
|
||||
transactions: vec![],
|
||||
@@ -434,9 +434,6 @@ mod tests {
|
||||
|
||||
assert_eq!(block_id, 1);
|
||||
assert_eq!(recovered_store.acc_map.len(), 1);
|
||||
assert_eq!(
|
||||
recovered_store.utxo_commitments_store.get_root().is_some(),
|
||||
true
|
||||
);
|
||||
assert!(recovered_store.utxo_commitments_store.get_root().is_some());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,16 +71,11 @@ impl PublicSCContext {
|
||||
|
||||
//`ToDo` Replace with `next_chunk` usage, when feature stabilizes in Rust
|
||||
for i in 0..=(ser_data.len() / 8) {
|
||||
let next_chunk: Vec<u8>;
|
||||
|
||||
if (i + 1) * 8 < ser_data.len() {
|
||||
next_chunk = ser_data[(i * 8)..((i + 1) * 8)].iter().cloned().collect();
|
||||
let next_chunk: Vec<u8> = if (i + 1) * 8 < ser_data.len() {
|
||||
ser_data[(i * 8)..((i + 1) * 8)].to_vec()
|
||||
} else {
|
||||
next_chunk = ser_data[(i * 8)..(ser_data.len())]
|
||||
.iter()
|
||||
.cloned()
|
||||
.collect();
|
||||
}
|
||||
ser_data[(i * 8)..(ser_data.len())].to_vec()
|
||||
};
|
||||
|
||||
u64_list.push(PublicSCContext::produce_u64_from_fit_vec(next_chunk));
|
||||
}
|
||||
|
||||
+23
-37
@@ -204,19 +204,18 @@ impl NodeCore {
|
||||
serde_json::to_vec(&ephm_key_holder.generate_ephemeral_public_key()).unwrap();
|
||||
|
||||
let encoded_data = Account::encrypt_data(
|
||||
&ephm_key_holder,
|
||||
ephm_key_holder,
|
||||
account.key_holder.viewing_public_key,
|
||||
&serde_json::to_vec(&utxo).unwrap(),
|
||||
);
|
||||
|
||||
let tag = account.make_tag();
|
||||
|
||||
let comm = generate_commitments(&vec![utxo]);
|
||||
let comm = generate_commitments(&[utxo]);
|
||||
|
||||
let mint_utxo_addr_bytes: Vec<u8> = zkvm::test_methods::MINT_UTXO_ID
|
||||
.iter()
|
||||
.map(|num| num.to_le_bytes())
|
||||
.flatten()
|
||||
.flat_map(|num| num.to_le_bytes())
|
||||
.collect();
|
||||
let sc_addr = hex::encode(mint_utxo_addr_bytes);
|
||||
|
||||
@@ -297,7 +296,7 @@ impl NodeCore {
|
||||
.map(|utxo| {
|
||||
(
|
||||
Account::encrypt_data(
|
||||
&ephm_key_holder,
|
||||
ephm_key_holder,
|
||||
account.key_holder.viewing_public_key,
|
||||
&serde_json::to_vec(&utxo).unwrap(),
|
||||
),
|
||||
@@ -312,8 +311,7 @@ impl NodeCore {
|
||||
let mint_multiple_utxo_addr_bytes: Vec<u8> =
|
||||
zkvm::test_methods::MINT_UTXO_MULTIPLE_ASSETS_ID
|
||||
.iter()
|
||||
.map(|num| num.to_le_bytes())
|
||||
.flatten()
|
||||
.flat_map(|num| num.to_le_bytes())
|
||||
.collect();
|
||||
let sc_addr = hex::encode(mint_multiple_utxo_addr_bytes);
|
||||
|
||||
@@ -386,14 +384,13 @@ impl NodeCore {
|
||||
.key_holder
|
||||
.utxo_secret_key_holder
|
||||
.nullifier_secret_key
|
||||
.to_bytes()
|
||||
.to_vec(),
|
||||
.to_bytes(),
|
||||
);
|
||||
|
||||
let (resulting_utxos, receipt) = prove_send_utxo(utxo, receivers)?;
|
||||
let utxo_hashes = resulting_utxos
|
||||
.iter()
|
||||
.map(|(utxo, addr)| (addr.clone(), utxo.hash))
|
||||
.map(|(utxo, addr)| (*addr, utxo.hash))
|
||||
.collect();
|
||||
|
||||
let utxos: Vec<UTXO> = resulting_utxos
|
||||
@@ -413,7 +410,7 @@ impl NodeCore {
|
||||
let accout_enc = acc_map_read_guard.acc_map.get(&utxo_enc.owner).unwrap();
|
||||
|
||||
let (ciphertext, nonce) = Account::encrypt_data(
|
||||
&ephm_key_holder,
|
||||
ephm_key_holder,
|
||||
accout_enc.key_holder.viewing_public_key,
|
||||
&serde_json::to_vec(&utxo_enc).unwrap(),
|
||||
);
|
||||
@@ -428,8 +425,7 @@ impl NodeCore {
|
||||
|
||||
let send_utxo_addr_bytes: Vec<u8> = zkvm::test_methods::SEND_UTXO_ID
|
||||
.iter()
|
||||
.map(|num| num.to_le_bytes())
|
||||
.flatten()
|
||||
.flat_map(|num| num.to_le_bytes())
|
||||
.collect();
|
||||
let sc_addr = hex::encode(send_utxo_addr_bytes);
|
||||
|
||||
@@ -535,7 +531,7 @@ impl NodeCore {
|
||||
let accout_enc = acc_map_read_guard.acc_map.get(&utxo_enc.owner).unwrap();
|
||||
|
||||
let (ciphertext, nonce) = Account::encrypt_data(
|
||||
&ephm_key_holder,
|
||||
ephm_key_holder,
|
||||
accout_enc.key_holder.viewing_public_key,
|
||||
&serde_json::to_vec(&utxo_enc).unwrap(),
|
||||
);
|
||||
@@ -552,7 +548,7 @@ impl NodeCore {
|
||||
let accout_enc = acc_map_read_guard.acc_map.get(&utxo_enc.owner).unwrap();
|
||||
|
||||
let (ciphertext, nonce) = Account::encrypt_data(
|
||||
&ephm_key_holder,
|
||||
ephm_key_holder,
|
||||
accout_enc.key_holder.viewing_public_key,
|
||||
&serde_json::to_vec(&utxo_enc).unwrap(),
|
||||
);
|
||||
@@ -573,8 +569,7 @@ impl NodeCore {
|
||||
let send_multiple_utxo_addr_bytes: Vec<u8> =
|
||||
zkvm::test_methods::SEND_UTXO_MULTIPLE_ASSETS_ID
|
||||
.iter()
|
||||
.map(|num| num.to_le_bytes())
|
||||
.flatten()
|
||||
.flat_map(|num| num.to_le_bytes())
|
||||
.collect();
|
||||
let sc_addr = hex::encode(send_multiple_utxo_addr_bytes);
|
||||
|
||||
@@ -654,14 +649,13 @@ impl NodeCore {
|
||||
.key_holder
|
||||
.utxo_secret_key_holder
|
||||
.nullifier_secret_key
|
||||
.to_bytes()
|
||||
.to_vec(),
|
||||
.to_bytes(),
|
||||
);
|
||||
|
||||
let (resulting_utxos, receipt) = prove_send_utxo_shielded(acc, balance as u128, receivers)?;
|
||||
let utxo_hashes = resulting_utxos
|
||||
.iter()
|
||||
.map(|(utxo, addr)| (addr.clone(), utxo.hash))
|
||||
.map(|(utxo, addr)| (*addr, utxo.hash))
|
||||
.collect();
|
||||
|
||||
let utxos: Vec<UTXO> = resulting_utxos
|
||||
@@ -681,7 +675,7 @@ impl NodeCore {
|
||||
let accout_enc = acc_map_read_guard.acc_map.get(&utxo_enc.owner).unwrap();
|
||||
|
||||
let (ciphertext, nonce) = Account::encrypt_data(
|
||||
&ephm_key_holder,
|
||||
ephm_key_holder,
|
||||
accout_enc.key_holder.viewing_public_key,
|
||||
&serde_json::to_vec(&utxo_enc).unwrap(),
|
||||
);
|
||||
@@ -696,8 +690,7 @@ impl NodeCore {
|
||||
|
||||
let mint_utxo_addr_bytes: Vec<u8> = zkvm::test_methods::SEND_UTXO_ID
|
||||
.iter()
|
||||
.map(|num| num.to_le_bytes())
|
||||
.flatten()
|
||||
.flat_map(|num| num.to_le_bytes())
|
||||
.collect();
|
||||
let sc_addr = hex::encode(mint_utxo_addr_bytes);
|
||||
|
||||
@@ -782,16 +775,14 @@ impl NodeCore {
|
||||
.key_holder
|
||||
.utxo_secret_key_holder
|
||||
.nullifier_secret_key
|
||||
.to_bytes()
|
||||
.to_vec(),
|
||||
.to_bytes(),
|
||||
);
|
||||
|
||||
let (resulting_balances, receipt) = prove_send_utxo_deshielded(utxo, receivers)?;
|
||||
|
||||
let send_utxo_addr_bytes: Vec<u8> = zkvm::test_methods::SEND_UTXO_ID
|
||||
.iter()
|
||||
.map(|num| num.to_le_bytes())
|
||||
.flatten()
|
||||
.flat_map(|num| num.to_le_bytes())
|
||||
.collect();
|
||||
let sc_addr = hex::encode(send_utxo_addr_bytes);
|
||||
|
||||
@@ -1372,14 +1363,13 @@ impl NodeCore {
|
||||
.key_holder
|
||||
.utxo_secret_key_holder
|
||||
.nullifier_secret_key
|
||||
.to_bytes()
|
||||
.to_vec(),
|
||||
.to_bytes(),
|
||||
);
|
||||
|
||||
let (resulting_utxos, receipt) = prove_send_utxo(utxo, receivers)?;
|
||||
let utxo_hashes = resulting_utxos
|
||||
.iter()
|
||||
.map(|(utxo, addr)| (addr.clone(), utxo.hash))
|
||||
.map(|(utxo, addr)| (*addr, utxo.hash))
|
||||
.collect();
|
||||
|
||||
let utxos: Vec<UTXO> = resulting_utxos
|
||||
@@ -1399,7 +1389,7 @@ impl NodeCore {
|
||||
let accout_enc = acc_map_read_guard.acc_map.get(&utxo_enc.owner).unwrap();
|
||||
|
||||
let (ciphertext, nonce) = Account::encrypt_data(
|
||||
&ephm_key_holder,
|
||||
ephm_key_holder,
|
||||
accout_enc.key_holder.viewing_public_key,
|
||||
&serde_json::to_vec(&utxo_enc).unwrap(),
|
||||
);
|
||||
@@ -1428,8 +1418,7 @@ impl NodeCore {
|
||||
|
||||
let send_utxo_addr_bytes: Vec<u8> = zkvm::test_methods::SEND_UTXO_ID
|
||||
.iter()
|
||||
.map(|num| num.to_le_bytes())
|
||||
.flatten()
|
||||
.flat_map(|num| num.to_le_bytes())
|
||||
.collect();
|
||||
let sc_addr = hex::encode(send_utxo_addr_bytes);
|
||||
|
||||
@@ -1528,10 +1517,7 @@ impl NodeCore {
|
||||
.send_split_tx(
|
||||
utxo.clone(),
|
||||
comm_gen_hash,
|
||||
addrs_receivers
|
||||
.clone()
|
||||
.map(|addr| (utxo.amount / 3, addr))
|
||||
.to_vec(),
|
||||
addrs_receivers.map(|addr| (utxo.amount / 3, addr)).to_vec(),
|
||||
visibility_list,
|
||||
)
|
||||
.await?;
|
||||
|
||||
@@ -22,8 +22,7 @@ pub async fn setup_empty_sc_states(node: &NodeChainStore) -> Result<()> {
|
||||
|
||||
let mint_utxo_addr_bytes: Vec<u8> = zkvm::test_methods::MINT_UTXO_ID
|
||||
.iter()
|
||||
.map(|num| num.to_le_bytes())
|
||||
.flatten()
|
||||
.flat_map(|num| num.to_le_bytes())
|
||||
.collect();
|
||||
let mint_utxo_addr = hex::encode(mint_utxo_addr_bytes);
|
||||
node.block_store
|
||||
@@ -32,8 +31,7 @@ pub async fn setup_empty_sc_states(node: &NodeChainStore) -> Result<()> {
|
||||
|
||||
let single_utxo_transfer_addr_bytes: Vec<u8> = zkvm::test_methods::SEND_UTXO_ID
|
||||
.iter()
|
||||
.map(|num| num.to_le_bytes())
|
||||
.flatten()
|
||||
.flat_map(|num| num.to_le_bytes())
|
||||
.collect();
|
||||
let single_utxo_transfer_addr = hex::encode(single_utxo_transfer_addr_bytes);
|
||||
node.block_store.put_sc_sc_state(
|
||||
@@ -46,8 +44,7 @@ pub async fn setup_empty_sc_states(node: &NodeChainStore) -> Result<()> {
|
||||
let mint_utxo_multiple_assets_addr_bytes: Vec<u8> =
|
||||
zkvm::test_methods::MINT_UTXO_MULTIPLE_ASSETS_ID
|
||||
.iter()
|
||||
.map(|num| num.to_le_bytes())
|
||||
.flatten()
|
||||
.flat_map(|num| num.to_le_bytes())
|
||||
.collect();
|
||||
let mint_utxo_multiple_assets_addr = hex::encode(mint_utxo_multiple_assets_addr_bytes);
|
||||
node.block_store.put_sc_sc_state(
|
||||
@@ -60,8 +57,7 @@ pub async fn setup_empty_sc_states(node: &NodeChainStore) -> Result<()> {
|
||||
let multiple_assets_utxo_transfer_addr_bytes: Vec<u8> =
|
||||
zkvm::test_methods::SEND_UTXO_MULTIPLE_ASSETS_ID
|
||||
.iter()
|
||||
.map(|num| num.to_le_bytes())
|
||||
.flatten()
|
||||
.flat_map(|num| num.to_le_bytes())
|
||||
.collect();
|
||||
let multiple_assets_utxo_transfer_addr = hex::encode(multiple_assets_utxo_transfer_addr_bytes);
|
||||
node.block_store.put_sc_sc_state(
|
||||
|
||||
Reference in New Issue
Block a user