@@ -132,6 +132,8 @@ func (s *IntegrationTestSuite) testGovCommunityPoolSpend() {
132132 sendAmount := sdk .NewInt64Coin (uatoneDenom , 10_000_000 ) // 10atone
133133 s .writeGovCommunitySpendProposal (s .chainA , sendAmount , recipient )
134134
135+ beforeSenderBalance , err := getSpecificBalance (chainAAPIEndpoint , sender , uatoneDenom )
136+ s .Require ().NoError (err )
135137 beforeRecipientBalance , err := getSpecificBalance (chainAAPIEndpoint , recipient , uatoneDenom )
136138 s .Require ().NoError (err )
137139
@@ -140,8 +142,20 @@ func (s *IntegrationTestSuite) testGovCommunityPoolSpend() {
140142 submitGovFlags := []string {configFile (proposalCommunitySpendFilename )}
141143 depositGovFlags := []string {strconv .Itoa (proposalCounter ), depositAmount .String ()}
142144 voteGovFlags := []string {strconv .Itoa (proposalCounter ), "yes" }
143- s .submitGovProposal (chainAAPIEndpoint , sender , proposalCounter , "CommunityPoolSpend" , submitGovFlags , depositGovFlags , voteGovFlags , "vote" )
145+ s .submitGovProposal (chainAAPIEndpoint , sender , proposalCounter , "CommunityPoolSpend" , submitGovFlags , depositGovFlags , voteGovFlags , "vote" , govtypesv1beta1 .StatusPassed )
146+
147+ // Check that sender is refunded with the proposal deposit
148+ s .Require ().Eventually (
149+ func () bool {
150+ afterSenderBalance , err := getSpecificBalance (chainAAPIEndpoint , sender , uatoneDenom )
151+ s .Require ().NoError (err )
144152
153+ return afterSenderBalance .IsEqual (beforeSenderBalance )
154+ },
155+ 10 * time .Second ,
156+ time .Second ,
157+ )
158+ // Check that recipient received the community pool spend
145159 s .Require ().Eventually (
146160 func () bool {
147161 afterRecipientBalance , err := getSpecificBalance (chainAAPIEndpoint , recipient , uatoneDenom )
@@ -153,6 +167,53 @@ func (s *IntegrationTestSuite) testGovCommunityPoolSpend() {
153167 time .Second ,
154168 )
155169 })
170+ s .Run ("community pool spend with number of no votes exceeds threshold" , func () {
171+ s .fundCommunityPool ()
172+ chainAAPIEndpoint := fmt .Sprintf ("http://%s" , s .valResources [s .chainA .id ][0 ].GetHostPort ("1317/tcp" ))
173+ senderAddress , _ := s .chainA .validators [0 ].keyInfo .GetAddress ()
174+ sender := senderAddress .String ()
175+ recipientAddress , _ := s .chainA .validators [1 ].keyInfo .GetAddress ()
176+ recipient := recipientAddress .String ()
177+ sendAmount := sdk .NewInt64Coin (uatoneDenom , 10_000_000 ) // 10atone
178+ s .writeGovCommunitySpendProposal (s .chainA , sendAmount , recipient )
179+
180+ beforeSenderBalance , err := getSpecificBalance (chainAAPIEndpoint , sender , uatoneDenom )
181+ s .Require ().NoError (err )
182+ beforeRecipientBalance , err := getSpecificBalance (chainAAPIEndpoint , recipient , uatoneDenom )
183+ s .Require ().NoError (err )
184+
185+ // Gov tests may be run in arbitrary order, each test must increment proposalCounter to have the correct proposal id to submit and query
186+ proposalCounter ++
187+ submitGovFlags := []string {configFile (proposalCommunitySpendFilename )}
188+ depositGovFlags := []string {strconv .Itoa (proposalCounter ), depositAmount .String ()}
189+ voteGovFlags := []string {strconv .Itoa (proposalCounter ), "no" }
190+ s .submitGovProposal (chainAAPIEndpoint , sender , proposalCounter , "CommunityPoolSpend" , submitGovFlags , depositGovFlags , voteGovFlags , "vote" , govtypesv1beta1 .StatusRejected )
191+
192+ // Check that sender is not refunded with the proposal deposit
193+ s .Require ().Eventually (
194+ func () bool {
195+ afterSenderBalance , err := getSpecificBalance (chainAAPIEndpoint , sender , uatoneDenom )
196+ s .Require ().NoError (err )
197+
198+ return afterSenderBalance .Add (depositAmount ).Add (initialDepositAmount ).
199+ IsEqual (beforeSenderBalance )
200+ },
201+ 10 * time .Second ,
202+ time .Second ,
203+ )
204+ // Check that recipient didnt receive the community pool spend since the
205+ // proposal was rejected
206+ s .Require ().Eventually (
207+ func () bool {
208+ afterRecipientBalance , err := getSpecificBalance (chainAAPIEndpoint , recipient , uatoneDenom )
209+ s .Require ().NoError (err )
210+
211+ return afterRecipientBalance .IsEqual (beforeRecipientBalance )
212+ },
213+ 10 * time .Second ,
214+ time .Second ,
215+ )
216+ })
156217}
157218
158219// testGovParamChange tests passing a param change proposal.
@@ -173,7 +234,7 @@ func (s *IntegrationTestSuite) testGovParamChange() {
173234 submitGovFlags := []string {configFile (proposalParamChangeFilename )}
174235 depositGovFlags := []string {strconv .Itoa (proposalCounter ), depositAmount .String ()}
175236 voteGovFlags := []string {strconv .Itoa (proposalCounter ), "yes" }
176- s .submitGovProposal (chainAAPIEndpoint , sender , proposalCounter , "cosmos.staking.v1beta1.MsgUpdateParams" , submitGovFlags , depositGovFlags , voteGovFlags , "vote" )
237+ s .submitGovProposal (chainAAPIEndpoint , sender , proposalCounter , "cosmos.staking.v1beta1.MsgUpdateParams" , submitGovFlags , depositGovFlags , voteGovFlags , "vote" , govtypesv1beta1 . StatusPassed )
177238
178239 newParams := s .queryStakingParams (chainAAPIEndpoint )
179240 s .Assert ().NotEqual (oldMaxValidator , newParams .Params .MaxValidators )
@@ -196,7 +257,7 @@ func (s *IntegrationTestSuite) testGovParamChange() {
196257 submitGovFlags := []string {configFile (proposalParamChangeFilename )}
197258 depositGovFlags := []string {strconv .Itoa (proposalCounter ), depositAmount .String ()}
198259 voteGovFlags := []string {strconv .Itoa (proposalCounter ), "yes" }
199- s .submitGovProposal (chainAAPIEndpoint , sender , proposalCounter , "atomone.photon.v1.MsgUpdateParams" , submitGovFlags , depositGovFlags , voteGovFlags , "vote" )
260+ s .submitGovProposal (chainAAPIEndpoint , sender , proposalCounter , "atomone.photon.v1.MsgUpdateParams" , submitGovFlags , depositGovFlags , voteGovFlags , "vote" , govtypesv1beta1 . StatusPassed )
200261
201262 newParams := s .queryPhotonParams (chainAAPIEndpoint )
202263 s .Assert ().True (newParams .Params .MintDisabled , "expected photon param mint disabled to be true" )
@@ -207,7 +268,7 @@ func (s *IntegrationTestSuite) testGovParamChange() {
207268 depositGovFlags = []string {strconv .Itoa (proposalCounter ), depositAmount .String ()}
208269 voteGovFlags = []string {strconv .Itoa (proposalCounter ), "yes" }
209270 s .writePhotonParamChangeProposal (s .chainA , params .Params )
210- s .submitGovProposal (chainAAPIEndpoint , sender , proposalCounter , "atomone.photon.v1.MsgUpdateParams" , submitGovFlags , depositGovFlags , voteGovFlags , "vote" )
271+ s .submitGovProposal (chainAAPIEndpoint , sender , proposalCounter , "atomone.photon.v1.MsgUpdateParams" , submitGovFlags , depositGovFlags , voteGovFlags , "vote" , govtypesv1beta1 . StatusPassed )
211272
212273 newParams = s .queryPhotonParams (chainAAPIEndpoint )
213274 s .Require ().False (newParams .Params .MintDisabled , "expected photon param mint disabled to be false" )
@@ -229,7 +290,7 @@ func (s *IntegrationTestSuite) testGovConstitutionAmendment() {
229290 submitGovFlags := []string {configFile (proposalConstitutionAmendmentFilename )}
230291 depositGovFlags := []string {strconv .Itoa (proposalCounter ), depositAmount .String ()}
231292 voteGovFlags := []string {strconv .Itoa (proposalCounter ), "yes" }
232- s .submitGovProposal (chainAAPIEndpoint , sender , proposalCounter , "gov/MsgSubmitProposal" , submitGovFlags , depositGovFlags , voteGovFlags , "vote" )
293+ s .submitGovProposal (chainAAPIEndpoint , sender , proposalCounter , "gov/MsgSubmitProposal" , submitGovFlags , depositGovFlags , voteGovFlags , "vote" , govtypesv1beta1 . StatusPassed )
233294
234295 s .Require ().Eventually (
235296 func () bool {
@@ -260,14 +321,14 @@ func (s *IntegrationTestSuite) submitLegacyGovProposal(chainAAPIEndpoint, sender
260321// Instead, the deposit is added to the "deposit" field of the proposal JSON (usually stored as a file)
261322// you can use `atomoned tx gov draft-proposal` to create a proposal file that you can use
262323// min initial deposit of 100uatone is required in e2e tests, otherwise the proposal would be dropped
263- func (s * IntegrationTestSuite ) submitGovProposal (chainAAPIEndpoint , sender string , proposalID int , proposalType string , submitFlags []string , depositFlags []string , voteFlags []string , voteCommand string ) {
324+ func (s * IntegrationTestSuite ) submitGovProposal (chainAAPIEndpoint , sender string , proposalID int , proposalType string , submitFlags []string , depositFlags []string , voteFlags []string , voteCommand string , expectedStatusAfterVote govtypesv1beta1. ProposalStatus ) {
264325 s .T ().Logf ("Submitting Gov Proposal: %s" , proposalType )
265326 sflags := submitFlags
266327 s .submitGovCommand (chainAAPIEndpoint , sender , proposalID , "submit-proposal" , sflags , govtypesv1beta1 .StatusDepositPeriod )
267328 s .T ().Logf ("Depositing Gov Proposal: %s" , proposalType )
268329 s .submitGovCommand (chainAAPIEndpoint , sender , proposalID , "deposit" , depositFlags , govtypesv1beta1 .StatusVotingPeriod )
269330 s .T ().Logf ("Voting Gov Proposal: %s" , proposalType )
270- s .submitGovCommand (chainAAPIEndpoint , sender , proposalID , voteCommand , voteFlags , govtypesv1beta1 . StatusPassed )
331+ s .submitGovCommand (chainAAPIEndpoint , sender , proposalID , voteCommand , voteFlags , expectedStatusAfterVote )
271332}
272333
273334func (s * IntegrationTestSuite ) verifyChainHaltedAtUpgradeHeight (c * chain , valIdx int , upgradeHeight int64 ) {
0 commit comments