mirror of
https://github.com/logos-blockchain/lssa.git
synced 2026-01-02 13:23:10 +00:00
fix: merge fixes
This commit is contained in:
parent
8ceb27421e
commit
5747070e39
@ -1,7 +1,7 @@
|
||||
use rs_merkle::Hasher;
|
||||
use std::io::{Cursor, Read};
|
||||
|
||||
use crate::{transaction::TransactionBody, OwnHasher};
|
||||
use crate::{OwnHasher, transaction::TransactionBody};
|
||||
|
||||
pub type BlockHash = [u8; 32];
|
||||
pub type BlockId = u64;
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
use rs_merkle::Hasher;
|
||||
use serde::Deserialize;
|
||||
use sha2::{digest::FixedOutput, Digest, Sha256};
|
||||
use sha2::{Digest, Sha256, digest::FixedOutput};
|
||||
|
||||
pub mod block;
|
||||
pub mod commitment;
|
||||
|
||||
@ -1,7 +1,4 @@
|
||||
use k256::ecdsa::{
|
||||
Signature, SigningKey, VerifyingKey,
|
||||
signature::{Signer, Verifier},
|
||||
};
|
||||
use k256::ecdsa::{Signature, SigningKey, VerifyingKey};
|
||||
use log::info;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
@ -188,14 +185,11 @@ pub type SignaturePrivateKey = SigningKey;
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use k256::{FieldBytes, ecdsa::signature::Signer};
|
||||
use secp256k1_zkp::{Tweak, constants::SECRET_KEY_SIZE};
|
||||
use sha2::{Digest, digest::FixedOutput};
|
||||
|
||||
use crate::{
|
||||
transaction::{TransactionBody, TxKind},
|
||||
TreeHashType,
|
||||
transaction::{TransactionBody, TxKind},
|
||||
};
|
||||
|
||||
fn test_transaction_body() -> TransactionBody {
|
||||
@ -228,62 +222,5 @@ mod tests {
|
||||
let body_new = TransactionBody::from_bytes(body_bytes);
|
||||
|
||||
assert_eq!(body, body_new);
|
||||
#[test]
|
||||
fn test_into_authenticated_succeeds_for_valid_signature() {
|
||||
let transaction = test_transaction();
|
||||
let authenticated_tx = transaction.clone().into_authenticated().unwrap();
|
||||
|
||||
let signature = authenticated_tx.transaction().signature;
|
||||
let hash = authenticated_tx.hash();
|
||||
|
||||
assert_eq!(authenticated_tx.transaction(), &transaction);
|
||||
assert_eq!(hash, &transaction.body.hash());
|
||||
assert!(
|
||||
authenticated_tx
|
||||
.transaction()
|
||||
.public_key
|
||||
.verify(&transaction.body.to_bytes(), &signature)
|
||||
.is_ok()
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_into_authenticated_fails_for_invalid_signature() {
|
||||
let body = test_transaction_body();
|
||||
let key_bytes = FieldBytes::from_slice(&[37; 32]);
|
||||
let private_key: SigningKey = SigningKey::from_bytes(key_bytes).unwrap();
|
||||
let transaction = {
|
||||
let mut this = Transaction::new(body, private_key.clone());
|
||||
// Modify the signature to make it invalid
|
||||
// We do this by changing it to the signature of something else
|
||||
this.signature = private_key.sign(b"deadbeef");
|
||||
this
|
||||
};
|
||||
|
||||
matches!(
|
||||
transaction.into_authenticated(),
|
||||
Err(TransactionSignatureError::InvalidSignature)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_authenticated_transaction_getter() {
|
||||
let transaction = test_transaction();
|
||||
let authenticated_tx = transaction.clone().into_authenticated().unwrap();
|
||||
assert_eq!(authenticated_tx.transaction(), &transaction);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_authenticated_transaction_hash_getter() {
|
||||
let transaction = test_transaction();
|
||||
let authenticated_tx = transaction.clone().into_authenticated().unwrap();
|
||||
assert_eq!(authenticated_tx.hash(), &transaction.body.hash());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_authenticated_transaction_into_transaction() {
|
||||
let transaction = test_transaction();
|
||||
let authenticated_tx = transaction.clone().into_authenticated().unwrap();
|
||||
assert_eq!(authenticated_tx.into_transaction(), transaction);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
use std::fmt::Display;
|
||||
|
||||
use anyhow::Result;
|
||||
use common::{block::HashableBlockData, transaction::TransactionBody, TreeHashType};
|
||||
use common::{TreeHashType, block::HashableBlockData, transaction::TransactionBody};
|
||||
use config::SequencerConfig;
|
||||
use log::{info, warn};
|
||||
use mempool::MemPool;
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
use std::{collections::HashMap, path::Path};
|
||||
|
||||
use anyhow::Result;
|
||||
use common::{block::Block, transaction::TransactionBody, TreeHashType};
|
||||
use common::{TreeHashType, block::Block, transaction::TransactionBody};
|
||||
use storage::RocksDBIO;
|
||||
|
||||
pub struct SequecerBlockStore {
|
||||
|
||||
@ -5,6 +5,7 @@ use sequencer_core::config::AccountInitialData;
|
||||
use serde_json::Value;
|
||||
|
||||
use common::{
|
||||
TreeHashType,
|
||||
block::HashableBlockData,
|
||||
rpc_primitives::{
|
||||
errors::RpcError,
|
||||
@ -18,7 +19,6 @@ use common::{
|
||||
},
|
||||
},
|
||||
transaction::TransactionBody,
|
||||
TreeHashType,
|
||||
};
|
||||
|
||||
use common::rpc_primitives::requests::{
|
||||
@ -276,8 +276,8 @@ impl JsonHandler {
|
||||
mod tests {
|
||||
use std::sync::Arc;
|
||||
|
||||
use crate::{rpc_handler, JsonHandler};
|
||||
use base64::{engine::general_purpose, Engine};
|
||||
use crate::{JsonHandler, rpc_handler};
|
||||
use base64::{Engine, engine::general_purpose};
|
||||
use common::{
|
||||
rpc_primitives::RpcPollingConfig, test_utils::sequencer_sign_key_for_testing,
|
||||
transaction::TransactionBody,
|
||||
|
||||
@ -2,10 +2,9 @@ use std::{fs::File, io::Write, path::PathBuf, str::FromStr, sync::Arc};
|
||||
|
||||
use base64::Engine;
|
||||
use common::{
|
||||
sequencer_client::{json::SendTxResponse, SequencerClient},
|
||||
transaction::TransactionBody,
|
||||
ExecutionFailureKind,
|
||||
sequencer_client::{SequencerClient, json::SendTxResponse},
|
||||
transaction::TransactionBody,
|
||||
};
|
||||
|
||||
use anyhow::Result;
|
||||
@ -122,7 +121,7 @@ impl WalletCore {
|
||||
|
||||
let tx = nssa::PublicTransaction::new(message, witness_set);
|
||||
|
||||
Ok(self.sequencer_client.send_tx(tx).await?)
|
||||
Ok(self.sequencer_client.send_tx_public(tx).await?)
|
||||
} else {
|
||||
Err(ExecutionFailureKind::InsufficientFundsError)
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user