mirror of
https://github.com/logos-blockchain/logos-execution-zone.git
synced 2026-06-26 17:09:35 +00:00
fix: reject public transactions with empty account_ids (#552)
Closes #513
This commit is contained in:
parent
066ffdd51a
commit
77af662ac6
@ -242,6 +242,21 @@ pub mod tests {
|
||||
assert!(matches!(result, Err(LeeError::InvalidInput(_))));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn empty_transaction_is_rejected() {
|
||||
let state = state_for_tests();
|
||||
let message = Message::new_preserialized(
|
||||
Program::authenticated_transfer_program().id(),
|
||||
vec![],
|
||||
vec![],
|
||||
vec![0; 4],
|
||||
);
|
||||
let witness_set = WitnessSet::from_raw_parts(vec![]);
|
||||
let tx = PublicTransaction::new(message, witness_set);
|
||||
let result = ValidatedStateDiff::from_public_transaction(&tx, &state, 1, 0);
|
||||
assert!(matches!(result, Err(LeeError::InvalidInput(_))));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn program_id_must_belong_to_bulitin_program_ids() {
|
||||
let (key1, key2, addr1, addr2) = keys_for_tests();
|
||||
|
||||
@ -49,6 +49,11 @@ impl ValidatedStateDiff {
|
||||
let message = tx.message();
|
||||
let witness_set = tx.witness_set();
|
||||
|
||||
ensure!(
|
||||
!message.account_ids.is_empty(),
|
||||
LeeError::InvalidInput("Public transaction must have at least one account".into())
|
||||
);
|
||||
|
||||
// All account_ids must be different
|
||||
ensure!(
|
||||
message.account_ids.iter().collect::<HashSet<_>>().len() == message.account_ids.len(),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user