Skip to content

Commit

Permalink
test(sequencer): add testing for cometbft block overflow in prepare p…
Browse files Browse the repository at this point in the history
…roposal
  • Loading branch information
Lilyjjo committed Apr 3, 2024
1 parent 9ad128f commit bc8a259
Showing 1 changed file with 74 additions and 0 deletions.
74 changes: 74 additions & 0 deletions crates/astria-sequencer/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2208,4 +2208,78 @@ mod test {
},
)
}

#[tokio::test]
async fn app_prepare_proposal_cometbft_max_bytes_overflow_ok() {
let (mut app, storage) = initialize_app_with_storage(None, vec![]).await;

// update storage with initalized genesis app state
let intermediate_state = StateDelta::new(storage.latest_snapshot());
let state = Arc::try_unwrap(std::mem::replace(
&mut app.state,
Arc::new(intermediate_state),
))
.expect("we have exclusive ownership of the State at commit()");
storage
.commit(state)
.await
.expect("applying genesis state should be okay");

// create txs which will cause cometbft overflow
let (alice_signing_key, _) = get_alice_signing_key_and_address();
let tx_pass = UnsignedTransaction {
nonce: 0,
actions: vec![
SequenceAction {
rollup_id: RollupId::from([1u8; 32]),
data: vec![1u8; 100_000],
fee_asset_id: get_native_asset().id(),
}
.into(),
],
}
.into_signed(&alice_signing_key);
let tx_overflow = UnsignedTransaction {
nonce: 1,
actions: vec![
SequenceAction {
rollup_id: RollupId::from([1u8; 32]),
data: vec![1u8; 100_000],
fee_asset_id: get_native_asset().id(),
}
.into(),
],
}
.into_signed(&alice_signing_key);

let txs: Vec<bytes::Bytes> = vec![
tx_pass.to_raw().encode_to_vec().into(),
tx_overflow.to_raw().encode_to_vec().into(),
];

// send to prepare_proposal
let prepare_args = abci::request::PrepareProposal {
max_tx_bytes: 200_200,
txs,
local_last_commit: None,
misbehavior: vec![],
height: Height::default(),
time: Time::now(),
next_validators_hash: Hash::default(),
proposer_address: account::Id::new([1u8; 20]),
};

let result = app
.prepare_proposal(prepare_args, storage)
.await
.expect("too large transactions should not cause prepare proposal to fail");

// see only first tx made it in
assert_eq!(
result.txs.len(),
3,
"total transaciton length should be three, including the two commitments and the one \
tx that fit"
);
}
}

0 comments on commit bc8a259

Please sign in to comment.