diff --git a/src/lib/indexer/eventProcessor.ts b/src/lib/indexer/eventProcessor.ts index 804ee845..d44d4a96 100644 --- a/src/lib/indexer/eventProcessor.ts +++ b/src/lib/indexer/eventProcessor.ts @@ -297,6 +297,7 @@ const DefaultEventProcessors: EventProcessors = { ]), } }, + /* why this is here? should it not be part of l3-195? 'rematch2-acceptFinal': (version, _transaction, _sender, inputs, outputs) => { if (version !== 1) throw new Error(`Incompatible version ${version} for rematch2-acceptFinal process`) @@ -338,6 +339,7 @@ const DefaultEventProcessors: EventProcessors = { ]), } }, + */ // eslint-disable-next-line @typescript-eslint/no-unused-vars 'match2-reject': (version, _transaction, _sender, inputs, _outputs) => { diff --git a/test/integration/onchain/match2.test.ts b/test/integration/onchain/match2.test.ts index 44901cff..da69fdd8 100644 --- a/test/integration/onchain/match2.test.ts +++ b/test/integration/onchain/match2.test.ts @@ -197,6 +197,50 @@ describe('on-chain', function () { expect(rematch2.latestTokenId).to.equal(lastTokenId + 4) }) + it.only('accepts a rematch2 proposal', async () => { + const proposal = await post(context.app, `/v1/match2/${ids.match2}/proposal`, {}) + await pollTransactionState(db, proposal.body.id, 'finalised') + const resAcceptA = await post(context.app, `/v1/match2/${ids.match2}/accept`, {}) + await pollTransactionState(db, resAcceptA.body.id, 'finalised') + const resAcceptFinal = await post(context.app, `/v1/match2/${ids.match2}/accept`, {}) + await pollTransactionState(db, resAcceptFinal.body.id, 'finalised') + + const lastTokenId = await node.getLastTokenId() + const reMatch = await post(context.app, '/v1/match2', { + demandA: ids.demandA, + demandB: ids.newDemandB, + replaces: ids.match2, + }) + ids.rematch2 = reMatch.body['id'] as string + + const resProposal = await post(context.app, `/v1/match2/${ids.rematch2}/proposal`, {}) + console.log({ resProposal, reMatch }) + await pollTransactionState(db, resProposal.body.id, 'finalised') + + // output + const [match2]: Match2Row[] = await db.getMatch2(ids.match2) + const [demandA]: DemandRow[] = await db.getDemand(ids.demandA) + const [demandB]: DemandRow[] = await db.getDemand(match2.demandB) + const [newDemandB]: DemandRow[] = await db.getDemand(ids.newDemandB) + const [rematch2]: Match2Row[] = await db.getMatch2(ids.rematch2) + + expect(demandA.state).to.equal('allocated') + expect(demandA.latestTokenId).to.equal(lastTokenId + 1) + expect(demandA.originalTokenId).to.equal(ids.originalDemandA) + + expect(demandB.state).to.equal('allocated') + expect(demandB.latestTokenId).to.equal(lastTokenId + 2) + + expect(match2.state).to.equal('cancelled') + expect(match2.latestTokenId).to.equal(lastTokenId + 3) + + expect(newDemandB.state).to.equal('allocated') + expect(newDemandB.latestTokenId).to.equal(lastTokenId + 4) + + expect(rematch2.state).to.equal('acceptedA') + expect(rematch2.latestTokenId).to.equal(lastTokenId + 5) + }) + describe('if multiple accepts have been submitted', () => { it('handles error and marks only one transaction finalised and others as failed', async () => { const proposal = await post(context.app, `/v1/match2/${ids.match2}/proposal`, {})