Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Round expected sat timestamps to the second #1386

Merged
merged 3 commits into from
Jan 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>.*",
);
}