@@ -144,7 +144,11 @@ mod tests {
144144 }
145145 }
146146
147- fn cast ( & mut self , voter : usize , proposal : & VerifierChangeProposal ) -> Option < AccountId > {
147+ fn must_cast (
148+ & mut self ,
149+ voter : usize ,
150+ proposal : & VerifierChangeProposal ,
151+ ) -> Option < AccountId > {
148152 self . votes
149153 . vote ( proposal. clone ( ) , self . voters [ voter] . clone ( ) , & self . params )
150154 . unwrap ( )
@@ -184,7 +188,7 @@ mod tests {
184188 let proposal = proposal ( "v.near" , 1 ) ;
185189
186190 // When one participant votes
187- let result = voting. cast ( 0 , & proposal) ;
191+ let result = voting. must_cast ( 0 , & proposal) ;
188192
189193 // Then no candidate wins yet, and the single vote is recorded
190194 assert_eq ! ( result, None ) ;
@@ -201,8 +205,8 @@ mod tests {
201205 let proposal = proposal ( "v.near" , 1 ) ;
202206
203207 // When two participants vote for the same (account, hash)
204- assert_eq ! ( voting. cast ( 0 , & proposal) , None ) ;
205- let result = voting. cast ( 1 , & proposal) ;
208+ assert_eq ! ( voting. must_cast ( 0 , & proposal) , None ) ;
209+ let result = voting. must_cast ( 1 , & proposal) ;
206210
207211 // Then the candidate wins and all pending votes are cleared
208212 assert_eq ! ( result, Some ( proposal. candidate_account_id) ) ;
@@ -218,8 +222,8 @@ mod tests {
218222 let proposal_hash_2 = proposal ( candidate, 2 ) ;
219223
220224 // When two participants vote for the same account but different code hashes
221- assert_eq ! ( voting. cast ( 0 , & proposal_hash_1) , None ) ;
222- let result = voting. cast ( 1 , & proposal_hash_2) ;
225+ assert_eq ! ( voting. must_cast ( 0 , & proposal_hash_1) , None ) ;
226+ let result = voting. must_cast ( 1 , & proposal_hash_2) ;
223227
224228 // Then neither bucket reaches threshold: the two votes land in separate
225229 // (account, hash) buckets.
@@ -241,16 +245,16 @@ mod tests {
241245 let second_proposal = proposal ( "b.near" , 1 ) ;
242246
243247 // When the same voter votes, then switches to a different candidate
244- voting. cast ( 0 , & first_proposal) ;
245- voting. cast ( 0 , & second_proposal) ;
248+ voting. must_cast ( 0 , & first_proposal) ;
249+ voting. must_cast ( 0 , & second_proposal) ;
246250
247251 // Then only the b.near vote remains (the a.near bucket is gone); a
248252 // second voter on b.near then crosses.
249253 assert_eq ! (
250254 voting. votes. pending( ) ,
251255 expected_votes( [ ( second_proposal. clone( ) , vec![ voting. voter( 0 ) ] ) ] )
252256 ) ;
253- let result = voting. cast ( 1 , & second_proposal) ;
257+ let result = voting. must_cast ( 1 , & second_proposal) ;
254258 assert_eq ! ( result, Some ( second_proposal. candidate_account_id) ) ;
255259 }
256260
@@ -259,7 +263,7 @@ mod tests {
259263 // Given 3 participants, threshold 2, and one recorded vote
260264 let mut voting = Voting :: with_threshold ( 2 ) ;
261265 let proposal = proposal ( "v.near" , 1 ) ;
262- voting. cast ( 0 , & proposal) ;
266+ voting. must_cast ( 0 , & proposal) ;
263267 assert_eq ! (
264268 voting. votes. pending( ) ,
265269 expected_votes( [ ( proposal, vec![ voting. voter( 0 ) ] ) ] )
@@ -281,8 +285,8 @@ mod tests {
281285 // Given 3 participants, threshold 3, and two voters sharing one bucket
282286 let mut voting = Voting :: with_threshold ( 3 ) ;
283287 let proposal = proposal ( "v.near" , 1 ) ;
284- voting. cast ( 0 , & proposal) ;
285- voting. cast ( 1 , & proposal) ;
288+ voting. must_cast ( 0 , & proposal) ;
289+ voting. must_cast ( 1 , & proposal) ;
286290 let both_voters =
287291 expected_votes ( [ ( proposal. clone ( ) , vec ! [ voting. voter( 0 ) , voting. voter( 1 ) ] ) ] ) ;
288292 assert_eq ! ( voting. votes. pending( ) , both_voters) ;
0 commit comments