-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Fixed the error during dry run #2365
base: master
Are you sure you want to change the base?
Changes from all commits
f032f7e
5faeba2
9f98d68
7dca9e6
5c607f6
ac4cd74
c5aca74
28a668c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -649,27 +649,33 @@ mod dry_run { | |
} | ||
|
||
#[tokio::test] | ||
async fn dry_run__errors_early_if_height_is_lower_than_chain_tip() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did a quick scan but couldn't see a test for this on the produce or produce_predefined. Maybe I missed it. Do you think we need that coverage? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We have test case for But after introduction of the state rewind feature, I don't think that |
||
// Given | ||
let last_block_height = BlockHeight::new(42); | ||
|
||
async fn dry_run__success_when_height_is_the_same_as_chain_height() { | ||
let executor = MockExecutorWithCapture::default(); | ||
let ctx = TestContextBuilder::new() | ||
.with_prev_height(last_block_height) | ||
.build_with_executor(executor.clone()); | ||
let ctx = TestContext::default_from_executor(executor); | ||
let producer = ctx.producer(); | ||
|
||
// When | ||
let _ = ctx | ||
.producer() | ||
.dry_run(vec![], last_block_height.pred(), None, None, None) | ||
const SAME_HEIGHT: u32 = 1; | ||
|
||
// Given | ||
let block = producer | ||
.produce_and_execute_block_txpool(SAME_HEIGHT.into(), Tai64::now()) | ||
.await | ||
.expect_err("expected failure"); | ||
.unwrap(); | ||
producer.view_provider.blocks.lock().unwrap().insert( | ||
SAME_HEIGHT.into(), | ||
block.result().block.clone().compress(&Default::default()), | ||
); | ||
|
||
// When | ||
let result = producer | ||
.dry_run(vec![], Some(SAME_HEIGHT.into()), None, None, None) | ||
.await; | ||
|
||
// Then | ||
assert!(executor.has_no_captured_block_timestamp()); | ||
assert!(result.is_ok(), "{:?}", result); | ||
} | ||
|
||
impl MockExecutorWithCapture<Transaction> { | ||
impl MockExecutorWithCapture { | ||
fn captured_block_timestamp(&self) -> Tai64 { | ||
*self | ||
.captured | ||
|
@@ -680,10 +686,6 @@ mod dry_run { | |
.header_to_produce | ||
.time() | ||
} | ||
|
||
fn has_no_captured_block_timestamp(&self) -> bool { | ||
self.captured.lock().unwrap().is_none() | ||
} | ||
} | ||
} | ||
|
||
|
@@ -722,10 +724,10 @@ prop_compose! { | |
} | ||
|
||
#[allow(clippy::arithmetic_side_effects)] | ||
fn ctx_for_block<Tx>( | ||
fn ctx_for_block( | ||
block: &Block, | ||
executor: MockExecutorWithCapture<Tx>, | ||
) -> TestContext<MockExecutorWithCapture<Tx>> { | ||
executor: MockExecutorWithCapture, | ||
) -> TestContext<MockExecutorWithCapture> { | ||
let prev_height = block.header().height().pred().unwrap(); | ||
let prev_da_height = block.header().da_height.as_u64() - 1; | ||
TestContextBuilder::new() | ||
|
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.
nice catch