Skip to content

Commit 82fba21

Browse files
committed
fixup
1 parent eaf9bea commit 82fba21

2 files changed

Lines changed: 17 additions & 11 deletions

File tree

src/test_utils/block.rs

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -116,15 +116,23 @@ impl TestBlockBuildBuilder {
116116
/// This creates a `BlockBuild` ready for simulation.
117117
/// Call `.build().await` on the result to execute the simulation and get a `BuiltBlock`.
118118
pub fn build(self) -> TestBlockBuild {
119-
let builder = self.sim_env_builder.unwrap_or_default();
120-
let ru_state_source = TestStateSource::new(builder.rollup_db());
121-
let host_state_source = TestStateSource::new(builder.host_db());
122-
123-
let (rollup_env, host_env) = match (self.rollup_env, self.host_env) {
124-
(Some(rollup), Some(host)) => (rollup, host),
125-
_ => builder.build(),
119+
let (rollup_env, host_env, rollup_db, host_db) = match self.env {
120+
TestBlockBuildEnv::Builder(builder) => {
121+
let rollup_db = builder.rollup_db();
122+
let host_db = builder.host_db();
123+
let (rollup, host) = builder.build();
124+
(rollup, host, rollup_db, host_db)
125+
}
126+
TestBlockBuildEnv::Built { rollup, host } => {
127+
let rollup_db = TestDb::new(Default::default());
128+
let host_db = TestDb::new(Default::default());
129+
(rollup, host, rollup_db, host_db)
130+
}
126131
};
127132

133+
let ru_state_source = TestStateSource::new(rollup_db);
134+
let host_state_source = TestStateSource::new(host_db);
135+
128136
// Convert the relative deadline into the absolute instant expected by `BlockBuild`.
129137
let finish_by = Instant::now() + self.deadline_duration;
130138

@@ -139,16 +147,14 @@ impl TestBlockBuildBuilder {
139147
ru_state_source,
140148
host_state_source,
141149
)
142-
.build()
143-
.await
144150
}
145151
}
146152

147153
/// Convenience function to quickly build a block with a cache and optional configuration.
148154
/// This is useful for simple test cases where you just want to simulate
149155
/// some transactions quickly.
150156
pub async fn quick_build_block(cache: SimCache, deadline: Duration) -> BuiltBlock {
151-
TestBlockBuildBuilder::new().with_cache(cache).with_deadline(deadline).into_block_build().await
157+
TestBlockBuildBuilder::new().with_cache(cache).with_deadline(deadline).build().build().await
152158
}
153159

154160
#[cfg(test)]

src/test_utils/db.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub type TestDb = CacheDB<EmptyDB>;
2121
/// which is required for preflight validity checks during simulation.
2222
#[derive(Debug, Clone)]
2323
pub struct TestStateSource {
24-
db: InnerDb<TestDb>,
24+
db: TestDb,
2525
}
2626

2727
impl TestStateSource {

0 commit comments

Comments
 (0)