11import { expect } from "chai" ;
22import { ERRORS } from "./helpers/errors.js" ;
3- import { ethers , allocGenesis } from "./helpers/setup.js" ;
3+ import { ethers , networkHelpers , allocGenesis } from "./helpers/setup.js" ;
44
55describe ( "CommitteeMultiSig" , function ( ) {
66
7- let signers : any ;
7+ let MultiSig : any , MockCaller : any ;
8+ let signers : any , snapshot : any ;
89
9- beforeEach ( async function ( ) {
10+ before ( async function ( ) {
1011 signers = await ethers . getSigners ( ) ;
1112 await allocGenesis ( ) ;
13+ MultiSig = await ethers . deployContract ( "CommitteeMultiSig" ) ;
14+ MockCaller = await ethers . deployContract ( "MockMultiSig" ) ;
15+ snapshot = await networkHelpers . takeSnapshot ( ) ;
1216 } ) ;
1317
14- describe ( "execute" , function ( ) {
15- let MultiSig : any , Mock : any ;
16-
17- beforeEach ( async function ( ) {
18- MultiSig = await ethers . deployContract ( "CommitteeMultiSig" ) ;
19- Mock = await ethers . deployContract ( "MockMultiSig" ) ;
20- } ) ;
18+ afterEach ( async function ( ) {
19+ await snapshot . restore ( ) ;
20+ } ) ;
2121
22+ describe ( "execute" , function ( ) {
2223 it ( "Should revert if the sender is not a miner" , async function ( ) {
2324 await expect (
24- MultiSig . connect ( signers [ 7 ] ) . execute ( Mock . target , "0xa1b2ca7d0000000000000000000000000000000000000000000000000000000000000001" )
25+ MultiSig . connect ( signers [ 7 ] ) . execute ( MockCaller . target , "0xa1b2ca7d0000000000000000000000000000000000000000000000000000000000000001" )
2526 ) . to . be . revertedWithCustomError ( MultiSig , ERRORS . NOT_MINER ) ;
2627 } ) ;
2728
2829 it ( "Should not execute method when threshold is not met" , async function ( ) {
2930 await expect (
30- MultiSig . connect ( signers [ 0 ] ) . execute ( Mock . target , "0xa1b2ca7d0000000000000000000000000000000000000000000000000000000000000001" )
31- ) . not . to . be . reverted ( ethers ) ;
31+ MultiSig . connect ( signers [ 0 ] ) . execute ( MockCaller . target , "0xa1b2ca7d0000000000000000000000000000000000000000000000000000000000000001" )
32+ ) . not . to . be . revert ( ethers ) ;
3233
33- expect ( await Mock . v ( ) ) . to . eq ( 0 ) ;
34+ expect ( await MockCaller . v ( ) ) . to . eq ( 0 ) ;
3435 } ) ;
3536
3637 it ( "Should execute method when threshold is met" , async function ( ) {
3738 for ( let i = 0 ; i < 3 ; i ++ ) {
3839 await expect (
39- MultiSig . connect ( signers [ i ] ) . execute ( Mock . target , "0xa1b2ca7d0000000000000000000000000000000000000000000000000000000000000001" )
40- ) . not . to . be . reverted ( ethers ) ;
40+ MultiSig . connect ( signers [ i ] ) . execute ( MockCaller . target , "0xa1b2ca7d0000000000000000000000000000000000000000000000000000000000000001" )
41+ ) . not . to . be . revert ( ethers ) ;
4142 }
42- expect ( await Mock . v ( ) ) . to . eq ( 0 ) ;
43+ expect ( await MockCaller . v ( ) ) . to . eq ( 0 ) ;
4344
4445 await expect (
45- MultiSig . connect ( signers [ 3 ] ) . execute ( Mock . target , "0xa1b2ca7d0000000000000000000000000000000000000000000000000000000000000001" )
46- ) . not . to . be . reverted ( ethers ) ;
47- expect ( await Mock . v ( ) ) . to . eq ( 1 ) ;
46+ MultiSig . connect ( signers [ 3 ] ) . execute ( MockCaller . target , "0xa1b2ca7d0000000000000000000000000000000000000000000000000000000000000001" )
47+ ) . not . to . be . revert ( ethers ) ;
48+ expect ( await MockCaller . v ( ) ) . to . eq ( 1 ) ;
4849 } ) ;
4950 } ) ;
5051} ) ;
0 commit comments