Skip to content

Commit 3823fcc

Browse files
author
Woosang Son
authored
feat: use fastcache (#164)
* feat: use fastcache for interblock cache * feat: add prometheus metric * feat: add more cache metric; bytes size, entry count * chore: param caching * feat: use fastcache as iavl nodedb cache * chore: remove debugging code; fix lint error * chore: fix lint error * chore: raise codecov * chore: raise codecov, modify metric description * chore: raise codecov * chore: disable Pseudo-Comparison of codecov * chore: trying codecov to succeed * chore: release threashold of coverage to update base report * chore: trying codecov to succeed * chore: base coverage is too low. lower target * chore: enable codecov app, modules, client * chore: enable codecov patch * chore: use telemetry instead of prometheus
1 parent 31fab61 commit 3823fcc

23 files changed

+295
-89
lines changed

baseapp/options.go

+12
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55
"io"
66

7+
"github.com/line/lbm-sdk/v2/store/iavl"
78
tmdb "github.com/line/tm-db/v2"
89

910
"github.com/line/lbm-sdk/v2/codec/types"
@@ -63,6 +64,17 @@ func SetInterBlockCache(cache sdk.MultiStorePersistentCache) func(*BaseApp) {
6364
return func(app *BaseApp) { app.setInterBlockCache(cache) }
6465
}
6566

67+
// SetIAVLCacheManager provides a BaseApp option function that sets the iavl CacheManager
68+
func SetIAVLCacheManager(size int) func(*BaseApp) {
69+
return func(app *BaseApp) {
70+
if size == 0 {
71+
app.cms.SetIAVLCacheManager(iavl.NewCacheManagerNoCache())
72+
} else {
73+
app.cms.SetIAVLCacheManager(iavl.NewCacheManagerSingleton(size))
74+
}
75+
}
76+
}
77+
6678
// SetSnapshotInterval sets the snapshot interval.
6779
func SetSnapshotInterval(interval uint64) func(*BaseApp) {
6880
return func(app *BaseApp) { app.SetSnapshotInterval(interval) }

codecov.yml

+26-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ coverage:
1717
project:
1818
default:
1919
# basic
20-
target: 75
20+
target: 20
2121
threshold: 1% # allow this much decrease on project
2222
base: auto
2323
# advanced
@@ -28,12 +28,36 @@ coverage:
2828
only_pulls: false
2929
flags: null
3030
paths: null
31+
app:
32+
target: 70%
33+
flags:
34+
- app
35+
modules:
36+
target: 70%
37+
flags:
38+
- modules
39+
client:
40+
flags:
41+
- client
3142
changes: false
32-
patch: off
3343
precision: 2
3444
range: 50...90
3545
round: down
3646

47+
flags:
48+
app:
49+
paths:
50+
- "app/"
51+
- "baseapp/"
52+
modules:
53+
paths:
54+
- "x/"
55+
- "!x/**/client/" # ignore client package
56+
client:
57+
paths:
58+
- "client/"
59+
- "x/**/client/"
60+
3761
parsers:
3862
gcov:
3963
branch_detection:

go.mod

+4-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ require (
66
github.com/99designs/keyring v1.1.6
77
github.com/CosmWasm/wasmvm v0.14.0-beta1
88
github.com/DataDog/zstd v1.4.5 // indirect
9+
github.com/VictoriaMetrics/fastcache v1.5.8
910
github.com/armon/go-metrics v0.3.6
1011
github.com/bgentry/speakeasy v0.1.0
1112
github.com/btcsuite/btcd v0.21.0-beta
@@ -15,6 +16,7 @@ require (
1516
github.com/cosmos/ledger-cosmos-go v0.11.1
1617
github.com/dvsekhvalnov/jose2go v0.0.0-20200901110807-248326c1351b
1718
github.com/enigmampc/btcutil v1.0.3-0.20200723161021-e2fb6adb2a25
19+
github.com/go-kit/kit v0.10.0
1820
github.com/gogo/gateway v1.1.0
1921
github.com/gogo/protobuf v1.3.3
2022
github.com/golang/mock v1.4.4
@@ -25,8 +27,8 @@ require (
2527
github.com/gorilla/mux v1.8.0
2628
github.com/grpc-ecosystem/go-grpc-middleware v1.2.2
2729
github.com/grpc-ecosystem/grpc-gateway v1.16.0
28-
github.com/hashicorp/golang-lru v0.5.4
29-
github.com/line/iavl/v2 v2.0.0-init.1.0.20210429094929-4f43a5568053
30+
github.com/hashicorp/golang-lru v0.5.4 // indirect
31+
github.com/line/iavl/v2 v2.0.0-init.1.0.20210507092458-8331d3daef36
3032
github.com/line/ostracon v0.34.9-0.20210429084710-ef4fe0a40c7d
3133
github.com/line/tm-db/v2 v2.0.0-init.1.0.20210413083915-5bb60e117524
3234
github.com/magiconair/properties v1.8.4

go.sum

+8-2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ github.com/OneOfOne/xxhash v1.2.2 h1:KMrpdQIwFcEqXDklaen+P1axHaj9BSKzvpUUfnHldSE
2626
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
2727
github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo=
2828
github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI=
29+
github.com/VictoriaMetrics/fastcache v1.5.8 h1:XW+YVx9lEXITBVv35ugK9OyotdNJVcbza69o3jmqWuI=
30+
github.com/VictoriaMetrics/fastcache v1.5.8/go.mod h1:SiMZNgwEPJ9qWLshu9tyuE6bKc9ZWYhcNV/L7jurprQ=
2931
github.com/VividCortex/gohistogram v1.0.0 h1:6+hBz+qvs0JOrrNhhmR7lFxo5sINxBCGXrdtl/UvroE=
3032
github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g=
3133
github.com/Workiva/go-datastructures v1.0.52 h1:PLSK6pwn8mYdaoaCZEMsXBpBotr4HHn9abU0yMQt0NI=
@@ -37,6 +39,8 @@ github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuy
3739
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
3840
github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
3941
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho=
42+
github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156 h1:eMwmnE/GDgah4HI848JfFxHt+iPb26b4zyfspmqY0/8=
43+
github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM=
4044
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
4145
github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ=
4246
github.com/apache/thrift v0.13.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ=
@@ -199,6 +203,8 @@ github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw
199203
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
200204
github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4=
201205
github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
206+
github.com/golang/snappy v0.0.3 h1:fHPg5GQYlCeLIPB9BZqMVR5nR9A+IM5zcgeTdjMYmLA=
207+
github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
202208
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
203209
github.com/google/btree v1.0.0 h1:0udJVsspx3VBr5FwtLhQQtuAsVc79tTq0ocGIPAU6qo=
204210
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
@@ -324,8 +330,8 @@ github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-b
324330
github.com/lightstep/lightstep-tracer-go v0.18.1/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4=
325331
github.com/line/gorocksdb v0.0.0-20210406043732-d4bea34b6d55 h1:cXVtMiJkvQ4kn0pxM2svH1ncJbFgQsLHtnFC9qJj2VM=
326332
github.com/line/gorocksdb v0.0.0-20210406043732-d4bea34b6d55/go.mod h1:DHRJroSL7NaRkpvocRx3OtRsleXVsYSxBI9SfHFlTQ0=
327-
github.com/line/iavl/v2 v2.0.0-init.1.0.20210429094929-4f43a5568053 h1:9uIrVlyHps0eZxyaVUypYkFKU0mhMsy7ucnfH2B1EoQ=
328-
github.com/line/iavl/v2 v2.0.0-init.1.0.20210429094929-4f43a5568053/go.mod h1:13R+3/WL61XaVzzYJiVMhBfW+ysG+pWDFmPSUms8JEI=
333+
github.com/line/iavl/v2 v2.0.0-init.1.0.20210507092458-8331d3daef36 h1:811bq0lFSv91AsR9mikOs+ArELnxVeNuYWh8QYUkL6k=
334+
github.com/line/iavl/v2 v2.0.0-init.1.0.20210507092458-8331d3daef36/go.mod h1:0Xz+0i1nlB9lrjUDEwpDRhcmjfEAkOjd20dRb40FBso=
329335
github.com/line/ostracon v0.34.9-0.20210429084710-ef4fe0a40c7d h1:/6vnjrk3SpCUUiIDBv8UzbYexabZBYXxkwyc3Bp9hPo=
330336
github.com/line/ostracon v0.34.9-0.20210429084710-ef4fe0a40c7d/go.mod h1:ttnbq+yQJMQ9a2MT5SEisOoa/+pOgh2KenTiK/rVdiw=
331337
github.com/line/tm-db/v2 v2.0.0-init.1.0.20210413083915-5bb60e117524 h1:eKXXnUm1SblC0AIXAMNDaSyvIbQ50yXqFbh9+Q8Kjvg=

server/config/config.go

+18-8
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import (
44
"fmt"
55
"strings"
66

7+
"github.com/line/lbm-sdk/v2/store/cache"
8+
"github.com/line/lbm-sdk/v2/store/iavl"
79
"github.com/spf13/viper"
810

911
storetypes "github.com/line/lbm-sdk/v2/store/types"
@@ -65,6 +67,12 @@ type BaseConfig struct {
6567
// IndexEvents defines the set of events in the form {eventType}.{attributeKey},
6668
// which informs Tendermint what to index. If empty, all events will be indexed.
6769
IndexEvents []string `mapstructure:"index-events"`
70+
71+
// Interblock cache size; bytes size unit
72+
InterBlockCacheSize int `mapstructure:"inter-block-cache-size"`
73+
74+
// IAVL cache size; bytes size unit
75+
IAVLCacheSize int `mapstructure:"iavl-cache-size"`
6876
}
6977

7078
// APIConfig defines the API listener configuration.
@@ -163,14 +171,16 @@ func (c *Config) GetMinGasPrices() sdk.DecCoins {
163171
func DefaultConfig() *Config {
164172
return &Config{
165173
BaseConfig: BaseConfig{
166-
MinGasPrices: defaultMinGasPrices,
167-
InterBlockCache: true,
168-
Pruning: storetypes.PruningOptionDefault,
169-
PruningKeepRecent: "0",
170-
PruningKeepEvery: "0",
171-
PruningInterval: "0",
172-
MinRetainBlocks: 0,
173-
IndexEvents: make([]string, 0),
174+
MinGasPrices: defaultMinGasPrices,
175+
InterBlockCache: true,
176+
InterBlockCacheSize: cache.DefaultCommitKVStoreCacheSize,
177+
IAVLCacheSize: iavl.DefaultIAVLCacheSize,
178+
Pruning: storetypes.PruningOptionDefault,
179+
PruningKeepRecent: "0",
180+
PruningKeepEvery: "0",
181+
PruningInterval: "0",
182+
MinRetainBlocks: 0,
183+
IndexEvents: make([]string, 0),
174184
},
175185
Telemetry: telemetry.Config{
176186
Enabled: false,

server/config/toml.go

+6
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@ min-retain-blocks = {{ .BaseConfig.MinRetainBlocks }}
6363
# InterBlockCache enables inter-block caching.
6464
inter-block-cache = {{ .BaseConfig.InterBlockCache }}
6565
66+
# InterBlockCacheSize is the maximum bytes size of the inter-block cache.
67+
inter-block-cache-size = {{ .BaseConfig.InterBlockCacheSize }}
68+
69+
# IAVLCacheSize is the maximum bytes size of iavl node cache
70+
iavl-cache-size = {{ .BaseConfig.IAVLCacheSize }}
71+
6672
# IndexEvents defines the set of events in the form {eventType}.{attributeKey},
6773
# which informs Tendermint what to index. If empty, all events will be indexed.
6874
#

server/mock/store.go

+8
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ func (ms multiStore) Restore(
117117
panic("not implemented")
118118
}
119119

120+
func (ms multiStore) SetIAVLCacheManager(cacheManager store.CacheManager) {
121+
panic("not implemented")
122+
}
123+
120124
var _ sdk.KVStore = kvStore{}
121125

122126
type kvStore struct {
@@ -181,6 +185,10 @@ func (kv kvStore) ReverseSubspaceIterator(prefix []byte) sdk.Iterator {
181185
panic("not implemented")
182186
}
183187

188+
func (kv kvStore) SetIAVLCacheManager(cacheManager store.CacheManager) {
189+
panic("not implemented")
190+
}
191+
184192
func NewCommitMultiStore() sdk.CommitMultiStore {
185193
return multiStore{kv: make(map[sdk.StoreKey]kvStore)}
186194
}

server/mock/store_test.go

+2
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,6 @@ func TestStore(t *testing.T) {
3232
require.False(t, store.Has(k))
3333
require.Panics(t, func() { store.Set([]byte(""), v) }, "setting an empty key should panic")
3434
require.Panics(t, func() { store.Set(nil, v) }, "setting a nil key should panic")
35+
36+
require.Panics(t, func() { cms.SetIAVLCacheManager(nil) }, "not implemented")
3537
}

server/start.go

+19-12
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import (
88
"runtime/pprof"
99
"time"
1010

11+
"github.com/line/lbm-sdk/v2/store/cache"
12+
"github.com/line/lbm-sdk/v2/store/iavl"
1113
"github.com/line/ostracon/abci/server"
1214
ostcmd "github.com/line/ostracon/cmd/ostracon/commands"
1315
ostos "github.com/line/ostracon/libs/os"
@@ -30,18 +32,21 @@ import (
3032

3133
// Ostracon full-node start flags
3234
const (
33-
flagWithOstracon = "with-ostracon"
34-
flagAddress = "address"
35-
flagTransport = "transport"
36-
flagTraceStore = "trace-store"
37-
flagCPUProfile = "cpu-profile"
38-
FlagMinGasPrices = "minimum-gas-prices"
39-
FlagHaltHeight = "halt-height"
40-
FlagHaltTime = "halt-time"
41-
FlagInterBlockCache = "inter-block-cache"
42-
FlagUnsafeSkipUpgrades = "unsafe-skip-upgrades"
43-
FlagTrace = "trace"
44-
FlagInvCheckPeriod = "inv-check-period"
35+
flagWithOstracon = "with-ostracon"
36+
flagAddress = "address"
37+
flagTransport = "transport"
38+
flagTraceStore = "trace-store"
39+
flagCPUProfile = "cpu-profile"
40+
FlagMinGasPrices = "minimum-gas-prices"
41+
FlagHaltHeight = "halt-height"
42+
FlagHaltTime = "halt-time"
43+
FlagInterBlockCache = "inter-block-cache"
44+
FlagInterBlockCacheSize = "inter-block-cache-size"
45+
FlagIAVLCacheSize = "iavl-cache-size"
46+
FlagUnsafeSkipUpgrades = "unsafe-skip-upgrades"
47+
FlagTrace = "trace"
48+
FlagInvCheckPeriod = "inv-check-period"
49+
FlagPrometheus = "prometheus"
4550

4651
FlagPruning = "pruning"
4752
FlagPruningKeepRecent = "pruning-keep-recent"
@@ -138,6 +143,8 @@ which accepts a path for the resulting pprof file.
138143
cmd.Flags().Uint64(FlagHaltHeight, 0, "Block height at which to gracefully halt the chain and shutdown the node")
139144
cmd.Flags().Uint64(FlagHaltTime, 0, "Minimum block time (in Unix seconds) at which to gracefully halt the chain and shutdown the node")
140145
cmd.Flags().Bool(FlagInterBlockCache, true, "Enable inter-block caching")
146+
cmd.Flags().Int(FlagInterBlockCacheSize, cache.DefaultCommitKVStoreCacheSize, "The maximum bytes size of the inter-block cache")
147+
cmd.Flags().Int(FlagIAVLCacheSize, iavl.DefaultIAVLCacheSize, "The maximum bytes size of the iavl node cache")
141148
cmd.Flags().String(flagCPUProfile, "", "Enable CPU profiling and write to the provided file")
142149
cmd.Flags().Bool(FlagTrace, false, "Provide full stack traces for errors in ABCI Log")
143150
cmd.Flags().String(FlagPruning, storetypes.PruningOptionDefault, "Pruning strategy (default|nothing|everything|custom)")

simapp/sim_test.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"os"
88
"testing"
99

10+
"github.com/line/lbm-sdk/v2/store/cache"
1011
abci "github.com/line/ostracon/abci/types"
1112
"github.com/line/ostracon/libs/log"
1213
ostproto "github.com/line/ostracon/proto/ostracon/types"
@@ -53,7 +54,7 @@ func fauxMerkleModeOpt(bapp *baseapp.BaseApp) {
5354
// interBlockCacheOpt returns a BaseApp option function that sets the persistent
5455
// inter-block write-through cache.
5556
func interBlockCacheOpt() func(*baseapp.BaseApp) {
56-
return baseapp.SetInterBlockCache(store.NewCommitKVStoreCacheManager())
57+
return baseapp.SetInterBlockCache(store.NewCommitKVStoreCacheManager(cache.DefaultCommitKVStoreCacheSize))
5758
}
5859

5960
func TestFullAppSimulation(t *testing.T) {
@@ -299,7 +300,8 @@ func TestAppStateDeterminism(t *testing.T) {
299300
}
300301

301302
db := memdb.NewDB()
302-
app := NewSimApp(logger, db, nil, true, map[int64]bool{}, DefaultNodeHome, FlagPeriodValue, MakeTestEncodingConfig(), EmptyAppOptions{}, interBlockCacheOpt())
303+
app := NewSimApp(logger, db, nil, true, map[int64]bool{}, DefaultNodeHome, FlagPeriodValue,
304+
MakeTestEncodingConfig(), EmptyAppOptions{}, interBlockCacheOpt())
303305

304306
fmt.Printf(
305307
"running non-determinism simulation; seed %d: %d/%d, attempt: %d/%d\n",

simapp/simd/cmd/root.go

+9-8
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,6 @@ import (
66
"os"
77
"path/filepath"
88

9-
ostcli "github.com/line/ostracon/libs/cli"
10-
"github.com/line/ostracon/libs/log"
11-
tmdb "github.com/line/tm-db/v2"
12-
"github.com/spf13/cast"
13-
"github.com/spf13/cobra"
14-
159
"github.com/line/lbm-sdk/v2/baseapp"
1610
"github.com/line/lbm-sdk/v2/client"
1711
"github.com/line/lbm-sdk/v2/client/debug"
@@ -32,6 +26,11 @@ import (
3226
banktypes "github.com/line/lbm-sdk/v2/x/bank/types"
3327
"github.com/line/lbm-sdk/v2/x/crisis"
3428
genutilcli "github.com/line/lbm-sdk/v2/x/genutil/client/cli"
29+
ostcli "github.com/line/ostracon/libs/cli"
30+
"github.com/line/ostracon/libs/log"
31+
tmdb "github.com/line/tm-db/v2"
32+
"github.com/spf13/cast"
33+
"github.com/spf13/cobra"
3534
)
3635

3736
// NewRootCmd creates a new root command for simd. It is called once in the
@@ -158,7 +157,8 @@ func (a appCreator) newApp(logger log.Logger, db tmdb.DB, traceStore io.Writer,
158157
var cache sdk.MultiStorePersistentCache
159158

160159
if cast.ToBool(appOpts.Get(server.FlagInterBlockCache)) {
161-
cache = store.NewCommitKVStoreCacheManager()
160+
cache = store.NewCommitKVStoreCacheManager(
161+
cast.ToInt(appOpts.Get(server.FlagInterBlockCacheSize)))
162162
}
163163

164164
skipUpgradeHeights := make(map[int64]bool)
@@ -193,8 +193,9 @@ func (a appCreator) newApp(logger log.Logger, db tmdb.DB, traceStore io.Writer,
193193
baseapp.SetHaltTime(cast.ToUint64(appOpts.Get(server.FlagHaltTime))),
194194
baseapp.SetMinRetainBlocks(cast.ToUint64(appOpts.Get(server.FlagMinRetainBlocks))),
195195
baseapp.SetInterBlockCache(cache),
196-
baseapp.SetIndexEvents(cast.ToStringSlice(appOpts.Get(server.FlagIndexEvents))),
196+
baseapp.SetIAVLCacheManager(cast.ToInt(appOpts.Get(server.FlagIAVLCacheSize))),
197197
baseapp.SetTrace(cast.ToBool(appOpts.Get(server.FlagTrace))),
198+
baseapp.SetIndexEvents(cast.ToStringSlice(appOpts.Get(server.FlagIndexEvents))),
198199
baseapp.SetSnapshotStore(snapshotStore),
199200
baseapp.SetSnapshotInterval(cast.ToUint64(appOpts.Get(server.FlagStateSyncSnapshotInterval))),
200201
baseapp.SetSnapshotKeepRecent(cast.ToUint32(appOpts.Get(server.FlagStateSyncSnapshotKeepRecent))),

simapp/simd/cmd/root_test.go

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package cmd
2+
3+
import (
4+
"os"
5+
"testing"
6+
7+
"github.com/line/lbm-sdk/v2/client/flags"
8+
"github.com/line/lbm-sdk/v2/server"
9+
"github.com/line/lbm-sdk/v2/simapp"
10+
"github.com/line/lbm-sdk/v2/store/types"
11+
"github.com/line/ostracon/libs/log"
12+
"github.com/line/tm-db/v2/memdb"
13+
"github.com/stretchr/testify/require"
14+
)
15+
16+
func TestNewApp(t *testing.T) {
17+
encodingConfig := simapp.MakeTestEncodingConfig()
18+
a := appCreator{encodingConfig}
19+
db := memdb.NewDB()
20+
tempDir := t.TempDir()
21+
ctx := server.NewDefaultContext()
22+
ctx.Viper.Set(flags.FlagHome, tempDir)
23+
ctx.Viper.Set(server.FlagPruning, types.PruningOptionNothing)
24+
app := a.newApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, ctx.Viper)
25+
require.NotNil(t, app)
26+
}

0 commit comments

Comments
 (0)