@@ -213,7 +213,7 @@ pub enum GovMsg {
213
213
#[ cfg( feature = "cosmwasm_1_2" ) ]
214
214
VoteWeighted {
215
215
proposal_id : u64 ,
216
- vote : WeightedVoteOption ,
216
+ options : Vec < WeightedVoteOption > ,
217
217
} ,
218
218
}
219
219
@@ -359,4 +359,47 @@ mod tests {
359
359
"Execute { contract_addr: \" joe\" , msg: Binary(009f9296), funds: [] }"
360
360
) ;
361
361
}
362
+
363
+ #[ test]
364
+ #[ cfg( feature = "stargate" ) ]
365
+ fn gov_msg_serializes_to_correct_json ( ) {
366
+ // Vote
367
+ let msg = GovMsg :: Vote {
368
+ proposal_id : 4 ,
369
+ vote : VoteOption :: NoWithVeto ,
370
+ } ;
371
+ let json = to_binary ( & msg) . unwrap ( ) ;
372
+ assert_eq ! (
373
+ String :: from_utf8_lossy( & json) ,
374
+ r#"{"vote":{"proposal_id":4,"vote":"no_with_veto"}}"# ,
375
+ ) ;
376
+
377
+ // VoteWeighted
378
+ #[ cfg( feature = "cosmwasm_1_2" ) ]
379
+ {
380
+ let msg = GovMsg :: VoteWeighted {
381
+ proposal_id : 25 ,
382
+ options : vec ! [
383
+ WeightedVoteOption {
384
+ weight: Decimal :: percent( 25 ) ,
385
+ option: VoteOption :: Yes ,
386
+ } ,
387
+ WeightedVoteOption {
388
+ weight: Decimal :: percent( 25 ) ,
389
+ option: VoteOption :: No ,
390
+ } ,
391
+ WeightedVoteOption {
392
+ weight: Decimal :: percent( 50 ) ,
393
+ option: VoteOption :: Abstain ,
394
+ } ,
395
+ ] ,
396
+ } ;
397
+
398
+ let json = to_binary ( & msg) . unwrap ( ) ;
399
+ assert_eq ! (
400
+ String :: from_utf8_lossy( & json) ,
401
+ r#"{"vote_weighted":{"proposal_id":25,"options":[{"option":"yes","weight":"0.25"},{"option":"no","weight":"0.25"},{"option":"abstain","weight":"0.5"}]}}"# ,
402
+ ) ;
403
+ }
404
+ }
362
405
}
0 commit comments