Skip to content
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

[test] Refactor bitcoin block tester base on Inscription events #2549

Merged
merged 1 commit into from
Aug 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion crates/rooch-framework-tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@

## How to build a bitcoin block tester genesis?

1. Download the events file `wget -c https://storage.googleapis.com/rooch_dev/ord_event_blk_858999.tar.zst`
2. Use unzstd and tar to decompressing the file to an event dir.
3. Run

```bash
cargo run -p rooch-framework-tests -- --btc-rpc-url http://localhost:9332 --btc-rpc-username your_username --btc-rpc-password your_pwd --blocks 790964 --blocks 855396
cargo run -p rooch-framework-tests -- --btc-rpc-url http://localhost:9332 --btc-rpc-username your_username --btc-rpc-password your_pwd --ord-event-dir your_local_event_dir --blocks 790964 --blocks 855396
```
11 changes: 8 additions & 3 deletions crates/rooch-framework-tests/src/binding_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ use rooch_types::crypto::RoochKeyPair;
use rooch_types::rooch_network::{BuiltinChainID, RoochNetwork};
use rooch_types::transaction::{L1BlockWithBody, L1Transaction, RoochTransaction};
use std::collections::VecDeque;
use std::env;
use std::path::Path;
use std::sync::Arc;
use std::{env, vec};
use tempfile::TempDir;
use tokio::runtime::Runtime;
use tracing::info;
Expand Down Expand Up @@ -151,20 +151,25 @@ impl RustBindingTest {
Ok(execute_result)
}

pub fn execute_l1_block_and_tx(&mut self, l1_block: L1BlockWithBody) -> Result<()> {
pub fn execute_l1_block_and_tx(
&mut self,
l1_block: L1BlockWithBody,
) -> Result<Vec<ExecuteTransactionResult>> {
let l1_txs = self.execute_l1_block(l1_block.clone())?;
let tx_len = l1_txs.len();
let mut total_gas_used = 0;
let mut results = vec![];
for l1_tx in l1_txs {
let resut = self.execute_l1_tx(l1_tx)?;
total_gas_used += resut.output.gas_used;
results.push(resut);
}
let avg_gas_used = total_gas_used / tx_len as u64;
info!(
"execute l1 block total gas used: {}, avg gas used: {}",
total_gas_used, avg_gas_used
);
Ok(())
Ok(results)
}

pub fn execute_l1_block(&mut self, l1_block: L1BlockWithBody) -> Result<Vec<L1Transaction>> {
Expand Down
Loading
Loading