Skip to content

Commit

Permalink
fix(tests): disable flaky filecoin test for now
Browse files Browse the repository at this point in the history
currently, seed.run fails 90%+ of the time because of the Filecoin test.

until we have a more reliable way to test the filecoin flow, the PR disables it.

the inserted comment suggests a few solutions -- either spinning up
custom infra for w3filecoin pipeline on each pr to get more reliable
results, or mocking out the pipeline
  • Loading branch information
hannahhoward committed Aug 30, 2024
1 parent e626c59 commit d106204
Showing 1 changed file with 57 additions and 45 deletions.
102 changes: 57 additions & 45 deletions test/filecoin.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {},
Expand Down Expand Up @@ -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)
// )
}))
})

Expand Down

0 comments on commit d106204

Please sign in to comment.