Skip to content
This repository was archived by the owner on Nov 30, 2021. It is now read-only.

Commit

Permalink
local testnet command
Browse files Browse the repository at this point in the history
  • Loading branch information
fedekunze committed Jul 7, 2020
1 parent a64afb6 commit cacc374
Show file tree
Hide file tree
Showing 8 changed files with 541 additions and 61 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ dist
tools-stamp
proto-tools-stamp
golangci-lint
local_testnet
keyring_test_cosmos

# Testing
coverage.txt
Expand Down
100 changes: 40 additions & 60 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,32 @@ ETHERMINT_DAEMON_BINARY = emintd
ETHERMINT_CLI_BINARY = emintcli
GO_MOD=GO111MODULE=on

This comment has been minimized.

Copy link
@J-Thompson12

J-Thompson12 Jul 22, 2020

Contributor

This isnt really related to this pr and i have a change for it on my next test pr but this command does not work on windows. I have to change it to GO111MODULE=on

BINDIR ?= $(GOPATH)/bin
BUILDDIR ?= $(CURDIR)/build
SIMAPP = github.com/cosmos/ethermint/app
RUNSIM = $(BINDIR)/runsim

all: tools verify install

#######################
### Build / Install ###
#######################
###############################################################################
### Build ###
###############################################################################

build: go.sum
go build -mod=readonly ./...

build-ethermint: go.sum
mkdir -p $(BUILDDIR)
go build -mod=readonly $(BUILD_FLAGS) -o $(BUILDDIR) ./cmd/$(ETHERMINT_DAEMON_BINARY)
go build -mod=readonly $(BUILD_FLAGS) -o $(BUILDDIR) ./cmd/$(ETHERMINT_CLI_BINARY)

build-ethermint-linux: go.sum
GOOS=linux GOARCH=amd64 CGO_ENABLED=1 $(MAKE) build-ethermint

build:
ifeq ($(OS),Windows_NT)
${GO_MOD} go build $(BUILD_FLAGS) -o build/$(ETHERMINT_DAEMON_BINARY).exe ./cmd/emintd
${GO_MOD} go build $(BUILD_FLAGS) -o build/$(ETHERMINT_CLI_BINARY).exe ./cmd/emintcli
else
${GO_MOD} go build $(BUILD_FLAGS) -o build/$(ETHERMINT_DAEMON_BINARY) ./cmd/emintd/
${GO_MOD} go build $(BUILD_FLAGS) -o build/$(ETHERMINT_CLI_BINARY) ./cmd/emintcli/
endif
.PHONY: build build-ethermint build-ethermint-linux

install:
${GO_MOD} go install $(BUILD_FLAGS) ./cmd/emintd
${GO_MOD} go install $(BUILD_FLAGS) ./cmd/emintcli
${GO_MOD} go install $(BUILD_FLAGS) ./cmd/$(ETHERMINT_DAEMON_BINARY)
${GO_MOD} go install $(BUILD_FLAGS) ./cmd/$(ETHERMINT_CLI_BINARY)

clean:
@rm -rf ./build ./vendor
Expand Down Expand Up @@ -91,48 +96,6 @@ $(RUNSIM):
@(cd /tmp && go get github.com/cosmos/tools/cmd/[email protected])

tools: $(RUNSIM)
ifdef GOLINT_CHECK
@echo "Golint is already installed. Run 'make update-tools' to update."
else
@echo "--> Installing golint"
${GO_MOD} go get -v $(GOLINT)
endif
ifdef GOCILINT_CHECK
@echo "golangci-lint is already installed. Run 'make update-tools' to update."
else
@echo "--> Installing golangci-lint"
${GO_MOD} go get -v $(GOCILINT)
endif
ifdef UNCONVERT_CHECK
@echo "Unconvert is already installed. Run 'make update-tools' to update."
else
@echo "--> Installing unconvert"
${GO_MOD} go get -v $(UNCONVERT)
endif
ifdef INEFFASSIGN_CHECK
@echo "Ineffassign is already installed. Run 'make update-tools' to update."
else
@echo "--> Installing ineffassign"
${GO_MOD} go get -v $(INEFFASSIGN)
endif
ifdef MISSPELL_CHECK
@echo "misspell is already installed. Run 'make update-tools' to update."
else
@echo "--> Installing misspell"
${GO_MOD} go get -v $(MISSPELL)
endif
ifdef ERRCHECK_CHECK
@echo "errcheck is already installed. Run 'make update-tools' to update."
else
@echo "--> Installing errcheck"
${GO_MOD} go get -v $(ERRCHECK)
endif
ifdef UNPARAM_CHECK
@echo "unparam is already installed. Run 'make update-tools' to update."
else
@echo "--> Installing unparam"
${GO_MOD} go get -v $(UNPARAM)
endif


