Skip to content

Commit 23d302b

Browse files
authored
Merge pull request #318 from bandprotocol/add-simulation-oracle
Add simulation test for Oracle module
2 parents d264e4b + e078abb commit 23d302b

29 files changed

+2156
-49
lines changed

.github/workflows/simulation.yml

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
name: Simulation
2+
on: pull_request
3+
4+
jobs:
5+
build:
6+
runs-on: ubuntu-latest
7+
steps:
8+
- uses: actions/checkout@v3
9+
- uses: actions/setup-go@v3
10+
with:
11+
go-version: "1.19"
12+
check-latest: true
13+
- name: Install Wabt (wat2wasm)
14+
run: |
15+
wget https://github.com/WebAssembly/wabt/releases/download/1.0.17/wabt-1.0.17-ubuntu.tar.gz
16+
tar -zxf wabt-1.0.17-ubuntu.tar.gz
17+
sudo cp wabt-1.0.17/bin/wat2wasm ~/go/bin
18+
- name: Install runsim
19+
run: go install github.com/cosmos/tools/cmd/runsim@v1.0.0
20+
- uses: actions/cache@v3
21+
with:
22+
path: ~/go/bin
23+
key: ${{ runner.os }}-go-binary
24+
25+
test-sim-import-export:
26+
runs-on: ubuntu-latest
27+
needs: [build]
28+
timeout-minutes: 45
29+
steps:
30+
- uses: actions/checkout@v3
31+
- uses: actions/setup-go@v3
32+
with:
33+
go-version: "1.19"
34+
check-latest: true
35+
- uses: actions/cache@v3
36+
with:
37+
path: ~/go/bin
38+
key: ${{ runner.os }}-go-binary
39+
- name: test-sim-import-export
40+
run: |
41+
make test-sim-import-export
42+
43+
test-sim-after-import:
44+
runs-on: ubuntu-latest
45+
needs: [build]
46+
timeout-minutes: 45
47+
steps:
48+
- uses: actions/checkout@v3
49+
- uses: actions/setup-go@v3
50+
with:
51+
go-version: "1.19"
52+
check-latest: true
53+
- uses: actions/cache@v3
54+
with:
55+
path: ~/go/bin
56+
key: ${{ runner.os }}-go-binary
57+
- name: test-sim-after-import
58+
run: |
59+
make test-sim-after-import
60+
61+
test-sim-multi-seed-short:
62+
runs-on: ubuntu-latest
63+
needs: [build]
64+
timeout-minutes: 45
65+
steps:
66+
- uses: actions/checkout@v3
67+
- uses: actions/setup-go@v3
68+
with:
69+
go-version: "1.19"
70+
check-latest: true
71+
- uses: actions/cache@v3
72+
with:
73+
path: ~/go/bin
74+
key: ${{ runner.os }}-go-binary
75+
- name: test-sim-multi-seed-short
76+
run: |
77+
make test-sim-multi-seed-short
78+
79+
test-sim-deterministic:
80+
runs-on: ubuntu-latest
81+
needs: [build]
82+
timeout-minutes: 45
83+
steps:
84+
- uses: actions/checkout@v3
85+
- uses: actions/setup-go@v3
86+
with:
87+
go-version: "1.19"
88+
check-latest: true
89+
- uses: actions/cache@v3
90+
with:
91+
path: ~/go/bin
92+
key: ${{ runner.os }}-go-binary
93+
- name: test-sim-deterministic
94+
run: |
95+
make test-sim-deterministic

Makefile

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ VERSION := $(shell echo $(shell git describe --tags) | sed 's/^v//')
33
COMMIT := $(shell git log -1 --format='%H')
44
LEDGER_ENABLED ?= true
55
BINDIR ?= $(GOPATH)/bin
6+
APP = ./app
67

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

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

40+
include contrib/devtools/Makefile
41+
3942
all: install
4043

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

95-
.PHONY: proto-all proto-gen proto-swagger-gen proto-format proto-lint proto-check-breaking
98+
###############################################################################
99+
### Simulation ###
100+
###############################################################################
101+
102+
test-sim-import-export: runsim
103+
@echo "Running application import/export simulation. This may take several minutes..."
104+
@$(BINDIR)/runsim -Jobs=4 -SimAppPkg=$(APP) -ExitOnFail 50 5 TestAppImportExport
105+
106+
test-sim-multi-seed-short: runsim
107+
@echo "Running short multi-seed application simulation. This may take awhile!"
108+
@$(BINDIR)/runsim -Jobs=4 -SimAppPkg=$(APP) -ExitOnFail 50 5 TestFullAppSimulation
109+
110+
test-sim-after-import: runsim
111+
@echo "Running application simulation-after-import. This may take several minutes..."
112+
@$(BINDIR)/runsim -Jobs=4 -SimAppPkg=$(APP) -ExitOnFail 50 5 TestAppSimulationAfterImport
113+
114+
test-sim-deterministic: runsim
115+
@echo "Running application deterministic simulation. This may take awhile!"
116+
@$(BINDIR)/runsim -Jobs=4 -SimAppPkg=$(APP) -ExitOnFail 1 1 TestAppStateDeterminism
117+
118+
.PHONY: proto-all proto-gen proto-swagger-gen proto-format proto-lint proto-check-breaking \
119+
test-sim-import-export test-sim-multi-seed-short test-sim-after-import test-sim-deterministic

app/app.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,14 @@ func NewBandApp(
513513
owasmVM,
514514
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
515515
)
516-
oracleModule := oracle.NewAppModule(app.OracleKeeper, app.GetSubspace(oracletypes.ModuleName))
516+
oracleModule := oracle.NewAppModule(
517+
appCodec,
518+
app.OracleKeeper,
519+
app.AccountKeeper,
520+
app.BankKeeper,
521+
app.StakingKeeper,
522+
app.GetSubspace(oracletypes.ModuleName),
523+
)
517524
oracleIBCModule := oracle.NewIBCModule(app.OracleKeeper)
518525

519526
// Create static IBC router, add transfer route, then set and seal it

0 commit comments

Comments
 (0)