Updates for upstream PR (community pool spend proposal) (#10)
Related cosmos/cosmos-sdk#4329
This commit is contained in:
committed by
Alessio Treglia
parent
5350d3b01b
commit
5c5bf7c49b
@@ -301,6 +301,14 @@ func InitializeTestLCD(t *testing.T, nValidators int, initAddrs []sdk.AccAddress
|
||||
accs = append(accs, acc)
|
||||
}
|
||||
|
||||
// distr data
|
||||
distrDataBz := genesisState[distr.ModuleName]
|
||||
var distrData distr.GenesisState
|
||||
cdc.MustUnmarshalJSON(distrDataBz, &distrData)
|
||||
distrData.FeePool.CommunityPool = sdk.DecCoins{sdk.DecCoin{"test", sdk.NewDecFromInt(sdk.NewInt(10))}}
|
||||
distrDataBz = cdc.MustMarshalJSON(distrData)
|
||||
genesisState[distr.ModuleName] = distrDataBz
|
||||
|
||||
// now add the account tokens to the non-bonded pool
|
||||
for _, acc := range accs {
|
||||
accTokens := acc.Coins.AmountOf(sdk.DefaultBondDenom)
|
||||
@@ -438,7 +446,7 @@ func registerRoutes(rs *lcd.RestServer) {
|
||||
distrrest.RegisterRoutes(rs.CliCtx, rs.Mux, rs.Cdc, distr.StoreKey)
|
||||
stakingrest.RegisterRoutes(rs.CliCtx, rs.Mux, rs.Cdc, rs.KeyBase)
|
||||
slashingrest.RegisterRoutes(rs.CliCtx, rs.Mux, rs.Cdc, rs.KeyBase)
|
||||
govrest.RegisterRoutes(rs.CliCtx, rs.Mux, rs.Cdc, paramsrest.ProposalRESTHandler(rs.CliCtx, rs.Cdc))
|
||||
govrest.RegisterRoutes(rs.CliCtx, rs.Mux, rs.Cdc, paramsrest.ProposalRESTHandler(rs.CliCtx, rs.Cdc), distrrest.ProposalRESTHandler(rs.CliCtx, rs.Cdc))
|
||||
mintrest.RegisterRoutes(rs.CliCtx, rs.Mux, rs.Cdc)
|
||||
}
|
||||
|
||||
@@ -1221,6 +1229,44 @@ func doSubmitParamChangeProposal(
|
||||
return txResp
|
||||
}
|
||||
|
||||
func doSubmitCommunityPoolSpendProposal(
|
||||
t *testing.T, port, seed, name, pwd string, proposerAddr sdk.AccAddress,
|
||||
amount sdk.Int, fees sdk.Coins,
|
||||
) sdk.TxResponse {
|
||||
|
||||
acc := getAccount(t, port, proposerAddr)
|
||||
accnum := acc.GetAccountNumber()
|
||||
sequence := acc.GetSequence()
|
||||
chainID := viper.GetString(client.FlagChainID)
|
||||
from := acc.GetAddress().String()
|
||||
|
||||
baseReq := rest.NewBaseReq(from, "", chainID, "", "", accnum, sequence, fees, nil, false)
|
||||
pr := distrrest.CommunityPoolSpendProposalReq{
|
||||
BaseReq: baseReq,
|
||||
Title: "Test",
|
||||
Description: "test",
|
||||
Proposer: proposerAddr,
|
||||
Recipient: proposerAddr,
|
||||
Deposit: sdk.Coins{sdk.NewCoin(sdk.DefaultBondDenom, amount)},
|
||||
Amount: sdk.Coins{sdk.NewCoin("test", sdk.NewInt(5))},
|
||||
}
|
||||
|
||||
req, err := cdc.MarshalJSON(pr)
|
||||
require.NoError(t, err)
|
||||
|
||||
resp, body := Request(t, port, "POST", "/gov/proposals/community_pool_spend", req)
|
||||
require.Equal(t, http.StatusOK, resp.StatusCode, body)
|
||||
|
||||
resp, body = signAndBroadcastGenTx(t, port, name, pwd, body, acc, client.DefaultGasAdjustment, false)
|
||||
require.Equal(t, http.StatusOK, resp.StatusCode, body)
|
||||
|
||||
var txResp sdk.TxResponse
|
||||
err = cdc.UnmarshalJSON([]byte(body), &txResp)
|
||||
require.NoError(t, err)
|
||||
|
||||
return txResp
|
||||
}
|
||||
|
||||
// GET /gov/proposals Query proposals
|
||||
func getProposalsAll(t *testing.T, port string) []gov.Proposal {
|
||||
res, body := Request(t, port, "GET", "/gov/proposals", nil)
|
||||
|
||||
Reference in New Issue
Block a user