From 766de85e0ca25bf2b4960354432f867641f0553d Mon Sep 17 00:00:00 2001 From: Liam Date: Thu, 18 Aug 2022 15:02:01 -0400 Subject: [PATCH 01/10] Add better errors for outputs --- src/index.rs | 36 +++++++++++++-- src/main.rs | 20 +++++--- src/purse.rs | 3 +- src/subcommand/list.rs | 3 +- src/subcommand/server.rs | 17 +------ src/subcommand/server/templates/output.rs | 24 ++++++++-- templates/output.html | 9 +++- tests/lib.rs | 2 +- tests/server.rs | 56 +++++++++++++++++++++-- tests/state.rs | 4 +- 10 files changed, 138 insertions(+), 36 deletions(-) diff --git a/src/index.rs b/src/index.rs index 837a27d129..a17d6d349e 100644 --- a/src/index.rs +++ b/src/index.rs @@ -10,6 +10,9 @@ mod rtx; const HEIGHT_TO_HASH: TableDefinition = TableDefinition::new("HEIGHT_TO_HASH"); const OUTPOINT_TO_ORDINAL_RANGES: TableDefinition<[u8], [u8]> = TableDefinition::new("OUTPOINT_TO_ORDINAL_RANGES"); +const OUTPOINT_TO_TXID: TableDefinition<[u8], [u8]> = TableDefinition::new("OUTPOINT_TO_TXID"); + +// TODO: USE SERIALIZE FUNCTION pub(crate) struct Index { client: Client, @@ -17,6 +20,11 @@ pub(crate) struct Index { database_path: PathBuf, } +pub(crate) enum List { + Spent(Txid), + Unspent(Vec<(u64, u64)>), +} + impl Index { pub(crate) fn open(options: &Options) -> Result { let rpc_url = options.rpc_url(); @@ -46,6 +54,7 @@ impl Index { tx.open_table(HEIGHT_TO_HASH)?; tx.open_table(OUTPOINT_TO_ORDINAL_RANGES)?; + tx.open_table(OUTPOINT_TO_TXID)?; tx.commit()?; @@ -130,6 +139,7 @@ impl Index { pub(crate) fn index_block(&self, wtx: &mut WriteTransaction) -> Result { let mut height_to_hash = wtx.open_table(HEIGHT_TO_HASH)?; let mut outpoint_to_ordinal_ranges = wtx.open_table(OUTPOINT_TO_ORDINAL_RANGES)?; + let mut outpoint_to_txid = wtx.open_table(OUTPOINT_TO_TXID)?; let start = Instant::now(); let mut ordinal_ranges_written = 0; @@ -206,6 +216,7 @@ impl Index { *txid, tx, &mut outpoint_to_ordinal_ranges, + &mut outpoint_to_txid, &mut input_ordinal_ranges, &mut ordinal_ranges_written, )?; @@ -218,6 +229,7 @@ impl Index { *txid, tx, &mut outpoint_to_ordinal_ranges, + &mut outpoint_to_txid, &mut coinbase_inputs, &mut ordinal_ranges_written, )?; @@ -266,6 +278,7 @@ impl Index { txid: Txid, tx: &Transaction, outpoint_to_ordinal_ranges: &mut Table<[u8], [u8]>, + outpoint_to_txid: &mut Table<[u8], [u8]>, input_ordinal_ranges: &mut VecDeque<(u64, u64)>, ordinal_ranges_written: &mut u64, ) -> Result { @@ -309,6 +322,14 @@ impl Index { outpoint_to_ordinal_ranges.insert(&outpoint_encoded, &ordinals)?; } + for input in &tx.input { + let mut outpoint_encoded = Vec::new(); + input + .previous_output + .consensus_encode(&mut outpoint_encoded)?; + outpoint_to_txid.insert(&outpoint_encoded, &txid)?; + } + Ok(()) } @@ -396,7 +417,7 @@ impl Index { ) } - pub(crate) fn list(&self, outpoint: OutPoint) -> Result>> { + pub(crate) fn list(&self, outpoint: OutPoint) -> Result> { let mut outpoint_encoded = Vec::new(); outpoint.consensus_encode(&mut outpoint_encoded)?; let ordinal_ranges = self.list_inner(&outpoint_encoded)?; @@ -406,9 +427,18 @@ impl Index { for chunk in ordinal_ranges.chunks_exact(11) { output.push(Self::decode_ordinal_range(chunk.try_into().unwrap())); } - Ok(Some(output)) + Ok(Some(List::Unspent(output))) } - None => Ok(None), + None => Ok( + self + .database + .begin_read()? + .open_table(OUTPOINT_TO_TXID)? + .get(&outpoint_encoded)? + .map(|txid| Txid::consensus_decode(txid)) + .transpose()? + .map(|txid| List::Spent(txid)), + ), } } diff --git a/src/main.rs b/src/main.rs index 348234bdb3..da4ca54681 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,14 +2,22 @@ use { self::{ - arguments::Arguments, blocktime::Blocktime, bytes::Bytes, degree::Degree, epoch::Epoch, - height::Height, index::Index, nft::Nft, options::Options, ordinal::Ordinal, purse::Purse, - sat_point::SatPoint, subcommand::Subcommand, + arguments::Arguments, + blocktime::Blocktime, + bytes::Bytes, + degree::Degree, + epoch::Epoch, + height::Height, + index::{Index, List}, + nft::Nft, + options::Options, + ordinal::Ordinal, + purse::Purse, + sat_point::SatPoint, + subcommand::Subcommand, }, anyhow::{anyhow, bail, Context, Error}, - axum::{ - extract, http::StatusCode, response::Html, response::IntoResponse, routing::get, Json, Router, - }, + axum::{extract, http::StatusCode, response::Html, response::IntoResponse, routing::get, Router}, axum_server::Handle, bdk::{ blockchain::rpc::{Auth, RpcBlockchain, RpcConfig}, diff --git a/src/purse.rs b/src/purse.rs index 006e35f74e..fe912b2cd3 100644 --- a/src/purse.rs +++ b/src/purse.rs @@ -73,7 +73,8 @@ impl Purse { let index = Index::index(options)?; for utxo in self.wallet.list_unspent()? { - if let Some(ranges) = index.list(utxo.outpoint)? { + // TODO: match on result of list + if let Some(List::Unspent(ranges)) = index.list(utxo.outpoint)? { for (start, end) in ranges { if ordinal.0 >= start && ordinal.0 < end { return Ok(utxo); diff --git a/src/subcommand/list.rs b/src/subcommand/list.rs index f34f6525f2..28657485cb 100644 --- a/src/subcommand/list.rs +++ b/src/subcommand/list.rs @@ -10,12 +10,13 @@ impl List { let index = Index::index(&options)?; match index.list(self.outpoint)? { - Some(ranges) => { + Some(crate::index::List::Unspent(ranges)) => { for (start, end) in ranges { println!("[{start},{end})"); } Ok(()) } + Some(crate::index::List::Spent(txid)) => Err(anyhow!("Output spent in transaction {txid}")), None => Err(anyhow!("Output not found")), } } diff --git a/src/subcommand/server.rs b/src/subcommand/server.rs index 8105d36d0c..18c1a00de5 100644 --- a/src/subcommand/server.rs +++ b/src/subcommand/server.rs @@ -78,7 +78,6 @@ impl Server { let app = Router::new() .route("/", get(Self::root)) - .route("/api/list/:outpoint", get(Self::api_list)) .route("/block/:hash", get(Self::block)) .route("/height", get(Self::height)) .route("/ordinal/:ordinal", get(Self::ordinal)) @@ -184,7 +183,7 @@ impl Server { extract::Path(outpoint): extract::Path, ) -> impl IntoResponse { match index.list(outpoint) { - Ok(Some(ranges)) => OutputHtml { outpoint, ranges }.page().into_response(), + Ok(Some(list)) => OutputHtml { outpoint, list }.page().into_response(), Ok(None) => ( StatusCode::NOT_FOUND, Html("Output unknown, invalid, or spent.".to_string()), @@ -305,20 +304,6 @@ impl Server { } } - async fn api_list( - extract::Path(outpoint): extract::Path, - index: extract::Extension>, - ) -> impl IntoResponse { - match index.list(outpoint) { - Ok(Some(ranges)) => (StatusCode::OK, Json(Some(ranges))), - Ok(None) => (StatusCode::NOT_FOUND, Json(None)), - Err(error) => { - eprintln!("Error serving request for outpoint {outpoint}: {error}"); - (StatusCode::INTERNAL_SERVER_ERROR, Json(None)) - } - } - } - async fn status() -> impl IntoResponse { ( StatusCode::OK, diff --git a/src/subcommand/server/templates/output.rs b/src/subcommand/server/templates/output.rs index a690088a74..cdb479fa87 100644 --- a/src/subcommand/server/templates/output.rs +++ b/src/subcommand/server/templates/output.rs @@ -3,7 +3,7 @@ use super::*; #[derive(Display)] pub(crate) struct OutputHtml { pub(crate) outpoint: OutPoint, - pub(crate) ranges: Vec<(u64, u64)>, + pub(crate) list: List, } impl Content for OutputHtml { @@ -23,13 +23,13 @@ mod tests { use {super::*, pretty_assertions::assert_eq, unindent::Unindent}; #[test] - fn output_html() { + fn unspent_output() { assert_eq!( OutputHtml { outpoint: "4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b:0" .parse() .unwrap(), - ranges: vec![(0, 1), (1, 2)] + list: List::Unspent(vec![(0, 1), (1, 2)]) } .to_string(), " @@ -43,4 +43,22 @@ mod tests { .unindent() ); } + + #[test] + fn spent_output() { + assert_eq!( + OutputHtml { + outpoint: "0000000000000000000000000000000000000000000000000000000000000000:0" + .parse() + .unwrap(), + list: List::Spent("1111111111111111111111111111111111111111111111111111111111111111".parse().unwrap()) + } + .to_string(), + " +

