Skip to content

Add dev tooling #22

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

Merged
merged 3 commits into from
Dec 5, 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
58 changes: 58 additions & 0 deletions Cargo-minimal.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,21 @@
# It is not intended for manual editing.
version = 3

[[package]]
name = "aho-corasick"
version = "1.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916"
dependencies = [
"memchr",
]

[[package]]
name = "anyhow"
version = "1.0.94"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c1fd03a028ef38ba2276dce7e33fcd6369c158a1bca17946c4b1b701891c1ff7"

[[package]]
name = "arrayvec"
version = "0.7.4"
Expand Down Expand Up @@ -169,6 +184,12 @@ version = "0.4.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "518ef76f2f87365916b142844c16d8fefd85039bc5699050210a7778ee1cd1de"

[[package]]
name = "memchr"
version = "2.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"

[[package]]
name = "minreq"
version = "2.11.2"
Expand Down Expand Up @@ -198,6 +219,35 @@ dependencies = [
"proc-macro2",
]

[[package]]
name = "regex"
version = "1.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191"
dependencies = [
"aho-corasick",
"memchr",
"regex-automata",
"regex-syntax",
]

[[package]]
name = "regex-automata"
version = "0.4.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908"
dependencies = [
"aho-corasick",
"memchr",
"regex-syntax",
]

[[package]]
name = "regex-syntax"
version = "0.8.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"

[[package]]
name = "ryu"
version = "1.0.18"
Expand Down Expand Up @@ -283,6 +333,14 @@ version = "1.0.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4"

[[package]]
name = "verify"
version = "0.1.0"
dependencies = [
"anyhow",
"regex",
]

[[package]]
name = "winapi"
version = "0.3.9"
Expand Down
58 changes: 58 additions & 0 deletions Cargo-recent.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,21 @@
# It is not intended for manual editing.
version = 3

[[package]]
name = "aho-corasick"
version = "1.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916"
dependencies = [
"memchr",
]

[[package]]
name = "anyhow"
version = "1.0.94"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c1fd03a028ef38ba2276dce7e33fcd6369c158a1bca17946c4b1b701891c1ff7"

[[package]]
name = "arrayvec"
version = "0.7.4"
Expand Down Expand Up @@ -169,6 +184,12 @@ version = "0.4.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "518ef76f2f87365916b142844c16d8fefd85039bc5699050210a7778ee1cd1de"

[[package]]
name = "memchr"
version = "2.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"

[[package]]
name = "minreq"
version = "2.11.2"
Expand Down Expand Up @@ -198,6 +219,35 @@ dependencies = [
"proc-macro2",
]

[[package]]
name = "regex"
version = "1.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191"
dependencies = [
"aho-corasick",
"memchr",
"regex-automata",
"regex-syntax",
]

[[package]]
name = "regex-automata"
version = "0.4.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908"
dependencies = [
"aho-corasick",
"memchr",
"regex-syntax",
]

[[package]]
name = "regex-syntax"
version = "0.8.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"

[[package]]
name = "ryu"
version = "1.0.18"
Expand Down Expand Up @@ -283,6 +333,14 @@ version = "1.0.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4"

[[package]]
name = "verify"
version = "0.1.0"
dependencies = [
"anyhow",
"regex",
]

[[package]]
name = "winapi"
version = "0.3.9"
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[workspace]
members = ["client", "types", "jsonrpc"]
members = ["client", "types", "jsonrpc", "verify"]
exclude = ["integration_test", "node"]
resolver = "2"

Expand Down
138 changes: 138 additions & 0 deletions contrib/extract.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
#!/usr/bin/perl
# SPDX-License-Identifier: CC0-1.0
#
# Create the `types/src/vXYZ/mod.rs` rusdoc.

use strict;
use warnings;
use Getopt::Long qw(:config no_auto_abbrev);

# The script name.
my $SCRIPT = $0;

# The Bitcoin Core version we are working with.
my $CORE_VERSION = "0.17.1";
# The file holding output of `bitcoin-cli --help`.
my $RPC_HELP_FILE = "types/src/v17/rpc-api.txt";

# Command line options.
my $help = 0;
my $debug = 0;

sub help
{
my ($exitcode) = @_;

print << "EOM";

Usage: $SCRIPT [OPTIONS]

Options:

-d, --debug Display debugging output.
-h, --help Display this help and exit.

Generates the rustdocs for the `types/vX.rs` module. Before running script set CORE_VERSION and RPC_HELP_FILE.

EOM
exit($exitcode);
}

GetOptions(
'd|debug' => \$debug,
'h|help' => \$help,
) or help(1);

