Skip to content
Open
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
32 changes: 5 additions & 27 deletions bitcoind-tests/Cargo.lock

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

9 changes: 1 addition & 8 deletions bitcoind-tests/tests/common/daemon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::str::FromStr;

use elements::encode::{deserialize, serialize_hex};
use elements::hex::FromHex;
use elementsd::bitcoincore_rpc::jsonrpc::serde_json::{json, Value};
use elementsd::bitcoincore_rpc::jsonrpc::serde_json::Value;
use elementsd::bitcoind::bitcoincore_rpc::RpcApi;
use elementsd::ElementsD;
use simplicityhl::elements;
Expand Down Expand Up @@ -52,7 +52,6 @@ pub trait Call {
fn get_new_address(&self) -> elements::Address;
fn send_to_address(&self, addr: &elements::Address, amt: &str) -> elements::Txid;
fn get_transaction(&self, txid: &elements::Txid) -> elements::Transaction;
fn test_mempool_accept(&self, hex: &elements::Transaction) -> bool;
fn send_raw_transaction(&self, hex: &elements::Transaction) -> elements::Txid;
fn generate(&self, blocks: u32);
}
Expand Down Expand Up @@ -108,10 +107,4 @@ impl Call for ElementsD {
&[blocks.into(), address.to_string().into()],
);
}

fn test_mempool_accept(&self, tx: &elements::Transaction) -> bool {
let result = self.call("testmempoolaccept", &[json!([serialize_hex(tx)])]);
let allowed = result.get(0).unwrap().get("allowed");
allowed.unwrap().as_bool().unwrap()
}
}
16 changes: 11 additions & 5 deletions bitcoind-tests/tests/common/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ use elements::{confidential, secp256k1_zkp as secp256k1};
use elementsd::ElementsD;
use secp256k1::XOnlyPublicKey;
use simplicity::jet::elements::{ElementsEnv, ElementsUtxo};
use simplicityhl::ast::ElementsJetHinter;
use simplicityhl::{elements, simplicity};

use crate::common::daemon::Call;

type FnWitness = fn([u8; 32]) -> simplicityhl::WitnessValues;

#[derive(Clone)]
pub struct TestCase<'a> {
pub name: &'static str,
template: Option<simplicityhl::TemplateProgram>,
Expand Down Expand Up @@ -53,16 +53,22 @@ impl<'a> TestCase<'a> {

pub fn program_path<P: AsRef<std::path::Path>>(mut self, path: P) -> Self {
let text = std::fs::read_to_string(path).expect("path should be readable");
let compiled = simplicityhl::CompiledProgram::new(text.as_str(), simplicityhl::Arguments::default(), false)
.expect("program should compile");
let compiled = simplicityhl::CompiledProgram::new(
text.as_str(),
simplicityhl::Arguments::default(),
false,
Box::new(ElementsJetHinter::new()),
)
.expect("program should compile");
self.compiled = Some(compiled);
self
}

pub fn template_path<P: AsRef<std::path::Path>>(mut self, path: P) -> Self {
let text = std::fs::read_to_string(path).expect("path should be readable");
let template =
simplicityhl::TemplateProgram::new(text.as_str()).expect("program should compile");
simplicityhl::TemplateProgram::new(text.as_str(), Box::new(ElementsJetHinter::new()))
.expect("program should compile");
self.template = Some(template);
self
}
Expand Down Expand Up @@ -205,7 +211,7 @@ impl<'a> TestCase<'a> {
let satisfied_program = compiled
.satisfy(witness_values)
.expect("program should be satisfiable");
let (program_bytes, witness_bytes) = satisfied_program.redeem().encode_to_vec();
let (program_bytes, witness_bytes) = satisfied_program.redeem().to_vec_with_witness();
psbt.inputs_mut()[0].final_script_witness = Some(vec![
witness_bytes,
program_bytes,
Expand Down
2 changes: 1 addition & 1 deletion fuzz/fuzz_targets/parse_witness_json_rtt.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#![cfg_attr(fuzzing, no_main)]

#[cfg(any(fuzzing, test))]
#[cfg(fuzzing)]
fn do_test(witness_values: simplicityhl::WitnessValues) {
let witness_text = serde_json::to_string(&witness_values)
.expect("Witness map should be convertible into JSON");
Expand Down
34 changes: 32 additions & 2 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,43 @@ check_fuzz:
build_fuzz:
cargo-fuzz check

# Check the standalone fuzz crate compiles
check_fuzz_crate:
cargo rbmt --lock-file existing run --toolchain nightly -- check --manifest-path fuzz/Cargo.toml

# Run fuzz target unit tests
check_fuzz_bins:
cargo rbmt --lock-file existing run --toolchain nightly -- test --manifest-path fuzz/Cargo.toml --bins

# Run CI-equivalent checks plus strict non-mutating RBMT checks
check_all:
cargo rbmt toolchains
cargo rbmt --lock-file existing test --toolchain stable
cargo rbmt --lock-file existing test --toolchain nightly
cargo rbmt --lock-file existing test --toolchain msrv
cargo test
cargo rbmt --lock-file existing lint
cargo rbmt --lock-file existing docs
cargo rbmt --lock-file existing docsrs
cargo rbmt fmt --check
rustup target add wasm32-unknown-unknown
just build_wasm
cargo rbmt tools cargo-fuzz
just check_fuzz_crate
just check_fuzz_bins
cargo rbmt --lock-file existing integration
cargo rbmt --lock-file existing bench
cargo rbmt --lock-file existing api --baseline master
cargo rbmt --lock-file existing prerelease --baseline master
just build_integration

# Build integration tests
build_integration:
cargo test --no-run --manifest-path ./bitcoind-tests/Cargo.toml
cargo test --locked --no-run --manifest-path ./bitcoind-tests/Cargo.toml

# Run integration tests (requires custom elementsd)
check_integration:
cargo test --manifest-path ./bitcoind-tests/Cargo.toml
cargo test --locked --manifest-path ./bitcoind-tests/Cargo.toml

# Build code for the WASM target
build_wasm:
Expand Down
Loading