Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add simulation tests #98

Merged
merged 35 commits into from
Sep 14, 2021
Merged
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
915de21
test: add sim_test
jaybxyz Aug 18, 2021
177e0f2
test: add decoder and its unit tests
jaybxyz Aug 19, 2021
d0ae112
test: add randomized genesis params
jaybxyz Aug 19, 2021
c36aa08
test: add params and unit tests
jaybxyz Aug 19, 2021
0704de1
chore: adding operations
jaybxyz Aug 19, 2021
2c2a710
Merge branch 'master' into kogisin/64-simulation-test
jaybxyz Aug 19, 2021
ee7e739
test: add operations and tests
jaybxyz Aug 20, 2021
34ec306
fix: lint checks
jaybxyz Aug 20, 2021
29f67d6
fix: nolint check for interBlockCacheOpt
jaybxyz Aug 20, 2021
8f03360
test: nolint unused code
jaybxyz Aug 20, 2021
d086a89
lint: last test
jaybxyz Aug 20, 2021
81977c3
chore: fix broken test and add todo for public plan proposal
jaybxyz Aug 20, 2021
8138dfb
chore: fix param changes, randomize epoch days, add farming fee colle…
jaybxyz Aug 21, 2021
9d07300
fix: broken test
jaybxyz Aug 21, 2021
783e3cc
Merge commit '6dea151437ce42ffd0b68c5486fa210195ce6696' into kogisin/…
jaybxyz Sep 2, 2021
5221ea8
docs: fix backticks location
jaybxyz Sep 3, 2021
2d25621
chore: add migration tests, sort imports, fix db to newDB, update Mak…
jaybxyz Sep 3, 2021
a7d3e70
chore: fix simulation logic, add minter permission to module account,…
jaybxyz Sep 6, 2021
9fcb8e3
feat: adding public plan proposals
jaybxyz Sep 6, 2021
13e7406
chore: adding simulation for public plan proposals work in progress
jaybxyz Sep 8, 2021
a9567eb
fix: add check for duplicate name value when creating private plans #101
jaybxyz Sep 8, 2021
ff5f461
test: fix broken tests
jaybxyz Sep 9, 2021
568dec8
chore: remove comments, refactor logic, fixing harvest
jaybxyz Sep 9, 2021
9723a89
build: update github workflow to split simulation jobs
jaybxyz Sep 9, 2021
08ce3b1
chore: add public plans, remove unused test codes and clean up logics
jaybxyz Sep 9, 2021
ef563e9
chore: debugging export and import simulation
jaybxyz Sep 10, 2021
749c19b
Merge branch 'master' into kogisin/88-simulation-public-plan
jaybxyz Sep 10, 2021
3e89634
Merge branch 'master' into kogisin/88-simulation-public-plan
dongsam Sep 13, 2021
279e276
fix: update simulation logics for f1 spec
dongsam Sep 13, 2021
86cb930
fix: fix test plan dates and expected codes, lint
dongsam Sep 13, 2021
a459eaf
fix: lint and validation logic of simulation
dongsam Sep 13, 2021
c20750e
fix: revert test plan and add validation logic for unstake
dongsam Sep 13, 2021
043807f
chore: remove unused test functions
dongsam Sep 13, 2021
af63cac
fix: apply suggested reviews
dongsam Sep 14, 2021
f6222e3
chore: fix lint
dongsam Sep 14, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
120 changes: 120 additions & 0 deletions .github/workflows/sims.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
name: Sims
# Sims workflow runs multiple types of simulations (nondeterminism, import-export, after-import)
# This workflow will run on all Pull Requests, if a .go, .mod or .sum file have been changed
on:
pull_request:
push:
branches:
- master
- develop

jobs:
build:
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, 'skip-sims')"
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2.1.3
with:
go-version: 1.16
- name: Display go version
run: go version
- run: make build

install-runsim:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/setup-go@v2.1.3
with:
go-version: 1.16
- name: Display go version
run: go version
- name: Install runsim
run: export GO111MODULE="on" && go get github.com/cosmos/tools/cmd/runsim@v1.0.0
- uses: actions/cache@v2.1.6
with:
path: ~/go/bin
key: ${{ runner.os }}-go-runsim-binary

