diff --git a/Cargo.lock b/Cargo.lock index 7707d87531..39195ca8eb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -329,6 +329,14 @@ version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" +[[package]] +name = "audit-cache" +version = "0.0.0" +dependencies = [ + "colored", + "reqwest", +] + [[package]] name = "autocfg" version = "1.1.0" @@ -694,6 +702,17 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" +[[package]] +name = "colored" +version = "2.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2674ec482fbc38012cf31e6c42ba0177b431a0cb6f15fe40efa5aab1bda516f6" +dependencies = [ + "is-terminal", + "lazy_static", + "windows-sys 0.48.0", +] + [[package]] name = "concurrent-queue" version = "2.3.0" diff --git a/Cargo.toml b/Cargo.toml index 1521e1d377..7095fe5975 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,7 +15,7 @@ copyright = "The Ord Maintainers" maintainer = "The Ord Maintainers" [workspace] -members = [".", "test-bitcoincore-rpc"] +members = [".", "test-bitcoincore-rpc", "crates/*"] [dependencies] anyhow = { version = "1.0.56", features = ["backtrace"] } diff --git a/crates/audit-cache/Cargo.toml b/crates/audit-cache/Cargo.toml new file mode 100644 index 0000000000..4cde90b3e8 --- /dev/null +++ b/crates/audit-cache/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "audit-cache" +version = "0.0.0" +edition = "2021" +publish = false + +[dependencies] +colored = "2.0.4" +reqwest = { version = "0.11.22", features = ["blocking"] } diff --git a/crates/audit-cache/src/main.rs b/crates/audit-cache/src/main.rs new file mode 100644 index 0000000000..a1c870f7ce --- /dev/null +++ b/crates/audit-cache/src/main.rs @@ -0,0 +1,88 @@ +use { + colored::Colorize, + reqwest::{blocking::get, StatusCode}, + std::process, +}; + +const ENDPOINTS: &[(&str, StatusCode, &str)] = &[ + // PNG content is cached + ( + "/content/6fb976ab49dcec017f1e201e84395983204ae1a7c2abf7ced0a85d692e442799i0", + StatusCode::OK, + "HIT", + ), + // HTML content is cached + ( + "/content/114c5c87c4d0a7facb2b4bf515a4ad385182c076a5cfcc2982bf2df103ec0fffi0", + StatusCode::OK, + "HIT", + ), + // content respopnses that aren't found aren't cached + ( + "/content/6fb976ab49dcec017f1e201e84395983204ae1a7c2abf7ced0a85d692e442799i1", + StatusCode::NOT_FOUND, + "BYPASS", + ), + // HTML previews are cached + ( + "/preview/114c5c87c4d0a7facb2b4bf515a4ad385182c076a5cfcc2982bf2df103ec0fffi0", + StatusCode::OK, + "HIT", + ), + // non-HTML previews are not cached + ( + "/preview/6fb976ab49dcec017f1e201e84395983204ae1a7c2abf7ced0a85d692e442799i0", + StatusCode::OK, + "BYPASS", + ), + ("/static/index.css", StatusCode::OK, "HIT"), + ("/static/index.js", StatusCode::OK, "HIT"), + ("/sat/FOO", StatusCode::BAD_REQUEST, "HIT"), + ("/", StatusCode::OK, "BYPASS"), + ("/blockheight", StatusCode::OK, "BYPASS"), +]; + +fn main() { + eprint!("Warming up the cache"); + + for (endpoint, expected_status_code, _expected_cache_status) in ENDPOINTS { + let response = get(format!("https://ordinals.com{endpoint}")).unwrap(); + + assert_eq!(response.status(), *expected_status_code); + + eprint!("."); + } + + eprintln!(); + + let mut failures = 0; + + for (endpoint, expected_status_code, expected_cache_status) in ENDPOINTS { + eprint!("GET {endpoint}"); + + let response = get(format!("https://ordinals.com{endpoint}")).unwrap(); + + let status_code = response.status(); + + eprint!(" {}", status_code.as_u16()); + + assert_eq!(response.status(), *expected_status_code); + + let cache_status = response.headers().get("cf-cache-status").unwrap(); + + let pass = cache_status == expected_cache_status; + + if pass { + eprintln!(" {}", cache_status.to_str().unwrap().green()); + } else { + eprintln!(" {}", cache_status.to_str().unwrap().red()); + } + + failures += u32::from(!pass); + } + + if failures > 0 { + eprintln!("{failures} failures"); + process::exit(1); + } +} diff --git a/docs/src/bounty/3.md b/docs/src/bounty/3.md index 39c916ae19..853eb37640 100644 --- a/docs/src/bounty/3.md +++ b/docs/src/bounty/3.md @@ -12,7 +12,7 @@ sat 0, the first sat to be mined is `nvtdijuwxlp` and the name of sat 2,099,999,997,689,999, the last sat to be mined, is `a`. The bounty is open for submissions until block 840000—the first block after the -fourth halvening. Submissions included in block 840000 or later will not be +fourth halving. Submissions included in block 840000 or later will not be considered. Both parts use [frequency.tsv](frequency.tsv), a list of words and the number diff --git a/docs/src/guides/explorer.md b/docs/src/guides/explorer.md index 4b45873f5d..1f120646e4 100644 --- a/docs/src/guides/explorer.md +++ b/docs/src/guides/explorer.md @@ -1,7 +1,7 @@ Ordinal Explorer ================ -The `ord` binary includes a block explorer. We host a instance of the block +The `ord` binary includes a block explorer. We host an instance of the block explorer on mainnet at [ordinals.com](https://ordinals.com), and on signet at [signet.ordinals.com](https://signet.ordinals.com). @@ -43,7 +43,7 @@ transaction: ### Outputs -Transaction outputs can searched by outpoint, for example, the only output of +Transaction outputs can be searched by outpoint, for example, the only output of the genesis block coinbase transaction: [4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b:0](https://ordinals.com/search/4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b:0) @@ -78,7 +78,7 @@ JSON-API You can run `ord server` with the `--enable-json-api` flag to access endpoints that return JSON instead of HTML if you set the HTTP `Accept: application/json` -header. The structure of theses objects closely follows +header. The structure of these objects closely follows what is shown in the HTML. These endpoints are: - `/inscription/` diff --git a/docs/src/guides/inscriptions.md b/docs/src/guides/inscriptions.md index 4219082501..8692bed9fd 100644 --- a/docs/src/guides/inscriptions.md +++ b/docs/src/guides/inscriptions.md @@ -309,7 +309,7 @@ See the pending transaction with: ord wallet transactions ``` -Once the send transaction confirms, you can can confirm receipt by running: +Once the send transaction confirms, you can confirm receipt by running: ``` ord wallet inscriptions diff --git a/justfile b/justfile index b8c4e6ec4b..4e549d1f7c 100644 --- a/justfile +++ b/justfile @@ -219,3 +219,6 @@ convert-logo-to-favicon: update-mdbook-theme: curl https://raw.githubusercontent.com/rust-lang/mdBook/v0.4.35/src/theme/index.hbs > docs/theme/index.hbs + +audit-cache: + cargo run --package audit-cache diff --git a/src/index/updater/rune_updater.rs b/src/index/updater/rune_updater.rs index 3c7f1b6ef0..6fe8dd0798 100644 --- a/src/index/updater/rune_updater.rs +++ b/src/index/updater/rune_updater.rs @@ -65,7 +65,7 @@ impl<'a, 'db, 'tx> RuneUpdater<'a, 'db, 'tx> { let mut allocated: Vec> = vec![HashMap::new(); tx.output.len()]; if let Some(runestone) = runestone { - // Determine if this runestone conains a valid issuance + // Determine if this runestone contains a valid issuance let mut allocation = match runestone.etching { Some(etching) => { // If the issuance symbol is already taken, the issuance is ignored diff --git a/src/media.rs b/src/media.rs index a141ee1f1e..c4859bd38b 100644 --- a/src/media.rs +++ b/src/media.rs @@ -200,7 +200,7 @@ mod tests { } #[test] - fn no_duplicate_exensions() { + fn no_duplicate_extensions() { let mut set = HashSet::new(); for (_, _, _, extensions) in Media::TABLE { for extension in *extensions {