Skip to content

Commit

Permalink
Merge pull request #59 from Agoric/ms/remove-background-voting-loop
Browse files Browse the repository at this point in the history
chore: Remove Background Voting Loop
  • Loading branch information
amessbee authored Sep 11, 2024
2 parents 3c28a51 + 2639959 commit 43e9517
Showing 1 changed file with 2 additions and 57 deletions.
59 changes: 2 additions & 57 deletions contract/scripts/run-chain.sh
Original file line number Diff line number Diff line change
@@ -1,67 +1,12 @@
#!/bin/bash

wait_for_bootstrap() {
endpoint="localhost"
while true; do
if json=$(curl -s --fail -m 15 "$endpoint:26657/status"); then
if [[ "$(echo "$json" | jq -r .jsonrpc)" == "2.0" ]]; then
if last_height=$(echo "$json" | jq -r .result.sync_info.latest_block_height); then
if [[ "$last_height" != "1" ]]; then
echo "$last_height"
return
else
echo "$last_height"
fi
fi
fi
fi
echo "waiting for next block..."
sleep 5
done
echo "done"
}

waitForBlock() (
echo "waiting for block..."
times=${1:-1}
echo "$times"
for ((i = 1; i <= times; i++)); do
b1=$(wait_for_bootstrap)
while true; do
b2=$(wait_for_bootstrap)
if [[ "$b1" != "$b2" ]]; then
echo "block produced"
break
fi
sleep 5
done
done
echo "done"
)

approveProposals() {
while true; do
proposals=$(make -s -C /workspace/contract gov-voting-q 2>/dev/null)
exit_status=$?
if [ $exit_status -eq 0 ]; then
echo "Approving proposals: $proposals"
printf $proposals | xargs -I {} make -s -C /workspace/contract vote PROPOSAL={}
else
echo "No proposals to approve, continuing..."
fi

sleep 10
done
}
. /usr/src/upgrade-test-scripts/env_setup.sh

# Start the chain in the background
/usr/src/upgrade-test-scripts/start_agd.sh &

# wait for blocks to start being produced
waitForBlock 2

# Approve any proposals forever in the background.
approveProposals &
waitForBlock 1

make -C /workspace/contract mint100

Expand Down

0 comments on commit 43e9517

Please sign in to comment.