Skip to content

Commit

Permalink
Carry bitcoin-da tests to e2e (#1515)
Browse files Browse the repository at this point in the history
  • Loading branch information
yaziciahmet authored Nov 26, 2024
1 parent 0494407 commit 61f962e
Show file tree
Hide file tree
Showing 15 changed files with 1,300 additions and 1,641 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -155,5 +155,7 @@ tower-http = { version = "0.5.0", features = ["full"] }
tower = { version = "0.4.13", features = ["full"] }
hyper = { version = "1.4.0" }

citrea-e2e = { git = "https://github.com/chainwayxyz/citrea-e2e", rev = "5baaef3" }

[patch.crates-io]
bitcoincore-rpc = { version = "0.18.0", git = "https://github.com/chainwayxyz/rust-bitcoincore-rpc.git", rev = "ca3cfa2" }
2 changes: 1 addition & 1 deletion bin/citrea/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ rustc_version_runtime = { workspace = true }
# bitcoin-e2e dependencies
bitcoin.workspace = true
bitcoincore-rpc.workspace = true
citrea-e2e = { git = "https://github.com/chainwayxyz/citrea-e2e", rev = "5baaef3" }
citrea-e2e = { workspace = true }

[build-dependencies]
sp1-helper = { version = "3.0.0", default-features = false }
Expand Down
3 changes: 3 additions & 0 deletions crates/bitcoin-da/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ sha2 = { workspace = true }

bitcoincore-rpc = { workspace = true, optional = true }

[dev-dependencies]
citrea-e2e = { workspace = true }

[features]
default = []
native = [
Expand Down
10 changes: 6 additions & 4 deletions crates/bitcoin-da/src/helpers/merkle_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ mod tests {
use bitcoin::hashes::Hash;

use super::*;
use crate::helpers::test_utils::get_mock_txs;
use crate::helpers::parsers::parse_hex_transaction;

#[test]
fn test_merkle_root_with_proof() {
Expand Down Expand Up @@ -145,10 +145,12 @@ mod tests {
compare_merkle_tree_against_bitcoin_impl(vec![[200; 32]; 2]);
compare_merkle_tree_against_bitcoin_impl(vec![[99; 32]; 1]);

let txs = get_mock_txs()
.iter()
let txs = std::fs::read_to_string("test_data/mock_txs.txt")
.unwrap()
.lines()
.map(|tx_hex| parse_hex_transaction(tx_hex).unwrap())
.map(|tx| tx.compute_wtxid().to_byte_array())
.collect();
.collect::<Vec<_>>();
compare_merkle_tree_against_bitcoin_impl(txs);
}

Expand Down
2 changes: 0 additions & 2 deletions crates/bitcoin-da/src/helpers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ use sha2::{Digest, Sha256};
pub mod builders;
pub mod merkle_tree;
pub mod parsers;
#[cfg(test)]
pub mod test_utils;

/// Type represents a typed enum for LightClient kind
#[repr(u16)]
Expand Down
2 changes: 1 addition & 1 deletion crates/bitcoin-da/src/helpers/parsers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ mod batch_proof {
}
}

#[cfg(all(test, feature = "native"))]
#[cfg(feature = "native")]
pub fn parse_hex_transaction(
tx_hex: &str,
) -> Result<Transaction, bitcoin::consensus::encode::Error> {
Expand Down
154 changes: 0 additions & 154 deletions crates/bitcoin-da/src/helpers/test_utils.rs

This file was deleted.

Loading

0 comments on commit 61f962e

Please sign in to comment.