help(0) if ($help);

main();

exit 0;

sub dprint
{
printf(STDERR @_) if $debug;
}

sub main {

# Open the file for reading
open(my $fh, '<', $RPC_HELP_FILE) or die "Could not open file '$RPC_HELP_FILE': $!\n";

# Loop over each line in the file
while (my $line = <$fh>) {
chomp($line);
if ($line =~ /^== (.+) ==/) { # Section heading.
my $section = $1; # Captures the placeholder text
start_section($section);
} elsif ($line =~ /^\s*$/) { # Blank line.
end_section();
} else {
add_method($line);
}
}

end_section();
print_footer();

# Close the file handle.
close($fh);
}

sub print_header {
print <<'EOM';
//! # JSON-RPC types for Bitcoin Core `v$CORE_VERSION`
//!
//! These structs are shaped for the JSON data returned by the JSON-RPC API. They use stdlib types
//! (or custom types) and where necessary implement an `into_model` function to convert the type to
//! a [`crate::model`] type of the same name. The types in this module are version specific. The
//! types in the `model` module are version nonspecific and are strongly typed using `rust-bitcoin`.
//!
//! ### Method name and implementation status
//!
//! Every JSON-RPC method supported by this version of Bitcoin Core is listed below along with its
//! current implementation status.
//!
EOM
}

sub print_footer {
print <<'EOM'
//!
//! **Items marked omitted were omitted because:**
//!
//! - Method does not return anything.
//! - Method returns a simple type (e.g. bool or integer).
//! - Method is deprecated.
EOM
}

# Print the blurb for the start of a section.
sub start_section {
my ($section) = @_; # Get the first argument

print <<'EOM';
//! <details>
//! <summary> Methods from the $section section </summary>
//!
//! | JSON-PRC Method Name | Status |
//! |:-----------------------------------|:---------------:|
EOM
}

# Print the blurb for the end of a section.
sub end_section {
print<<'EOM';
//!
//! </details>
//!
EOM
}

sub add_method {
my ($line) = @_;
if ($line =~ /^(\S+)/) {
my ($method) = $1;
printf "//! \| %-34s \| |\n", $method
}
}
27 changes: 15 additions & 12 deletions integration_test/tests/blockchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,22 +76,25 @@ fn get_block_header_verbose() { // verbose = true
// optional as suggested in the docs but to no avail.
#[test]
#[cfg(feature = "0_17_1")]
fn get_block_stats() {
get_block_stats_by_height();
get_block_stats_by_hash();
}

fn get_block_stats_by_height() {
let node = Node::new_no_wallet();
let json = node.client.get_block_stats_by_height(0).expect("getblockstats");
assert!(json.into_model().is_ok());
}

// FIXME: Same as get_block_stats_by_height above.
#[test]
#[cfg(feature = "0_17_1")]
fn get_block_stats_by_hash() { // verbose = true
let node = Node::new_no_wallet();
let block_hash = best_block_hash();
let json = node.client.get_block_stats_by_block_hash(&block_hash).expect("getblockstats");
assert!(json.into_model().is_ok());
}


#[test]
fn get_block_stats_by_height_txindex() {
let node = Node::new_no_wallet_txindex();
Expand Down Expand Up @@ -130,37 +133,37 @@ fn get_difficulty() {

#[test]
#[cfg(feature = "TODO")]
fn get_mempool_ancestors() {}
fn get_mempool_ancestors() { todo!() }

#[test]
#[cfg(feature = "TODO")]
fn get_mempool_descendants() {}
fn get_mempool_descendants() { todo!() }

#[test]
#[cfg(feature = "TODO")]
fn get_mempool_entry() {}
fn get_mempool_entry() { todo!() }

#[test]
#[cfg(feature = "TODO")]
fn get_mempool_info() {}
fn get_mempool_info() { todo!() }

#[test]
#[cfg(feature = "TODO")]
fn get_raw_mempool() {}
fn get_raw_mempool() { todo!() }

#[test]
#[cfg(feature = "TODO")]
fn get_tx_out() {}
fn get_tx_out() { todo!() }

#[test]
#[cfg(feature = "TODO")]
fn get_tx_out_proof() {}
fn get_tx_out_proof() { todo!() }

#[test]
#[cfg(feature = "TODO")]
fn get_tx_out_set_info() {}
fn get_tx_out_set_info() { todo!() }

#[test]
#[cfg(feature = "TODO")]
fn verify_tx_out_proof() {}
fn verify_tx_out_proof() { todo!() }

Loading
Loading