Skip to content

Commit

Permalink
fix: insert test tenant binary keys instead of paths
Browse files Browse the repository at this point in the history
  • Loading branch information
0xawaz committed Nov 25, 2024
1 parent 14ae5df commit 3aadd4d
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 22 deletions.
4 changes: 2 additions & 2 deletions fhevm-engine/fhevm-db/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ FROM rust:1.74

# Install dependencies and tools
RUN apt-get update && \
apt-get install -y libpq-dev && \
apt-get install -y libpq-dev postgresql-client vim-common && \
cargo install sqlx-cli --no-default-features --features postgres --locked && \
apt-get clean && rm -rf /var/lib/apt/lists/*

Expand All @@ -16,4 +16,4 @@ COPY fhevm-engine/fhevm-keys /fhevm-keys
RUN chmod +x /initialize_db.sh

# Run the initialization script as the entrypoint
ENTRYPOINT ["/bin/bash", "/initialize_db.sh"]
ENTRYPOINT ["/bin/bash", "/initialize_db.sh"]
29 changes: 29 additions & 0 deletions fhevm-engine/fhevm-db/initialize_db.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,33 @@ sqlx database create
echo "Running migrations..."
sqlx migrate run --source /migrations || { echo "Failed to run migrations."; exit 1; }

# 3. Insert test tenant with keys
echo "Running Insert test tenant..."
TENANT_API_KEY=a1503fb6-d79b-4e9e-826d-44cf262f3e05
ACL_CONTRACT_ADDRESS=0x339EcE85B9E11a3A3AA557582784a15d7F82AAf2
INPUT_VERIFIER_ADDRESS=0x69dE3158643e738a0724418b21a35FAA20CBb1c5

PKS="$(cat /fhevm-keys/pks | xxd -p | tr -d '\n')"
SKS="$(cat /fhevm-keys/sks | xxd -p | tr -d '\n')"
PUBLIC_PARAMS="$(cat /fhevm-keys/pp | xxd -p | tr -d '\n')"
CKS="$(cat /fhevm-keys/cks | xxd -p | tr -d '\n')"

QUERY="
INSERT INTO tenants(tenant_api_key, chain_id, acl_contract_address, verifying_contract_address, pks_key, sks_key, public_params, cks_key)
VALUES (
'${TENANT_API_KEY}',
12345,
'${ACL_CONTRACT_ADDRESS}',
'${INPUT_VERIFIER_ADDRESS}',
decode('${PKS}', 'hex'),
decode('${SKS}', 'hex'),
decode('${PUBLIC_PARAMS}', 'hex'),
decode('${CKS}', 'hex')
)
"

echo $QUERY | psql $DATABASE_URL

echo 'Test tenant insertion done'

echo "Database initialization complete."

This file was deleted.

This file was deleted.

0 comments on commit 3aadd4d

Please sign in to comment.