From d1f17ff903a57b8d42b2095a5d8c06ceafd9ebe7 Mon Sep 17 00:00:00 2001 From: frog power 4000 Date: Mon, 10 Jun 2019 11:57:38 +0200 Subject: [PATCH] Merge PR #4520: add some noalias's also fix alias directory in mint --- x/auth/alias.go | 7 - x/auth/ante_test.go | 256 +++++++++++----------- x/auth/querier_test.go | 3 +- x/auth/types/test_common.go | 2 +- x/distribution/alias.go | 1 + x/distribution/keeper/hooks.go | 13 +- x/distribution/keeper/test_common.go | 1 + x/mint/alias.go | 5 +- x/mint/internal/types/expected_keepers.go | 2 +- x/slashing/alias.go | 2 - x/slashing/keeper.go | 4 +- x/slashing/module.go | 4 +- x/slashing/types/expected_keepers.go | 2 +- x/staking/alias.go | 17 -- x/staking/handler_test.go | 2 +- x/staking/keeper/test_common.go | 2 +- x/staking/module.go | 8 +- x/staking/types/expected_keepers.go | 12 +- x/staking/types/validator.go | 3 +- 19 files changed, 162 insertions(+), 184 deletions(-) diff --git a/x/auth/alias.go b/x/auth/alias.go index 3c1fe15fde..2cfba026aa 100644 --- a/x/auth/alias.go +++ b/x/auth/alias.go @@ -49,13 +49,6 @@ var ( StdSignBytes = types.StdSignBytes DefaultTxDecoder = types.DefaultTxDecoder DefaultTxEncoder = types.DefaultTxEncoder - NewTestMsg = types.NewTestMsg - NewTestStdFee = types.NewTestStdFee - NewTestCoins = types.NewTestCoins - KeyTestPubAddr = types.KeyTestPubAddr - NewTestTx = types.NewTestTx - NewTestTxWithMemo = types.NewTestTxWithMemo - NewTestTxWithSignBytes = types.NewTestTxWithSignBytes NewTxBuilder = types.NewTxBuilder NewTxBuilderFromCLI = types.NewTxBuilderFromCLI MakeSignature = types.MakeSignature diff --git a/x/auth/ante_test.go b/x/auth/ante_test.go index f0c3125144..03be6b91c8 100644 --- a/x/auth/ante_test.go +++ b/x/auth/ante_test.go @@ -51,21 +51,21 @@ func TestAnteHandlerSigErrors(t *testing.T) { anteHandler := NewAnteHandler(input.ak, input.fck, DefaultSigVerificationGasConsumer) // keys and addresses - priv1, _, addr1 := KeyTestPubAddr() - priv2, _, addr2 := KeyTestPubAddr() - priv3, _, addr3 := KeyTestPubAddr() + priv1, _, addr1 := types.KeyTestPubAddr() + priv2, _, addr2 := types.KeyTestPubAddr() + priv3, _, addr3 := types.KeyTestPubAddr() // msg and signatures var tx sdk.Tx - msg1 := NewTestMsg(addr1, addr2) - msg2 := NewTestMsg(addr1, addr3) - fee := NewTestStdFee() + msg1 := types.NewTestMsg(addr1, addr2) + msg2 := types.NewTestMsg(addr1, addr3) + fee := types.NewTestStdFee() msgs := []sdk.Msg{msg1, msg2} // test no signatures privs, accNums, seqs := []crypto.PrivKey{}, []uint64{}, []uint64{} - tx = NewTestTx(ctx, msgs, privs, accNums, seqs, fee) + tx = types.NewTestTx(ctx, msgs, privs, accNums, seqs, fee) // tx.GetSigners returns addresses in correct order: addr1, addr2, addr3 expectedSigners := []sdk.AccAddress{addr1, addr2, addr3} @@ -77,12 +77,12 @@ func TestAnteHandlerSigErrors(t *testing.T) { // test num sigs dont match GetSigners privs, accNums, seqs = []crypto.PrivKey{priv1}, []uint64{0}, []uint64{0} - tx = NewTestTx(ctx, msgs, privs, accNums, seqs, fee) + tx = types.NewTestTx(ctx, msgs, privs, accNums, seqs, fee) checkInvalidTx(t, anteHandler, ctx, tx, false, sdk.CodeUnauthorized) // test an unrecognized account privs, accNums, seqs = []crypto.PrivKey{priv1, priv2, priv3}, []uint64{0, 1, 2}, []uint64{0, 0, 0} - tx = NewTestTx(ctx, msgs, privs, accNums, seqs, fee) + tx = types.NewTestTx(ctx, msgs, privs, accNums, seqs, fee) checkInvalidTx(t, anteHandler, ctx, tx, false, sdk.CodeUnknownAddress) // save the first account, but second is still unrecognized @@ -100,50 +100,50 @@ func TestAnteHandlerAccountNumbers(t *testing.T) { ctx := input.ctx.WithBlockHeight(1) // keys and addresses - priv1, _, addr1 := KeyTestPubAddr() - priv2, _, addr2 := KeyTestPubAddr() + priv1, _, addr1 := types.KeyTestPubAddr() + priv2, _, addr2 := types.KeyTestPubAddr() // set the accounts acc1 := input.ak.NewAccountWithAddress(ctx, addr1) - acc1.SetCoins(NewTestCoins()) + acc1.SetCoins(types.NewTestCoins()) input.ak.SetAccount(ctx, acc1) acc2 := input.ak.NewAccountWithAddress(ctx, addr2) - acc2.SetCoins(NewTestCoins()) + acc2.SetCoins(types.NewTestCoins()) input.ak.SetAccount(ctx, acc2) // msg and signatures var tx sdk.Tx - msg := NewTestMsg(addr1) - fee := NewTestStdFee() + msg := types.NewTestMsg(addr1) + fee := types.NewTestStdFee() msgs := []sdk.Msg{msg} // test good tx from one signer privs, accnums, seqs := []crypto.PrivKey{priv1}, []uint64{0}, []uint64{0} - tx = NewTestTx(ctx, msgs, privs, accnums, seqs, fee) + tx = types.NewTestTx(ctx, msgs, privs, accnums, seqs, fee) checkValidTx(t, anteHandler, ctx, tx, false) // new tx from wrong account number seqs = []uint64{1} - tx = NewTestTx(ctx, msgs, privs, []uint64{1}, seqs, fee) + tx = types.NewTestTx(ctx, msgs, privs, []uint64{1}, seqs, fee) checkInvalidTx(t, anteHandler, ctx, tx, false, sdk.CodeUnauthorized) // from correct account number seqs = []uint64{1} - tx = NewTestTx(ctx, msgs, privs, []uint64{0}, seqs, fee) + tx = types.NewTestTx(ctx, msgs, privs, []uint64{0}, seqs, fee) checkValidTx(t, anteHandler, ctx, tx, false) // new tx with another signer and incorrect account numbers - msg1 := NewTestMsg(addr1, addr2) - msg2 := NewTestMsg(addr2, addr1) + msg1 := types.NewTestMsg(addr1, addr2) + msg2 := types.NewTestMsg(addr2, addr1) msgs = []sdk.Msg{msg1, msg2} privs, accnums, seqs = []crypto.PrivKey{priv1, priv2}, []uint64{1, 0}, []uint64{2, 0} - tx = NewTestTx(ctx, msgs, privs, accnums, seqs, fee) + tx = types.NewTestTx(ctx, msgs, privs, accnums, seqs, fee) checkInvalidTx(t, anteHandler, ctx, tx, false, sdk.CodeUnauthorized) // correct account numbers privs, accnums, seqs = []crypto.PrivKey{priv1, priv2}, []uint64{0, 1}, []uint64{2, 0} - tx = NewTestTx(ctx, msgs, privs, accnums, seqs, fee) + tx = types.NewTestTx(ctx, msgs, privs, accnums, seqs, fee) checkValidTx(t, anteHandler, ctx, tx, false) } @@ -155,50 +155,50 @@ func TestAnteHandlerAccountNumbersAtBlockHeightZero(t *testing.T) { ctx := input.ctx.WithBlockHeight(0) // keys and addresses - priv1, _, addr1 := KeyTestPubAddr() - priv2, _, addr2 := KeyTestPubAddr() + priv1, _, addr1 := types.KeyTestPubAddr() + priv2, _, addr2 := types.KeyTestPubAddr() // set the accounts acc1 := input.ak.NewAccountWithAddress(ctx, addr1) - acc1.SetCoins(NewTestCoins()) + acc1.SetCoins(types.NewTestCoins()) input.ak.SetAccount(ctx, acc1) acc2 := input.ak.NewAccountWithAddress(ctx, addr2) - acc2.SetCoins(NewTestCoins()) + acc2.SetCoins(types.NewTestCoins()) input.ak.SetAccount(ctx, acc2) // msg and signatures var tx sdk.Tx - msg := NewTestMsg(addr1) - fee := NewTestStdFee() + msg := types.NewTestMsg(addr1) + fee := types.NewTestStdFee() msgs := []sdk.Msg{msg} // test good tx from one signer privs, accnums, seqs := []crypto.PrivKey{priv1}, []uint64{0}, []uint64{0} - tx = NewTestTx(ctx, msgs, privs, accnums, seqs, fee) + tx = types.NewTestTx(ctx, msgs, privs, accnums, seqs, fee) checkValidTx(t, anteHandler, ctx, tx, false) // new tx from wrong account number seqs = []uint64{1} - tx = NewTestTx(ctx, msgs, privs, []uint64{1}, seqs, fee) + tx = types.NewTestTx(ctx, msgs, privs, []uint64{1}, seqs, fee) checkInvalidTx(t, anteHandler, ctx, tx, false, sdk.CodeUnauthorized) // from correct account number seqs = []uint64{1} - tx = NewTestTx(ctx, msgs, privs, []uint64{0}, seqs, fee) + tx = types.NewTestTx(ctx, msgs, privs, []uint64{0}, seqs, fee) checkValidTx(t, anteHandler, ctx, tx, false) // new tx with another signer and incorrect account numbers - msg1 := NewTestMsg(addr1, addr2) - msg2 := NewTestMsg(addr2, addr1) + msg1 := types.NewTestMsg(addr1, addr2) + msg2 := types.NewTestMsg(addr2, addr1) msgs = []sdk.Msg{msg1, msg2} privs, accnums, seqs = []crypto.PrivKey{priv1, priv2}, []uint64{1, 0}, []uint64{2, 0} - tx = NewTestTx(ctx, msgs, privs, accnums, seqs, fee) + tx = types.NewTestTx(ctx, msgs, privs, accnums, seqs, fee) checkInvalidTx(t, anteHandler, ctx, tx, false, sdk.CodeUnauthorized) // correct account numbers privs, accnums, seqs = []crypto.PrivKey{priv1, priv2}, []uint64{0, 0}, []uint64{2, 0} - tx = NewTestTx(ctx, msgs, privs, accnums, seqs, fee) + tx = types.NewTestTx(ctx, msgs, privs, accnums, seqs, fee) checkValidTx(t, anteHandler, ctx, tx, false) } @@ -210,31 +210,31 @@ func TestAnteHandlerSequences(t *testing.T) { ctx := input.ctx.WithBlockHeight(1) // keys and addresses - priv1, _, addr1 := KeyTestPubAddr() - priv2, _, addr2 := KeyTestPubAddr() - priv3, _, addr3 := KeyTestPubAddr() + priv1, _, addr1 := types.KeyTestPubAddr() + priv2, _, addr2 := types.KeyTestPubAddr() + priv3, _, addr3 := types.KeyTestPubAddr() // set the accounts acc1 := input.ak.NewAccountWithAddress(ctx, addr1) - acc1.SetCoins(NewTestCoins()) + acc1.SetCoins(types.NewTestCoins()) input.ak.SetAccount(ctx, acc1) acc2 := input.ak.NewAccountWithAddress(ctx, addr2) - acc2.SetCoins(NewTestCoins()) + acc2.SetCoins(types.NewTestCoins()) input.ak.SetAccount(ctx, acc2) acc3 := input.ak.NewAccountWithAddress(ctx, addr3) - acc3.SetCoins(NewTestCoins()) + acc3.SetCoins(types.NewTestCoins()) input.ak.SetAccount(ctx, acc3) // msg and signatures var tx sdk.Tx - msg := NewTestMsg(addr1) - fee := NewTestStdFee() + msg := types.NewTestMsg(addr1) + fee := types.NewTestStdFee() msgs := []sdk.Msg{msg} // test good tx from one signer privs, accnums, seqs := []crypto.PrivKey{priv1}, []uint64{0}, []uint64{0} - tx = NewTestTx(ctx, msgs, privs, accnums, seqs, fee) + tx = types.NewTestTx(ctx, msgs, privs, accnums, seqs, fee) checkValidTx(t, anteHandler, ctx, tx, false) // test sending it again fails (replay protection) @@ -242,37 +242,37 @@ func TestAnteHandlerSequences(t *testing.T) { // fix sequence, should pass seqs = []uint64{1} - tx = NewTestTx(ctx, msgs, privs, accnums, seqs, fee) + tx = types.NewTestTx(ctx, msgs, privs, accnums, seqs, fee) checkValidTx(t, anteHandler, ctx, tx, false) // new tx with another signer and correct sequences - msg1 := NewTestMsg(addr1, addr2) - msg2 := NewTestMsg(addr3, addr1) + msg1 := types.NewTestMsg(addr1, addr2) + msg2 := types.NewTestMsg(addr3, addr1) msgs = []sdk.Msg{msg1, msg2} privs, accnums, seqs = []crypto.PrivKey{priv1, priv2, priv3}, []uint64{0, 1, 2}, []uint64{2, 0, 0} - tx = NewTestTx(ctx, msgs, privs, accnums, seqs, fee) + tx = types.NewTestTx(ctx, msgs, privs, accnums, seqs, fee) checkValidTx(t, anteHandler, ctx, tx, false) // replay fails checkInvalidTx(t, anteHandler, ctx, tx, false, sdk.CodeUnauthorized) // tx from just second signer with incorrect sequence fails - msg = NewTestMsg(addr2) + msg = types.NewTestMsg(addr2) msgs = []sdk.Msg{msg} privs, accnums, seqs = []crypto.PrivKey{priv2}, []uint64{1}, []uint64{0} - tx = NewTestTx(ctx, msgs, privs, accnums, seqs, fee) + tx = types.NewTestTx(ctx, msgs, privs, accnums, seqs, fee) checkInvalidTx(t, anteHandler, ctx, tx, false, sdk.CodeUnauthorized) // fix the sequence and it passes - tx = NewTestTx(ctx, msgs, []crypto.PrivKey{priv2}, []uint64{1}, []uint64{1}, fee) + tx = types.NewTestTx(ctx, msgs, []crypto.PrivKey{priv2}, []uint64{1}, []uint64{1}, fee) checkValidTx(t, anteHandler, ctx, tx, false) // another tx from both of them that passes - msg = NewTestMsg(addr1, addr2) + msg = types.NewTestMsg(addr1, addr2) msgs = []sdk.Msg{msg} privs, accnums, seqs = []crypto.PrivKey{priv1, priv2}, []uint64{0, 1}, []uint64{3, 2} - tx = NewTestTx(ctx, msgs, privs, accnums, seqs, fee) + tx = types.NewTestTx(ctx, msgs, privs, accnums, seqs, fee) checkValidTx(t, anteHandler, ctx, tx, false) } @@ -284,7 +284,7 @@ func TestAnteHandlerFees(t *testing.T) { anteHandler := NewAnteHandler(input.ak, input.fck, DefaultSigVerificationGasConsumer) // keys and addresses - priv1, _, addr1 := KeyTestPubAddr() + priv1, _, addr1 := types.KeyTestPubAddr() // set the accounts acc1 := input.ak.NewAccountWithAddress(ctx, addr1) @@ -292,13 +292,13 @@ func TestAnteHandlerFees(t *testing.T) { // msg and signatures var tx sdk.Tx - msg := NewTestMsg(addr1) + msg := types.NewTestMsg(addr1) privs, accnums, seqs := []crypto.PrivKey{priv1}, []uint64{0}, []uint64{0} - fee := NewTestStdFee() + fee := types.NewTestStdFee() msgs := []sdk.Msg{msg} // signer does not have enough funds to pay the fee - tx = NewTestTx(ctx, msgs, privs, accnums, seqs, fee) + tx = types.NewTestTx(ctx, msgs, privs, accnums, seqs, fee) checkInvalidTx(t, anteHandler, ctx, tx, false, sdk.CodeInsufficientFunds) acc1.SetCoins(sdk.NewCoins(sdk.NewInt64Coin("atom", 149))) @@ -325,7 +325,7 @@ func TestAnteHandlerMemoGas(t *testing.T) { ctx := input.ctx.WithBlockHeight(1) // keys and addresses - priv1, _, addr1 := KeyTestPubAddr() + priv1, _, addr1 := types.KeyTestPubAddr() // set the accounts acc1 := input.ak.NewAccountWithAddress(ctx, addr1) @@ -333,27 +333,27 @@ func TestAnteHandlerMemoGas(t *testing.T) { // msg and signatures var tx sdk.Tx - msg := NewTestMsg(addr1) + msg := types.NewTestMsg(addr1) privs, accnums, seqs := []crypto.PrivKey{priv1}, []uint64{0}, []uint64{0} fee := NewStdFee(0, sdk.NewCoins(sdk.NewInt64Coin("atom", 0))) // tx does not have enough gas - tx = NewTestTx(ctx, []sdk.Msg{msg}, privs, accnums, seqs, fee) + tx = types.NewTestTx(ctx, []sdk.Msg{msg}, privs, accnums, seqs, fee) checkInvalidTx(t, anteHandler, ctx, tx, false, sdk.CodeOutOfGas) // tx with memo doesn't have enough gas fee = NewStdFee(801, sdk.NewCoins(sdk.NewInt64Coin("atom", 0))) - tx = NewTestTxWithMemo(ctx, []sdk.Msg{msg}, privs, accnums, seqs, fee, "abcininasidniandsinasindiansdiansdinaisndiasndiadninsd") + tx = types.NewTestTxWithMemo(ctx, []sdk.Msg{msg}, privs, accnums, seqs, fee, "abcininasidniandsinasindiansdiansdinaisndiasndiadninsd") checkInvalidTx(t, anteHandler, ctx, tx, false, sdk.CodeOutOfGas) // memo too large fee = NewStdFee(9000, sdk.NewCoins(sdk.NewInt64Coin("atom", 0))) - tx = NewTestTxWithMemo(ctx, []sdk.Msg{msg}, privs, accnums, seqs, fee, strings.Repeat("01234567890", 500)) + tx = types.NewTestTxWithMemo(ctx, []sdk.Msg{msg}, privs, accnums, seqs, fee, strings.Repeat("01234567890", 500)) checkInvalidTx(t, anteHandler, ctx, tx, false, sdk.CodeMemoTooLarge) // tx with memo has enough gas fee = NewStdFee(9000, sdk.NewCoins(sdk.NewInt64Coin("atom", 0))) - tx = NewTestTxWithMemo(ctx, []sdk.Msg{msg}, privs, accnums, seqs, fee, strings.Repeat("0123456789", 10)) + tx = types.NewTestTxWithMemo(ctx, []sdk.Msg{msg}, privs, accnums, seqs, fee, strings.Repeat("0123456789", 10)) checkValidTx(t, anteHandler, ctx, tx, false) } @@ -364,43 +364,43 @@ func TestAnteHandlerMultiSigner(t *testing.T) { ctx := input.ctx.WithBlockHeight(1) // keys and addresses - priv1, _, addr1 := KeyTestPubAddr() - priv2, _, addr2 := KeyTestPubAddr() - priv3, _, addr3 := KeyTestPubAddr() + priv1, _, addr1 := types.KeyTestPubAddr() + priv2, _, addr2 := types.KeyTestPubAddr() + priv3, _, addr3 := types.KeyTestPubAddr() // set the accounts acc1 := input.ak.NewAccountWithAddress(ctx, addr1) - acc1.SetCoins(NewTestCoins()) + acc1.SetCoins(types.NewTestCoins()) input.ak.SetAccount(ctx, acc1) acc2 := input.ak.NewAccountWithAddress(ctx, addr2) - acc2.SetCoins(NewTestCoins()) + acc2.SetCoins(types.NewTestCoins()) input.ak.SetAccount(ctx, acc2) acc3 := input.ak.NewAccountWithAddress(ctx, addr3) - acc3.SetCoins(NewTestCoins()) + acc3.SetCoins(types.NewTestCoins()) input.ak.SetAccount(ctx, acc3) // set up msgs and fee var tx sdk.Tx - msg1 := NewTestMsg(addr1, addr2) - msg2 := NewTestMsg(addr3, addr1) - msg3 := NewTestMsg(addr2, addr3) + msg1 := types.NewTestMsg(addr1, addr2) + msg2 := types.NewTestMsg(addr3, addr1) + msg3 := types.NewTestMsg(addr2, addr3) msgs := []sdk.Msg{msg1, msg2, msg3} - fee := NewTestStdFee() + fee := types.NewTestStdFee() // signers in order privs, accnums, seqs := []crypto.PrivKey{priv1, priv2, priv3}, []uint64{0, 1, 2}, []uint64{0, 0, 0} - tx = NewTestTxWithMemo(ctx, msgs, privs, accnums, seqs, fee, "Check signers are in expected order and different account numbers works") + tx = types.NewTestTxWithMemo(ctx, msgs, privs, accnums, seqs, fee, "Check signers are in expected order and different account numbers works") checkValidTx(t, anteHandler, ctx, tx, false) // change sequence numbers - tx = NewTestTx(ctx, []sdk.Msg{msg1}, []crypto.PrivKey{priv1, priv2}, []uint64{0, 1}, []uint64{1, 1}, fee) + tx = types.NewTestTx(ctx, []sdk.Msg{msg1}, []crypto.PrivKey{priv1, priv2}, []uint64{0, 1}, []uint64{1, 1}, fee) checkValidTx(t, anteHandler, ctx, tx, false) - tx = NewTestTx(ctx, []sdk.Msg{msg2}, []crypto.PrivKey{priv3, priv1}, []uint64{2, 0}, []uint64{1, 2}, fee) + tx = types.NewTestTx(ctx, []sdk.Msg{msg2}, []crypto.PrivKey{priv3, priv1}, []uint64{2, 0}, []uint64{1, 2}, fee) checkValidTx(t, anteHandler, ctx, tx, false) // expected seqs = [3, 2, 2] - tx = NewTestTxWithMemo(ctx, msgs, privs, accnums, []uint64{3, 2, 2}, fee, "Check signers are in expected order and different account numbers and sequence numbers works") + tx = types.NewTestTxWithMemo(ctx, msgs, privs, accnums, []uint64{3, 2, 2}, fee, "Check signers are in expected order and different account numbers and sequence numbers works") checkValidTx(t, anteHandler, ctx, tx, false) } @@ -411,29 +411,29 @@ func TestAnteHandlerBadSignBytes(t *testing.T) { ctx := input.ctx.WithBlockHeight(1) // keys and addresses - priv1, _, addr1 := KeyTestPubAddr() - priv2, _, addr2 := KeyTestPubAddr() + priv1, _, addr1 := types.KeyTestPubAddr() + priv2, _, addr2 := types.KeyTestPubAddr() // set the accounts acc1 := input.ak.NewAccountWithAddress(ctx, addr1) - acc1.SetCoins(NewTestCoins()) + acc1.SetCoins(types.NewTestCoins()) input.ak.SetAccount(ctx, acc1) acc2 := input.ak.NewAccountWithAddress(ctx, addr2) - acc2.SetCoins(NewTestCoins()) + acc2.SetCoins(types.NewTestCoins()) input.ak.SetAccount(ctx, acc2) var tx sdk.Tx - msg := NewTestMsg(addr1) + msg := types.NewTestMsg(addr1) msgs := []sdk.Msg{msg} - fee := NewTestStdFee() - fee2 := NewTestStdFee() + fee := types.NewTestStdFee() + fee2 := types.NewTestStdFee() fee2.Gas += 100 - fee3 := NewTestStdFee() + fee3 := types.NewTestStdFee() fee3.Amount[0].Amount = fee3.Amount[0].Amount.AddRaw(100) // test good tx and signBytes privs, accnums, seqs := []crypto.PrivKey{priv1}, []uint64{0}, []uint64{0} - tx = NewTestTx(ctx, msgs, privs, accnums, seqs, fee) + tx = types.NewTestTx(ctx, msgs, privs, accnums, seqs, fee) checkValidTx(t, anteHandler, ctx, tx, false) chainID := ctx.ChainID() @@ -448,17 +448,17 @@ func TestAnteHandlerBadSignBytes(t *testing.T) { msgs []sdk.Msg code sdk.CodeType }{ - {chainID2, 0, 1, fee, msgs, codeUnauth}, // test wrong chain_id - {chainID, 0, 2, fee, msgs, codeUnauth}, // test wrong seqs - {chainID, 1, 1, fee, msgs, codeUnauth}, // test wrong accnum - {chainID, 0, 1, fee, []sdk.Msg{NewTestMsg(addr2)}, codeUnauth}, // test wrong msg - {chainID, 0, 1, fee2, msgs, codeUnauth}, // test wrong fee - {chainID, 0, 1, fee3, msgs, codeUnauth}, // test wrong fee + {chainID2, 0, 1, fee, msgs, codeUnauth}, // test wrong chain_id + {chainID, 0, 2, fee, msgs, codeUnauth}, // test wrong seqs + {chainID, 1, 1, fee, msgs, codeUnauth}, // test wrong accnum + {chainID, 0, 1, fee, []sdk.Msg{types.NewTestMsg(addr2)}, codeUnauth}, // test wrong msg + {chainID, 0, 1, fee2, msgs, codeUnauth}, // test wrong fee + {chainID, 0, 1, fee3, msgs, codeUnauth}, // test wrong fee } privs, seqs = []crypto.PrivKey{priv1}, []uint64{1} for _, cs := range cases { - tx := NewTestTxWithSignBytes( + tx := types.NewTestTxWithSignBytes( msgs, privs, accnums, seqs, fee, StdSignBytes(cs.chainID, cs.accnum, cs.seq, cs.fee, cs.msgs, ""), "", @@ -468,14 +468,14 @@ func TestAnteHandlerBadSignBytes(t *testing.T) { // test wrong signer if public key exist privs, accnums, seqs = []crypto.PrivKey{priv2}, []uint64{0}, []uint64{1} - tx = NewTestTx(ctx, msgs, privs, accnums, seqs, fee) + tx = types.NewTestTx(ctx, msgs, privs, accnums, seqs, fee) checkInvalidTx(t, anteHandler, ctx, tx, false, sdk.CodeUnauthorized) // test wrong signer if public doesn't exist - msg = NewTestMsg(addr2) + msg = types.NewTestMsg(addr2) msgs = []sdk.Msg{msg} privs, accnums, seqs = []crypto.PrivKey{priv1}, []uint64{1}, []uint64{0} - tx = NewTestTx(ctx, msgs, privs, accnums, seqs, fee) + tx = types.NewTestTx(ctx, msgs, privs, accnums, seqs, fee) checkInvalidTx(t, anteHandler, ctx, tx, false, sdk.CodeInvalidPubKey) } @@ -486,34 +486,34 @@ func TestAnteHandlerSetPubKey(t *testing.T) { ctx := input.ctx.WithBlockHeight(1) // keys and addresses - priv1, _, addr1 := KeyTestPubAddr() - _, _, addr2 := KeyTestPubAddr() + priv1, _, addr1 := types.KeyTestPubAddr() + _, _, addr2 := types.KeyTestPubAddr() // set the accounts acc1 := input.ak.NewAccountWithAddress(ctx, addr1) - acc1.SetCoins(NewTestCoins()) + acc1.SetCoins(types.NewTestCoins()) input.ak.SetAccount(ctx, acc1) acc2 := input.ak.NewAccountWithAddress(ctx, addr2) - acc2.SetCoins(NewTestCoins()) + acc2.SetCoins(types.NewTestCoins()) input.ak.SetAccount(ctx, acc2) var tx sdk.Tx // test good tx and set public key - msg := NewTestMsg(addr1) + msg := types.NewTestMsg(addr1) msgs := []sdk.Msg{msg} privs, accnums, seqs := []crypto.PrivKey{priv1}, []uint64{0}, []uint64{0} - fee := NewTestStdFee() - tx = NewTestTx(ctx, msgs, privs, accnums, seqs, fee) + fee := types.NewTestStdFee() + tx = types.NewTestTx(ctx, msgs, privs, accnums, seqs, fee) checkValidTx(t, anteHandler, ctx, tx, false) acc1 = input.ak.GetAccount(ctx, addr1) require.Equal(t, acc1.GetPubKey(), priv1.PubKey()) // test public key not found - msg = NewTestMsg(addr2) + msg = types.NewTestMsg(addr2) msgs = []sdk.Msg{msg} - tx = NewTestTx(ctx, msgs, privs, []uint64{1}, seqs, fee) + tx = types.NewTestTx(ctx, msgs, privs, []uint64{1}, seqs, fee) sigs := tx.(types.StdTx).GetSignatures() sigs[0].PubKey = nil checkInvalidTx(t, anteHandler, ctx, tx, false, sdk.CodeInvalidPubKey) @@ -522,7 +522,7 @@ func TestAnteHandlerSetPubKey(t *testing.T) { require.Nil(t, acc2.GetPubKey()) // test invalid signature and public key - tx = NewTestTx(ctx, msgs, privs, []uint64{1}, seqs, fee) + tx = types.NewTestTx(ctx, msgs, privs, []uint64{1}, seqs, fee) checkInvalidTx(t, anteHandler, ctx, tx, false, sdk.CodeInvalidPubKey) acc2 = input.ak.GetAccount(ctx, addr2) @@ -534,8 +534,8 @@ func TestProcessPubKey(t *testing.T) { ctx := input.ctx // keys - _, _, addr1 := KeyTestPubAddr() - priv2, _, addr2 := KeyTestPubAddr() + _, _, addr1 := types.KeyTestPubAddr() + priv2, _, addr2 := types.KeyTestPubAddr() acc1 := input.ak.NewAccountWithAddress(ctx, addr1) acc2 := input.ak.NewAccountWithAddress(ctx, addr2) @@ -680,32 +680,32 @@ func TestAnteHandlerSigLimitExceeded(t *testing.T) { ctx := input.ctx.WithBlockHeight(1) // keys and addresses - priv1, _, addr1 := KeyTestPubAddr() - priv2, _, addr2 := KeyTestPubAddr() - priv3, _, addr3 := KeyTestPubAddr() - priv4, _, addr4 := KeyTestPubAddr() - priv5, _, addr5 := KeyTestPubAddr() - priv6, _, addr6 := KeyTestPubAddr() - priv7, _, addr7 := KeyTestPubAddr() - priv8, _, addr8 := KeyTestPubAddr() + priv1, _, addr1 := types.KeyTestPubAddr() + priv2, _, addr2 := types.KeyTestPubAddr() + priv3, _, addr3 := types.KeyTestPubAddr() + priv4, _, addr4 := types.KeyTestPubAddr() + priv5, _, addr5 := types.KeyTestPubAddr() + priv6, _, addr6 := types.KeyTestPubAddr() + priv7, _, addr7 := types.KeyTestPubAddr() + priv8, _, addr8 := types.KeyTestPubAddr() // set the accounts acc1 := input.ak.NewAccountWithAddress(ctx, addr1) - acc1.SetCoins(NewTestCoins()) + acc1.SetCoins(types.NewTestCoins()) input.ak.SetAccount(ctx, acc1) acc2 := input.ak.NewAccountWithAddress(ctx, addr2) - acc2.SetCoins(NewTestCoins()) + acc2.SetCoins(types.NewTestCoins()) input.ak.SetAccount(ctx, acc2) var tx sdk.Tx - msg := NewTestMsg(addr1, addr2, addr3, addr4, addr5, addr6, addr7, addr8) + msg := types.NewTestMsg(addr1, addr2, addr3, addr4, addr5, addr6, addr7, addr8) msgs := []sdk.Msg{msg} - fee := NewTestStdFee() + fee := types.NewTestStdFee() // test rejection logic privs, accnums, seqs := []crypto.PrivKey{priv1, priv2, priv3, priv4, priv5, priv6, priv7, priv8}, []uint64{0, 0, 0, 0, 0, 0, 0, 0}, []uint64{0, 0, 0, 0, 0, 0, 0, 0} - tx = NewTestTx(ctx, msgs, privs, accnums, seqs, fee) + tx = types.NewTestTx(ctx, msgs, privs, accnums, seqs, fee) checkInvalidTx(t, anteHandler, ctx, tx, false, sdk.CodeTooManySignatures) } @@ -776,16 +776,16 @@ func TestCustomSignatureVerificationGasConsumer(t *testing.T) { ctx := input.ctx.WithBlockHeight(1) // verify that an secp256k1 account gets rejected - priv1, _, addr1 := KeyTestPubAddr() + priv1, _, addr1 := types.KeyTestPubAddr() acc1 := input.ak.NewAccountWithAddress(ctx, addr1) _ = acc1.SetCoins(sdk.NewCoins(sdk.NewInt64Coin("atom", 150))) input.ak.SetAccount(ctx, acc1) var tx sdk.Tx - msg := NewTestMsg(addr1) + msg := types.NewTestMsg(addr1) privs, accnums, seqs := []crypto.PrivKey{priv1}, []uint64{0}, []uint64{0} - fee := NewTestStdFee() + fee := types.NewTestStdFee() msgs := []sdk.Msg{msg} - tx = NewTestTx(ctx, msgs, privs, accnums, seqs, fee) + tx = types.NewTestTx(ctx, msgs, privs, accnums, seqs, fee) checkInvalidTx(t, anteHandler, ctx, tx, false, sdk.CodeInvalidPubKey) // verify that an ed25519 account gets accepted @@ -795,10 +795,10 @@ func TestCustomSignatureVerificationGasConsumer(t *testing.T) { acc2 := input.ak.NewAccountWithAddress(ctx, addr2) _ = acc2.SetCoins(sdk.NewCoins(sdk.NewInt64Coin("atom", 150))) input.ak.SetAccount(ctx, acc2) - msg = NewTestMsg(addr2) + msg = types.NewTestMsg(addr2) privs, accnums, seqs = []crypto.PrivKey{priv2}, []uint64{1}, []uint64{0} - fee = NewTestStdFee() + fee = types.NewTestStdFee() msgs = []sdk.Msg{msg} - tx = NewTestTx(ctx, msgs, privs, accnums, seqs, fee) + tx = types.NewTestTx(ctx, msgs, privs, accnums, seqs, fee) checkValidTx(t, anteHandler, ctx, tx, false) } diff --git a/x/auth/querier_test.go b/x/auth/querier_test.go index 72e60b2086..16c7bb5821 100644 --- a/x/auth/querier_test.go +++ b/x/auth/querier_test.go @@ -4,6 +4,7 @@ import ( "fmt" "testing" + "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/stretchr/testify/require" abci "github.com/tendermint/tendermint/abci/types" ) @@ -24,7 +25,7 @@ func Test_queryAccount(t *testing.T) { require.NotNil(t, err) require.Nil(t, res) - _, _, addr := KeyTestPubAddr() + _, _, addr := types.KeyTestPubAddr() req.Data = input.cdc.MustMarshalJSON(NewQueryAccountParams(addr)) res, err = queryAccount(input.ctx, req, input.ak) require.NotNil(t, err) diff --git a/x/auth/types/test_common.go b/x/auth/types/test_common.go index c6f4d26b1d..14e5d8910c 100644 --- a/x/auth/types/test_common.go +++ b/x/auth/types/test_common.go @@ -1,4 +1,4 @@ -//nolint +// nolint noalias package types import ( diff --git a/x/distribution/alias.go b/x/distribution/alias.go index 619ae1d89e..c44dfaab25 100644 --- a/x/distribution/alias.go +++ b/x/distribution/alias.go @@ -134,6 +134,7 @@ type ( DelegatorStartingInfo = types.DelegatorStartingInfo CodeType = types.CodeType StakingKeeper = types.StakingKeeper + StakingHooks = types.StakingHooks BankKeeper = types.BankKeeper FeeCollectionKeeper = types.FeeCollectionKeeper FeePool = types.FeePool diff --git a/x/distribution/keeper/hooks.go b/x/distribution/keeper/hooks.go index 01ef5ef118..e75a445d03 100644 --- a/x/distribution/keeper/hooks.go +++ b/x/distribution/keeper/hooks.go @@ -15,12 +15,13 @@ var _ types.StakingHooks = Hooks{} // Create new distribution hooks func (k Keeper) Hooks() Hooks { return Hooks{k} } -// nolint +// initialize validator distribution record func (h Hooks) AfterValidatorCreated(ctx sdk.Context, valAddr sdk.ValAddress) { val := h.k.stakingKeeper.Validator(ctx, valAddr) h.k.initializeValidator(ctx, val) } +// cleanup for after validator is removed func (h Hooks) AfterValidatorRemoved(ctx sdk.Context, _ sdk.ConsAddress, valAddr sdk.ValAddress) { // fetch outstanding @@ -73,30 +74,28 @@ func (h Hooks) AfterValidatorRemoved(ctx sdk.Context, _ sdk.ConsAddress, valAddr h.k.DeleteValidatorCurrentRewards(ctx, valAddr) } +// increment period func (h Hooks) BeforeDelegationCreated(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) { val := h.k.stakingKeeper.Validator(ctx, valAddr) - - // increment period h.k.incrementValidatorPeriod(ctx, val) } +// withdraw delegation rewards (which also increments period) func (h Hooks) BeforeDelegationSharesModified(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) { val := h.k.stakingKeeper.Validator(ctx, valAddr) del := h.k.stakingKeeper.Delegation(ctx, delAddr, valAddr) - - // withdraw delegation rewards (which also increments period) if _, err := h.k.withdrawDelegationRewards(ctx, val, del); err != nil { panic(err) } } +// create new delegation period record func (h Hooks) AfterDelegationModified(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) { - // create new delegation period record h.k.initializeDelegation(ctx, valAddr, delAddr) } +// record the slash event func (h Hooks) BeforeValidatorSlashed(ctx sdk.Context, valAddr sdk.ValAddress, fraction sdk.Dec) { - // record the slash event h.k.updateValidatorSlashFraction(ctx, valAddr, fraction) } diff --git a/x/distribution/keeper/test_common.go b/x/distribution/keeper/test_common.go index 6e2c230924..ae49ca7d59 100644 --- a/x/distribution/keeper/test_common.go +++ b/x/distribution/keeper/test_common.go @@ -47,6 +47,7 @@ var ( valConsAddr2 = sdk.ConsAddress(valConsPk2.Address()) valConsAddr3 = sdk.ConsAddress(valConsPk3.Address()) + // TODO move to common testing package for all modules // test addresses TestAddrs = []sdk.AccAddress{ delAddr1, delAddr2, delAddr3, diff --git a/x/mint/alias.go b/x/mint/alias.go index 40010389fa..e3a9bcf1e9 100644 --- a/x/mint/alias.go +++ b/x/mint/alias.go @@ -1,7 +1,8 @@ // nolint // autogenerated code using github.com/rigelrozanski/multitool // aliases generated for the following subdirectories: -// ALIASGEN: github.com/cosmos/cosmos-sdk/x/mint/types +// ALIASGEN: github.com/cosmos/cosmos-sdk/x/mint/internal/keeper +// ALIASGEN: github.com/cosmos/cosmos-sdk/x/mint/internal/types package mint import ( @@ -21,9 +22,9 @@ const ( var ( // functions aliases - NewMinter = types.NewMinter NewKeeper = keeper.NewKeeper NewQuerier = keeper.NewQuerier + NewMinter = types.NewMinter InitialMinter = types.InitialMinter DefaultInitialMinter = types.DefaultInitialMinter ValidateMinter = types.ValidateMinter diff --git a/x/mint/internal/types/expected_keepers.go b/x/mint/internal/types/expected_keepers.go index 425c219808..99a961ee75 100644 --- a/x/mint/internal/types/expected_keepers.go +++ b/x/mint/internal/types/expected_keepers.go @@ -1,4 +1,4 @@ -package types +package types // noalias import ( sdk "github.com/cosmos/cosmos-sdk/types" diff --git a/x/slashing/alias.go b/x/slashing/alias.go index a3129e7fae..9a686247dd 100644 --- a/x/slashing/alias.go +++ b/x/slashing/alias.go @@ -77,8 +77,6 @@ var ( type ( CodeType = types.CodeType - StakingKeeper = types.StakingKeeper - AccountKeeper = types.AccountKeeper GenesisState = types.GenesisState MissedBlock = types.MissedBlock MsgUnjail = types.MsgUnjail diff --git a/x/slashing/keeper.go b/x/slashing/keeper.go index e0e4d83113..3fdd1f1ae9 100644 --- a/x/slashing/keeper.go +++ b/x/slashing/keeper.go @@ -17,7 +17,7 @@ import ( type Keeper struct { storeKey sdk.StoreKey cdc *codec.Codec - sk StakingKeeper + sk types.StakingKeeper paramspace params.Subspace // codespace @@ -25,7 +25,7 @@ type Keeper struct { } // NewKeeper creates a slashing keeper -func NewKeeper(cdc *codec.Codec, key sdk.StoreKey, sk StakingKeeper, paramspace params.Subspace, codespace sdk.CodespaceType) Keeper { +func NewKeeper(cdc *codec.Codec, key sdk.StoreKey, sk types.StakingKeeper, paramspace params.Subspace, codespace sdk.CodespaceType) Keeper { keeper := Keeper{ storeKey: key, cdc: cdc, diff --git a/x/slashing/module.go b/x/slashing/module.go index c8771c1609..8ac01d9ef5 100644 --- a/x/slashing/module.go +++ b/x/slashing/module.go @@ -72,11 +72,11 @@ func (AppModuleBasic) GetQueryCmd(cdc *codec.Codec) *cobra.Command { type AppModule struct { AppModuleBasic keeper Keeper - stakingKeeper StakingKeeper + stakingKeeper types.StakingKeeper } // NewAppModule creates a new AppModule object -func NewAppModule(keeper Keeper, stakingKeeper StakingKeeper) AppModule { +func NewAppModule(keeper Keeper, stakingKeeper types.StakingKeeper) AppModule { return AppModule{ AppModuleBasic: AppModuleBasic{}, keeper: keeper, diff --git a/x/slashing/types/expected_keepers.go b/x/slashing/types/expected_keepers.go index 94b6276c04..4626e079b1 100644 --- a/x/slashing/types/expected_keepers.go +++ b/x/slashing/types/expected_keepers.go @@ -1,4 +1,4 @@ -package types +package types // noalias import ( sdk "github.com/cosmos/cosmos-sdk/types" diff --git a/x/staking/alias.go b/x/staking/alias.go index 18c8f0ce66..c3c1c87d2f 100644 --- a/x/staking/alias.go +++ b/x/staking/alias.go @@ -63,15 +63,6 @@ var ( NewKeeper = keeper.NewKeeper ParamKeyTable = keeper.ParamKeyTable NewQuerier = keeper.NewQuerier - ValEq = keeper.ValEq - MakeTestCodec = keeper.MakeTestCodec - CreateTestInput = keeper.CreateTestInput - NewPubKey = keeper.NewPubKey - TestAddr = keeper.TestAddr - ValidatorByPowerIndexExists = keeper.ValidatorByPowerIndexExists - TestingUpdateValidator = keeper.TestingUpdateValidator - RandomValidator = keeper.RandomValidator - RandomBondedValidator = keeper.RandomBondedValidator RegisterCodec = types.RegisterCodec NewCommissionRates = types.NewCommissionRates NewCommission = types.NewCommission @@ -190,8 +181,6 @@ var ( NewDescription = types.NewDescription // variable aliases - Addrs = keeper.Addrs - PKs = keeper.PKs ModuleCdc = types.ModuleCdc PoolKey = types.PoolKey LastValidatorPowerKey = types.LastValidatorPowerKey @@ -234,13 +223,7 @@ type ( RedelegationEntryResponse = types.RedelegationEntryResponse RedelegationResponses = types.RedelegationResponses CodeType = types.CodeType - DistributionKeeper = types.DistributionKeeper - FeeCollectionKeeper = types.FeeCollectionKeeper - BankKeeper = types.BankKeeper AccountKeeper = types.AccountKeeper - ValidatorSet = types.ValidatorSet - DelegationSet = types.DelegationSet - StakingHooks = types.StakingHooks GenesisState = types.GenesisState LastValidatorPower = types.LastValidatorPower MultiStakingHooks = types.MultiStakingHooks diff --git a/x/staking/handler_test.go b/x/staking/handler_test.go index 429b6610fa..29f4961c41 100644 --- a/x/staking/handler_test.go +++ b/x/staking/handler_test.go @@ -56,7 +56,7 @@ func TestValidatorByPowerIndex(t *testing.T) { validator, found := keeper.GetValidator(ctx, validatorAddr) require.True(t, found) power := GetValidatorsByPowerIndexKey(validator) - require.True(t, ValidatorByPowerIndexExists(ctx, keeper, power)) + require.True(t, keep.ValidatorByPowerIndexExists(ctx, keeper, power)) // create a second validator keep it bonded msgCreateValidator = NewTestMsgCreateValidator(validatorAddr3, keep.PKs[2], initBond) diff --git a/x/staking/keeper/test_common.go b/x/staking/keeper/test_common.go index a2e13c3664..2753bf0a79 100644 --- a/x/staking/keeper/test_common.go +++ b/x/staking/keeper/test_common.go @@ -1,4 +1,4 @@ -package keeper +package keeper // noalias import ( "bytes" diff --git a/x/staking/module.go b/x/staking/module.go index 527c50ed16..0c4e9a61a5 100644 --- a/x/staking/module.go +++ b/x/staking/module.go @@ -96,14 +96,14 @@ func (AppModuleBasic) BuildCreateValidatorMsg(cliCtx context.CLIContext, type AppModule struct { AppModuleBasic keeper Keeper - fcKeeper FeeCollectionKeeper - distrKeeper DistributionKeeper - accKeeper AccountKeeper + fcKeeper types.FeeCollectionKeeper + distrKeeper types.DistributionKeeper + accKeeper types.AccountKeeper } // NewAppModule creates a new AppModule object func NewAppModule(keeper Keeper, fcKeeper types.FeeCollectionKeeper, - distrKeeper types.DistributionKeeper, accKeeper AccountKeeper) AppModule { + distrKeeper types.DistributionKeeper, accKeeper types.AccountKeeper) AppModule { return AppModule{ AppModuleBasic: AppModuleBasic{}, diff --git a/x/staking/types/expected_keepers.go b/x/staking/types/expected_keepers.go index c029320721..4470daba89 100644 --- a/x/staking/types/expected_keepers.go +++ b/x/staking/types/expected_keepers.go @@ -6,18 +6,18 @@ import ( "github.com/cosmos/cosmos-sdk/x/staking/exported" ) -// expected coin keeper +// expected coin keeper (noalias) type DistributionKeeper interface { GetFeePoolCommunityCoins(ctx sdk.Context) sdk.DecCoins GetValidatorOutstandingRewardsCoins(ctx sdk.Context, val sdk.ValAddress) sdk.DecCoins } -// expected fee collection keeper +// expected fee collection keeper (noalias) type FeeCollectionKeeper interface { GetCollectedFees(ctx sdk.Context) sdk.Coins } -// expected bank keeper +// expected bank keeper (noalias) type BankKeeper interface { DelegateCoins(ctx sdk.Context, addr sdk.AccAddress, amt sdk.Coins) (sdk.Tags, sdk.Error) UndelegateCoins(ctx sdk.Context, addr sdk.AccAddress, amt sdk.Coins) (sdk.Tags, sdk.Error) @@ -28,7 +28,7 @@ type AccountKeeper interface { IterateAccounts(ctx sdk.Context, process func(auth.Account) (stop bool)) } -// ValidatorSet expected properties for the set of all validators +// ValidatorSet expected properties for the set of all validators (noalias) type ValidatorSet interface { // iterate through validators by operator address, execute func for each validator IterateValidators(sdk.Context, @@ -60,7 +60,7 @@ type ValidatorSet interface { MaxValidators(sdk.Context) uint16 } -// DelegationSet expected properties for the set of all delegations for a particular +// DelegationSet expected properties for the set of all delegations for a particular (noalias) type DelegationSet interface { GetValidatorSet() ValidatorSet // validator set for which delegation set is based upon @@ -77,7 +77,7 @@ type DelegationSet interface { // state. The second keeper must implement this interface, which then the // staking keeper can call. -// StakingHooks event hooks for staking validator object +// StakingHooks event hooks for staking validator object (noalias) type StakingHooks interface { AfterValidatorCreated(ctx sdk.Context, valAddr sdk.ValAddress) // Must be called when a validator is created BeforeValidatorModified(ctx sdk.Context, valAddr sdk.ValAddress) // Must be called when a validator's state changes diff --git a/x/staking/types/validator.go b/x/staking/types/validator.go index 598426e15d..f2b1f1777c 100644 --- a/x/staking/types/validator.go +++ b/x/staking/types/validator.go @@ -9,7 +9,7 @@ import ( abci "github.com/tendermint/tendermint/abci/types" "github.com/tendermint/tendermint/crypto" tmtypes "github.com/tendermint/tendermint/types" - "gopkg.in/yaml.v2" + yaml "gopkg.in/yaml.v2" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" @@ -49,6 +49,7 @@ type Validator struct { MinSelfDelegation sdk.Int `json:"min_self_delegation"` // validator's self declared minimum self delegation } +// custom marshal yaml function due to consensus pubkey func (v Validator) MarshalYAML() (interface{}, error) { bs, err := yaml.Marshal(struct { OperatorAddress sdk.ValAddress