test-sim-nondeterminism:
runs-on: ubuntu-latest
needs: [build, install-runsim]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2.1.3
with:
go-version: 1.16
- name: Display go version
run: go version
- uses: technote-space/get-diff-action@v4
with:
PATTERNS: |
**/**.go
go.mod
go.sum
- uses: actions/cache@v2.1.6
with:
path: ~/go/bin
key: ${{ runner.os }}-go-runsim-binary
if: env.GIT_DIFF
- name: test-sim-nondeterminism
run: |
make test-sim-nondeterminism
if: env.GIT_DIFF

# test-sim-import-export:
# runs-on: ubuntu-latest
# needs: [build, install-runsim]
# steps:
# - uses: actions/checkout@v2
# - uses: actions/setup-go@v2.1.3
# with:
# go-version: 1.16
# - name: Display go version
# run: go version
# - uses: technote-space/get-diff-action@v4
# with:
# SUFFIX_FILTER: |
# **/**.go
# go.mod
# go.sum
# SET_ENV_NAME_INSERTIONS: 1
# SET_ENV_NAME_LINES: 1
# - uses: actions/cache@v2.1.6
# with:
# path: ~/go/bin
# key: ${{ runner.os }}-go-runsim-binary
# if: env.GIT_DIFF
# - name: test-sim-import-export
# run: |
# make test-sim-import-export
# if: env.GIT_DIFF

# test-sim-after-import:
# runs-on: ubuntu-latest
# needs: [build, install-runsim]
# steps:
# - uses: actions/checkout@v2
# - uses: actions/setup-go@v2.1.3
# with:
# go-version: 1.16
# - name: Display go version
# run: go version
# - uses: technote-space/get-diff-action@v4
# with:
# SUFFIX_FILTER: |
# **/**.go
# go.mod
# go.sum
# SET_ENV_NAME_INSERTIONS: 1
# SET_ENV_NAME_LINES: 1
# - uses: actions/cache@v2.1.6
# with:
# path: ~/go/bin
# key: ${{ runner.os }}-go-runsim-binary
# if: env.GIT_DIFF
# - name: test-sim-after-import
# run: |
# make test-sim-after-import
# if: env.GIT_DIFF
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,4 @@ jobs:
done
- uses: codecov/codecov-action@v1.0.14
with:
file: ./coverage.txt
file: ./coverage.txt
19 changes: 19 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ BINDIR ?= $(GOPATH)/bin
DOCKER := $(shell which docker)
DOCKER_BUF := $(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace bufbuild/buf
BUILDDIR ?= $(CURDIR)/build
SIMAPP = ./app

export GO111MODULE = on

Expand Down Expand Up @@ -154,6 +155,24 @@ benchmark:

.PHONY: test test-all test-unit test-race test-cover test-build

test-sim-nondeterminism:
@echo "Running non-determinism test..."
@go test -mod=readonly $(SIMAPP) -run TestAppStateDeterminism -Enabled=true \
-NumBlocks=100 -BlockSize=200 -Commit=true -Period=0 -v -timeout 24h

test-sim-import-export: runsim
@echo "Running application import/export simulation. This may take several minutes..."
@$(BINDIR)/runsim -Jobs=4 -SimAppPkg=$(SIMAPP) -ExitOnFail 10 5 TestAppImportExport

test-sim-after-import: runsim
@echo "Running application simulation-after-import. This may take several minutes..."
@$(BINDIR)/runsim -Jobs=4 -SimAppPkg=$(SIMAPP) -ExitOnFail 10 5 TestAppSimulationAfterImport

.PHONY: \
test-sim-nondeterminism \
test-sim-import-export \
test-sim-after-import

###############################################################################
### Localnet ###
###############################################################################
Expand Down
15 changes: 12 additions & 3 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ var (
mint.AppModuleBasic{},
distr.AppModuleBasic{},
gov.NewAppModuleBasic(
paramsclient.ProposalHandler, distrclient.ProposalHandler, upgradeclient.ProposalHandler, upgradeclient.CancelProposalHandler,
paramsclient.ProposalHandler, distrclient.ProposalHandler,
upgradeclient.ProposalHandler, upgradeclient.CancelProposalHandler,
farmingclient.ProposalHandler,
// todo: farming proposal handler
),
params.AppModuleBasic{},
crisis.AppModuleBasic{},
Expand All @@ -137,7 +137,7 @@ var (
stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking},
stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking},
govtypes.ModuleName: {authtypes.Burner},
farmingtypes.ModuleName: nil,
farmingtypes.ModuleName: {authtypes.Minter},
// todo: farming Staking Reserve Coin TBD
}
)
Expand Down Expand Up @@ -580,6 +580,15 @@ func RegisterSwaggerAPI(ctx client.Context, rtr *mux.Router) {
rtr.PathPrefix("/swagger/").Handler(http.StripPrefix("/swagger/", staticServer))
}

// GetMaccPerms returns a copy of the module account permissions
func GetMaccPerms() map[string][]string {
dupMaccPerms := make(map[string][]string)
for k, v := range maccPerms {
dupMaccPerms[k] = v
}
return dupMaccPerms
}

// initParamsKeeper init params keeper and its subspaces
func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino, key, tkey sdk.StoreKey) paramskeeper.Keeper {
paramsKeeper := paramskeeper.NewKeeper(appCodec, legacyAmino, key, tkey)
Expand Down
Loading