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

Make ord info work without ordinal index #874

Merged
merged 2 commits into from
Dec 1, 2022
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
7 changes: 0 additions & 7 deletions src/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,13 +346,6 @@ impl Index {

#[cfg(test)]
pub(crate) fn statistic(&self, statistic: Statistic) -> Result<u64> {
if matches!(
statistic,
Statistic::OutputsTraversed | Statistic::OrdinalRanges
) {
self.require_ordinal_index("statistic")?;
}

Ok(
self
.database
Expand Down
19 changes: 15 additions & 4 deletions tests/info.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use super::*;

#[test]
fn json() {
fn json_with_ordinal_index() {
let rpc_server = test_bitcoincore_rpc::spawn();
CommandBuilder::new("--index-ordinals info")
.rpc_server(&rpc_server)
Expand All @@ -11,6 +11,17 @@ fn json() {
.run();
}

#[test]
fn json_without_ordinal_index() {
let rpc_server = test_bitcoincore_rpc::spawn();
CommandBuilder::new("info")
.rpc_server(&rpc_server)
.stdout_regex(
r#"\{"blocks_indexed":1,"branch_pages":\d+,"fragmented_bytes":\d+,"index_file_size":\d+,"leaf_pages":\d+,"metadata_bytes":\d+,"ordinal_ranges":0,"outputs_traversed":0,"page_size":\d+,"stored_bytes":\d+,"transactions":\[\{"starting_block_count":0,"starting_timestamp":\d+\}\],"tree_height":\d+,"utxos_indexed":0\}"#
)
.run();
}

#[test]
fn transactions() {
let rpc_server = test_bitcoincore_rpc::spawn();
Expand All @@ -20,7 +31,7 @@ fn transactions() {
let index_path = tempdir.path().join("index.redb");

CommandBuilder::new(format!(
"--index-ordinals --index {} info --transactions",
"--index {} info --transactions",
index_path.display()
))
.rpc_server(&rpc_server)
Expand All @@ -30,7 +41,7 @@ fn transactions() {
rpc_server.mine_blocks(10);

CommandBuilder::new(format!(
"--index-ordinals --index {} info --transactions",
"--index {} info --transactions",
index_path.display()
))
.rpc_server(&rpc_server)
Expand All @@ -40,7 +51,7 @@ fn transactions() {
rpc_server.mine_blocks(10);

CommandBuilder::new(format!(
"--index-ordinals --index {} info --transactions",
"--index {} info --transactions",
index_path.display()
))
.rpc_server(&rpc_server)
Expand Down
2 changes: 1 addition & 1 deletion tests/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ HELLOWORLD.*",
),
);

let ord_server = TestServer::spawn_with_args(&rpc_server, &["--index-ordinals"]);
let ord_server = TestServer::spawn_with_args(&rpc_server, &[]);
ord_server.assert_response_regex(
&format!("/inscription/{}", reveal_tx),
&format!(
Expand Down