Skip to content

Commit

Permalink
send b64 genesis
Browse files Browse the repository at this point in the history
Signed-off-by: Nicholas Rempel <[email protected]>
  • Loading branch information
Nicholas Rempel committed May 1, 2020
1 parent 74eb6b9 commit de7838a
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions demo/runners/support/agent.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import asyncio
import asyncpg
import base64
import functools
import json
import logging
Expand Down Expand Up @@ -252,7 +253,13 @@ async def create_and_publish_revocation_registry(

# if PUBLIC_TAILS_URL is specified, upload tails file to tails server
if os.getenv("PUBLIC_TAILS_URL"):
tails_server_hash = await self.admin_PUT_FILE(tails_file, tails_file_url)
b64_genesis = base64.b64encode(str.encode((await default_genesis_txns())))
tails_server_hash = await self.admin_PUT_FILE(
tails_file,
tails_file_url,
params=None,
headers={"X-Genesis-Transactions": b64_genesis.decode("utf-8")}
)
assert my_tails_hash == tails_server_hash.decode("utf-8")
log_msg(f"Public tails file URL: {tails_file_url}")

Expand Down Expand Up @@ -538,11 +545,11 @@ async def admin_GET_FILE(self, path, params=None) -> bytes:
self.log(f"Error during GET FILE {path}: {str(e)}")
raise

async def admin_PUT_FILE(self, file, url, params=None) -> bytes:
async def admin_PUT_FILE(self, file, url, params=None, headers=None) -> bytes:
try:
params = {k: v for (k, v) in (params or {}).items() if v is not None}
resp = await self.client_session.request(
"PUT", url, params=params, data=file
"PUT", url, params=params, data=file, headers=headers
)
resp.raise_for_status()
return await resp.read()
Expand Down

0 comments on commit de7838a

Please sign in to comment.