Skip to content

Commit

Permalink
more debug
Browse files Browse the repository at this point in the history
  • Loading branch information
paulo-ocean committed Jul 24, 2024
1 parent 5d6e2e8 commit 498d1b0
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 14 deletions.
1 change: 1 addition & 0 deletions src/components/storage/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ export class ArweaveStorage extends Storage {
forceChecksum: boolean
): Promise<FileInfoResponse> {
const url = urlJoin(process.env.ARWEAVE_GATEWAY, fileObject.transactionId)
console.log('URL:', url)
const { contentLength, contentType, contentChecksum } = await fetchFileMetadata(
url,
'get',
Expand Down
24 changes: 12 additions & 12 deletions src/test/unit/storage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ describe('URL Storage with malformed URL', () => {
})

describe('Arweave Storage getFileInfo tests', function () {
this.timeout(15000)
// this.timeout(15000)
let storage: ArweaveStorage

console.log('STORAGE TESTING....')
Expand All @@ -348,18 +348,18 @@ describe('Arweave Storage getFileInfo tests', function () {
assert(fileInfo[0].contentLength === '680782', 'Content length is incorrect')
})

// it('Throws error when transaction ID is missing in request', async () => {
// console.log('DO YOU SEE ME??')
it('Throws error when transaction ID is missing in request', async () => {
console.log('DO YOU SEE ME??')

// const fileInfoRequest: FileInfoRequest = { type: FileObjectType.ARWEAVE }
// try {
// console.log('3 - DO YOU STILL SEE ME??')
// await storage.getFileInfo(fileInfoRequest)
// console.log('4 - DO YOU STILL SEE ME HERE??')
// } catch (err) {
// expect(err.message).to.equal('Transaction ID is required for type arweave')
// }
// })
const fileInfoRequest: FileInfoRequest = { type: FileObjectType.ARWEAVE }
try {
console.log('3 - DO YOU STILL SEE ME??')
await storage.getFileInfo(fileInfoRequest)
console.log('4 - DO YOU STILL SEE ME HERE??')
} catch (err) {
expect(err.message).to.equal('Transaction ID is required for type arweave')
}
})
})

describe('Arweave Storage with malformed transaction ID', () => {
Expand Down
9 changes: 7 additions & 2 deletions src/utils/asset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,12 @@ export async function fetchFileMetadata(
const response = await axios({
url,
method: method || 'get',
responseType: 'stream'
responseType: 'stream',
timeout: 10000 // 10 seconds timeout
})
contentType = response.headers['content-type']
let totalSize = 0
console.log('reading content')
for await (const chunk of response.data) {
totalSize += chunk.length
contentChecksum.update(chunk)
Expand All @@ -56,8 +58,11 @@ export async function fetchFileMetadata(
}
}
contentLength = totalSize
} catch (error) {}
} catch (error) {
console.log('Got error: ', error)
}

console.log('im out')
return {
contentLength: contentLength.toString(),
contentType,
Expand Down

0 comments on commit 498d1b0

Please sign in to comment.