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

add missing dcap arg within dockerfile #3004

Merged
merged 7 commits into from
Aug 27, 2024
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
12 changes: 7 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ jobs:
- name: Tee-worker check ts code format
working-directory: ./tee-worker/ts-tests
run: pnpm run check-format

- name: Dynamic-contract install npm deps
working-directory: ./tee-worker/litentry/core/assertion-build/src/dynamic
run: pnpm install
Expand Down Expand Up @@ -440,6 +440,7 @@ jobs:
WORKER_ENV_DATA_PROVIDERS_CONFIG=1
WORKER_MOCK_SERVER=1
ADDITIONAL_FEATURES_ARG=
RA_METHOD=dcap

- name: Copy caches from the built image
if: needs.set-condition.outputs.rebuild_tee == 'true'
Expand Down Expand Up @@ -539,8 +540,9 @@ jobs:
tags: local-builder:latest
target: builder
build-args: |
WORKER_MODE_ARG=offchain-worker
WORKER_MODE_ARG=offchain-worker
ADDITIONAL_FEATURES_ARG=
RA_METHOD=dcap

- name: Build worker
if: needs.set-condition.outputs.rebuild_bitacross == 'true'
Expand Down Expand Up @@ -648,15 +650,15 @@ jobs:
- name: Fail early
if: failure()
uses: andymckay/[email protected]

parachain-dynamic-contract-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Enable corepack and pnpm
run: corepack enable && corepack enable pnpm

- name: Install npm deps
working-directory: ./tee-worker/litentry/core/assertion-build/src/dynamic
run: pnpm install
Expand Down Expand Up @@ -1025,7 +1027,7 @@ jobs:
docker load < litentry-parachain-dev.tar.gz
docker load < litentry-identity.tar.gz
docker load < litentry-bitacross.tar.gz

- name: Dockerhub login
uses: docker/login-action@v3
with:
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/create-release-draft.yml
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,6 @@ jobs:
SGX_MODE=HW
IMAGE_FOR_RELEASE=true
SGX_COMMERCIAL_KEY=enclave_key.pem
RA_METHOD=dcap
- name: Build worker
uses: docker/build-push-action@v6
Expand Down Expand Up @@ -277,7 +276,6 @@ jobs:
SGX_MODE=HW
IMAGE_FOR_RELEASE=true
SGX_COMMERCIAL_KEY=enclave_key.pem
RA_METHOD=dcap
- name: Build worker
uses: docker/build-push-action@v6
Expand Down
2 changes: 1 addition & 1 deletion bitacross-worker/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ SGX_PRODUCTION ?= 0
######## Worker Feature Settings ########
# Set offchain-worker as default feature mode
WORKER_MODE ?= offchain-worker
RA_METHOD ?=
RA_METHOD ?= dcap

SKIP_WASM_BUILD = 1
# include the build settings from rust-sgx-sdk
Expand Down
5 changes: 5 additions & 0 deletions bitacross-worker/build.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
LABEL maintainer="Trust Computing GmbH <[email protected]>"

# set environment variables
ENV SGX_SDK /opt/sgxsdk

Check warning on line 26 in bitacross-worker/build.Dockerfile

View workflow job for this annotation

GitHub Actions / bitacross-build

Legacy key/value format with whitespace separator should not be used

LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format More info: https://docs.docker.com/go/dockerfile/rule/legacy-key-value-format/
ENV PATH "$PATH:${SGX_SDK}/bin:${SGX_SDK}/bin/x64:/opt/rust/bin"

Check warning on line 27 in bitacross-worker/build.Dockerfile

View workflow job for this annotation

GitHub Actions / bitacross-build

Legacy key/value format with whitespace separator should not be used

LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format More info: https://docs.docker.com/go/dockerfile/rule/legacy-key-value-format/
ENV PKG_CONFIG_PATH "${PKG_CONFIG_PATH}:${SGX_SDK}/pkgconfig"

