SHOWING: First 60
it's all about the culture.
this is new art.
you are now minting the concept of a concept.#47,428,351text
assert_eq!(response.status(), StatusCode::OK);
assert_eq!(
response.headers().get("content-type").unwrap(),
"application/json"
);
assert_eq!(
response.text().unwrap(),
format!("\"{}\"", hex::encode(encoded_metadata))
);
}
#[test]
fn inscriptions_page() {
let rpc_server = test_bitcoincore_rpc::spawn();
create_wallet(&rpc_server);
let (inscription, _) = inscribe(&rpc_server);
TestServer::spawn_with_args(&rpc_server, &[]).assert_response_regex(
"/inscriptions",
format!(
".*<h1>All Inscriptions</h1>
<div class=thumbnails>
<a href=/inscription/{inscription}>.*</a>
</div>
.*",
),
);
}
#[test]
fn inscriptions_page_is_sorted() {
let rpc_server = test_bitcoincore_rpc::spawn();
create_wallet(&rpc_server);
let mut regex = String::new();
for _ in 0..8 {
let (inscription, _) = inscribe(&rpc_server);
regex.insert_str(0, &format!(".*<a href=/inscription/{inscription}>.*"));
}
TestServer::spawn_with_args(&rpc_server, &[]).assert_response_regex("/inscriptions", ®ex);
#44,997,318text }
pub(crate) fn request(&self, path: impl AsRef<str>) -> Response {
self.sync_server();
reqwest::blocking::get(self.url().join(path.as_ref()).unwrap()).unwrap()
}
pub(crate) fn json_request(&self, path: impl AsRef<str>) -> Response {
self.sync_server();
let client = reqwest::blocking::Client::new();
client
.get(self.url().join(path.as_ref()).unwrap())
.header(reqwest::header::ACCEPT, "application/json")
.send()
.unwrap()
}
pub(crate) fn sync_server(&self) {
let client = Client::new(&self.rpc_url, Auth::None).unwrap();
let chain_block_count = client.get_block_count().unwrap() + 1;
for i in 0.. {
let response = reqwest::blocking::get(self.url().join("/blockcount").unwrap()).unwrap();
assert_eq!(response.status(), StatusCode::OK);
if response.text().unwrap().parse::<u64>().unwrap() == chain_block_count {
break;
} else if i == 20 {
panic!("index failed to synchronize with chain");
}
thread::sleep(Duration::from_millis(25));
#44,997,310textuse {super::*, std::ops::Deref};
#[test]
fn inscribe_creates_inscriptions() {
let rpc_server = test_bitcoincore_rpc::spawn();
rpc_server.mine_blocks(1);
assert_eq!(rpc_server.descriptors().len(), 0);
create_wallet(&rpc_server);
let (inscription, _) = inscribe(&rpc_server);
assert_eq!(rpc_server.descriptors().len(), 3);
let request =
TestServer::spawn_with_args(&rpc_server, &[]).request(format!("/content/{inscription}"));
assert_eq!(request.status(), 200);
assert_eq!(
request.headers().get("content-type").unwrap(),
"text/plain;charset=utf-8"
);
assert_eq!(request.text().unwrap(), "FOO");
}
#[test]
fn inscribe_works_with_huge_expensive_inscriptions() {
let rpc_server = test_bitcoincore_rpc::spawn();
create_wallet(&rpc_server);
let txid = rpc_server.mine_blocks(1)[0].txdata[0].txid();
CommandBuilder::new(format!(
"wallet inscribe --file foo.txt --satpoint {txid}:0:0 --fee-rate 10"
))
.write("foo.txt", [0; 350_000])
.rpc_server(&rpc_server)
.run_and_deserialize_output::<Inscribe>();
#44,997,058text "index_path": ".*\.redb",
"leaf_pages": \d+,
"metadata_bytes": \d+,
"outputs_traversed": 0,
"page_size": \d+,
"sat_ranges": 0,
"stored_bytes": \d+,
"tables": .*,
"transactions": \[
\{
"starting_block_count": 0,
"starting_timestamp": \d+
\}
\],
"tree_height": \d+,
"utxos_indexed": 0
\}
"#,
)
.run_and_extract_stdout();
}
#[test]
fn transactions() {
let rpc_server = test_bitcoincore_rpc::spawn();
let tempdir = TempDir::new().unwrap();
let index_path = tempdir.path().join("index.redb");
assert!(CommandBuilder::new(format!(
"--index {} index info --transactions",
index_path.display()
))
.rpc_server(&rpc_server)
.run_and_deserialize_output::<Vec<TransactionsOutput>>()
.is_empty());
rpc_server.mine_blocks(10);
let output = CommandBuilder::new(format!(
"--index {} index info --transactions",
index_path.display()
))
.rpc_server(&rpc_server)
.run_and_deserialize_output::<Vec<TransactionsOutput>>();
assert_eq!(output[0].start, 0);
#44,996,955textuse {super::*, ord::subcommand::wallet::balance::Output};
#[test]
fn wallet_balance() {
let rpc_server = test_bitcoincore_rpc::spawn();
create_wallet(&rpc_server);
assert_eq!(
CommandBuilder::new("wallet balance")
.rpc_server(&rpc_server)
.run_and_deserialize_output::<Output>()
.cardinal,
0
);
rpc_server.mine_blocks(1);
assert_eq!(
CommandBuilder::new("wallet balance")
.rpc_server(&rpc_server)
.run_and_deserialize_output::<Output>()
.cardinal,
50 * COIN_VALUE
);
}
#[test]
fn wallet_balance_only_counts_cardinal_utxos() {
let rpc_server = test_bitcoincore_rpc::spawn();
create_wallet(&rpc_server);
assert_eq!(
CommandBuilder::new("wallet balance")
.rpc_server(&rpc_server)
.run_and_deserialize_output::<Output>()
.cardinal,
0
);
inscribe(&rpc_server);
assert_eq!(
CommandBuilder::new("wallet balance")
.rpc_server(&rpc_server)
.run_and_deserialize_output::<Output>()
.cardinal,
100 * COIN_VALUE - 10_000
#44,996,954text