SHOWING: First 60
0#60,355,703texttoken-transfer20,000,000,000.dmt-nat#59,304,640taptoken-transfer30,000,000,000.dmt-nat#58,707,588taptransfer125,000.csas#51,368,301brc-20
let info = server.index.info().unwrap();
assert_eq!(info.transactions.len(), 1);
assert_eq!(info.transactions[0].starting_block_count, 0);
server.index.update().unwrap();
assert_eq!(server.index.statistic(crate::index::Statistic::Commits), 1);
let info = server.index.info().unwrap();
assert_eq!(info.transactions.len(), 1);
assert_eq!(info.transactions[0].starting_block_count, 0);
server.mine_blocks(1);
thread::sleep(Duration::from_millis(10));
server.index.update().unwrap();
assert_eq!(server.index.statistic(crate::index::Statistic::Commits), 2);
let info = server.index.info().unwrap();
assert_eq!(info.transactions.len(), 2);
assert_eq!(info.transactions[0].starting_block_count, 0);
assert_eq!(info.transactions[1].starting_block_count, 1);
assert!(
info.transactions[1].starting_timestamp - info.transactions[0].starting_timestamp >= 10
);
}
#[test]
fn outputs_traversed_are_tracked() {
let server = TestServer::new_with_sat_index();#45,000,615text );
}
#[test]
fn content_security_policy_with_origin() {
let (headers, _) = Server::content_response(
Inscription::new(Some("text/plain".as_bytes().to_vec()), Some(vec![1, 2, 3])),
AcceptEncoding::default(),
&PageConfig {
csp_origin: Some("https://ordinals.com".into()),
..Default::default()
},
)
.unwrap()
.unwrap();
assert_eq!(headers["content-security-policy"], HeaderValue::from_static("default-src https://ordinals.com/content/ https://ordinals.com/blockheight https://ordinals.com/blockhash https://ordinals.com/blockhash/ https://ordinals.com/blocktime https://ordinals.com/r/ 'unsafe-eval' 'unsafe-inline' data: blob:"));
}
#[test]
fn code_preview() {
let server = TestServer::new_with_regtest();
server.mine_blocks(1);
let txid = server.bitcoin_rpc_server.broadcast_tx(TransactionTemplate {
inputs: &[(
1,
0,
0,
inscription("text/javascript", "hello").to_witness(),
)],
..Default::default()#45,000,609text
let response = test_server.get("/blockcount");
assert_eq!(response.status(), StatusCode::OK);
assert_eq!(response.text().unwrap(), "2");
}
#[test]
fn block_height_endpoint() {
let test_server = TestServer::new();
let response = test_server.get("/blockheight");
assert_eq!(response.status(), StatusCode::OK);
assert_eq!(response.text().unwrap(), "0");
test_server.mine_blocks(2);
let response = test_server.get("/blockheight");
assert_eq!(response.status(), StatusCode::OK);
assert_eq!(response.text().unwrap(), "2");
}
#[test]
fn block_hash_endpoint() {
let test_server = TestServer::new();
let response = test_server.get("/blockhash");
assert_eq!(response.status(), StatusCode::OK);
assert_eq!(
response.text().unwrap(),
"000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f"
);
}
#[test]
fn block_hash_from_height_endpoint() {
let test_server = TestServer::new();
let response = test_server.get("/blockhash/0");#45,000,544text
#[test]
fn unknown_preview() {
let server = TestServer::new_with_regtest();
server.mine_blocks(1);
let txid = server.bitcoin_rpc_server.broadcast_tx(TransactionTemplate {
inputs: &[(1, 0, 0, inscription("text/foo", "hello").to_witness())],
..Default::default()
});
server.mine_blocks(1);
server.assert_response_csp(
format!("/preview/{}", InscriptionId { txid, index: 0 }),
StatusCode::OK,
"default-src 'self'",
fs::read_to_string("templates/preview-unknown.html").unwrap(),
);
}
#[test]
fn video_preview() {
let server = TestServer::new_with_regtest();
server.mine_blocks(1);
let txid = server.bitcoin_rpc_server.broadcast_tx(TransactionTemplate {
inputs: &[(1, 0, 0, inscription("video/webm", "hello").to_witness())],
..Default::default()
});
let inscription_id = InscriptionId { txid, index: 0 };
server.mine_blocks(1);
server.assert_response_regex(
format!("/preview/{inscription_id}"),
StatusCode::OK,#45,000,000textuse super::*;
fn target_as_block_hash(target: bitcoin::Target) -> BlockHash {
BlockHash::from_raw_hash(Hash::from_byte_array(target.to_le_bytes()))
}
#[derive(Boilerplate)]
pub(crate) struct BlockHtml {
hash: BlockHash,
target: BlockHash,
best_height: Height,
block: Block,
height: Height,
inscription_count: usize,
featured_inscriptions: Vec<InscriptionId>,
}
impl BlockHtml {
pub(crate) fn new(
block: Block,
height: Height,
best_height: Height,
inscription_count: usize,
featured_inscriptions: Vec<InscriptionId>,
) -> Self {
Self {
hash: block.header.block_hash(),
target: target_as_block_hash(block.header.target()),
block,
height,
best_height,
inscription_count,
featured_inscriptions,
}
}
}
#[derive(Debug, PartialEq, Serialize, Deserialize)]
pub struct BlockJson {
pub hash: BlockHash,
pub target: BlockHash,
pub best_height: u32,
pub height: u32,
pub inscriptions: Vec<InscriptionId>,
}
impl BlockJson {
pub(crate) fn new(#44,999,203text let acme_cache = if let Some(acme_cache) = acme_cache {
acme_cache.clone()
} else {
options.data_dir()?.join("acme-cache")
};
Ok(acme_cache)
}
fn acme_domains(&self) -> Result<Vec<String>> {
if !self.acme_domain.is_empty() {
Ok(self.acme_domain.clone())
} else {
Ok(vec![System::new()
.host_name()
.ok_or(anyhow!("no hostname found"))?])
}
}
fn http_port(&self) -> Option<u16> {
if self.http || self.http_port.is_some() || (self.https_port.is_none() && !self.https) {
Some(self.http_port.unwrap_or(80))
} else {
None
}
}
fn https_port(&self) -> Option<u16> {
if self.https || self.https_port.is_some() {
Some(self.https_port.unwrap_or(443))
} else {
None
}
}
fn acceptor(&self, options: &Options) -> Result<AxumAcceptor> {
let config = AcmeConfig::new(self.acme_domains()?)
.contact(&self.acme_contact)
.cache_option(Some(DirCache::new(Self::acme_cache(
self.acme_cache.as_ref(),#44,996,493textdmt-mint.nat#44,255,332tapdmt-mint.nat#44,255,321tapdmt-mint.nat#44,255,287tapdmt-mint.nat#44,255,283tapdmt-mint.nat#44,255,279tapdmt-mint.nat#44,255,267tapdmt-mint.nat#44,255,244tapdmt-mint.nat#44,255,225tapdmt-mint.nat#44,255,208tapdmt-mint.nat#44,255,198tapdmt-mint.nat#44,255,196tapdmt-mint.nat#44,255,186tapdmt-mint.nat#44,255,170tapdmt-mint.nat#44,255,164tapdmt-mint.nat#44,255,144tapdmt-mint.nat#44,255,099tapdmt-mint.nat#44,255,086tapdmt-mint.nat#44,255,060tapdmt-mint.nat#44,255,037tapdmt-mint.nat#44,255,034tapdmt-mint.nat#44,255,012tapdmt-mint.nat#44,254,973tapdmt-mint.nat#44,252,141tapdmt-mint.nat#44,252,135tapdmt-mint.nat#44,252,120tapdmt-mint.nat#44,252,088tapdmt-mint.nat#44,249,588tapdmt-mint.nat#44,249,580tap