Check warning on line 28 in bitacross-worker/build.Dockerfile

View workflow job for this annotation

GitHub Actions / bitacross-build

Legacy key/value format with whitespace separator should not be used

LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format More info: https://docs.docker.com/go/dockerfile/rule/legacy-key-value-format/
ENV LD_LIBRARY_PATH "${LD_LIBRARY_PATH}:${SGX_SDK}/sdk_libs"

Check warning on line 29 in bitacross-worker/build.Dockerfile

View workflow job for this annotation

GitHub Actions / bitacross-build

Legacy key/value format with whitespace separator should not be used

LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format More info: https://docs.docker.com/go/dockerfile/rule/legacy-key-value-format/
ENV CARGO_NET_GIT_FETCH_WITH_CLI true

Check warning on line 30 in bitacross-worker/build.Dockerfile

View workflow job for this annotation

GitHub Actions / bitacross-build

Legacy key/value format with whitespace separator should not be used

LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format More info: https://docs.docker.com/go/dockerfile/rule/legacy-key-value-format/

ENV SCCACHE_CACHE_SIZE="20G"
ENV SCCACHE_DIR="/opt/rust/sccache"
Expand All @@ -42,6 +42,9 @@

ENV HOME=/home/ubuntu

ARG RA_METHOD
ENV RA_METHOD=$RA_METHOD

ARG WORKER_MODE_ARG
ENV WORKER_MODE=$WORKER_MODE_ARG

Expand All @@ -53,8 +56,8 @@

ARG FINGERPRINT=none

ARG SGX_COMMERCIAL_KEY

Check warning on line 59 in bitacross-worker/build.Dockerfile

View workflow job for this annotation

GitHub Actions / bitacross-build

Sensitive data should not be used in the ARG or ENV commands

SecretsUsedInArgOrEnv: Do not use ARG or ENV instructions for sensitive data (ARG "SGX_COMMERCIAL_KEY") More info: https://docs.docker.com/go/dockerfile/rule/secrets-used-in-arg-or-env/
ENV SGX_COMMERCIAL_KEY=$SGX_COMMERCIAL_KEY

Check warning on line 60 in bitacross-worker/build.Dockerfile

View workflow job for this annotation

GitHub Actions / bitacross-build

Sensitive data should not be used in the ARG or ENV commands

SecretsUsedInArgOrEnv: Do not use ARG or ENV instructions for sensitive data (ENV "SGX_COMMERCIAL_KEY") More info: https://docs.docker.com/go/dockerfile/rule/secrets-used-in-arg-or-env/

WORKDIR $HOME/bitacross-worker
COPY . $HOME
Expand All @@ -81,8 +84,8 @@
ARG SCRIPT_DIR=/usr/local/worker-cli
ARG LOG_DIR=/usr/local/log

ENV SCRIPT_DIR ${SCRIPT_DIR}

Check warning on line 87 in bitacross-worker/build.Dockerfile

View workflow job for this annotation

GitHub Actions / bitacross-build

Legacy key/value format with whitespace separator should not be used

LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format More info: https://docs.docker.com/go/dockerfile/rule/legacy-key-value-format/
ENV LOG_DIR ${LOG_DIR}

Check warning on line 88 in bitacross-worker/build.Dockerfile

View workflow job for this annotation

GitHub Actions / bitacross-build

Legacy key/value format with whitespace separator should not be used

LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format More info: https://docs.docker.com/go/dockerfile/rule/legacy-key-value-format/

