@@ -987,12 +987,16 @@ describe("api", async () => {
987
987
WHTokenBalance . fromString ( "150" ) ,
988
988
) ;
989
989
990
+ let voteStart = Math . floor ( Date . now ( ) / 1000 ) + 12 ;
990
991
let proposalIdInput = await addTestProposal (
991
992
user3StakeConnection ,
992
- Math . floor ( Date . now ( ) / 1000 ) + 12 ,
993
+ voteStart ,
993
994
) ;
994
- await sleep ( 13000 ) ;
995
995
996
+ while ( voteStart >= Math . floor ( Date . now ( ) / 1000 ) ) {
997
+ await sleep ( 1000 ) ;
998
+ }
999
+ await sleep ( 1000 ) ;
996
1000
await user3StakeConnection . castVote (
997
1001
proposalIdInput ,
998
1002
new BN ( 10 ) ,
@@ -1027,6 +1031,7 @@ describe("api", async () => {
1027
1031
it ( "should cast vote with the correct weight" , async ( ) => {
1028
1032
let stakeAccountCheckpointsAddress ;
1029
1033
let proposalIdInput ;
1034
+ let voteStart ;
1030
1035
1031
1036
// Create 6 checkpoints, 1 second apart
1032
1037
for ( let i = 0 ; i < 6 ; i ++ ) {
@@ -1038,15 +1043,20 @@ describe("api", async () => {
1038
1043
// Create a proposal with a start time 10 seconds in the future in iteration 5
1039
1044
// We do this because the vote weight window is 10 seconds
1040
1045
if ( i == 4 ) {
1046
+ voteStart = Math . floor ( Date . now ( ) / 1000 ) + 10 ;
1041
1047
proposalIdInput = await addTestProposal (
1042
1048
user7StakeConnection ,
1043
- Math . floor ( Date . now ( ) / 1000 ) + 10 ,
1049
+ voteStart ,
1044
1050
) ;
1045
1051
}
1046
1052
1047
1053
await sleep ( 1000 ) ;
1048
1054
}
1049
1055
1056
+ while ( voteStart >= Math . floor ( Date . now ( ) / 1000 ) ) {
1057
+ await sleep ( 1000 ) ;
1058
+ }
1059
+ await sleep ( 1000 ) ;
1050
1060
await user7StakeConnection . castVote (
1051
1061
proposalIdInput ,
1052
1062
new BN ( 10 ) ,
@@ -1062,7 +1072,6 @@ describe("api", async () => {
1062
1072
assert . equal ( againstVotes . toString ( ) , "10" ) ;
1063
1073
assert . equal ( forVotes . toString ( ) , "20" ) ;
1064
1074
assert . equal ( abstainVotes . toString ( ) , "12" ) ;
1065
-
1066
1075
} ) ;
1067
1076
1068
1077
it ( "should fail to castVote if next voter checkpoints are invalid" , async ( ) => {
@@ -1090,6 +1099,9 @@ describe("api", async () => {
1090
1099
) ;
1091
1100
}
1092
1101
await sleep ( 5000 ) ;
1102
+ while ( voteStart >= Math . floor ( Date . now ( ) / 1000 ) ) {
1103
+ await sleep ( 1000 ) ;
1104
+ }
1093
1105
1094
1106
let currentStakeAccountCheckpointsAddress =
1095
1107
await user4StakeConnection . getStakeAccountCheckpointsAddress (
0 commit comments