,
chain: Chain,
) -> Self {
Self {
diff --git a/src/test.rs b/src/test.rs
index e9ecf96f57..82ffc78bed 100644
--- a/src/test.rs
+++ b/src/test.rs
@@ -17,6 +17,19 @@ macro_rules! assert_regex_match {
};
}
+macro_rules! assert_matches {
+ ($expression:expr, $( $pattern:pat_param )|+ $( if $guard:expr )? $(,)?) => {
+ match $expression {
+ $( $pattern )|+ $( if $guard )? => {}
+ left => panic!(
+ "assertion failed: (left ~= right)\n left: `{:?}`\n right: `{}`",
+ left,
+ stringify!($($pattern)|+ $(if $guard)?)
+ ),
+ }
+ }
+}
+
pub(crate) fn txid(n: u64) -> Txid {
let hex = format!("{n:x}");
@@ -80,3 +93,13 @@ pub(crate) fn tx_out(value: u64, address: Address) -> TxOut {
pub(crate) fn inscription(content_type: &str, content: impl AsRef<[u8]>) -> Inscription {
Inscription::new(Some(content_type.into()), Some(content.as_ref().into()))
}
+
+pub(crate) fn inscription_id(n: u32) -> InscriptionId {
+ let hex = format!("{n:x}");
+
+ if hex.is_empty() || hex.len() > 1 {
+ panic!();
+ }
+
+ format!("{}i{n}", hex.repeat(64)).parse().unwrap()
+}
diff --git a/templates/inscription.html b/templates/inscription.html
index 3a30fee049..fa6249f06c 100644
--- a/templates/inscription.html
+++ b/templates/inscription.html
@@ -40,7 +40,7 @@ Inscription {{ self.number }}
genesis height
{{ self.genesis_height }}
genesis transaction
- {{ self.inscription_id }}
+ {{ self.inscription_id.txid }}
location
{{ self.satpoint }}
output
diff --git a/templates/transaction.html b/templates/transaction.html
index f4e3fe6888..7bc578a29b 100644
--- a/templates/transaction.html
+++ b/templates/transaction.html
@@ -1,8 +1,8 @@
Transaction {{self.txid}}
-%% if let Some(inscription) = &self.inscription {
+%% if let Some(id) = self.inscription {
Inscription Geneses
-{{ Iframe::thumbnail(self.txid) }}
+{{ Iframe::thumbnail(id) }}
%% }
{{"Output".tally(self.transaction.output.len())}}
diff --git a/tests/lib.rs b/tests/lib.rs
index ff2ebb8fe1..4516b772fd 100644
--- a/tests/lib.rs
+++ b/tests/lib.rs
@@ -47,11 +47,11 @@ fn reveal_txid_from_inscribe_stdout(stdout: &str) -> Txid {
.unwrap()
}
-fn create_inscription(rpc_server: &test_bitcoincore_rpc::Handle, filename: &str) -> Txid {
- let txid = rpc_server.mine_blocks(1)[0].txdata[0].txid();
+fn create_inscription(rpc_server: &test_bitcoincore_rpc::Handle, filename: &str) -> String {
+ rpc_server.mine_blocks(1);
let stdout = CommandBuilder::new(format!(
- "--chain {} wallet inscribe --satpoint {txid}:0:0 {filename}",
+ "--chain {} wallet inscribe {filename}",
rpc_server.network()
))
.write(filename, "HELLOWORLD")
@@ -59,11 +59,11 @@ fn create_inscription(rpc_server: &test_bitcoincore_rpc::Handle, filename: &str)
.stdout_regex("commit\t[[:xdigit:]]{64}\nreveal\t[[:xdigit:]]{64}\n")
.run();
- let inscription_id = reveal_txid_from_inscribe_stdout(&stdout);
+ let reveal_txid = reveal_txid_from_inscribe_stdout(&stdout);
rpc_server.mine_blocks(1);
- inscription_id
+ format!("{reveal_txid}i0")
}
fn create_wallet(rpc_server: &test_bitcoincore_rpc::Handle) {
diff --git a/tests/server.rs b/tests/server.rs
index b2096fe455..d71bedcb42 100644
--- a/tests/server.rs
+++ b/tests/server.rs
@@ -48,21 +48,25 @@ fn inscription_page() {
let reveal_tx = reveal_txid_from_inscribe_stdout(&stdout);
+ let inscription_id = format!("{reveal_tx}i0");
+
rpc_server.mine_blocks(1);
TestServer::spawn_with_args(&rpc_server, &[]).assert_response_regex(
- format!("/inscription/{reveal_tx}"),
+ format!("/inscription/{inscription_id}"),
format!(
- ".*.*
+ ".*.*
Inscription 0
-.*.*
+.*.*
- id
- - {reveal_tx}
+ - {inscription_id}
- address
- bc1.*
+ - output value
+ - 9860
- content
- - link
+ - link
- content size
- 10 bytes
- content type
@@ -142,18 +146,20 @@ fn inscription_page_after_send() {
let reveal_txid = reveal_txid_from_inscribe_stdout(&stdout);
+ let inscription_id = format!("{reveal_txid}i0");
+
rpc_server.mine_blocks(1);
let ord_server = TestServer::spawn_with_args(&rpc_server, &[]);
ord_server.assert_response_regex(
- format!("/inscription/{reveal_txid}"),
+ format!("/inscription/{inscription_id}"),
format!(
r".*Inscription 0
.*- location
\s*- {reveal_txid}:0:0
.*",
),
);
let txid = CommandBuilder::new(format!(
- "wallet send bc1qcqgs2pps4u4yedfyl5pysdjjncs8et5utseepv {reveal_txid}"
+ "wallet send bc1qcqgs2pps4u4yedfyl5pysdjjncs8et5utseepv {inscription_id}"
))
.rpc_server(&rpc_server)
.stdout_regex(".*")
@@ -165,7 +171,7 @@ fn inscription_page_after_send() {
let ord_server = TestServer::spawn_with_args(&rpc_server, &[]);
ord_server.assert_response_regex(
- format!("/inscription/{reveal_txid}"),
+ format!("/inscription/{inscription_id}"),
format!(
r".*Inscription 0
.*- address
\s*- bc1qcqgs2pps4u4yedfyl5pysdjjncs8et5utseepv
.*- location
\s*- {send_txid}:0:0
.*",
),
@@ -177,20 +183,14 @@ fn inscription_content() {
let rpc_server = test_bitcoincore_rpc::spawn();
create_wallet(&rpc_server);
- let txid = rpc_server.mine_blocks(1)[0].txdata[0].txid();
-
- let stdout = CommandBuilder::new(format!("wallet inscribe --satpoint {txid}:0:0 hello.txt"))
- .write("hello.txt", "HELLOWORLD")
- .rpc_server(&rpc_server)
- .stdout_regex("commit\t[[:xdigit:]]{64}\nreveal\t[[:xdigit:]]{64}\n")
- .run();
+ rpc_server.mine_blocks(1);
- let reveal_tx = reveal_txid_from_inscribe_stdout(&stdout);
+ let inscription_id = create_inscription(&rpc_server, "foo.txt");
rpc_server.mine_blocks(1);
let response =
- TestServer::spawn_with_args(&rpc_server, &[]).request(&format!("/content/{reveal_tx}"));
+ TestServer::spawn_with_args(&rpc_server, &[]).request(&format!("/content/{inscription_id}"));
assert_eq!(response.status(), StatusCode::OK);
assert_eq!(
@@ -249,24 +249,14 @@ fn inscriptions_page() {
let rpc_server = test_bitcoincore_rpc::spawn();
create_wallet(&rpc_server);
- let txid = rpc_server.mine_blocks(1)[0].txdata[0].txid();
-
- let stdout = CommandBuilder::new(format!("wallet inscribe --satpoint {txid}:0:0 hello.txt"))
- .write("hello.txt", "HELLOWORLD")
- .rpc_server(&rpc_server)
- .stdout_regex("commit\t[[:xdigit:]]{64}\nreveal\t[[:xdigit:]]{64}\n")
- .run();
-
- let reveal_tx = reveal_txid_from_inscribe_stdout(&stdout);
-
- rpc_server.mine_blocks(1);
+ let inscription_id = create_inscription(&rpc_server, "foo.png");
TestServer::spawn_with_args(&rpc_server, &[]).assert_response_regex(
"/inscriptions",
format!(
".*Inscriptions
.*",
),
diff --git a/tests/wallet/inscribe.rs b/tests/wallet/inscribe.rs
index c0634d44f6..1e5eb455ed 100644
--- a/tests/wallet/inscribe.rs
+++ b/tests/wallet/inscribe.rs
@@ -15,7 +15,9 @@ fn inscribe_creates_inscription_transactions() {
.stdout_regex("commit\t[[:xdigit:]]{64}\nreveal\t[[:xdigit:]]{64}\n")
.run();
- let inscription_id = reveal_txid_from_inscribe_stdout(&stdout);
+ let reveal_txid = reveal_txid_from_inscribe_stdout(&stdout);
+
+ let inscription_id = format!("{reveal_txid}i0");
assert_eq!(rpc_server.descriptors().len(), 3);
@@ -35,24 +37,18 @@ fn inscribe_creates_inscription_transactions() {
#[test]
fn inscribe_with_satpoint_arg_inscribes_specific_satpoint() {
let rpc_server = test_bitcoincore_rpc::spawn();
- let txid = rpc_server.mine_blocks(1)[0].txdata[0].txid();
+ rpc_server.mine_blocks(1);
assert_eq!(rpc_server.descriptors().len(), 0);
create_wallet(&rpc_server);
- let stdout = CommandBuilder::new(format!("wallet inscribe --satpoint {txid}:0:0 hello.txt"))
- .write("hello.txt", "HELLOWORLD")
- .rpc_server(&rpc_server)
- .stdout_regex("commit\t[[:xdigit:]]{64}\nreveal\t[[:xdigit:]]{64}\n")
- .run();
+ assert_eq!(rpc_server.descriptors().len(), 2);
- let inscription_id = reveal_txid_from_inscribe_stdout(&stdout);
+ let inscription_id = create_inscription(&rpc_server, "foo.txt");
assert_eq!(rpc_server.descriptors().len(), 3);
- rpc_server.mine_blocks(1);
-
let request =
TestServer::spawn_with_args(&rpc_server, &[]).request(&format!("/content/{inscription_id}"));
@@ -212,8 +208,8 @@ fn refuse_to_reinscribe_sats() {
fn refuse_to_inscribe_already_inscribed_utxo() {
let rpc_server = test_bitcoincore_rpc::spawn();
create_wallet(&rpc_server);
-
rpc_server.mine_blocks(1);
+
let stdout = CommandBuilder::new("wallet inscribe degenerate.png")
.write("degenerate.png", [1; 100])
.rpc_server(&rpc_server)
@@ -222,7 +218,7 @@ fn refuse_to_inscribe_already_inscribed_utxo() {
rpc_server.mine_blocks(1);
- let inscription_id = reveal_txid_from_inscribe_stdout(&stdout);
+ let reveal_txid = reveal_txid_from_inscribe_stdout(&stdout);
let inscription_utxo = OutPoint {
txid: reveal_txid_from_inscribe_stdout(&stdout),
@@ -236,7 +232,7 @@ fn refuse_to_inscribe_already_inscribed_utxo() {
.rpc_server(&rpc_server)
.expected_exit_code(1)
.expected_stderr(format!(
- "error: utxo {inscription_utxo} already inscribed with inscription {inscription_id} on sat {inscription_utxo}:0\n",
+ "error: utxo {inscription_utxo} already inscribed with inscription {reveal_txid}i0 on sat {inscription_utxo}:0\n",
))
.run();
}
@@ -245,15 +241,17 @@ fn refuse_to_inscribe_already_inscribed_utxo() {
fn inscribe_with_optional_satpoint_arg() {
let rpc_server = test_bitcoincore_rpc::spawn();
create_wallet(&rpc_server);
- rpc_server.mine_blocks(1);
+ let txid = rpc_server.mine_blocks(1)[0].txdata[0].txid();
- let stdout = CommandBuilder::new("wallet inscribe hello.txt")
+ let stdout = CommandBuilder::new(format!("wallet inscribe hello.txt --satpoint {txid}:0:0"))
.write("hello.txt", "HELLOWORLD")
.rpc_server(&rpc_server)
.stdout_regex("commit\t[[:xdigit:]]{64}\nreveal\t[[:xdigit:]]{64}\n")
.run();
- let inscription_id = reveal_txid_from_inscribe_stdout(&stdout);
+ let reveal_txid = reveal_txid_from_inscribe_stdout(&stdout);
+
+ let inscription_id = format!("{reveal_txid}i0");
rpc_server.mine_blocks(1);
diff --git a/tests/wallet/inscriptions.rs b/tests/wallet/inscriptions.rs
index 6265445fe2..b81503b1fc 100644
--- a/tests/wallet/inscriptions.rs
+++ b/tests/wallet/inscriptions.rs
@@ -4,21 +4,22 @@ use super::*;
fn inscriptions() {
let rpc_server = test_bitcoincore_rpc::spawn();
create_wallet(&rpc_server);
- let txid = rpc_server.mine_blocks(1)[0].txdata[0].txid();
+ rpc_server.mine_blocks(1);
- let inscription_id = reveal_txid_from_inscribe_stdout(
- &CommandBuilder::new(format!("wallet inscribe --satpoint {txid}:0:0 hello.txt"))
+ let reveal_txid = reveal_txid_from_inscribe_stdout(
+ &CommandBuilder::new("wallet inscribe hello.txt")
.write("hello.txt", "HELLOWORLD")
.rpc_server(&rpc_server)
.stdout_regex("commit\t[[:xdigit:]]{64}\nreveal\t[[:xdigit:]]{64}\n")
.run(),
);
-
rpc_server.mine_blocks(1);
+ let inscription_id = format!("{reveal_txid}i0");
+
CommandBuilder::new("wallet inscriptions")
.rpc_server(&rpc_server)
- .expected_stdout(format!("{inscription_id}\t{inscription_id}:0:0\n"))
+ .expected_stdout(format!("{inscription_id}\t{reveal_txid}:0:0\n"))
.run();
let stdout = CommandBuilder::new("wallet receive")
@@ -54,7 +55,7 @@ fn inscriptions_includes_locked_utxos() {
rpc_server.mine_blocks(1);
- let inscription_id = reveal_txid_from_inscribe_stdout(
+ let txid = reveal_txid_from_inscribe_stdout(
&CommandBuilder::new("wallet inscribe hello.txt")
.write("hello.txt", "HELLOWORLD")
.rpc_server(&rpc_server)
@@ -64,13 +65,10 @@ fn inscriptions_includes_locked_utxos() {
rpc_server.mine_blocks(1);
- rpc_server.lock(OutPoint {
- txid: inscription_id,
- vout: 0,
- });
+ rpc_server.lock(OutPoint { txid, vout: 0 });
CommandBuilder::new("wallet inscriptions")
.rpc_server(&rpc_server)
- .expected_stdout(format!("{inscription_id}\t{inscription_id}:0:0\n"))
+ .expected_stdout(format!("{txid}i0\t{txid}:0:0\n"))
.run();
}
diff --git a/tests/wallet/send.rs b/tests/wallet/send.rs
index 561c1e7163..7878e4d741 100644
--- a/tests/wallet/send.rs
+++ b/tests/wallet/send.rs
@@ -4,21 +4,14 @@ use super::*;
fn inscriptions_can_be_sent() {
let rpc_server = test_bitcoincore_rpc::spawn();
create_wallet(&rpc_server);
-
rpc_server.mine_blocks(1);
- let stdout = CommandBuilder::new("--index-sats wallet inscribe degenerate.png")
- .write("degenerate.png", [1; 520])
- .rpc_server(&rpc_server)
- .stdout_regex("commit\t[[:xdigit:]]{64}\nreveal\t[[:xdigit:]]{64}\n")
- .run();
-
- let reveal_txid = reveal_txid_from_inscribe_stdout(&stdout);
+ let inscription_id = create_inscription(&rpc_server, "foo.txt");
rpc_server.mine_blocks(1);
let stdout = CommandBuilder::new(format!(
- "wallet send bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4 {reveal_txid}"
+ "wallet send bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4 {inscription_id}"
))
.rpc_server(&rpc_server)
.stdout_regex(r".*")
@@ -33,13 +26,13 @@ fn inscriptions_can_be_sent() {
let ord_server = TestServer::spawn_with_args(&rpc_server, &[]);
ord_server.assert_response_regex(
- format!("/inscription/{reveal_txid}"),
+ format!("/inscription/{inscription_id}"),
format!(
".*Inscription 0
.*.*
- content size
- - 520 bytes
+ - 10 bytes
- content type
- - image/png
+ - text/plain;charset=utf-8
.*
- location
- {send_txid}:0:0
@@ -58,10 +51,10 @@ fn send_unknown_inscription() {
let txid = rpc_server.mine_blocks(1)[0].txdata[0].txid();
CommandBuilder::new(format!(
- "wallet send bc1qcqgs2pps4u4yedfyl5pysdjjncs8et5utseepv {txid}"
+ "wallet send bc1qcqgs2pps4u4yedfyl5pysdjjncs8et5utseepv {txid}i0"
))
.rpc_server(&rpc_server)
- .expected_stderr(format!("error: No inscription found for {txid}\n"))
+ .expected_stderr(format!("error: Inscription {txid}i0 not found\n"))
.expected_exit_code(1)
.run();
}
@@ -70,22 +63,14 @@ fn send_unknown_inscription() {
fn send_inscribed_sat() {
let rpc_server = test_bitcoincore_rpc::spawn();
create_wallet(&rpc_server);
- let txid = rpc_server.mine_blocks(1)[0].txdata[0].txid();
+ rpc_server.mine_blocks(1);
- let stdout = CommandBuilder::new(format!(
- "--index-sats wallet inscribe --satpoint {txid}:0:0 degenerate.png"
- ))
- .write("degenerate.png", [1; 520])
- .rpc_server(&rpc_server)
- .stdout_regex("commit\t[[:xdigit:]]{64}\nreveal\t[[:xdigit:]]{64}\n")
- .run();
+ let inscription_id = create_inscription(&rpc_server, "foo.txt");
rpc_server.mine_blocks(1);
- let reveal_txid = reveal_txid_from_inscribe_stdout(&stdout);
-
let stdout = CommandBuilder::new(format!(
- "wallet send bc1qcqgs2pps4u4yedfyl5pysdjjncs8et5utseepv {reveal_txid}"
+ "wallet send bc1qcqgs2pps4u4yedfyl5pysdjjncs8et5utseepv {inscription_id}"
))
.rpc_server(&rpc_server)
.stdout_regex("[[:xdigit:]]{64}\n")
@@ -97,7 +82,7 @@ fn send_inscribed_sat() {
let ord_server = TestServer::spawn_with_args(&rpc_server, &[]);
ord_server.assert_response_regex(
- format!("/inscription/{reveal_txid}"),
+ format!("/inscription/{inscription_id}"),
format!(
".*Inscription 0
.*- location
.*- {send_txid}:0:0
.*",
),
@@ -209,7 +194,7 @@ fn do_not_accidentally_send_an_inscription() {
.stdout_regex("commit\t[[:xdigit:]]{64}\nreveal\t[[:xdigit:]]{64}\n")
.run();
- let inscription_id = reveal_txid_from_inscribe_stdout(&stdout);
+ let reveal_txid = reveal_txid_from_inscribe_stdout(&stdout);
rpc_server.mine_blocks(1);
@@ -224,7 +209,7 @@ fn do_not_accidentally_send_an_inscription() {
.rpc_server(&rpc_server)
.expected_exit_code(1)
.expected_stderr(format!(
- "error: cannot send {inscription_utxo}:55 without also sending inscription {inscription_id} at {inscription_utxo}:0\n"
+ "error: cannot send {inscription_utxo}:55 without also sending inscription {reveal_txid}i0 at {inscription_utxo}:0\n"
))
.run();
}
@@ -349,7 +334,7 @@ fn wallet_send_with_fee_rate() {
let reveal_txid = reveal_txid_from_inscribe_stdout(&stdout);
CommandBuilder::new(format!(
- "wallet send bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4 {reveal_txid} --fee-rate 2.0"
+ "wallet send bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4 {reveal_txid}i0 --fee-rate 2.0"
))
.rpc_server(&rpc_server)
.stdout_regex("[[:xdigit:]]{64}\n")