Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasochem committed Dec 9, 2023
1 parent 5d18e9d commit b414882
Showing 1 changed file with 97 additions and 1 deletion.
98 changes: 97 additions & 1 deletion test/charts/private-chain.expect.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -829,6 +829,10 @@ spec:
extra_args="${extra_args} --operations-pool $(cat /etc/tezos/baker-config/${my_baker_account}_operations_pool)"
fi
if [ -f /etc/tezos/baker-config/${my_baker_account}_dal_node ]; then
extra_args="${extra_args} --dal-node $(cat /etc/tezos/baker-config/${my_baker_account}_dal_node)"
fi
CLIENT="$TEZ_BIN/octez-client -d $CLIENT_DIR"
CMD="$TEZ_BIN/octez-baker-$proto_command -d $CLIENT_DIR"
Expand Down Expand Up @@ -906,6 +910,10 @@ spec:
extra_args="${extra_args} --operations-pool $(cat /etc/tezos/baker-config/${my_baker_account}_operations_pool)"
fi
if [ -f /etc/tezos/baker-config/${my_baker_account}_dal_node ]; then
extra_args="${extra_args} --dal-node $(cat /etc/tezos/baker-config/${my_baker_account}_dal_node)"
fi
CLIENT="$TEZ_BIN/octez-client -d $CLIENT_DIR"
CMD="$TEZ_BIN/octez-baker-$proto_command -d $CLIENT_DIR"
Expand Down Expand Up @@ -983,6 +991,10 @@ spec:
extra_args="${extra_args} --operations-pool $(cat /etc/tezos/baker-config/${my_baker_account}_operations_pool)"
fi
if [ -f /etc/tezos/baker-config/${my_baker_account}_dal_node ]; then
extra_args="${extra_args} --dal-node $(cat /etc/tezos/baker-config/${my_baker_account}_dal_node)"
fi
CLIENT="$TEZ_BIN/octez-client -d $CLIENT_DIR"
CMD="$TEZ_BIN/octez-baker-$proto_command -d $CLIENT_DIR"
Expand Down Expand Up @@ -1060,6 +1072,10 @@ spec:
extra_args="${extra_args} --operations-pool $(cat /etc/tezos/baker-config/${my_baker_account}_operations_pool)"
fi
if [ -f /etc/tezos/baker-config/${my_baker_account}_dal_node ]; then
extra_args="${extra_args} --dal-node $(cat /etc/tezos/baker-config/${my_baker_account}_dal_node)"
fi
CLIENT="$TEZ_BIN/octez-client -d $CLIENT_DIR"
CMD="$TEZ_BIN/octez-baker-$proto_command -d $CLIENT_DIR"
Expand Down Expand Up @@ -1137,6 +1153,10 @@ spec:
extra_args="${extra_args} --operations-pool $(cat /etc/tezos/baker-config/${my_baker_account}_operations_pool)"
fi
if [ -f /etc/tezos/baker-config/${my_baker_account}_dal_node ]; then
extra_args="${extra_args} --dal-node $(cat /etc/tezos/baker-config/${my_baker_account}_dal_node)"
fi
CLIENT="$TEZ_BIN/octez-client -d $CLIENT_DIR"
CMD="$TEZ_BIN/octez-baker-$proto_command -d $CLIENT_DIR"
Expand Down Expand Up @@ -1620,20 +1640,96 @@ spec:
args:
- "-c"
- |
set -e
CLIENT="/usr/local/bin/octez-client --endpoint http://tezos-node-rpc:8732"
OUTPUT=""
until OUTPUT=$($CLIENT rpc get /chains/main/blocks/head/header) && echo "$OUTPUT" | grep '"level":'; do
sleep 2
done
set -x
set -o pipefail
if ! echo "$OUTPUT" | grep '"level": 0,'; then
echo "Chain already activated, considering activation successful and exiting"
exit 0
fi
# Substitute #fromfile with the hex encoded files in question.
# This is for bootstrapped smart rollups.
# Note that this is low-level string substitution with `read`
# Due to the size of the hex-encoded kernel, using `sed` was not possible.
PARAMETERS_FILE='/etc/tezos/parameters.json'
TMP_PARAMETERS_FILE='/etc/tezos/tmp_parameters.json'
# Pattern to search for
pattern='fromfile#'
# Buffer for characters
buffer=''
# Whether 'fromfile#' was detected
detected_fromfile=false
# Process each character
while IFS= read -r -n1 char
do
# Add the character to the buffer
buffer=$(printf "%s%s" "$buffer" "$char")
# If the buffer ends with the pattern
if [ "${buffer%"$pattern"}" != "$buffer" ]
then
detected_fromfile=true
# Clear the buffer
buffer=''
# Read the filename
filename=''
while IFS= read -r -n1 char && [ "$char" != '"' ]
do
filename=$(printf "%s%s" "$filename" "$char")
done
echo "Found kernel file: $filename"
# Check if file exists
if [ ! -f "$filename" ]; then
echo "Kernel file $filename not found!"
exit 1
fi
# Convert the file content to hex and append to the temp file
xxd -p -c 0 "$filename" | tr -d '\n' >> $TMP_PARAMETERS_FILE
# Add a closing double quote
printf '"' >> $TMP_PARAMETERS_FILE
elif [ ${#buffer} -ge ${#pattern} ]
then
# Write the oldest character in the buffer to the temporary file
printf "%s" "${buffer%"${buffer#?}"}" >> $TMP_PARAMETERS_FILE
# Remove the oldest character from the buffer
buffer=${buffer#?}
fi
done < "$PARAMETERS_FILE"
# If there's anything left in the buffer, write it to the file
if [ -n "$buffer" ]
then
printf "%s" "$buffer" >> $TMP_PARAMETERS_FILE
fi
# Replace the original parameters.json file with the modified one only if 'fromfile#' was detected
if $detected_fromfile; then
mv $TMP_PARAMETERS_FILE $PARAMETERS_FILE
echo "Updated JSON saved in '$PARAMETERS_FILE'"
else
rm -f $TMP_PARAMETERS_FILE
echo "No 'fromfile#' detected in '$PARAMETERS_FILE', no changes made."
fi
echo Activating chain:
$CLIENT -d /var/tezos/client --block \
genesis activate protocol \
Expand Down

0 comments on commit b414882

Please sign in to comment.