#######################
Expand Down Expand Up @@ -266,8 +229,8 @@ test-sim-nondeterminism:

test-sim-custom-genesis-fast:
@echo "Running custom genesis simulation..."
@echo "By default, ${HOME}/.emintd/config/genesis.json will be used."
@go test -mod=readonly $(SIMAPP) -run TestFullAppSimulation -Genesis=${HOME}/.emintd/config/genesis.json \
@echo "By default, ${HOME}/.$(ETHERMINT_DAEMON_BINARY)/config/genesis.json will be used."
@go test -mod=readonly $(SIMAPP) -run TestFullAppSimulation -Genesis=${HOME}/.$(ETHERMINT_DAEMON_BINARY)/config/genesis.json \
-Enabled=true -NumBlocks=100 -BlockSize=200 -Commit=true -Seed=99 -Period=5 -v -timeout 24h

test-sim-import-export: runsim
Expand All @@ -280,8 +243,8 @@ test-sim-after-import: runsim

test-sim-custom-genesis-multi-seed: runsim
@echo "Running multi-seed custom genesis simulation..."
@echo "By default, ${HOME}/.emintd/config/genesis.json will be used."
@$(BINDIR)/runsim -Jobs=4 -Genesis=${HOME}/.emintd/config/genesis.json 400 5 TestFullAppSimulation
@echo "By default, ${HOME}/.$(ETHERMINT_DAEMON_BINARY)/config/genesis.json will be used."
@$(BINDIR)/runsim -Jobs=4 -Genesis=${HOME}/.$(ETHERMINT_DAEMON_BINARY)/config/genesis.json 400 5 TestFullAppSimulation

test-sim-multi-seed-long: runsim
@echo "Running multi-seed application simulation. This may take awhile!"
Expand Down Expand Up @@ -310,4 +273,21 @@ docs-serve:
docs-build:
@cd docs && \
npm install && \
npm run build
npm run build

###############################################################################
### Localnet ###
###############################################################################

build-docker-local-ethermint:
@$(MAKE) -C networks/local

# Run a 4-node testnet locally
localnet-start: build-ethermint-linux localnet-stop
@if ! [ -f build/node0/$(ETHERMINT_DAEMON_BINARY)/config/genesis.json ]; then docker run --rm -v $(CURDIR)/build:/$(ETHERMINT_DAEMON_BINARY):Z ethermint/node testnet --v 4 -o . --starting-ip-address 192.168.10.2 --keyring-backend=test ; fi
docker-compose up -d

localnet-stop:
docker-compose down

.PHONY: build-docker-local-ethermint localnet-start localnet-stop
2 changes: 1 addition & 1 deletion cmd/emintd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func main() {
app.DefaultNodeHome, app.DefaultCLIHome,
),
genutilcli.ValidateGenesisCmd(ctx, cdc, app.ModuleBasics),

testnetCmd(ctx, cdc, app.ModuleBasics, bank.GenesisBalancesIterator{}),
// AddGenesisAccountCmd allows users to add accounts to the genesis file
AddGenesisAccountCmd(ctx, cdc, appCodec, app.DefaultNodeHome, app.DefaultCLIHome),
flags.NewCompletionCmd(rootCmd, true),
Expand Down
Loading

0 comments on commit cacc374

Please sign in to comment.