Skip to content

Commit

Permalink
fix: handle empty responses
Browse files Browse the repository at this point in the history
  • Loading branch information
aboutlo committed Nov 23, 2023
1 parent ecde67f commit a73d216
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export async function upload(buildDir, privateKey, dryRun) {
)
while (!response.confirmed?.number_of_confirmations > 0) {
console.log(
`${txId} confirmations: ${response.confirmed.number_of_confirmations}`,
`${txId} confirmations: ${response.confirmed?.number_of_confirmations}`,
)
await sleep(1000 * 5)
response = await arweave.transactions.getStatus(txId)
Expand Down
5 changes: 4 additions & 1 deletion src/upload.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe('upload', () => {
},
}))

// getStatusMock.mock.mockImplementationOnce()

getStatusMock.mock.mockImplementationOnce(() => ({
confirmed: {
number_of_confirmations: 0,
Expand All @@ -47,6 +47,9 @@ describe('upload', () => {
},
}))

// empty response
getStatusMock.mock.mockImplementationOnce(() => ({}))

signMock = mock.fn()
arweaveMock = mock.method(arweave, 'init', () => {
return {
Expand Down

0 comments on commit a73d216

Please sign in to comment.