forked from celestiaorg/celestia-app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdefault_overrides_test.go
91 lines (75 loc) · 3.14 KB
/
default_overrides_test.go
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package app
import (
"testing"
"time"
"github.com/celestiaorg/celestia-app/app/encoding"
"github.com/cosmos/cosmos-sdk/types"
distributiontypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
"github.com/stretchr/testify/assert"
tmcfg "github.com/tendermint/tendermint/config"
)
// Test_newGovModule verifies that the gov module's genesis state has defaults
// overridden.
func Test_newGovModule(t *testing.T) {
encCfg := encoding.MakeConfig(ModuleEncodingRegisters...)
day := time.Duration(time.Hour * 24)
oneWeek := day * 7
govModule := newGovModule()
raw := govModule.DefaultGenesis(encCfg.Codec)
govGenesisState := govtypes.GenesisState{}
encCfg.Codec.MustUnmarshalJSON(raw, &govGenesisState)
want := []types.Coin{{
Denom: BondDenom,
Amount: types.NewInt(10_000_000_000),
}}
assert.Equal(t, want, govGenesisState.DepositParams.MinDeposit)
assert.Equal(t, oneWeek, *govGenesisState.DepositParams.MaxDepositPeriod)
assert.Equal(t, oneWeek, *govGenesisState.VotingParams.VotingPeriod)
}
// TestDefaultGenesis verifies that the distribution module's genesis state has
// defaults overridden.
func TestDefaultGenesis(t *testing.T) {
encCfg := encoding.MakeConfig(ModuleEncodingRegisters...)
dm := distributionModule{}
raw := dm.DefaultGenesis(encCfg.Codec)
distributionGenesisState := distributiontypes.GenesisState{}
encCfg.Codec.MustUnmarshalJSON(raw, &distributionGenesisState)
// Verify that BaseProposerReward and BonusProposerReward were overridden to 0%.
assert.Equal(t, types.ZeroDec(), distributionGenesisState.Params.BaseProposerReward)
assert.Equal(t, types.ZeroDec(), distributionGenesisState.Params.BonusProposerReward)
// Verify that other params weren't overridden.
assert.Equal(t, distributiontypes.DefaultParams().WithdrawAddrEnabled, distributionGenesisState.Params.WithdrawAddrEnabled)
assert.Equal(t, distributiontypes.DefaultParams().CommunityTax, distributionGenesisState.Params.CommunityTax)
}
func TestDefaultAppConfig(t *testing.T) {
cfg := DefaultAppConfig()
assert.False(t, cfg.API.Enable)
assert.False(t, cfg.GRPC.Enable)
assert.False(t, cfg.GRPCWeb.Enable)
assert.Equal(t, uint64(1500), cfg.StateSync.SnapshotInterval)
assert.Equal(t, uint32(2), cfg.StateSync.SnapshotKeepRecent)
assert.Equal(t, "0.1utia", cfg.MinGasPrices)
}
func TestDefaultConsensusConfig(t *testing.T) {
got := DefaultConsensusConfig()
t.Run("mempool overrides", func(t *testing.T) {
want := tmcfg.MempoolConfig{
// defaults
Broadcast: tmcfg.DefaultMempoolConfig().Broadcast,
CacheSize: tmcfg.DefaultMempoolConfig().CacheSize,
KeepInvalidTxsInCache: tmcfg.DefaultMempoolConfig().KeepInvalidTxsInCache,
Recheck: tmcfg.DefaultMempoolConfig().Recheck,
RootDir: tmcfg.DefaultMempoolConfig().RootDir,
Size: tmcfg.DefaultMempoolConfig().Size,
WalPath: tmcfg.DefaultMempoolConfig().WalPath,
// overrides
MaxTxBytes: 7_897_088,
MaxTxsBytes: 39_485_440,
TTLDuration: 75 * time.Second,
TTLNumBlocks: 5,
Version: "v1",
}
assert.Equal(t, want, *got.Mempool)
})
}