@@ -173,6 +173,33 @@ func (suite *KeeperTestSuite) TestSubmitProposal() {
173173 }
174174}
175175
176+ // TestSubmitProposal_EmitsMessagesWithoutLeadingComma is a regression test for
177+ // https://github.com/cosmos/cosmos-sdk/issues/26045 — the proposal_messages
178+ // event attribute previously contained a leading comma because each type URL
179+ // was prepended with one inside the loop.
180+ func (suite * KeeperTestSuite ) TestSubmitProposal_EmitsMessagesWithoutLeadingComma () {
181+ suite .reset ()
182+
183+ govAcct := suite .govKeeper .GetGovernanceAccount (suite .ctx ).GetAddress ().String ()
184+ tp := v1beta1.TextProposal {Title : "title" , Description : "description" }
185+ prop , err := v1 .NewLegacyContent (& tp , govAcct )
186+ suite .Require ().NoError (err )
187+
188+ msgs := []sdk.Msg {prop , prop }
189+ _ , err = suite .govKeeper .SubmitProposal (suite .ctx , msgs , "" , "title" , "summary" , suite .addrs [0 ], false )
190+ suite .Require ().NoError (err )
191+
192+ attrs , ok := suite .ctx .EventManager ().Events ().GetAttributes (types .AttributeKeyProposalMessages )
193+ suite .Require ().True (ok , "proposal_messages attribute should be emitted" )
194+ suite .Require ().NotEmpty (attrs )
195+
196+ value := attrs [0 ].Value
197+ suite .Require ().False (strings .HasPrefix (value , "," ), "proposal_messages must not start with a leading comma, got %q" , value )
198+
199+ expected := strings .Join ([]string {sdk .MsgTypeURL (prop ), sdk .MsgTypeURL (prop )}, "," )
200+ suite .Require ().Equal (expected , value )
201+ }
202+
176203func (suite * KeeperTestSuite ) TestCancelProposal () {
177204 govAcct := suite .govKeeper .GetGovernanceAccount (suite .ctx ).GetAddress ().String ()
178205 tp := v1beta1.TextProposal {Title : "title" , Description : "description" }
0 commit comments