|
| 1 | +// +build unit |
| 2 | + |
| 3 | +package app |
| 4 | + |
| 5 | +import ( |
| 6 | + "testing" |
| 7 | + |
| 8 | + sdk "github.com/cosmos/cosmos-sdk/types" |
| 9 | + "github.com/cosmos/cosmos-sdk/types/errors" |
| 10 | + "github.com/cosmos/cosmos-sdk/x/distribution" |
| 11 | + "github.com/tendermint/tendermint/crypto/secp256k1" |
| 12 | + |
| 13 | + "github.com/dfinance/dnode/cmd/config" |
| 14 | +) |
| 15 | + |
| 16 | +// Check disabled distribution transactions. |
| 17 | +func TestDistribution_MessagesNotWorking(t *testing.T) { |
| 18 | + t.Parallel() |
| 19 | + |
| 20 | + app, appStop := NewTestDnAppMockVM() |
| 21 | + defer appStop() |
| 22 | + |
| 23 | + genValidators, _, _, _ := CreateGenAccounts(9, GenDefCoins(t)) |
| 24 | + nodePrivKey := secp256k1.PrivKeySecp256k1(CheckSetGenesisMockVM(t, app, genValidators)) |
| 25 | + nodePubKey := nodePrivKey.PubKey() |
| 26 | + nodeAddress := sdk.AccAddress(nodePubKey.Address()) |
| 27 | + valAddress := sdk.ValAddress(nodePubKey.Address()) |
| 28 | + |
| 29 | + // check withdraw rewards tx. |
| 30 | + { |
| 31 | + senderAcc, senderPrivKey := GetAccountCheckTx(app, nodeAddress), nodePrivKey |
| 32 | + // need delegator and validator address. |
| 33 | + withdrawRewardsMsg := distribution.NewMsgWithdrawDelegatorReward(nodeAddress, valAddress) |
| 34 | + tx := GenTx([]sdk.Msg{withdrawRewardsMsg}, []uint64{senderAcc.GetAccountNumber()}, []uint64{senderAcc.GetSequence()}, senderPrivKey) |
| 35 | + CheckDeliverSpecificErrorTx(t, app, tx, errors.ErrUnknownRequest) |
| 36 | + } |
| 37 | + |
| 38 | + // check withdraw validator comission tx. |
| 39 | + { |
| 40 | + senderAcc, senderPrivKey := GetAccountCheckTx(app, nodeAddress), nodePrivKey |
| 41 | + withdrawComissionMsg := distribution.NewMsgWithdrawValidatorCommission(valAddress) |
| 42 | + tx := GenTx([]sdk.Msg{withdrawComissionMsg}, []uint64{senderAcc.GetAccountNumber()}, []uint64{senderAcc.GetSequence()}, senderPrivKey) |
| 43 | + CheckDeliverSpecificErrorTx(t, app, tx, errors.ErrUnknownRequest) |
| 44 | + } |
| 45 | + |
| 46 | + // check fund community pool. |
| 47 | + { |
| 48 | + senderAcc, senderPrivKey := GetAccountCheckTx(app, nodeAddress), nodePrivKey |
| 49 | + withdrawComissionMsg := distribution.MsgFundCommunityPool(sdk.NewCoins(sdk.NewCoin(config.MainDenom, sdk.NewInt(1))), nodeAddress) |
| 50 | + tx := GenTx([]sdk.Msg{withdrawComissionMsg}, []uint64{senderAcc.GetAccountNumber()}, []uint64{senderAcc.GetSequence()}, senderPrivKey) |
| 51 | + CheckDeliverSpecificErrorTx(t, app, tx, errors.ErrUnknownRequest) |
| 52 | + } |
| 53 | + |
| 54 | + // check set withdraw address. |
| 55 | + { |
| 56 | + senderAcc, senderPrivKey := GetAccountCheckTx(app, nodeAddress), nodePrivKey |
| 57 | + withdrawAddress := distribution.NewMsgSetWithdrawAddress(nodeAddress, sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address())) |
| 58 | + tx := GenTx([]sdk.Msg{withdrawAddress}, []uint64{senderAcc.GetAccountNumber()}, []uint64{senderAcc.GetSequence()}, senderPrivKey) |
| 59 | + CheckDeliverSpecificErrorTx(t, app, tx, errors.ErrUnknownRequest) |
| 60 | + } |
| 61 | +} |
0 commit comments