@@ -14,16 +14,10 @@ const logger = {
1414const mockQuery = jest . fn ( )
1515const mockNetworkSubgraph = { query : mockQuery } as any
1616
17- const mockGetCollectionInfo = jest . fn ( )
1817const mockCollectEstimateGas = jest . fn ( )
1918const mockCollect = jest . fn ( )
20- const mockGetAgreement = jest . fn ( )
2119
2220const mockContracts = {
23- RecurringCollector : {
24- getCollectionInfo : mockGetCollectionInfo ,
25- getAgreement : mockGetAgreement ,
26- } ,
2721 SubgraphService : {
2822 collect : Object . assign ( mockCollect , {
2923 estimateGas : mockCollectEstimateGas ,
@@ -40,6 +34,7 @@ const mockGraphNode = {
4034 entityCount : jest . fn ( ) ,
4135 proofOfIndexing : jest . fn ( ) ,
4236 blockHashFromNumber : jest . fn ( ) ,
37+ subgraphFeatures : jest . fn ( ) . mockResolvedValue ( { network : 'mainnet' } ) ,
4338} as any
4439
4540const mockNetwork = {
@@ -86,24 +81,6 @@ function makeReadyAgreement(id = '0x00000000000000000000000000000001') {
8681 }
8782}
8883
89- function makeAgreementData ( ) {
90- return {
91- dataService : '0x0000' ,
92- payer : '0x0000' ,
93- serviceProvider : '0x0000' ,
94- acceptedAt : 1000n ,
95- lastCollectionAt : 0n ,
96- endsAt : 9999999999n ,
97- maxInitialTokens : 1000000n ,
98- maxOngoingTokensPerSecond : 100n ,
99- minSecondsPerCollection : 3600 ,
100- maxSecondsPerCollection : 86400 ,
101- updateNonce : 0 ,
102- canceledAt : 0n ,
103- state : 1 ,
104- }
105- }
106-
10784describe ( 'DipsManager.collectAgreementPayments' , ( ) => {
10885 beforeEach ( ( ) => {
10986 jest . clearAllMocks ( )
@@ -132,32 +109,14 @@ describe('DipsManager.collectAgreementPayments', () => {
132109 const dm = createDipsManager ( )
133110 await dm . collectAgreementPayments ( )
134111
135- // Should not even call getAgreement since tracker skips it
136- expect ( mockGetAgreement ) . not . toHaveBeenCalled ( )
137- expect ( mockExecuteTransaction ) . not . toHaveBeenCalled ( )
138- } )
139-
140- test ( 'skips agreement when getCollectionInfo says not collectable' , async ( ) => {
141- mockQuery . mockResolvedValueOnce ( {
142- data : { indexingAgreements : [ makeReadyAgreement ( ) ] } ,
143- } )
144-
145- mockGetAgreement . mockResolvedValueOnce ( makeAgreementData ( ) )
146- mockGetCollectionInfo . mockResolvedValueOnce ( [ false , 0n , 1 ] )
147-
148- const dm = createDipsManager ( )
149- await dm . collectAgreementPayments ( )
150-
151112 expect ( mockExecuteTransaction ) . not . toHaveBeenCalled ( )
152113 } )
153114
154- test ( 'collects payment when agreement is ready and collectable ' , async ( ) => {
115+ test ( 'collects payment when agreement is ready' , async ( ) => {
155116 mockQuery . mockResolvedValueOnce ( {
156117 data : { indexingAgreements : [ makeReadyAgreement ( ) ] } ,
157118 } )
158119
159- mockGetAgreement . mockResolvedValueOnce ( makeAgreementData ( ) )
160- mockGetCollectionInfo . mockResolvedValueOnce ( [ true , 7200n , 0 ] )
161120 mockGraphNode . entityCount . mockResolvedValueOnce ( [ 500 ] )
162121 mockGraphNode . blockHashFromNumber . mockResolvedValueOnce ( '0x' + 'ab' . repeat ( 32 ) )
163122 mockGraphNode . proofOfIndexing . mockResolvedValueOnce ( '0x' + 'cd' . repeat ( 32 ) )
@@ -174,8 +133,6 @@ describe('DipsManager.collectAgreementPayments', () => {
174133 . mockResolvedValueOnce ( { data : { indexingAgreements : [ makeReadyAgreement ( ) ] } } )
175134 . mockResolvedValueOnce ( { data : { indexingAgreements : [ makeReadyAgreement ( ) ] } } )
176135
177- mockGetAgreement . mockResolvedValue ( makeAgreementData ( ) )
178- mockGetCollectionInfo . mockResolvedValue ( [ true , 7200n , 0 ] )
179136 mockGraphNode . entityCount . mockResolvedValue ( [ 500 ] )
180137 mockGraphNode . blockHashFromNumber . mockResolvedValue ( '0x' + 'ab' . repeat ( 32 ) )
181138 mockGraphNode . proofOfIndexing . mockResolvedValue ( '0x' + 'cd' . repeat ( 32 ) )
@@ -198,8 +155,6 @@ describe('DipsManager.collectAgreementPayments', () => {
198155 data : { indexingAgreements : [ makeReadyAgreement ( ) ] } ,
199156 } )
200157
201- mockGetAgreement . mockResolvedValueOnce ( makeAgreementData ( ) )
202- mockGetCollectionInfo . mockResolvedValueOnce ( [ true , 7200n , 0 ] )
203158 mockGraphNode . entityCount . mockResolvedValueOnce ( [ 500 ] )
204159 mockGraphNode . blockHashFromNumber . mockResolvedValueOnce ( '0x' + 'ab' . repeat ( 32 ) )
205160 mockGraphNode . proofOfIndexing . mockResolvedValueOnce ( null ) // POI unavailable
@@ -218,8 +173,6 @@ describe('DipsManager.collectAgreementPayments', () => {
218173 data : { indexingAgreements : [ makeReadyAgreement ( ) ] } ,
219174 } )
220175
221- mockGetAgreement . mockResolvedValueOnce ( makeAgreementData ( ) )
222- mockGetCollectionInfo . mockResolvedValueOnce ( [ true , 7200n , 0 ] )
223176 mockGraphNode . entityCount . mockResolvedValueOnce ( [ 500 ] )
224177 mockGraphNode . blockHashFromNumber . mockResolvedValueOnce ( '0x' + 'ab' . repeat ( 32 ) )
225178 mockGraphNode . proofOfIndexing . mockResolvedValueOnce ( '0x' + 'cd' . repeat ( 32 ) )
0 commit comments