Output 0000000000000000000000000000000000000000000000000000000000000000:0

+ Spent by transaction 1111111111111111111111111111111111111111111111111111111111111111. + " + .unindent() + ); + } } diff --git a/templates/output.html b/templates/output.html index ede2e426ea..fe57b0d383 100644 --- a/templates/output.html +++ b/templates/output.html @@ -1,7 +1,14 @@

Output {{self.outpoint}}

+%% match &self.list { +%% List::Unspent(ranges) => {

Ordinal Ranges

    -%% for (start, end) in &self.ranges { +%% for (start, end) in ranges {
  • [{{start}},{{end}})
  • %% }
+%% } +%% List::Spent(txid) => { +Spent by transaction {{ txid }}. +%% } +%% } diff --git a/tests/lib.rs b/tests/lib.rs index 32c2027185..7f6a304f79 100644 --- a/tests/lib.rs +++ b/tests/lib.rs @@ -13,7 +13,7 @@ use { wallet::{signer::SignOptions, AddressIndex, SyncOptions, Wallet}, KeychainKind, }, - bitcoin::{hash_types::Txid, network::constants::Network, Address, Block, OutPoint}, + bitcoin::{hash_types::Txid, network::constants::Network, Address, Block, OutPoint, Transaction}, bitcoincore_rpc::{Client, RawTx, RpcApi}, executable_path::executable_path, log::LevelFilter, diff --git a/tests/server.rs b/tests/server.rs index a246576255..e375406c8c 100644 --- a/tests/server.rs +++ b/tests/server.rs @@ -141,18 +141,68 @@ fn output() { } #[test] -fn invalid_vout_returns_404() { +fn unknown_output_returns_404() { let mut state = State::new(); state.blocks(1); state.request( - "output/0396bc915f141f7de025f72ae9b6bb8dcdb5f444fc245d8fac486ba67a38eef8:0", + "output/0000000000000000000000000000000000000000000000000000000000000000:0", 404, - "Output unknown, invalid, or spent.", + "Output unknown.", ); } +#[test] +fn spent_output_returns_200() { + let mut state = State::new(); + + state.blocks(101); + + let transaction = state.transaction(TransactionOptions { + slots: &[(1, 0, 0)], + output_count: 1, + fee: 0, + }); + + let txid = transaction.txid(); + + state.blocks(1); + + state.request_regex( + &format!("output/{txid}:0"), + 200, + &format!( + ".*Output {txid}:0.*

Output {txid}:0

+

Ordinal Ranges

+.*" + ), + ); + + let transaction = state.transaction(TransactionOptions { + slots: &[(102, 1, 0)], + output_count: 1, + fee: 0, + }); + + state.blocks(1); + + state.request_regex( + &format!("output/{txid}:0"), + 200, + &format!("Output spent in transaction {}.", transaction.txid()), + ); +} + +#[test] +fn invalid_output_returns_400() { + let mut state = State::new(); + + state.request_regex(&format!("output/foo:0"), 400, "bruh"); +} + #[test] fn root() { let mut state = State::new(); diff --git a/tests/state.rs b/tests/state.rs index fdbb9c2cbf..8afafd8934 100644 --- a/tests/state.rs +++ b/tests/state.rs @@ -139,7 +139,7 @@ impl State { .unwrap() } - pub(crate) fn transaction(&self, options: TransactionOptions) { + pub(crate) fn transaction(&self, options: TransactionOptions) -> Transaction { self.sync(); let input_value = options @@ -197,6 +197,8 @@ impl State { &[tx.raw_hex().into(), 21000000.into()], ) .unwrap(); + + tx } pub(crate) fn request(&mut self, path: &str, status: u16, expected_response: &str) { From 0109622b7e0f24e3002aec34b4760de3f591acac Mon Sep 17 00:00:00 2001 From: Liam Date: Thu, 18 Aug 2022 15:10:10 -0400 Subject: [PATCH 02/10] Refactorings --- src/index.rs | 4 ++-- tests/server.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/index.rs b/src/index.rs index a17d6d349e..9f8c009788 100644 --- a/src/index.rs +++ b/src/index.rs @@ -435,9 +435,9 @@ impl Index { .begin_read()? .open_table(OUTPOINT_TO_TXID)? .get(&outpoint_encoded)? - .map(|txid| Txid::consensus_decode(txid)) + .map(Txid::consensus_decode) .transpose()? - .map(|txid| List::Spent(txid)), + .map(List::Spent), ), } } diff --git a/tests/server.rs b/tests/server.rs index d4a51b0604..8a41f251b4 100644 --- a/tests/server.rs +++ b/tests/server.rs @@ -194,7 +194,7 @@ fn spent_output_returns_200() { fn invalid_output_returns_400() { let mut state = State::new(); - state.request_regex(&format!("output/foo:0"), 400, "bruh"); + state.request_regex("output/foo:0", 400, "bruh"); } #[test] From 65117dce33a4d01838173e18d18129f33e0bed91 Mon Sep 17 00:00:00 2001 From: Liam Date: Thu, 18 Aug 2022 15:23:42 -0400 Subject: [PATCH 03/10] Address remaining todos --- src/index.rs | 23 ++++++++--------------- src/purse.rs | 19 ++++++++++++++----- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/src/index.rs b/src/index.rs index 9f8c009788..5aca1acb78 100644 --- a/src/index.rs +++ b/src/index.rs @@ -1,5 +1,6 @@ use { super::*, + bitcoin::consensus::encode::serialize, bitcoincore_rpc::{Auth, Client, RpcApi}, rayon::iter::{IntoParallelRefIterator, ParallelIterator}, redb::WriteStrategy, @@ -12,8 +13,6 @@ const OUTPOINT_TO_ORDINAL_RANGES: TableDefinition<[u8], [u8]> = TableDefinition::new("OUTPOINT_TO_ORDINAL_RANGES"); const OUTPOINT_TO_TXID: TableDefinition<[u8], [u8]> = TableDefinition::new("OUTPOINT_TO_TXID"); -// TODO: USE SERIALIZE FUNCTION - pub(crate) struct Index { client: Client, database: Database, @@ -198,11 +197,10 @@ impl Index { let mut input_ordinal_ranges = VecDeque::new(); for input in &tx.input { - let mut key = Vec::new(); - input.previous_output.consensus_encode(&mut key)?; + let key = serialize(&input.previous_output); let ordinal_ranges = outpoint_to_ordinal_ranges - .get(key.as_slice())? + .get(&key)? .ok_or_else(|| anyhow!("Could not find outpoint in index"))?; for chunk in ordinal_ranges.chunks_exact(11) { @@ -317,17 +315,11 @@ impl Index { *ordinal_ranges_written += 1; } - let mut outpoint_encoded = Vec::new(); - outpoint.consensus_encode(&mut outpoint_encoded)?; - outpoint_to_ordinal_ranges.insert(&outpoint_encoded, &ordinals)?; + outpoint_to_ordinal_ranges.insert(&serialize(&outpoint), &ordinals)?; } for input in &tx.input { - let mut outpoint_encoded = Vec::new(); - input - .previous_output - .consensus_encode(&mut outpoint_encoded)?; - outpoint_to_txid.insert(&outpoint_encoded, &txid)?; + outpoint_to_txid.insert(&serialize(&input.previous_output), &txid)?; } Ok(()) @@ -418,9 +410,10 @@ impl Index { } pub(crate) fn list(&self, outpoint: OutPoint) -> Result> { - let mut outpoint_encoded = Vec::new(); - outpoint.consensus_encode(&mut outpoint_encoded)?; + let outpoint_encoded = serialize(&outpoint); + let ordinal_ranges = self.list_inner(&outpoint_encoded)?; + match ordinal_ranges { Some(ordinal_ranges) => { let mut output = Vec::new(); diff --git a/src/purse.rs b/src/purse.rs index fe912b2cd3..0c545157cb 100644 --- a/src/purse.rs +++ b/src/purse.rs @@ -73,13 +73,22 @@ impl Purse { let index = Index::index(options)?; for utxo in self.wallet.list_unspent()? { - // TODO: match on result of list - if let Some(List::Unspent(ranges)) = index.list(utxo.outpoint)? { - for (start, end) in ranges { - if ordinal.0 >= start && ordinal.0 < end { - return Ok(utxo); + match index.list(utxo.outpoint)? { + Some(List::Unspent(ranges)) => { + for (start, end) in ranges { + if ordinal.0 >= start && ordinal.0 < end { + return Ok(utxo); + } } } + Some(List::Spent(txid)) => { + return Err(anyhow!( + "UTXO unspent in wallet but spent in index by transaction {txid}" + )); + } + None => { + return Err(anyhow!("UTXO unspent in wallet but not found in index")); + } } } From 1f57db3541528c6b0baf58a3cf7cd3765f623c03 Mon Sep 17 00:00:00 2001 From: Liam Date: Thu, 18 Aug 2022 15:28:57 -0400 Subject: [PATCH 04/10] Consistency --- src/index.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/index.rs b/src/index.rs index 5aca1acb78..47b1bf7374 100644 --- a/src/index.rs +++ b/src/index.rs @@ -415,13 +415,12 @@ impl Index { let ordinal_ranges = self.list_inner(&outpoint_encoded)?; match ordinal_ranges { - Some(ordinal_ranges) => { - let mut output = Vec::new(); - for chunk in ordinal_ranges.chunks_exact(11) { - output.push(Self::decode_ordinal_range(chunk.try_into().unwrap())); - } - Ok(Some(List::Unspent(output))) - } + Some(ordinal_ranges) => Ok(Some(List::Unspent( + ordinal_ranges + .chunks_exact(11) + .map(|chunk| Self::decode_ordinal_range(chunk.try_into().unwrap())) + .collect(), + ))), None => Ok( self .database From 3a9af844e43913917bf43292dcc55c784b09dd4c Mon Sep 17 00:00:00 2001 From: Liam Date: Thu, 18 Aug 2022 15:36:36 -0400 Subject: [PATCH 05/10] Wrap in P --- src/subcommand/server/templates/output.rs | 2 +- templates/output.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/subcommand/server/templates/output.rs b/src/subcommand/server/templates/output.rs index 7ebba1d607..7908b8c85d 100644 --- a/src/subcommand/server/templates/output.rs +++ b/src/subcommand/server/templates/output.rs @@ -50,7 +50,7 @@ mod tests { .to_string(), "

Output 0000000000000000000000000000000000000000000000000000000000000000:0

- Spent by transaction 1111111111111111111111111111111111111111111111111111111111111111. +

Spent by transaction 1111111111111111111111111111111111111111111111111111111111111111.

" .unindent() ); diff --git a/templates/output.html b/templates/output.html index fe57b0d383..6b6dc39f18 100644 --- a/templates/output.html +++ b/templates/output.html @@ -9,6 +9,6 @@

Ordinal Ranges

%% } %% List::Spent(txid) => { -Spent by transaction {{ txid }}. +

Spent by transaction {{ txid }}.

%% } %% } From cb8b7c683302b12adb45e5177581dc309da0e624 Mon Sep 17 00:00:00 2001 From: Liam Date: Thu, 18 Aug 2022 16:08:09 -0400 Subject: [PATCH 06/10] Fix final test --- src/subcommand/server.rs | 2 +- tests/server.rs | 41 +++++++++++++++++----------------------- 2 files changed, 18 insertions(+), 25 deletions(-) diff --git a/src/subcommand/server.rs b/src/subcommand/server.rs index 86c543ff06..ee552aa857 100644 --- a/src/subcommand/server.rs +++ b/src/subcommand/server.rs @@ -205,7 +205,7 @@ impl Server { Ok(Some(list)) => OutputHtml { outpoint, list }.page().into_response(), Ok(None) => ( StatusCode::NOT_FOUND, - Html("Output unknown, invalid, or spent.".to_string()), + Html("Output unknown.".to_string()), ) .into_response(), Err(err) => { diff --git a/tests/server.rs b/tests/server.rs index 8a41f251b4..456582d3e5 100644 --- a/tests/server.rs +++ b/tests/server.rs @@ -1,18 +1,5 @@ use super::*; -#[test] -fn list() { - let mut state = State::new(); - - state.blocks(1); - - state.request( - "api/list/4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b:0", - 200, - "[[0,5000000000]]", - ); -} - #[test] fn status() { State::new().request("status", 200, "OK"); @@ -138,8 +125,6 @@ fn output() { fn unknown_output_returns_404() { let mut state = State::new(); - state.blocks(1); - state.request( "output/0000000000000000000000000000000000000000000000000000000000000000:0", 404, @@ -153,13 +138,13 @@ fn spent_output_returns_200() { state.blocks(101); - let transaction = state.transaction(TransactionOptions { - slots: &[(1, 0, 0)], - output_count: 1, - fee: 0, - }); - - let txid = transaction.txid(); + let txid = state + .transaction(TransactionOptions { + slots: &[(1, 0, 0)], + output_count: 1, + fee: 0, + }) + .txid(); state.blocks(1); @@ -186,7 +171,11 @@ fn spent_output_returns_200() { state.request_regex( &format!("output/{txid}:0"), 200, - &format!("Output spent in transaction {}.", transaction.txid()), + &format!( + ".*

Spent by transaction {}.

.*", + transaction.txid(), + transaction.txid() + ), ); } @@ -194,7 +183,11 @@ fn spent_output_returns_200() { fn invalid_output_returns_400() { let mut state = State::new(); - state.request_regex("output/foo:0", 400, "bruh"); + state.request_regex( + "output/foo:0", + 400, + "Invalid URL: error parsing TXID: odd hex string length 3", + ); } #[test] From 96d2ef4ca1f5040f0ee6295cab28b61d1a07d08a Mon Sep 17 00:00:00 2001 From: Liam Date: Thu, 18 Aug 2022 16:15:20 -0400 Subject: [PATCH 07/10] Format --- src/subcommand/server.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/subcommand/server.rs b/src/subcommand/server.rs index ee552aa857..471eded702 100644 --- a/src/subcommand/server.rs +++ b/src/subcommand/server.rs @@ -203,11 +203,7 @@ impl Server { ) -> impl IntoResponse { match index.list(outpoint) { Ok(Some(list)) => OutputHtml { outpoint, list }.page().into_response(), - Ok(None) => ( - StatusCode::NOT_FOUND, - Html("Output unknown.".to_string()), - ) - .into_response(), + Ok(None) => (StatusCode::NOT_FOUND, Html("Output unknown.".to_string())).into_response(), Err(err) => { eprintln!("Error serving request for output: {err}"); ( From f9f32da2b9aa4efe8087e1ba256ecd578a3f7915 Mon Sep 17 00:00:00 2001 From: Liam Date: Thu, 18 Aug 2022 16:39:18 -0400 Subject: [PATCH 08/10] Fix this test --- tests/list.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/list.rs b/tests/list.rs index 5b0324db6d..2b1bb2db98 100644 --- a/tests/list.rs +++ b/tests/list.rs @@ -172,7 +172,7 @@ fn old_transactions_are_pruned() { fee: 50 * 100_000_000, }) .blocks(1) - .expected_stderr("error: Output not found\n") + .expected_stderr("error: Output spent in transaction 3dbc87de25bf5a52ddfa8038bda36e09622f4dec7951d81ac43e4b0e8c54bc5b\n") .expected_status(1) .run() } From 108b75773d878726780abc8813ba91ccc1091c5a Mon Sep 17 00:00:00 2001 From: Casey Rodarmor Date: Thu, 18 Aug 2022 13:46:31 -0700 Subject: [PATCH 09/10] Remove calls to api/list --- tests/wallet.rs | 28 ---------------------------- 1 file changed, 28 deletions(-) diff --git a/tests/wallet.rs b/tests/wallet.rs index 281132bdab..93f6e2ddd6 100644 --- a/tests/wallet.rs +++ b/tests/wallet.rs @@ -233,20 +233,6 @@ fn send_owned_ordinal() { .stdout_regex("[[:xdigit:]]{64}:[[:digit:]] 5000000000\n") .output(); - output.state.request( - &format!( - "api/list/{}", - output - .stdout - .split(' ') - .collect::>() - .first() - .unwrap() - ), - 200, - "[[5000000000,10000000000]]", - ); - let wallet = Wallet::new( Bip84( ( @@ -326,20 +312,6 @@ fn send_foreign_ordinal() { .stdout_regex("[[:xdigit:]]{64}:[[:digit:]] 5000000000\n") .output(); - output.state.request( - &format!( - "api/list/{}", - output - .stdout - .split(' ') - .collect::>() - .first() - .unwrap() - ), - 200, - "[[5000000000,10000000000]]", - ); - let wallet = Wallet::new( Bip84( ( From a4bc8d59a41a2fb41cf96bdc271eb3bd4f9ce840 Mon Sep 17 00:00:00 2001 From: Casey Rodarmor Date: Thu, 18 Aug 2022 13:48:38 -0700 Subject: [PATCH 10/10] Placate clippy --- tests/wallet.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/wallet.rs b/tests/wallet.rs index 93f6e2ddd6..43d6e78e81 100644 --- a/tests/wallet.rs +++ b/tests/wallet.rs @@ -227,7 +227,7 @@ fn send_owned_ordinal() { ) .unwrap(); - let mut output = Test::with_state(output.state) + let output = Test::with_state(output.state) .command("--network regtest wallet utxos") .expected_status(0) .stdout_regex("[[:xdigit:]]{64}:[[:digit:]] 5000000000\n") @@ -306,7 +306,7 @@ fn send_foreign_ordinal() { .generate_to_address(1, &from_address) .unwrap(); - let mut output = Test::with_state(output.state) + let output = Test::with_state(output.state) .command("--network regtest wallet utxos") .expected_status(0) .stdout_regex("[[:xdigit:]]{64}:[[:digit:]] 5000000000\n")