Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
506af8e
feat: add DIPs (Distributed Indexing Payments) support
pcarranzav Jul 24, 2025
40cf61d
feat: complete DIPs integration with ethers v6 migration
pcarranzav Jul 25, 2025
2cbd218
feat: implement receipt-based payment system for DIPs
pcarranzav Aug 1, 2025
7c9328d
fix: update DIP test mock to match receipt-based payment response
Maikol Feb 18, 2026
4867f1c
chore: update toolshed to dips supported version
Maikol Feb 25, 2026
e8eb72f
fix: formatting error
Maikol Feb 26, 2026
1e56892
feat: add pending RCA proposal consumer and migration
Maikol Mar 3, 2026
d61927f
feat: implement on-chain accept for recurring agreements
Maikol Mar 4, 2026
ce96f62
fix: retry allocation ID generation when on-chain collision detected
Maikol Mar 11, 2026
e53e255
feat: use isDenied to determine DIPS allocation token amount
Maikol Mar 13, 2026
116b4bb
refactor: add getPendingProposalsForDeployment and deduplicate test mock
Maikol Mar 13, 2026
8ec9fd9
fix: formatting
Maikol Mar 13, 2026
6991c36
chore: remove reallocate step and add continuous RAV collection for l…
Maikol Mar 17, 2026
ed88229
fix: ci lint issues
Maikol Mar 17, 2026
6d1e759
feat: implement on-chain collect for DIPs agreements
Maikol Mar 23, 2026
6c575b9
fix: linting errors
Maikol Mar 24, 2026
7f73b68
fix: remove contract pre-check from DIPs collection
Maikol Mar 24, 2026
dc68bb2
fix: use tuple encoding and MaxUint256 slippage for DIPs collection
Maikol Apr 3, 2026
c9f63cd
feat: implement on-chain cancel for DIPs agreements
Maikol Apr 3, 2026
940d4c1
fix: dips tests
Maikol Apr 4, 2026
ad6035a
feat: on-chain acceptance fixes for DIPs recurring agreements
MoonBoi9001 Mar 18, 2026
9b96b9f
fix(dips): pass rca and signature as separate args to acceptIndexingA…
MoonBoi9001 Apr 16, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
144 changes: 144 additions & 0 deletions packages/indexer-agent/src/__tests__/agent.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import {
Agent,
convertSubgraphBasedRulesToDeploymentBased,
consolidateAllocationDecisions,
resolveTargetDeployments,
} from '../agent'
import {
ActivationCriteria,
Allocation,
AllocationDecision,
AllocationStatus,
INDEXING_RULE_GLOBAL,
IndexingDecisionBasis,
IndexingRuleAttributes,
Expand Down Expand Up @@ -328,3 +333,142 @@ describe('resolveTargetDeployments function', () => {
)
})
})

describe('reconcileDeploymentAllocationAction', () => {
const deployment = new SubgraphDeploymentID(
'QmXZiV6S13ha6QXq4dmaM3TB4CHcDxBMvGexSNu9Kc28EH',
)

// eslint-disable-next-line @typescript-eslint/no-explicit-any
const mockLogger: any = {
child: jest.fn().mockReturnThis(),
info: jest.fn(),
warn: jest.fn(),
error: jest.fn(),
debug: jest.fn(),
trace: jest.fn(),
}

const activeAllocations: Allocation[] = [
{
id: '0x0000000000000000000000000000000000000001',
status: AllocationStatus.ACTIVE,
isLegacy: false,
subgraphDeployment: {
id: deployment,
ipfsHash: deployment.ipfsHash,
},
indexer: '0x0000000000000000000000000000000000000000',
allocatedTokens: BigInt(1000),
createdAt: 0,
createdAtEpoch: 1,
createdAtBlockHash: '0x0',
closedAt: 0,
closedAtEpoch: 0,
closedAtEpochStartBlockHash: undefined,
previousEpochStartBlockHash: undefined,
closedAtBlockHash: '0x0',
poi: undefined,
queryFeeRebates: undefined,
queryFeesCollected: undefined,
} as unknown as Allocation,
]

const decision = new AllocationDecision(
deployment,
{
identifier: deployment.ipfsHash,
identifierType: SubgraphIdentifierType.DEPLOYMENT,
allocationAmount: '1000',
decisionBasis: IndexingDecisionBasis.RULES,
} as IndexingRuleAttributes,
true,
ActivationCriteria.SIGNAL_THRESHOLD,
'eip155:42161',
)

function createAgent() {
const agent = Object.create(Agent.prototype)
agent.logger = mockLogger
agent.graphNode = {
indexingStatus: jest.fn().mockResolvedValue([
{
subgraphDeployment: { ipfsHash: deployment.ipfsHash },
health: 'healthy',
},
]),
}
agent.identifyExpiringAllocations = jest
.fn()
.mockResolvedValue([activeAllocations[0]])
return agent
}

function createOperator() {
return {
closeEligibleAllocations: jest.fn(),
createAllocation: jest.fn(),
refreshExpiredAllocations: jest.fn(),
presentPOIForAllocations: jest.fn(),
}
}

function createNetwork(isHorizon: boolean) {
return {
isHorizon: { value: jest.fn().mockResolvedValue(isHorizon) },
specification: { networkIdentifier: 'eip155:42161' },
networkMonitor: {
closedAllocations: jest.fn().mockResolvedValue([]),
},
}
}

it('should call presentPOIForAllocations instead of refreshExpiredAllocations for Horizon allocations', async () => {
const agent = createAgent()
const operator = createOperator()
const network = createNetwork(true)

await agent.reconcileDeploymentAllocationAction(
decision,
activeAllocations,
10,
{ value: jest.fn().mockResolvedValue(28) },
network,
operator,
false,
)

expect(agent.identifyExpiringAllocations).toHaveBeenCalled()
expect(operator.refreshExpiredAllocations).not.toHaveBeenCalled()
expect(operator.presentPOIForAllocations).toHaveBeenCalledWith(
expect.anything(),
[activeAllocations[0]],
network,
)
})

it('should call refreshExpiredAllocations for legacy allocations', async () => {
const agent = createAgent()
const operator = createOperator()
const network = createNetwork(false)

await agent.reconcileDeploymentAllocationAction(
decision,
activeAllocations,
10,
{ value: jest.fn().mockResolvedValue(28) },
network,
operator,
false,
)

expect(agent.identifyExpiringAllocations).toHaveBeenCalled()
expect(operator.refreshExpiredAllocations).toHaveBeenCalledWith(
expect.anything(),
decision,
[activeAllocations[0]],
false,
)
expect(operator.presentPOIForAllocations).not.toHaveBeenCalled()
})
})
1 change: 1 addition & 0 deletions packages/indexer-agent/src/__tests__/indexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ const setup = async () => {
const network = await Network.create(
logger,
networkSpecification,
models,
queryFeeModels,
graphNode,
metrics,
Expand Down
Loading