Skip to content

Commit

Permalink
Round expected sat timestamps (#1386)
Browse files Browse the repository at this point in the history
  • Loading branch information
casey authored Jan 26, 2023
1 parent 226c769 commit dbda9b6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use {
super::*,
bitcoin::BlockHeader,
bitcoincore_rpc::{json::GetBlockHeaderResult, Auth, Client},
chrono::SubsecRound,
indicatif::{ProgressBar, ProgressStyle},
log::log_enabled,
redb::{Database, ReadableTable, Table, TableDefinition, WriteStrategy, WriteTransaction},
Expand Down Expand Up @@ -633,6 +634,7 @@ impl Index {

Ok(Blocktime::Expected(
Utc::now()
.round_subsecs(0)
.checked_add_signed(chrono::Duration::seconds(
10 * 60 * i64::try_from(expected_blocks)?,
))
Expand Down
10 changes: 10 additions & 0 deletions tests/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,3 +286,13 @@ fn inscriptions_page_has_next_and_previous() {
),
);
}

#[test]
fn expected_sat_time_is_rounded() {
let rpc_server = test_bitcoincore_rpc::spawn();

TestServer::spawn_with_args(&rpc_server, &[]).assert_response_regex(
"/sat/2099999997689999",
r".*<dt>timestamp</dt><dd><time>.* \d+:\d+:\d+ UTC</time> \(expected\)</dd>.*",
);
}

0 comments on commit dbda9b6

Please sign in to comment.