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

Add simulation test for Oracle module #318

Merged
merged 17 commits into from
Feb 22, 2024
Merged
95 changes: 95 additions & 0 deletions .github/workflows/simulation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
name: Simulation
on: pull_request

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: "1.19"
check-latest: true
- name: Install Wabt (wat2wasm)
run: |
wget https://github.com/WebAssembly/wabt/releases/download/1.0.17/wabt-1.0.17-ubuntu.tar.gz
tar -zxf wabt-1.0.17-ubuntu.tar.gz
sudo cp wabt-1.0.17/bin/wat2wasm ~/go/bin
- name: Install runsim
run: go install github.com/cosmos/tools/cmd/runsim@v1.0.0
- uses: actions/cache@v3
with:
path: ~/go/bin
key: ${{ runner.os }}-go-binary

test-sim-import-export:
runs-on: ubuntu-latest
needs: [build]
timeout-minutes: 45
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: "1.19"
check-latest: true
- uses: actions/cache@v3
with:
path: ~/go/bin
key: ${{ runner.os }}-go-binary
- name: test-sim-import-export
run: |
make test-sim-import-export

test-sim-after-import:
runs-on: ubuntu-latest
needs: [build]
timeout-minutes: 45
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: "1.19"
check-latest: true
- uses: actions/cache@v3
with:
path: ~/go/bin
key: ${{ runner.os }}-go-binary
- name: test-sim-after-import
run: |
make test-sim-after-import

test-sim-multi-seed-short:
runs-on: ubuntu-latest
needs: [build]
timeout-minutes: 45
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: "1.19"
check-latest: true
- uses: actions/cache@v3
with:
path: ~/go/bin
key: ${{ runner.os }}-go-binary
- name: test-sim-multi-seed-short
run: |
make test-sim-multi-seed-short

test-sim-deterministic:
runs-on: ubuntu-latest
needs: [build]
timeout-minutes: 45
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: "1.19"
check-latest: true
- uses: actions/cache@v3
with:
path: ~/go/bin
key: ${{ runner.os }}-go-binary
- name: test-sim-deterministic
run: |
make test-sim-deterministic
26 changes: 25 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ VERSION := $(shell echo $(shell git describe --tags) | sed 's/^v//')
COMMIT := $(shell git log -1 --format='%H')
LEDGER_ENABLED ?= true
BINDIR ?= $(GOPATH)/bin
APP = ./app

DOCKER := $(shell which docker)
DOCKER_BUF := $(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace bufbuild/buf
Expand Down Expand Up @@ -36,6 +37,8 @@ ldflags := $(strip $(ldflags))

BUILD_FLAGS := -tags "$(build_tags_comma_sep)" -ldflags '$(ldflags)'

include contrib/devtools/Makefile

all: install

install: go.sum
Expand Down Expand Up @@ -92,4 +95,25 @@ proto-lint:
proto-check-breaking:
@$(protoImage) buf breaking --against $(HTTPS_GIT)#branch=main

.PHONY: proto-all proto-gen proto-swagger-gen proto-format proto-lint proto-check-breaking
###############################################################################
### Simulation ###
###############################################################################

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

test-sim-multi-seed-short: runsim
@echo "Running short multi-seed application simulation. This may take awhile!"
@$(BINDIR)/runsim -Jobs=4 -SimAppPkg=$(APP) -ExitOnFail 50 5 TestFullAppSimulation

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

test-sim-deterministic: runsim
@echo "Running application deterministic simulation. This may take awhile!"
@$(BINDIR)/runsim -Jobs=4 -SimAppPkg=$(APP) -ExitOnFail 1 1 TestAppStateDeterminism

.PHONY: proto-all proto-gen proto-swagger-gen proto-format proto-lint proto-check-breaking \
test-sim-import-export test-sim-multi-seed-short test-sim-after-import test-sim-deterministic
9 changes: 8 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,14 @@ func NewBandApp(
owasmVM,
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)
oracleModule := oracle.NewAppModule(app.OracleKeeper, app.GetSubspace(oracletypes.ModuleName))
oracleModule := oracle.NewAppModule(
appCodec,
app.OracleKeeper,
app.AccountKeeper,
app.BankKeeper,
app.StakingKeeper,
app.GetSubspace(oracletypes.ModuleName),
)
oracleIBCModule := oracle.NewIBCModule(app.OracleKeeper)

// Create static IBC router, add transfer route, then set and seal it
Expand Down
Loading
Loading