@@ -3,7 +3,7 @@ import { assert, expect } from "chai";
33import hre from "hardhat" ;
44import { getAddress } from "viem" ;
55import { hardhat } from "viem/chains" ;
6- import { GenderEnum } from "../../types" ;
6+ import { GenderEnum , ElectionStatusEnum } from "../../types" ;
77import { getDobEpochFromAge } from "../../lib/utils" ;
88
99describe ( "ElectionDatabase Unit Tests" , function ( ) {
@@ -445,7 +445,7 @@ describe("ElectionDatabase Unit Tests", function () {
445445 electionDatabase . write . enrollCandidate ( [ 0n ] , {
446446 account : candidate1 . account ,
447447 } )
448- ) . to . be . rejectedWith ( "ElectionDatabase__ElectionActive " ) ;
448+ ) . to . be . rejectedWith ( "ElectionDatabase__ElectionNotNew " ) ;
449449 } ) ;
450450
451451 it ( "should revert if candidate not registered in CandidateDatabase" , async function ( ) {
@@ -553,7 +553,7 @@ describe("ElectionDatabase Unit Tests", function () {
553553 electionDatabase . write . withdrawCandidate ( [ 0n ] , {
554554 account : candidate1 . account ,
555555 } )
556- ) . to . be . rejectedWith ( "ElectionDatabase__ElectionActive " ) ;
556+ ) . to . be . rejectedWith ( "ElectionDatabase__ElectionNotNew " ) ;
557557 } ) ;
558558
559559 it ( "should revert if candidate not enrolled" , async function ( ) {
@@ -768,13 +768,13 @@ describe("ElectionDatabase Unit Tests", function () {
768768 ) ;
769769
770770 // Verify election status
771- const isActive = await electionDatabase . read . getElectionStatus ( [ 0n ] ) ;
772- assert . equal ( isActive , true ) ;
771+ const status = await electionDatabase . read . getElectionStatus ( [ 0n ] ) ;
772+ assert . equal ( status , ElectionStatusEnum . ACTIVE ) ;
773773 } ) ;
774774 } ) ;
775775
776- describe ( "adminCloseElection " , function ( ) {
777- it ( "should emit ElectionClosed on success" , async function ( ) {
776+ describe ( "adminCompleteElection " , function ( ) {
777+ it ( "should emit ElectionCompleted on success" , async function ( ) {
778778 const { electionDatabase, candidate1, owner, publicClient } =
779779 await loadFixture ( deployElectionDatabaseFixture ) ;
780780
@@ -794,11 +794,11 @@ describe("ElectionDatabase Unit Tests", function () {
794794 const hash3 = await electionDatabase . write . adminOpenElection ( [ 0n ] ) ;
795795 await publicClient . waitForTransactionReceipt ( { hash : hash3 } ) ;
796796
797- // Close election
798- const hash4 = await electionDatabase . write . adminCloseElection ( [ 0n ] ) ;
797+ // Complete election
798+ const hash4 = await electionDatabase . write . adminCompleteElection ( [ 0n ] ) ;
799799 await publicClient . waitForTransactionReceipt ( { hash : hash4 } ) ;
800800
801- const events = await electionDatabase . getEvents . ElectionClosed ( ) ;
801+ const events = await electionDatabase . getEvents . ElectionCompleted ( ) ;
802802 expect ( events ) . to . have . lengthOf ( 1 ) ;
803803 assert . equal ( events [ 0 ] . args . electionId , 0n ) ;
804804 assert . equal (
@@ -807,8 +807,8 @@ describe("ElectionDatabase Unit Tests", function () {
807807 ) ;
808808
809809 // Verify election status
810- const isActive = await electionDatabase . read . getElectionStatus ( [ 0n ] ) ;
811- assert . equal ( isActive , false ) ;
810+ const status = await electionDatabase . read . getElectionStatus ( [ 0n ] ) ;
811+ assert . equal ( status , ElectionStatusEnum . COMPLETED ) ;
812812 } ) ;
813813 } ) ;
814814 } ) ;
@@ -867,7 +867,7 @@ describe("ElectionDatabase Unit Tests", function () {
867867 electionDatabase . write . vote ( [ 0n , candidate1 . account . address ] , {
868868 account : voter1 . account ,
869869 } )
870- ) . to . be . rejectedWith ( "ElectionDatabase__ElectionClosed " ) ;
870+ ) . to . be . rejectedWith ( "ElectionDatabase__ElectionNotActive " ) ;
871871 } ) ;
872872
873873 it ( "should revert if candidate not enrolled in election" , async function ( ) {
@@ -1041,7 +1041,7 @@ describe("ElectionDatabase Unit Tests", function () {
10411041 const details = await electionDatabase . read . getElectionDetails ( [ 0n ] ) ;
10421042 assert . equal ( details [ 0 ] , "Presidential Election 2023" ) ;
10431043 assert . equal ( details [ 1 ] , "National presidential election" ) ;
1044- assert . equal ( details [ 2 ] , false ) ; // isActive
1044+ assert . equal ( details [ 2 ] , ElectionStatusEnum . NEW ) ; // status
10451045 assert . equal ( details [ 3 ] . length , 1 ) ; // candidates array
10461046 assert . equal (
10471047 getAddress ( details [ 3 ] [ 0 ] ) ,
0 commit comments