Skip to content

Commit 7c1b808

Browse files
committed
fix: ensure
1 parent 1393d1b commit 7c1b808

File tree

2 files changed

+24
-18
lines changed

2 files changed

+24
-18
lines changed

packages/indexer-common/src/indexing-fees/__tests__/dips.test.ts

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,25 @@ const setup = async () => {
107107
dipsCollector = network.dipsCollector!
108108
}
109109

110+
const ensureGlobalIndexingRule = async () => {
111+
const indexerManagementClient = await createIndexerManagementClient({
112+
models: managementModels,
113+
graphNode,
114+
logger,
115+
defaults: {
116+
globalIndexingRule: {
117+
allocationAmount: parseGRT('1000'),
118+
parallelAllocations: 1,
119+
},
120+
},
121+
network,
122+
})
123+
124+
const operator = new Operator(logger, indexerManagementClient, networkSpecWithDips)
125+
await operator.ensureGlobalIndexingRule()
126+
logger.debug('Ensured global indexing rule')
127+
}
128+
110129
const setupEach = async () => {
111130
sequelize = await sequelize.sync({ force: true })
112131
}
@@ -275,6 +294,7 @@ describe('DipsManager', () => {
275294
})
276295

277296
test('creates indexing rules for active agreements', async () => {
297+
await ensureGlobalIndexingRule()
278298
// Mock fetch the subgraph deployment from the network subgraph
279299
network.networkMonitor.subgraphDeployment = jest
280300
.fn()
@@ -301,6 +321,7 @@ describe('DipsManager', () => {
301321
})
302322

303323
test('does not create or modify an indexing rule if it already exists', async () => {
324+
await ensureGlobalIndexingRule()
304325
// Create an indexing rule with the same identifier
305326
await managementModels.IndexingRule.create({
306327
identifier: testDeploymentId,
@@ -441,23 +462,6 @@ describe('DipsCollector', () => {
441462
graphNode.entityCount = jest.fn().mockResolvedValue([250000])
442463
})
443464
test('collects payment for a specific agreement', async () => {
444-
const indexerManagementClient = await createIndexerManagementClient({
445-
models: managementModels,
446-
graphNode,
447-
logger,
448-
defaults: {
449-
globalIndexingRule: {
450-
allocationAmount: parseGRT('1000'),
451-
parallelAllocations: 1,
452-
},
453-
},
454-
network,
455-
})
456-
457-
const operator = new Operator(logger, indexerManagementClient, networkSpecWithDips)
458-
await operator.ensureGlobalIndexingRule()
459-
logger.debug('Ensured global indexing rule')
460-
461465
const agreement = await managementModels.IndexingAgreement.findOne({
462466
where: { id: testAgreementId },
463467
})

packages/indexer-common/src/indexing-fees/dips.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,9 @@ export class DipsManager {
128128
agreement.subgraph_deployment_id,
129129
)
130130
this.logger.info(
131-
`Checking if indexing rule exists for agreement ${agreement.id}, deployment ${subgraphDeploymentID.toString()}`,
131+
`Checking if indexing rule exists for agreement ${
132+
agreement.id
133+
}, deployment ${subgraphDeploymentID.toString()}`,
132134
)
133135
// If there is not yet an indexingRule that deems this deployment worth allocating to, make one
134136
if (!(await this.parent.matchingRuleExists(this.logger, subgraphDeploymentID))) {

0 commit comments

Comments
 (0)