Skip to content

Commit

Permalink
fix: make scenario2-run-client is now idempotent
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfig committed May 7, 2021
1 parent c83dc19 commit 5f08b89
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions packages/cosmic-swingset/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ GENESIS_TIME = $(shell TZ=UTC date +%Y-%m-%dT%H:%M:%SZ)
GOSRC = ../../golang/cosmos
AG_SOLO = $(shell cd ../solo/bin && pwd)/ag-solo

SHELL = bash

# By default, make the fake chain in scenario3 produce
# "blocks" as soon as they come in.
FAKE_CHAIN_DELAY = 0
Expand Down Expand Up @@ -87,7 +89,18 @@ scenario2-run-client: t1-provision-one-with-powers t1-start-ag-solo
# Provision the ag-solo from an provisionpass-holding address (idempotent).
AGORIC_POWERS = agoric.bankManager,agoric.agoricNamesAdmin,agoric.pegasusConnections,agoric.priceAuthorityAdmin,agoric.treasuryCreator,agoric.vattp
SOLO_COINS = 13000000ubld
t1-provision-one-with-powers:
COSMOS_RPC_HOST = localhost
COSMOS_RPC_PORT = 26657
wait-for-cosmos:
@echo -n "Waiting for $(COSMOS_RPC_HOST):$(COSMOS_RPC_PORT) to come live..."
@while ! curl -s http://$(COSMOS_RPC_HOST):$(COSMOS_RPC_PORT)/status >/dev/null; do \
echo -n '.'; \
sleep 5; \
done
@echo ' done!'
sleep 10 # Generous timeout to wait for chain to be ready

t1-provision-one-with-powers: wait-for-cosmos
addr=$$(cat t1/$(BASE_PORT)/ag-cosmos-helper-address); \
$(AGCH) --home=t1/bootstrap query swingset egress $$addr --chain-id=$(CHAIN_ID) || \
{ $(AGCH) --home=t1/bootstrap tx bank send --keyring-backend=test --from=bootstrap \
Expand All @@ -97,7 +110,7 @@ t1-provision-one-with-powers:
--gas=auto --gas-adjustment=1.2 --broadcast-mode=block --yes --chain-id=$(CHAIN_ID) \
t1/$(BASE_PORT) $$addr $(AGORIC_POWERS) | tee /dev/stderr | grep -q '"code":0'; }

t1-provision-one:
t1-provision-one: wait-for-cosmos
addr=$$(cat t1/$(BASE_PORT)/ag-cosmos-helper-address); \
$(AGCH) --home=t1/bootstrap query swingset egress $$addr --chain-id=$(CHAIN_ID) || \
{ $(AGCH) --home=t1/bootstrap tx bank send --keyring-backend=test --from=bootstrap \
Expand Down Expand Up @@ -168,7 +181,7 @@ set-local-gci-ingress:
set -e; \
gci=`./calc-gci.js t1/n0/config/genesis.json`; \
rpcport=`./calc-rpcport.js t1/n0/config/config.toml`; \
for dir in t1/[0-9]*; do \
(cd $$dir && \
set -e; for port in `seq $(BASE_PORT) $$(($(BASE_PORT) + $(NUM_SOLOS) - 1))`; do \
(cd t1/$$port && \
$(AG_SOLO) set-gci-ingress --chainID=$(CHAIN_ID) $$gci $$rpcport); \
done

0 comments on commit 5f08b89

Please sign in to comment.