Skip to content

Commit

Permalink
use IntegrationTest::generate_block to generate blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
eval-exec committed Feb 18, 2024
1 parent df44a06 commit 8371c48
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
15 changes: 4 additions & 11 deletions test/src/miner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,25 +41,18 @@ impl Miner {
}

pub fn generate_block(&self) -> H256 {
let template = self
.rpc
.lock()
.unwrap()
.get_block_template(None, None, None)
.expect("RPC get_block_template");
let work_id = template.work_id.value();
let block = Into::<Block>::into(template);
self.rpc
.lock()
.unwrap()
.submit_block(work_id.to_string(), block.into())
.expect("RPC submit_block")
.generate_block()
.expect("RPC generate_block")
}

pub fn generate_blocks(&self, count: u64) {
log::info!("generating {} blocks...", count);
(0..count).for_each(|_| {
self.generate_block();
let block_hash = self.generate_block();
log::info!("generated block: {}", block_hash);
thread::sleep(Duration::from_millis(10));
})
}
Expand Down
4 changes: 4 additions & 0 deletions test/src/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,10 @@ impl Setup {
.as_array_mut()
.unwrap()
.push(toml::Value::String("Indexer".to_string()));
value["rpc"]["modules"]
.as_array_mut()
.unwrap()
.push(toml::Value::String("IntegrationTest".to_string()));
// value["indexer_v2"]["index_tx_pool"] = true;
value
.as_table_mut()
Expand Down

0 comments on commit 8371c48

Please sign in to comment.