Skip to content

Commit 012b53c

Browse files
committed
Refactor TestSlashingGetParams and cleanup test_helpers
1 parent 3e547a5 commit 012b53c

File tree

2 files changed

+194
-242
lines changed

2 files changed

+194
-242
lines changed

cmd/gaia/cli_test/cli_test.go

+18-34
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ import (
77
"path"
88
"path/filepath"
99
"testing"
10-
11-
"github.com/cosmos/cosmos-sdk/x/slashing"
10+
"time"
1211

1312
"github.com/tendermint/tendermint/crypto/ed25519"
1413

@@ -27,7 +26,7 @@ import (
2726

2827
func TestGaiaCLIMinimumFees(t *testing.T) {
2928
t.Parallel()
30-
f := initializeFixtures(t)
29+
f := InitFixtures(t)
3130

3231
// start gaiad server with minimum fees
3332
fees := fmt.Sprintf("--minimum_fees=%s,%s", sdk.NewInt64Coin(feeDenom, 2), sdk.NewInt64Coin(denom, 2))
@@ -70,7 +69,7 @@ func TestGaiaCLIMinimumFees(t *testing.T) {
7069

7170
func TestGaiaCLIFeesDeduction(t *testing.T) {
7271
t.Parallel()
73-
f := initializeFixtures(t)
72+
f := InitFixtures(t)
7473

7574
// start gaiad server with minimum fees
7675
proc := f.GDStart(fmt.Sprintf("--minimum_fees=%s", sdk.NewInt64Coin(fooDenom, 1)))
@@ -120,7 +119,7 @@ func TestGaiaCLIFeesDeduction(t *testing.T) {
120119

121120
func TestGaiaCLISend(t *testing.T) {
122121
t.Parallel()
123-
f := initializeFixtures(t)
122+
f := InitFixtures(t)
124123

125124
// start gaiad server
126125
proc := f.GDStart()
@@ -176,7 +175,7 @@ func TestGaiaCLISend(t *testing.T) {
176175

177176
func TestGaiaCLIGasAuto(t *testing.T) {
178177
t.Parallel()
179-
f := initializeFixtures(t)
178+
f := InitFixtures(t)
180179

181180
// start gaiad server
182181
proc := f.GDStart()
@@ -236,7 +235,7 @@ func TestGaiaCLIGasAuto(t *testing.T) {
236235

237236
func TestGaiaCLICreateValidator(t *testing.T) {
238237
t.Parallel()
239-
f := initializeFixtures(t)
238+
f := InitFixtures(t)
240239

241240
// start gaiad server
242241
proc := f.GDStart()
@@ -319,7 +318,7 @@ func TestGaiaCLICreateValidator(t *testing.T) {
319318

320319
func TestGaiaCLISubmitProposal(t *testing.T) {
321320
t.Parallel()
322-
f := initializeFixtures(t)
321+
f := InitFixtures(t)
323322

324323
// start gaiad server
325324
proc := f.GDStart()
@@ -460,7 +459,7 @@ func TestGaiaCLISubmitProposal(t *testing.T) {
460459

461460
func TestGaiaCLIValidateSignatures(t *testing.T) {
462461
t.Parallel()
463-
f := initializeFixtures(t)
462+
f := InitFixtures(t)
464463

465464
// start gaiad server
466465
proc := f.GDStart()
@@ -510,7 +509,7 @@ func TestGaiaCLIValidateSignatures(t *testing.T) {
510509

511510
func TestGaiaCLISendGenerateSignAndBroadcast(t *testing.T) {
512511
t.Parallel()
513-
f := initializeFixtures(t)
512+
f := InitFixtures(t)
514513

515514
// start gaiad server
516515
proc := f.GDStart()
@@ -601,7 +600,7 @@ func TestGaiaCLISendGenerateSignAndBroadcast(t *testing.T) {
601600

602601
func TestGaiaCLIConfig(t *testing.T) {
603602
t.Parallel()
604-
f := initializeFixtures(t)
603+
f := InitFixtures(t)
605604
node := fmt.Sprintf("%s:%s", f.RPCAddr, f.Port)
606605

607606
// Set available configuration options
@@ -620,7 +619,8 @@ trace = false
620619
trust-node = true
621620
`, f.ChainID, node)
622621
require.Equal(t, expectedConfig, string(config))
623-
cleanupDirs(f.GDHome, f.GCLIHome)
622+
623+
f.Cleanup()
624624
}
625625

626626
func TestGaiadCollectGentxs(t *testing.T) {
@@ -659,32 +659,16 @@ func TestGaiadCollectGentxs(t *testing.T) {
659659
f.Cleanup(gentxDir)
660660
}
661661

662-
// ---------------------------------------------------------------------------
663-
// Slashing
664-
665662
func TestSlashingGetParams(t *testing.T) {
666663
t.Parallel()
667-
cdc := app.MakeCodec()
668-
f := initializeFixtures(t)
669-
flags := fmt.Sprintf("--home=%s --node=%v --chain-id=%v", f.GCLIHome, f.RPCAddr, f.ChainID)
664+
f := InitFixtures(t)
670665

671666
// start gaiad server
672-
proc := tests.GoExecuteTWithStdout(
673-
t,
674-
fmt.Sprintf(
675-
"gaiad start --home=%s --rpc.laddr=%v --p2p.laddr=%v",
676-
f.GDHome, f.RPCAddr, f.P2PAddr,
677-
),
678-
)
679-
667+
proc := f.GDStart()
680668
defer proc.Stop(false)
681-
tests.WaitForTMStart(f.Port)
682-
tests.WaitForNextNBlocksTM(1, f.Port)
683669

684-
res, errStr := tests.ExecuteT(t, fmt.Sprintf("gaiacli query slashing params %s", flags), "")
685-
require.Empty(t, errStr)
686-
687-
var params slashing.Params
688-
err := cdc.UnmarshalJSON([]byte(res), &params)
689-
require.NoError(t, err)
670+
params := f.QuerySlashingParams()
671+
require.Equal(t, time.Duration(120000000000), params.MaxEvidenceAge)
672+
require.Equal(t, int64(100), params.SignedBlocksWindow)
673+
require.Equal(t, sdk.NewDecWithPrec(5, 1), params.MinSignedPerWindow)
690674
}

0 commit comments

Comments
 (0)