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

Automatically updating the repl file with the fixtures #217

Open
huitseeker opened this issue Sep 11, 2024 · 1 comment
Open

Automatically updating the repl file with the fixtures #217

huitseeker opened this issue Sep 11, 2024 · 1 comment
Labels
CI Related to CI in our repository

Comments

@huitseeker
Copy link
Member

Unfortunately I don't know of a good way of loading the data from a .json file inside the .repl test file, so for now we would still need to manually update the repl file with the new data from the fixtures for future tests. (i.e. the fixture-generator will only update the .json files)

Originally posted by @wwared in #216 (review)

@huitseeker
Copy link
Member Author

This jq-based script might help?

#!/bin/bash

# Paths to the fixture files
EPOCH_CHANGE_FIXTURE="ethereum/pact/fixtures/epoch_change_fixture.json"
INCLUSION_FIXTURE="ethereum/pact/fixtures/inclusion_fixture.json"
TEST_REPL="ethereum/pact/test.repl"

# Extract values from the epoch change fixture
PUBLIC_VALUES_EPOCH=$(jq -r '.publicValues' "$EPOCH_CHANGE_FIXTURE")
VERIFIER_KEY_EPOCH=$(jq -r '.vkey' "$EPOCH_CHANGE_FIXTURE")
PROOF_EPOCH=$(jq -r '.proof' "$EPOCH_CHANGE_FIXTURE")

# Extract values from the inclusion fixture
PUBLIC_VALUES_INCLUSION=$(jq -r '.publicValues' "$INCLUSION_FIXTURE")
VERIFIER_KEY_INCLUSION=$(jq -r '.vkey' "$INCLUSION_FIXTURE")
PROOF_INCLUSION=$(jq -r '.proof' "$INCLUSION_FIXTURE")

# Update inclusion-event-processing line in test.repl
INCLUSION_LINE="(inclusion-event-processing {'public-values: \"$PUBLIC_VALUES_INCLUSION\", 'verifier-key: \"$VERIFIER_KEY_INCLUSION\", 'proof: \"$PROOF_INCLUSION\"})"
sed -i "/inclusion-event-processing/c\\$INCLUSION_LINE" "$TEST_REPL"

# Update committee-change-event-processing line in test.repl
COMMITTEE_CHANGE_LINE="(committee-change-event-processing {'public-values: \"$PUBLIC_VALUES_EPOCH\", 'verifier-key: \"$VERIFIER_KEY_EPOCH\", 'proof: \"$PROOF_EPOCH\"})"
sed -i "/committee-change-event-processing/c\\$COMMITTEE_CHANGE_LINE" "$TEST_REPL"

echo "Updated event-processing lines in ethereum/pact/test.repl with values from fixture files."

@tchataigner tchataigner added the CI Related to CI in our repository label Sep 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI Related to CI in our repository
Projects
None yet
Development

No branches or pull requests

2 participants