@@ -257,6 +257,17 @@ contract("Voting Hybrid", (accounts) => {
257
257
expect ( deprecated ) . to . equal ( true ) ;
258
258
} ) ;
259
259
260
+ it ( "cannot make a motion before initialised" , async ( ) => {
261
+ voting = await VotingHybrid . new ( ) ;
262
+ await voting . install ( colony . address ) ;
263
+
264
+ const action = await encodeTxData ( colony , "makeTask" , [ 1 , UINT256_MAX , FAKE , 1 , 0 , 0 ] ) ;
265
+ await checkErrorRevert (
266
+ voting . createRootMotion ( ADDRESS_ZERO , action , domain1Key , domain1Value , domain1Mask , domain1Siblings ) ,
267
+ "voting-base-not-active"
268
+ ) ;
269
+ } ) ;
270
+
260
271
it ( "cannot initialise twice or more if not root" , async ( ) => {
261
272
await checkErrorRevert ( voting . initialise ( HALF , HALF , WAD , WAD , YEAR , YEAR , YEAR , YEAR ) , "voting-base-already-initialised" ) ;
262
273
await checkErrorRevert ( voting . initialise ( HALF , HALF , WAD , WAD , YEAR , YEAR , YEAR , YEAR , { from : USER2 } ) , "voting-base-caller-not-root" ) ;
@@ -314,6 +325,15 @@ contract("Voting Hybrid", (accounts) => {
314
325
expect ( motion . skillId ) . to . eq . BN ( domain1 . skillId ) ;
315
326
} ) ;
316
327
328
+ it ( "does not lock the token when a motion is created" , async ( ) => {
329
+ const action = await encodeTxData ( colony , "makeTask" , [ 1 , UINT256_MAX , FAKE , 1 , 0 , 0 ] ) ;
330
+ await voting . createRootMotion ( ADDRESS_ZERO , action , domain1Key , domain1Value , domain1Mask , domain1Siblings ) ;
331
+ const motionId = await voting . getMotionCount ( ) ;
332
+
333
+ const lockId = await voting . getLockId ( motionId ) ;
334
+ expect ( lockId ) . to . be . zero ;
335
+ } ) ;
336
+
317
337
it ( "can create a motion with an alternative target" , async ( ) => {
318
338
const action = await encodeTxData ( colony , "makeTask" , [ 1 , 0 , FAKE , 2 , 0 , 0 ] ) ;
319
339
await voting . createRootMotion ( voting . address , action , domain1Key , domain1Value , domain1Mask , domain1Siblings ) ;
@@ -742,6 +762,32 @@ contract("Voting Hybrid", (accounts) => {
742
762
await voting . revealVote ( motionId , SALT , NAY , { from : USER0 } ) ;
743
763
} ) ;
744
764
765
+ it ( "locks the token when the first reveal is made" , async ( ) => {
766
+ await voting . submitVote ( motionId , soliditySha3 ( SALT , NAY ) , user0Key , user0Value , user0Mask , user0Siblings , { from : USER0 } ) ;
767
+
768
+ await forwardTime ( SUBMIT_PERIOD , this ) ;
769
+
770
+ let lockId = await voting . getLockId ( motionId ) ;
771
+ expect ( lockId ) . to . be . zero ;
772
+
773
+ await voting . revealVote ( motionId , SALT , NAY , { from : USER0 } ) ;
774
+
775
+ lockId = await voting . getLockId ( motionId ) ;
776
+ expect ( lockId ) . to . not . be . zero ;
777
+ } ) ;
778
+
779
+ it ( "can unlock the token once revealed" , async ( ) => {
780
+ await voting . submitVote ( motionId , soliditySha3 ( SALT , NAY ) , user0Key , user0Value , user0Mask , user0Siblings , { from : USER0 } ) ;
781
+
782
+ await forwardTime ( SUBMIT_PERIOD , this ) ;
783
+
784
+ await voting . revealVote ( motionId , SALT , NAY , { from : USER0 } ) ;
785
+
786
+ const lockId = await voting . getLockId ( motionId ) ;
787
+ const { lockCount } = await tokenLocking . getUserLock ( token . address , USER0 ) ;
788
+ expect ( lockCount ) . to . eq . BN ( lockId ) ;
789
+ } ) ;
790
+
745
791
it ( "can tally votes from two users" , async ( ) => {
746
792
await voting . submitVote ( motionId , soliditySha3 ( SALT , YAY ) , user0Key , user0Value , user0Mask , user0Siblings , { from : USER0 } ) ;
747
793
await voting . submitVote ( motionId , soliditySha3 ( SALT , YAY ) , user1Key , user1Value , user1Mask , user1Siblings , { from : USER1 } ) ;
0 commit comments