@@ -44,18 +44,6 @@ describe("CrossChainModule", () => {
4444 } ) ,
4545 ) . to . be . revertedWithCustomError ( crossChainModule , "NotInitializing" ) ;
4646 } ) ;
47-
48- it ( "should get exception if try to initialize with zero address" , async ( ) => {
49- const newCrossChainModule = await ethers . deployContract ( "CrossChainModuleMock" ) ;
50-
51- await expect (
52- newCrossChainModule . initialize ( {
53- subscriptionsSynchronizer : ethers . ZeroAddress ,
54- } ) ,
55- )
56- . to . be . revertedWithCustomError ( newCrossChainModule , "ZeroAddr" )
57- . withArgs ( "SubscriptionsSynchronizer" ) ;
58- } ) ;
5947 } ) ;
6048
6149 describe ( "#setSubscriptionSynchronizer" , ( ) => {
@@ -64,12 +52,6 @@ describe("CrossChainModule", () => {
6452
6553 await expect ( tx ) . to . emit ( crossChainModule , "SubscriptionSynchronizerUpdated" ) . withArgs ( FIRST ) ;
6654 } ) ;
67-
68- it ( "should get exception if try to set zero address" , async ( ) => {
69- await expect ( crossChainModule . setSubscriptionSynchronizer ( ethers . ZeroAddress ) )
70- . to . be . revertedWithCustomError ( crossChainModule , "ZeroAddr" )
71- . withArgs ( "SubscriptionsSynchronizer" ) ;
72- } ) ;
7355 } ) ;
7456
7557 describe ( "#extendSubscription" , ( ) => {
@@ -96,5 +78,32 @@ describe("CrossChainModule", () => {
9678 expect ( await crossChainModule . hasActiveSubscription ( FIRST ) ) . to . be . true ;
9779 expect ( await crossChainModule . hasSubscriptionDebt ( FIRST ) ) . to . be . false ;
9880 } ) ;
81+
82+ it ( "should correctly extend subscription and not sync data if synchronizer is zero address" , async ( ) => {
83+ const duration = 3600n * 24n * 30n ;
84+ const expectedStartTime = BigInt ( await time . latest ( ) ) + 100n ;
85+ const expectedEndTime = expectedStartTime + duration ;
86+
87+ await crossChainModule . setSubscriptionSynchronizer ( ethers . ZeroAddress ) ;
88+
89+ expect ( await crossChainModule . getSubscriptionStartTime ( FIRST ) ) . to . be . eq ( 0n ) ;
90+ expect ( await crossChainModule . getSubscriptionEndTime ( FIRST ) ) . to . be . eq ( await time . latest ( ) ) ;
91+ expect ( await crossChainModule . hasSubscription ( FIRST ) ) . to . be . false ;
92+ expect ( await crossChainModule . hasActiveSubscription ( FIRST ) ) . to . be . false ;
93+ expect ( await crossChainModule . hasSubscriptionDebt ( FIRST ) ) . to . be . false ;
94+
95+ await time . setNextBlockTimestamp ( expectedStartTime ) ;
96+ const tx = await crossChainModule . extendSubscription ( FIRST , duration ) ;
97+
98+ await expect ( tx )
99+ . to . emit ( crossChainModule , "SubscriptionExtended" )
100+ . withArgs ( FIRST . address , duration , expectedEndTime ) ;
101+
102+ expect ( await crossChainModule . getSubscriptionStartTime ( FIRST ) ) . to . be . eq ( expectedStartTime ) ;
103+ expect ( await crossChainModule . getSubscriptionEndTime ( FIRST ) ) . to . be . eq ( expectedEndTime ) ;
104+ expect ( await crossChainModule . hasSubscription ( FIRST ) ) . to . be . true ;
105+ expect ( await crossChainModule . hasActiveSubscription ( FIRST ) ) . to . be . true ;
106+ expect ( await crossChainModule . hasSubscriptionDebt ( FIRST ) ) . to . be . false ;
107+ } ) ;
99108 } ) ;
100109} ) ;
0 commit comments