forked from babylonlabs-io/babylon
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathencoding.go
More file actions
67 lines (57 loc) · 1.72 KB
/
Copy pathencoding.go
File metadata and controls
67 lines (57 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package app
import (
"os"
"cosmossdk.io/log"
wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
dbm "github.com/cosmos/cosmos-db"
"github.com/cosmos/cosmos-sdk/client/flags"
simsutils "github.com/cosmos/cosmos-sdk/testutil/sims"
appparams "github.com/babylonlabs-io/babylon/v4/app/params"
"github.com/babylonlabs-io/babylon/v4/testutil/signer"
bbn "github.com/babylonlabs-io/babylon/v4/types"
checkpointingtypes "github.com/babylonlabs-io/babylon/v4/x/checkpointing/types"
)
// TmpAppOptions returns an app option with tmp dir and btc network. It is up to
// the caller to clean up the temp dir.
func TmpAppOptions() (simsutils.AppOptionsMap, func()) {
dir, err := os.MkdirTemp("", "babylon-tmp-app")
if err != nil {
panic(err)
}
appOpts := simsutils.AppOptionsMap{
flags.FlagHome: dir,
"btc-config.network": string(bbn.BtcSimnet),
}
cleanup := func() {
os.RemoveAll(dir)
}
return appOpts, cleanup
}
// NewTmpBabylonApp returns a new BabylonApp
func NewTmpBabylonApp() *BabylonApp {
tbs, _ := signer.SetupTestBlsSigner()
blsSigner := checkpointingtypes.BlsSigner(tbs)
appOpts, cleanup := TmpAppOptions()
defer cleanup()
return NewBabylonApp(
log.NewNopLogger(),
dbm.NewMemDB(),
nil,
true,
map[int64]bool{},
0,
&blsSigner,
appOpts,
[]wasmkeeper.Option{})
}
// GetEncodingConfig returns a *registered* encoding config
// Note that the only way to register configuration is through the app creation
func GetEncodingConfig() *appparams.EncodingConfig {
tmpApp := NewTmpBabylonApp()
return &appparams.EncodingConfig{
InterfaceRegistry: tmpApp.InterfaceRegistry(),
Codec: tmpApp.AppCodec(),
TxConfig: tmpApp.TxConfig(),
Amino: tmpApp.LegacyAmino(),
}
}