Skip to content

Commit

Permalink
fix: upgrade w3up client rc with receipt poll for accept (#384)
Browse files Browse the repository at this point in the history
Tests blob client with storacha/w3up#1459
  • Loading branch information
vasco-santos committed Jun 4, 2024
1 parent 921c0d8 commit 62eb7c3
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 8 deletions.
66 changes: 61 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"@web3-storage/data-segment": "5.1.0",
"@web3-storage/filecoin-client": "^3.3.3",
"@web3-storage/upload-client": "16.0.1",
"@web3-storage/w3up-client": "14.0.0-rc.2",
"@web3-storage/w3up-client": "14.0.0-rc.4",
"ava": "^4.3.3",
"chalk": "4.1.2",
"constructs": "10.3.0",
Expand Down
5 changes: 4 additions & 1 deletion test/bridge.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import pWaitFor from 'p-wait-for'
import { test } from './helpers/context.js'
import {
getApiEndpoint,
getReceiptsEndpoint,
getDynamoDb
} from './helpers/deployment.js'
import { randomFile } from './helpers/random.js'
Expand Down Expand Up @@ -114,7 +115,9 @@ test('the bridge can make various types of requests', async t => {
// verify that uploading a file changes the upload/list response
// upload a file and wait for it to show up
const file = await randomFile(42)
const fileLink = await client.uploadFile(file)
const fileLink = await client.uploadFile(file, {
receiptsEndpoint: getReceiptsEndpoint()
})
let secondReceipts
await pWaitFor(async () => {
const secondResponse = await makeBridgeRequest(
Expand Down
2 changes: 2 additions & 0 deletions test/filecoin.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
getApiEndpoint,
getAwsBucketClient,
getRoundaboutEndpoint,
getReceiptsEndpoint,
getDynamoDb,
getStage,
getAwsRegion
Expand Down Expand Up @@ -74,6 +75,7 @@ test('w3filecoin integration flow', async t => {
})
console.log(`shard file written with {${meta.cid}, ${content}, ${meta.piece}}`)
},
receiptsEndpoint: getReceiptsEndpoint()
})
t.is(uploadFiles.length, 1)
return uploadFiles[0]
Expand Down
18 changes: 18 additions & 0 deletions test/helpers/deployment.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,24 @@ export const getRoundaboutEndpoint = () => {
return testEnv[`${getStackName()}-${id}`].ApiEndpoint
}

export const getReceiptsEndpoint = () => {
// CI/CD deployment
if (process.env.SEED_APP_NAME) {
const stage = getStage()
return `https://${stage}.up.web3.storage/receipt/`
}

const require = createRequire(import.meta.url)
const testEnv = require(path.join(
process.cwd(),
'.sst/outputs.json'
))

// Get Upload API endpoint
const id = 'UploadApiStack'
return `${testEnv[`${getStackName()}-${id}`].ApiEndpoint}/receipt/`
}

export const getSatnavBucketInfo = () => {
// CI/CD deployment
if (process.env.SEED_APP_NAME) {
Expand Down
4 changes: 3 additions & 1 deletion test/integration.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
getApiEndpoint,
getCloudflareBucketClient,
getRoundaboutEndpoint,
getReceiptsEndpoint,
getDynamoDb
} from './helpers/deployment.js'
import { createMailSlurpInbox, createNewClient, setupNewClient } from './helpers/up-client.js'
Expand Down Expand Up @@ -177,7 +178,8 @@ test('w3infra store/upload integration flow', async t => {
onShardStored: (meta) => {
shards.push(meta.cid)
console.log('Shard file written', meta.cid)
}
},
receiptsEndpoint: getReceiptsEndpoint()
})
t.truthy(fileLink)
t.is(shards.length, 1)
Expand Down

0 comments on commit 62eb7c3

Please sign in to comment.