mirror of
https://github.com/logos-blockchain/lssa.git
synced 2026-01-04 14:23:11 +00:00
fix: comments fix 1
This commit is contained in:
parent
a24a40f4bc
commit
00532b564b
@ -263,35 +263,6 @@ mod tests {
|
||||
use secp256k1_zkp::Tweak;
|
||||
use transaction_mempool::TransactionMempool;
|
||||
|
||||
fn setup_sequencer_config() -> SequencerConfig {
|
||||
let mut rng = rand::thread_rng();
|
||||
let random_u8: u8 = rng.gen();
|
||||
|
||||
let path_str = format!("/tmp/sequencer_{:?}", random_u8);
|
||||
|
||||
SequencerConfig {
|
||||
home: PathBuf::from(path_str),
|
||||
override_rust_log: Some("info".to_string()),
|
||||
genesis_id: 1,
|
||||
is_genesis_random: false,
|
||||
max_num_tx_in_block: 10,
|
||||
block_create_timeout_millis: 1000,
|
||||
port: 8080,
|
||||
initial_accounts: vec![
|
||||
AccountInitialData {
|
||||
addr: "bfd91e6703273a115ad7f099ef32f621243be69369d00ddef5d3a25117d09a8c"
|
||||
.to_string(),
|
||||
balance: 10,
|
||||
},
|
||||
AccountInitialData {
|
||||
addr: "20573479053979b98d2ad09ef31a0750f22c77709bed51c4e64946bd1e376f31"
|
||||
.to_string(),
|
||||
balance: 100,
|
||||
},
|
||||
],
|
||||
}
|
||||
}
|
||||
|
||||
fn setup_sequencer_config_variable_initial_accounts(
|
||||
initial_accounts: Vec<AccountInitialData>,
|
||||
) -> SequencerConfig {
|
||||
@ -312,6 +283,23 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
fn setup_sequencer_config() -> SequencerConfig {
|
||||
let initial_accounts = vec![
|
||||
AccountInitialData {
|
||||
addr: "bfd91e6703273a115ad7f099ef32f621243be69369d00ddef5d3a25117d09a8c"
|
||||
.to_string(),
|
||||
balance: 10,
|
||||
},
|
||||
AccountInitialData {
|
||||
addr: "20573479053979b98d2ad09ef31a0750f22c77709bed51c4e64946bd1e376f31"
|
||||
.to_string(),
|
||||
balance: 100,
|
||||
},
|
||||
];
|
||||
|
||||
setup_sequencer_config_variable_initial_accounts(initial_accounts)
|
||||
}
|
||||
|
||||
fn create_dummy_transaction(
|
||||
hash: TreeHashType,
|
||||
nullifier_created_hashes: Vec<[u8; 32]>,
|
||||
@ -401,12 +389,14 @@ mod tests {
|
||||
balance: 1000,
|
||||
},
|
||||
AccountInitialData {
|
||||
addr: "bfd91e6703273a115ad7f099ef32f621243be69369d00ddef5d3a25117ffffff"
|
||||
addr: "20573479053979b98d2ad09ef31a0750f22c77709bed51c4e64946bd1effffff"
|
||||
.to_string(),
|
||||
balance: 1000,
|
||||
},
|
||||
];
|
||||
|
||||
let intial_accounts_len = initial_accounts.len();
|
||||
|
||||
let config = setup_sequencer_config_variable_initial_accounts(initial_accounts);
|
||||
let sequencer = SequencerCore::start_from_config(config.clone());
|
||||
|
||||
@ -417,7 +407,7 @@ mod tests {
|
||||
.try_into()
|
||||
.unwrap();
|
||||
let acc2_addr: [u8; 32] = hex::decode(
|
||||
"bfd91e6703273a115ad7f099ef32f621243be69369d00ddef5d3a25117ffffff".to_string(),
|
||||
"20573479053979b98d2ad09ef31a0750f22c77709bed51c4e64946bd1effffff".to_string(),
|
||||
)
|
||||
.unwrap()
|
||||
.try_into()
|
||||
@ -426,6 +416,8 @@ mod tests {
|
||||
assert!(sequencer.store.acc_store.contains_account(&acc1_addr));
|
||||
assert!(sequencer.store.acc_store.contains_account(&acc2_addr));
|
||||
|
||||
assert_eq!(sequencer.store.acc_store.len(), intial_accounts_len);
|
||||
|
||||
assert_eq!(
|
||||
1000,
|
||||
sequencer
|
||||
|
||||
@ -16,7 +16,7 @@ impl AccountPublicData {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new_with_balance(address: AccountAddress, balance: u64) -> Self {
|
||||
fn new_with_balance(address: AccountAddress, balance: u64) -> Self {
|
||||
Self { balance, address }
|
||||
}
|
||||
}
|
||||
@ -64,6 +64,11 @@ impl SequencerAccountsStore {
|
||||
pub fn unregister_account(&mut self, account_addr: AccountAddress) {
|
||||
self.accounts.remove(&account_addr);
|
||||
}
|
||||
|
||||
///Number of accounts present in store
|
||||
pub fn len(&self) -> usize {
|
||||
self.accounts.len()
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for SequencerAccountsStore {
|
||||
@ -162,4 +167,14 @@ mod tests {
|
||||
|
||||
assert_eq!(acc_balance, 10);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn account_sequencer_store_fetch_unknown_account() {
|
||||
let seq_acc_store =
|
||||
SequencerAccountsStore::new(&[([6; 32], 120), ([7; 32], 15), ([8; 32], 10)]);
|
||||
|
||||
let acc_balance = seq_acc_store.get_account_balance(&[9; 32]);
|
||||
|
||||
assert!(acc_balance.is_none());
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user