COPY --from=local-builder:latest /home/ubuntu/bitacross-worker/bin/bitacross-cli /usr/local/bin
COPY --from=local-builder:latest /home/ubuntu/bitacross-worker/cli/*.sh /usr/local/worker-cli/
Expand All @@ -107,15 +110,16 @@
COPY --from=local-builder:latest /home/ubuntu/bitacross-worker/cli/*.sh /usr/local/worker-cli/
COPY --from=local-builder:latest /lib/x86_64-linux-gnu/libsgx* /lib/x86_64-linux-gnu/
COPY --from=local-builder:latest /lib/x86_64-linux-gnu/libdcap* /lib/x86_64-linux-gnu/
COPY --from=local-builder:latest /lib/x86_64-linux-gnu/libprotobuf* /lib/x86_64-linux-gnu/

RUN touch spid.txt key.txt
RUN chmod +x /usr/local/bin/bitacross-worker
RUN ls -al /usr/local/bin

# checks
ENV SGX_SDK /opt/sgxsdk

Check warning on line 120 in bitacross-worker/build.Dockerfile

View workflow job for this annotation

GitHub Actions / bitacross-build

Legacy key/value format with whitespace separator should not be used

LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format More info: https://docs.docker.com/go/dockerfile/rule/legacy-key-value-format/
ENV SGX_ENCLAVE_SIGNER $SGX_SDK/bin/x64/sgx_sign

Check warning on line 121 in bitacross-worker/build.Dockerfile

View workflow job for this annotation

GitHub Actions / bitacross-build

Legacy key/value format with whitespace separator should not be used

LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format More info: https://docs.docker.com/go/dockerfile/rule/legacy-key-value-format/
ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/intel/sgx-aesm-service/aesm:$SGX_SDK/sdk_libs

Check warning on line 122 in bitacross-worker/build.Dockerfile

View workflow job for this annotation

GitHub Actions / bitacross-build

Variables should be defined before their use

UndefinedVar: Usage of undefined variable '$LD_LIBRARY_PATH' More info: https://docs.docker.com/go/dockerfile/rule/undefined-var/
ENV AESM_PATH=/opt/intel/sgx-aesm-service/aesm

RUN ldd /usr/local/bin/bitacross-worker && /usr/local/bin/bitacross-worker --version
Expand Down Expand Up @@ -145,6 +149,7 @@
COPY --from=local-builder:latest /opt/sgxsdk /opt/sgxsdk
COPY --from=local-builder:latest /lib/x86_64-linux-gnu/libsgx* /lib/x86_64-linux-gnu/
COPY --from=local-builder:latest /lib/x86_64-linux-gnu/libdcap* /lib/x86_64-linux-gnu/
COPY --from=local-builder:latest /lib/x86_64-linux-gnu/libprotobuf* /lib/x86_64-linux-gnu/

ENV DEBIAN_FRONTEND noninteractive
ENV TERM xterm
Expand Down
1 change: 1 addition & 0 deletions tee-worker/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tee-worker/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ SGX_PRODUCTION ?= 0
WORKER_MODE ?= sidechain
WORKER_DEV ?= 0
WORKER_MOCK_SERVER ?= 0
RA_METHOD ?=
RA_METHOD ?= dcap

SKIP_WASM_BUILD = 1
# include the build settings from rust-sgx-sdk
Expand Down
5 changes: 5 additions & 0 deletions tee-worker/build.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
LABEL maintainer="Trust Computing GmbH <[email protected]>"

# set environment variables
ENV SGX_SDK /opt/sgxsdk

Check warning on line 25 in tee-worker/build.Dockerfile

View workflow job for this annotation

GitHub Actions / identity-build

Legacy key/value format with whitespace separator should not be used

LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format More info: https://docs.docker.com/go/dockerfile/rule/legacy-key-value-format/
ENV PATH "$PATH:${SGX_SDK}/bin:${SGX_SDK}/bin/x64:/opt/rust/bin"

Check warning on line 26 in tee-worker/build.Dockerfile

View workflow job for this annotation

GitHub Actions / identity-build

Legacy key/value format with whitespace separator should not be used

LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format More info: https://docs.docker.com/go/dockerfile/rule/legacy-key-value-format/
ENV PKG_CONFIG_PATH "${PKG_CONFIG_PATH}:${SGX_SDK}/pkgconfig"

Check warning on line 27 in tee-worker/build.Dockerfile

View workflow job for this annotation

GitHub Actions / identity-build

Legacy key/value format with whitespace separator should not be used

LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format More info: https://docs.docker.com/go/dockerfile/rule/legacy-key-value-format/
ENV LD_LIBRARY_PATH "${LD_LIBRARY_PATH}:${SGX_SDK}/sdk_libs"

Check warning on line 28 in tee-worker/build.Dockerfile

View workflow job for this annotation

GitHub Actions / identity-build

Legacy key/value format with whitespace separator should not be used

LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format More info: https://docs.docker.com/go/dockerfile/rule/legacy-key-value-format/
ENV CARGO_NET_GIT_FETCH_WITH_CLI true

Check warning on line 29 in tee-worker/build.Dockerfile

View workflow job for this annotation

GitHub Actions / identity-build

Legacy key/value format with whitespace separator should not be used

LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format More info: https://docs.docker.com/go/dockerfile/rule/legacy-key-value-format/

ENV SCCACHE_CACHE_SIZE="20G"
ENV SCCACHE_DIR="/opt/rust/sccache"
Expand All @@ -41,6 +41,9 @@

ENV HOME=/home/ubuntu

ARG RA_METHOD
ENV RA_METHOD=$RA_METHOD

ARG WORKER_MODE_ARG
ENV WORKER_MODE=$WORKER_MODE_ARG

Expand All @@ -58,8 +61,8 @@

ARG FINGERPRINT=none

ARG SGX_COMMERCIAL_KEY

Check warning on line 64 in tee-worker/build.Dockerfile

View workflow job for this annotation

GitHub Actions / identity-build

Sensitive data should not be used in the ARG or ENV commands

SecretsUsedInArgOrEnv: Do not use ARG or ENV instructions for sensitive data (ARG "SGX_COMMERCIAL_KEY") More info: https://docs.docker.com/go/dockerfile/rule/secrets-used-in-arg-or-env/
ENV SGX_COMMERCIAL_KEY=$SGX_COMMERCIAL_KEY

Check warning on line 65 in tee-worker/build.Dockerfile

View workflow job for this annotation

GitHub Actions / identity-build

Sensitive data should not be used in the ARG or ENV commands

SecretsUsedInArgOrEnv: Do not use ARG or ENV instructions for sensitive data (ENV "SGX_COMMERCIAL_KEY") More info: https://docs.docker.com/go/dockerfile/rule/secrets-used-in-arg-or-env/

WORKDIR $HOME/tee-worker
COPY . $HOME
Expand Down Expand Up @@ -97,8 +100,8 @@
ARG SCRIPT_DIR=/usr/local/worker-cli
ARG LOG_DIR=/usr/local/log

ENV SCRIPT_DIR ${SCRIPT_DIR}

Check warning on line 103 in tee-worker/build.Dockerfile

View workflow job for this annotation

GitHub Actions / identity-build

Legacy key/value format with whitespace separator should not be used

LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format More info: https://docs.docker.com/go/dockerfile/rule/legacy-key-value-format/
ENV LOG_DIR ${LOG_DIR}

Check warning on line 104 in tee-worker/build.Dockerfile

View workflow job for this annotation

GitHub Actions / identity-build

Legacy key/value format with whitespace separator should not be used

LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format More info: https://docs.docker.com/go/dockerfile/rule/legacy-key-value-format/

COPY --from=local-builder:latest /home/ubuntu/tee-worker/bin/litentry-cli /usr/local/bin
COPY --from=local-builder:latest /home/ubuntu/tee-worker/cli/*.sh /usr/local/worker-cli/
Expand All @@ -123,15 +126,16 @@
COPY --from=local-builder:latest /home/ubuntu/tee-worker/cli/*.sh /usr/local/worker-cli/
COPY --from=local-builder:latest /lib/x86_64-linux-gnu/libsgx* /lib/x86_64-linux-gnu/
COPY --from=local-builder:latest /lib/x86_64-linux-gnu/libdcap* /lib/x86_64-linux-gnu/
COPY --from=local-builder:latest /lib/x86_64-linux-gnu/libprotobuf* /lib/x86_64-linux-gnu/

RUN touch spid.txt key.txt
RUN chmod +x /usr/local/bin/litentry-worker
RUN ls -al /usr/local/bin

# checks
ENV SGX_SDK /opt/sgxsdk

Check warning on line 136 in tee-worker/build.Dockerfile

View workflow job for this annotation

GitHub Actions / identity-build

Legacy key/value format with whitespace separator should not be used

LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format More info: https://docs.docker.com/go/dockerfile/rule/legacy-key-value-format/
ENV SGX_ENCLAVE_SIGNER $SGX_SDK/bin/x64/sgx_sign

Check warning on line 137 in tee-worker/build.Dockerfile

View workflow job for this annotation

GitHub Actions / identity-build

Legacy key/value format with whitespace separator should not be used

LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format More info: https://docs.docker.com/go/dockerfile/rule/legacy-key-value-format/
ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/intel/sgx-aesm-service/aesm:$SGX_SDK/sdk_libs

Check warning on line 138 in tee-worker/build.Dockerfile

View workflow job for this annotation

GitHub Actions / identity-build

Variables should be defined before their use

UndefinedVar: Usage of undefined variable '$LD_LIBRARY_PATH' More info: https://docs.docker.com/go/dockerfile/rule/undefined-var/
ENV AESM_PATH=/opt/intel/sgx-aesm-service/aesm

RUN ldd /usr/local/bin/litentry-worker && /usr/local/bin/litentry-worker --version
Expand Down Expand Up @@ -161,6 +165,7 @@
COPY --from=local-builder:latest /opt/sgxsdk /opt/sgxsdk
COPY --from=local-builder:latest /lib/x86_64-linux-gnu/libsgx* /lib/x86_64-linux-gnu/
COPY --from=local-builder:latest /lib/x86_64-linux-gnu/libdcap* /lib/x86_64-linux-gnu/
COPY --from=local-builder:latest /lib/x86_64-linux-gnu/libprotobuf* /lib/x86_64-linux-gnu/

ENV DEBIAN_FRONTEND noninteractive
ENV TERM xterm
Expand Down
1 change: 1 addition & 0 deletions tee-worker/litentry/core/assertion-build/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ litentry-primitives = { path = "../../primitives", default-features = false }
pallet-parachain-staking = { git = "https://github.com/litentry/litentry-parachain", branch = "release-v0.9.19", default-features = false }

[dev-dependencies]
chrono = { version = "0.4.19", default-features = false, features = ["alloc"] }
env_logger = "0.10.0"
lc-mock-server = { path = "../mock-server" }
litentry-hex-utils = { path = "../../../../primitives/hex" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,99 +181,107 @@ impl Domains {
#[cfg(test)]
mod tests {
use super::Domains;
use chrono::{Duration, SecondsFormat, Utc};
use litentry_primitives::BnbDigitDomainType;

const RESPONSE: &'static str = r#"
{
"0xr4b0bf28adfcee93c5069982a895785c9231c1fe1": [
{
"nodeHash": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe",
"bind": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe",
"name": "1",
"expires": "2024-08-24T00:36:44Z"
},
{
"nodeHash": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe",
"bind": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe",
"name": "2",
"expires": "2032-08-24T00:15:56Z"
}
],
"0xr4b0bf28adfcee93c5069982a895785c9231c1fe2": [
{
"nodeHash": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe",
"bind": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe",
"name": "3",
"expires": "2023-08-24T20:36:26Z"
},
{
"nodeHash": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe",
"bind": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe",
"name": "4",
"expires": "2023-08-24T20:35:59Z"
},
{
"nodeHash": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe",
"bind": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe",
"name": "win",
"expires": "2023-08-24T20:38:29Z"
}
],
"0xr4b0bf28adfcee93c5069982a895785c9231c1fe3": [
{
"nodeHash": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe",
"bind": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe",
"name": "5",
"expires": "2024-08-24T06:33:32Z"
},
{
"nodeHash": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe",
"bind": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe",
"name": "6",
"expires": "2024-08-24T07:57:41Z"
},
{
"nodeHash": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe",
"bind": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe",
"name": "7",
"expires": "2023-09-16T19:36:14Z"
}
],
"0xr4b0bf28adfcee93c5069982a895785c9231c1fe4": [
{
"nodeHash": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe",
"bind": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe",
"name": "8",
"expires": "2028-09-18T13:35:38Z"
}
],
"0xr4b0bf28adfcee93c5069982a895785c9231c1fe5": [
{
"nodeHash": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe",
"bind": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe",
"name": "9",
"expires": "2023-09-03T08:35:40Z"
}
],
"0xr4b0bf28adfcee93c5069982a895785c9231c1fe6": [
{
"nodeHash": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe",
"bind": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe",
"name": "000",
"expires": "2024-10-30T18:40:51Z"
},
{
"nodeHash": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe",
"bind": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe",
"name": "999",
"expires": "2024-03-19T18:16:59Z"
}
]
}
"#;

fn new_domains() -> Domains {
let value: serde_json::Value = serde_json::from_str(RESPONSE).unwrap();
let future_date = Utc::now()
.checked_add_signed(Duration::days(10))
.expect("Failed to add duration")
.to_rfc3339_opts(SecondsFormat::Secs, true);
let response = format!(
r#"
{{
"0xr4b0bf28adfcee93c5069982a895785c9231c1fe1": [
{{
"nodeHash": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe",
"bind": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe",
"name": "1",
"expires": "2024-08-24T00:36:44Z"
}},
{{
"nodeHash": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe",
"bind": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe",
"name": "2",
"expires": "{}"
}}
],
"0xr4b0bf28adfcee93c5069982a895785c9231c1fe2": [
{{
"nodeHash": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe",
"bind": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe",
"name": "3",
"expires": "2023-08-24T20:36:26Z"
}},
{{
"nodeHash": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe",
"bind": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe",
"name": "4",
"expires": "2023-08-24T20:35:59Z"
}},
{{
"nodeHash": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe",
"bind": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe",
"name": "win",
"expires": "2023-08-24T20:38:29Z"
}}
],
"0xr4b0bf28adfcee93c5069982a895785c9231c1fe3": [
{{
"nodeHash": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe",
"bind": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe",
"name": "5",
"expires": "2024-08-24T06:33:32Z"
}},
{{
"nodeHash": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe",
"bind": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe",
"name": "6",
"expires": "2024-08-24T07:57:41Z"
}},
{{
"nodeHash": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe",
"bind": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe",
"name": "7",
"expires": "2023-09-16T19:36:14Z"
}}
],
"0xr4b0bf28adfcee93c5069982a895785c9231c1fe4": [
{{
"nodeHash": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe",
"bind": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe",
"name": "8",
"expires": "{}"
}}
],
"0xr4b0bf28adfcee93c5069982a895785c9231c1fe5": [
{{
"nodeHash": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe",
"bind": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe",
"name": "9",
"expires": "2023-09-03T08:35:40Z"
}}
],
"0xr4b0bf28adfcee93c5069982a895785c9231c1fe6": [
{{
"nodeHash": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe",
"bind": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe",
"name": "000",
"expires": "{}"
}},
{{
"nodeHash": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe",
"bind": "0xr4b0bf28adfcee93c5069982a895785c9231c1fe",
"name": "999",
"expires": "2024-03-19T18:16:59Z"
}}
]
}}
"#,
future_date, future_date, future_date
);

let value: serde_json::Value = serde_json::from_str(response.as_str()).unwrap();
Domains::from_value(&value).unwrap()
}

Expand Down