-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(composer): add missing blackbox tests #1834
Open
ethanoroshiba
wants to merge
5
commits into
main
Choose a base branch
from
ENG-914/composer_blackbox_tests
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
2bf83c3
remove old tests, add missing blackbox tests
ethanoroshiba f1cf32a
remove unused test_utils change
ethanoroshiba 5d10104
Merge branch 'main' into ENG-914/composer_blackbox_tests
ethanoroshiba f59bd54
Merge branch 'main' into ENG-914/composer_blackbox_tests
ethanoroshiba e27d2fc
fix changes from merge
ethanoroshiba File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,224 @@ | ||
use std::time::Duration; | ||
|
||
use astria_core::{ | ||
generated::composer::v1::{ | ||
grpc_collector_service_client::GrpcCollectorServiceClient, | ||
SubmitRollupTransactionRequest, | ||
}, | ||
primitive::v1::{ | ||
RollupId, | ||
ROLLUP_ID_LEN, | ||
}, | ||
protocol::transaction::v1::action::RollupDataSubmission, | ||
}; | ||
use tokio::time; | ||
|
||
use crate::helper::{ | ||
mount_broadcast_tx_sync_rollup_data_submissions_mock, | ||
signed_tx_from_request, | ||
spawn_composer, | ||
}; | ||
|
||
/// Test to check that the executor sends a signed transaction to the sequencer after its | ||
/// `block_timer` has ticked | ||
#[tokio::test] | ||
async fn bundle_triggered_by_block_timer() { | ||
let test_composer = spawn_composer(&["test1"], None, true).await; | ||
let mut composer_client = GrpcCollectorServiceClient::connect(format!( | ||
"http://{}", | ||
test_composer.grpc_collector_addr | ||
)) | ||
.await | ||
.unwrap(); | ||
|
||
let response_guard = | ||
mount_broadcast_tx_sync_rollup_data_submissions_mock(&test_composer.sequencer).await; | ||
|
||
// send two sequence actions to the executor, both small enough to fit in a single bundle | ||
// without filling it | ||
let rollup_id = RollupId::new([0; ROLLUP_ID_LEN]); | ||
let data = vec![0u8; 1000]; | ||
|
||
let seq0 = RollupDataSubmission { | ||
data: data.clone().into(), | ||
rollup_id, | ||
fee_asset: "nria".parse().unwrap(), | ||
}; | ||
|
||
// make sure at least one block has passed so that the executor will submit the bundle | ||
// despite it not being full | ||
time::pause(); | ||
time::timeout(Duration::from_millis(1000), async { | ||
composer_client | ||
.submit_rollup_transaction(SubmitRollupTransactionRequest { | ||
rollup_id: Some(rollup_id.into_raw()), | ||
data: data.into(), | ||
}) | ||
.await | ||
.expect("rollup transactions should have been submitted successfully to grpc collector") | ||
}) | ||
.await | ||
.unwrap(); | ||
time::advance(Duration::from_millis(2000)).await; | ||
time::resume(); | ||
|
||
// wait for the mock sequencer to receive the signed transaction | ||
tokio::time::timeout( | ||
Duration::from_millis(100), | ||
response_guard.wait_until_satisfied(), | ||
) | ||
.await | ||
.unwrap(); | ||
|
||
// verify only one signed transaction was received by the mock sequencer | ||
let expected_rollup_data_submissions = [seq0]; | ||
let requests = response_guard.received_requests().await; | ||
assert_eq!(requests.len(), 1); | ||
|
||
// verify the expected sequence actions were received | ||
let signed_tx = signed_tx_from_request(&requests[0]); | ||
let actions = signed_tx.actions(); | ||
|
||
assert_eq!( | ||
actions.len(), | ||
expected_rollup_data_submissions.len(), | ||
"received more than one action, one was supposed to fill the bundle" | ||
); | ||
|
||
for (action, expected_rollup_data_submission) in | ||
actions.iter().zip(expected_rollup_data_submissions.iter()) | ||
{ | ||
let rollup_data_submission = action.as_rollup_data_submission().unwrap(); | ||
assert_eq!( | ||
rollup_data_submission.rollup_id, expected_rollup_data_submission.rollup_id, | ||
"chain id does not match. actual {:?} expected {:?}", | ||
rollup_data_submission.rollup_id, expected_rollup_data_submission.rollup_id | ||
); | ||
assert_eq!( | ||
rollup_data_submission.data, expected_rollup_data_submission.data, | ||
"data does not match expected data for action with rollup_id {:?}", | ||
rollup_data_submission.rollup_id, | ||
); | ||
} | ||
} | ||
|
||
/// Test to check that the executor sends a signed transaction with two sequence actions to the | ||
/// sequencer. | ||
#[tokio::test] | ||
async fn two_rollup_data_submissions_single_bundle() { | ||
let test_composer = spawn_composer(&["test1"], None, true).await; | ||
let mut composer_client = GrpcCollectorServiceClient::connect(format!( | ||
"http://{}", | ||
test_composer.grpc_collector_addr | ||
)) | ||
.await | ||
.unwrap(); | ||
|
||
let response_guard = | ||
mount_broadcast_tx_sync_rollup_data_submissions_mock(&test_composer.sequencer).await; | ||
|
||
// send two sequence actions to the executor, both small enough to fit in a single bundle | ||
// without filling it | ||
let seq0 = RollupDataSubmission { | ||
rollup_id: RollupId::new([0; ROLLUP_ID_LEN]), | ||
data: vec![0u8; 1000].into(), | ||
fee_asset: "nria".parse().unwrap(), | ||
}; | ||
|
||
let seq1 = RollupDataSubmission { | ||
rollup_id: RollupId::new([1; ROLLUP_ID_LEN]), | ||
data: vec![1u8; 1000].into(), | ||
fee_asset: "nria".parse().unwrap(), | ||
}; | ||
|
||
// make sure at least one block has passed so that the executor will submit the bundle | ||
// despite it not being full | ||
time::pause(); | ||
time::timeout(Duration::from_millis(1000), async { | ||
composer_client | ||
.submit_rollup_transaction(SubmitRollupTransactionRequest { | ||
rollup_id: Some(seq0.rollup_id.into_raw()), | ||
data: seq0.data.clone(), | ||
}) | ||
.await | ||
.expect("rollup transactions should have been submitted successfully to grpc collector") | ||
}) | ||
.await | ||
.unwrap(); | ||
time::timeout(Duration::from_millis(1000), async { | ||
composer_client | ||
.submit_rollup_transaction(SubmitRollupTransactionRequest { | ||
rollup_id: Some(seq1.rollup_id.into_raw()), | ||
data: seq1.data.clone(), | ||
}) | ||
.await | ||
.expect("rollup transactions should have been submitted successfully to grpc collector") | ||
}) | ||
.await | ||
.unwrap(); | ||
time::advance(Duration::from_millis(2000)).await; | ||
time::resume(); | ||
|
||
// wait for the mock sequencer to receive the signed transaction | ||
tokio::time::timeout( | ||
Duration::from_millis(100), | ||
response_guard.wait_until_satisfied(), | ||
) | ||
.await | ||
.unwrap(); | ||
|
||
// verify only one signed transaction was received by the mock sequencer | ||
let expected_rollup_data_submissions = [seq0, seq1]; | ||
let requests = response_guard.received_requests().await; | ||
assert_eq!(requests.len(), 1); | ||
|
||
// verify the expected sequence actions were received | ||
let signed_tx = signed_tx_from_request(&requests[0]); | ||
let actions = signed_tx.actions(); | ||
|
||
assert_eq!( | ||
actions.len(), | ||
expected_rollup_data_submissions.len(), | ||
"received more than one action, one was supposed to fill the bundle" | ||
); | ||
|
||
for (action, expected_rollup_data_submission) in | ||
actions.iter().zip(expected_rollup_data_submissions.iter()) | ||
{ | ||
let rollup_data_submission = action.as_rollup_data_submission().unwrap(); | ||
assert_eq!( | ||
rollup_data_submission.rollup_id, expected_rollup_data_submission.rollup_id, | ||
"chain id does not match. actual {:?} expected {:?}", | ||
rollup_data_submission.rollup_id, expected_rollup_data_submission.rollup_id | ||
); | ||
assert_eq!( | ||
rollup_data_submission.data, expected_rollup_data_submission.data, | ||
"data does not match expected data for action with rollup_id {:?}", | ||
rollup_data_submission.rollup_id, | ||
); | ||
} | ||
} | ||
|
||
/// Test to check that executor's chain ID check is properly checked against the sequencer's chain | ||
/// ID | ||
#[tokio::test] | ||
async fn chain_id_mismatch_returns_error() { | ||
// TODO(https://github.com/astriaorg/astria/issues/1833): this test will currently succeed if | ||
// the executor fails for any reason on startup, not just if the chain ID is incorrect. This is | ||
// a symptom of the current implementation of executor, though, which should be propagating | ||
// errors. As such, I think it is out of the scope for the following test-only changes and | ||
// should be fixed in a followup. | ||
|
||
let bad_chain_id = "bad_id"; | ||
let test_composer = spawn_composer(&["test1"], Some(bad_chain_id), false).await; | ||
let err = test_composer.composer.await.unwrap().unwrap_err(); | ||
for cause in err.chain() { | ||
if cause | ||
.to_string() | ||
.contains("executor failed while waiting for it to become ready") | ||
{ | ||
return; | ||
} | ||
} | ||
panic!("did not find expected executor error message") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This sometimes times out, even when increasing the timeout time. Unsure as to if this is a problem with the test or something flaky about composer.