Skip to content

Commit

Permalink
t8n: write output body to sys.stdout if specified
Browse files Browse the repository at this point in the history
  • Loading branch information
danceratopz committed Aug 24, 2023
1 parent 2a592a8 commit 4cf1654
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/ethereum_spec_tools/evm_tools/t8n/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,17 +404,20 @@ def run(self) -> int:
json_state = self.alloc.to_json()
json_result = self.result.to_json()

json_output = {}

if self.options.output_body:
txs_rlp_path = os.path.join(
self.options.output_basedir,
self.options.output_body,
)
txs_rlp = "0x" + rlp.encode(self.txs.all_txs).hex()
with open(txs_rlp_path, "w") as f:
json.dump(txs_rlp, f)
self.logger.info(f"Wrote transaction rlp to {txs_rlp_path}")

json_output = {}
if self.options.output_body == "stdout":
json_output["body"] = txs_rlp
else:
txs_rlp_path = os.path.join(
self.options.output_basedir,
self.options.output_body,
)
with open(txs_rlp_path, "w") as f:
json.dump(txs_rlp, f)
self.logger.info(f"Wrote transaction rlp to {txs_rlp_path}")

if self.options.output_alloc == "stdout":
json_output["alloc"] = json_state
Expand Down

0 comments on commit 4cf1654

Please sign in to comment.