Skip to content

Commit 28c15c8

Browse files
authored
Merge pull request #795 from oasisprotocol/andrej/feature/localnet-advance-epoch
Add advance-epoch.sh script to localnet Docker images
2 parents 97a933f + 23c45ae commit 28c15c8

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

docker/common/advance-epoch.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/env bash
2+
#
3+
# This script advances the mock epoch by 1 or by the number of epochs
4+
# given as the first argument to this script.
5+
6+
set -eo pipefail
7+
8+
num_epochs="${1:-1}"
9+
10+
OASIS_NODE_SOCKET=${OASIS_NODE_DATADIR}/net-runner/network/client-0/internal.sock
11+
12+
if [[ "${BEACON_BACKEND:-mock}" != "mock" ]]; then
13+
echo "This command only works with the mock beacon backend."
14+
echo "Run the container with BEACON_BACKEND set to 'mock' to enable it."
15+
exit 1
16+
fi
17+
18+
# Wait for the Oasis Node to start.
19+
while [[ ! -S ${OASIS_NODE_SOCKET} ]]; do sleep 1; done
20+
21+
old_epoch=`${OASIS_NODE_BINARY} control status -a unix:${OASIS_NODE_SOCKET} | jq '.consensus.latest_epoch'`
22+
new_epoch=$((old_epoch + num_epochs))
23+
${OASIS_NODE_BINARY} debug control set-epoch --epoch ${new_epoch} -a unix:${OASIS_NODE_SOCKET}
24+
25+
echo "Epoch advanced from ${old_epoch} to ${new_epoch}."
26+
exit 0

0 commit comments

Comments
 (0)