diff --git a/test/filecoin.test.js b/test/filecoin.test.js index 4f37bfbb..2491340b 100644 --- a/test/filecoin.test.js +++ b/test/filecoin.test.js @@ -147,6 +147,7 @@ test('w3filecoin integration flow', async t => { const workflowWithReceiptResponseAfterRedirect = await fetch(workflowLocation) // Get receipt from Message Archive const agentMessageBytes = new Uint8Array((await workflowWithReceiptResponseAfterRedirect.arrayBuffer())) + console.log(agentMessageBytes.length) const agentMessage = await CAR.request.decode({ body: agentMessageBytes, headers: {}, @@ -195,56 +196,67 @@ test('w3filecoin integration flow', async t => { (res) => Boolean(res.ok) ) - // Await for `piece/accept` receipt - const pieceAcceptReceiptCid = receiptPieceOfferRes.ok?.fx.join?.link() - if (!pieceAcceptReceiptCid) { - throw new Error('piece/offer receipt has no effect for piece/accept') - } - console.log(`wait for piece/accept receipt ${pieceAcceptReceiptCid.toString()} ...`) - const receiptPieceAcceptRes = await waitForStoreOperationOkResult( - () => receiptStoreFilecoin.get(pieceAcceptReceiptCid), - (res) => Boolean(res.ok) - ) + // TODO: This code is disabled as it tests running, real, shared infrastructure + // that is maintained outside of this repo, and could fail for reasons unrelated + // to what's happening in this repo + // To the extent we want a kitchen-sink test, it should happen with + // infra deployed specifically for the test, with predictable performance + // Alternatively, if we're simply testing interactions with expected behavior + // for w3-filecoininfra, we should use a mocked version of the service with + // predictable responses. + // This rest of this test is disabled until one of these solutions is put + // in place - // Await for `aggregate/offer` receipt - const aggregateOfferReceiptCid = receiptPieceAcceptRes.ok?.fx.join?.link() - if (!aggregateOfferReceiptCid) { - throw new Error('piece/accept receipt has no effect for aggregate/offer') - } - console.log(`wait for aggregate/offer receipt ${aggregateOfferReceiptCid.toString()} ...`) - const receiptAggregateOfferRes = await waitForStoreOperationOkResult( - () => receiptStoreFilecoin.get(aggregateOfferReceiptCid), - (res) => Boolean(res.ok) - ) + // // Await for `piece/accept` receipt + // const pieceAcceptReceiptCid = receiptPieceOfferRes.ok?.fx.join?.link() + // if (!pieceAcceptReceiptCid) { + // throw new Error('piece/offer receipt has no effect for piece/accept') + // } + // console.log(`wait for piece/accept receipt ${pieceAcceptReceiptCid.toString()} ...`) + // const receiptPieceAcceptRes = await waitForStoreOperationOkResult( + // () => receiptStoreFilecoin.get(pieceAcceptReceiptCid), + // (res) => Boolean(res.ok) + // ) - // @ts-ignore no type for aggregate - const aggregate = receiptAggregateOfferRes.ok?.out.ok?.aggregate + // // Await for `aggregate/offer` receipt + // const aggregateOfferReceiptCid = receiptPieceAcceptRes.ok?.fx.join?.link() + // if (!aggregateOfferReceiptCid) { + // throw new Error('piece/accept receipt has no effect for aggregate/offer') + // } + // console.log(`wait for aggregate/offer receipt ${aggregateOfferReceiptCid.toString()} ...`) + // const receiptAggregateOfferRes = await waitForStoreOperationOkResult( + // () => receiptStoreFilecoin.get(aggregateOfferReceiptCid), + // (res) => Boolean(res.ok) + // ) - // Put FAKE value in table to issue final receipt via cron? - const dealId = 1111 - console.log(`put deal on deal tracker for aggregate ${aggregate}`) - await putDealToDealTracker(aggregate.toString(), dealId) + // // @ts-ignore no type for aggregate + // const aggregate = receiptAggregateOfferRes.ok?.out.ok?.aggregate - // Await for `aggregate/accept` receipt - const aggregateAcceptReceiptCid = receiptAggregateOfferRes.ok?.fx.join?.link() - if (!aggregateAcceptReceiptCid) { - throw new Error('aggregate/offer receipt has no effect for aggregate/accept') - } - console.log(`wait for aggregate/accept receipt ${aggregateAcceptReceiptCid.toString()} ...`) - await waitForStoreOperationOkResult( - async () => { - // Trigger cron to update and issue receipts based on deals - await pRetry(async () => { - const url = 'https://staging.dealer.web3.storage/cron' - const res = await fetch(url) - if (!res.ok) throw new Error(`failed request to ${url}: ${res.status}`) - }, { onFailedAttempt: console.warn }) + // // Put FAKE value in table to issue final receipt via cron? + // const dealId = 1111 + // console.log(`put deal on deal tracker for aggregate ${aggregate}`) + // await putDealToDealTracker(aggregate.toString(), dealId) - return receiptStoreFilecoin.get(aggregateAcceptReceiptCid) - // return agentStoreFilecoin.receipts.get(aggregateAcceptReceiptCid) - }, - (res) => Boolean(res.ok) - ) + // // Await for `aggregate/accept` receipt + // const aggregateAcceptReceiptCid = receiptAggregateOfferRes.ok?.fx.join?.link() + // if (!aggregateAcceptReceiptCid) { + // throw new Error('aggregate/offer receipt has no effect for aggregate/accept') + // } + // console.log(`wait for aggregate/accept receipt ${aggregateAcceptReceiptCid.toString()} ...`) + // await waitForStoreOperationOkResult( + // async () => { + // // Trigger cron to update and issue receipts based on deals + // await pRetry(async () => { + // const url = 'https://staging.dealer.web3.storage/cron' + // const res = await fetch(url) + // if (!res.ok) throw new Error(`failed request to ${url}: ${res.status}`) + // }, { onFailedAttempt: console.warn }) + + // return receiptStoreFilecoin.get(aggregateAcceptReceiptCid) + // // return agentStoreFilecoin.receipts.get(aggregateAcceptReceiptCid) + // }, + // (res) => Boolean(res.ok) + // ) })) })