fix: reject public transactions with empty account_ids (#552)

Closes #513
This commit is contained in:
jonesmarvin8 2026-06-24 13:33:51 -04:00 committed by GitHub
parent 066ffdd51a
commit 77af662ac6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 20 additions and 0 deletions

View File

@ -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();

View File

@ -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(),