From 40038f96c937f3eb26d063ebbffa4a9b34bc6dc7 Mon Sep 17 00:00:00 2001 From: Tibo-lg Date: Thu, 28 Mar 2024 10:25:56 +0900 Subject: [PATCH 1/2] Fix postgres db issue in docker compose for oracle --- docker-compose.yml | 6 ++++-- testconfig/oracle/oracledb.dockerfile | 9 +++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 testconfig/oracle/oracledb.dockerfile diff --git a/docker-compose.yml b/docker-compose.yml index b0733055..565fe9e5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -46,7 +46,10 @@ services: - ./testconfig/oracle/certs/oracle:/key oracle-db: - image: "postgres:12.2" + image: oracledb:latest + build: + context: . + dockerfile: ./testconfig/oracle/oracledb.dockerfile profiles: [oracle] command: | -c log_statement=all @@ -62,7 +65,6 @@ services: - POSTGRES_DB=db volumes: - oracle-db-data:/var/lib/postgresql/data/ # persist data even if container shuts down - - ./testconfig/oracle/certs/db:/certs volumes: diff --git a/testconfig/oracle/oracledb.dockerfile b/testconfig/oracle/oracledb.dockerfile new file mode 100644 index 00000000..99630ae5 --- /dev/null +++ b/testconfig/oracle/oracledb.dockerfile @@ -0,0 +1,9 @@ +FROM postgres:16.2 + +RUN mkdir certs +COPY ./testconfig/oracle/certs/db/db.crt /certs/ +COPY ./testconfig/oracle/certs/db/db.key /certs/ +RUN chmod 600 /certs/db.key +RUN chown postgres /certs/db.key + +CMD ["postgres"] From 6e05eab9b2b92f9e0036725caa787aa2e91bc958 Mon Sep 17 00:00:00 2001 From: Tibo-lg Date: Thu, 28 Mar 2024 10:32:37 +0900 Subject: [PATCH 2/2] Make clippy happy --- p2pd-oracle-client/src/lib.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/p2pd-oracle-client/src/lib.rs b/p2pd-oracle-client/src/lib.rs index cb955a8e..10689cf6 100644 --- a/p2pd-oracle-client/src/lib.rs +++ b/p2pd-oracle-client/src/lib.rs @@ -18,7 +18,7 @@ extern crate reqwest; extern crate secp256k1_zkp; extern crate serde; -use chrono::{DateTime, NaiveDateTime, SecondsFormat, Utc}; +use chrono::{DateTime, SecondsFormat, Utc}; use dlc_manager::error::Error as DlcManagerError; use dlc_manager::Oracle; use dlc_messages::oracle_msgs::{OracleAnnouncement, OracleAttestation}; @@ -130,9 +130,14 @@ fn parse_event_id(event_id: &str) -> Result<(String, DateTime), DlcManagerE let timestamp: i64 = timestamp_str .parse() .map_err(|_| DlcManagerError::OracleError("Invalid timestamp format".to_string()))?; - let naive_date_time = NaiveDateTime::from_timestamp_opt(timestamp, 0).ok_or_else(|| { - DlcManagerError::InvalidParameters(format!("Invalid timestamp {} in event id", timestamp)) - })?; + let naive_date_time = DateTime::from_timestamp(timestamp, 0) + .ok_or_else(|| { + DlcManagerError::InvalidParameters(format!( + "Invalid timestamp {} in event id", + timestamp + )) + })? + .naive_utc(); let date_time = DateTime::from_naive_utc_and_offset(naive_date_time, Utc); Ok((asset_id.to_string(), date_time)) }