Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion retriever/lib/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,9 @@ export async function getOwnerAndValidateClient(env, clientAddress, rootCid) {
`Wallet '${clientAddress}' is sanctioned and cannot retrieve root_cid '${rootCid}'.`,
)

const withApprovedProvider = withCDN.filter((row) => row.piece_retrieval_url)
const withApprovedProvider = withClientNotSanctioned.filter(
(row) => row.piece_retrieval_url,
)
httpAssert(
withApprovedProvider.length > 0,
404,
Expand Down
28 changes: 28 additions & 0 deletions retriever/test/store.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { env } from 'cloudflare:test'
import {
withProofSetRoots,
withApprovedProvider,
withWalletDetails,
} from './test-data-builders.js'

describe('logRetrievalResult', () => {
Expand Down Expand Up @@ -174,6 +175,33 @@ describe('getOwnerAndValidateClient', () => {
)
})

it('returns error when client wallet is sanctioned', async () => {
const cid = 'cid-sanctioned'
const proofSetId = 'set-sanctioned'
const railId = 'rail-sanctioned'
const owner = APPROVED_OWNER_ADDRESS
const clientAddress = '0xabcdef1234567890abcdef1234567890abcdef13'

await withApprovedProvider(env, { ownerAddress: owner })

await withProofSetRoots(env, {
owner,
clientAddress,
rootCid: cid,
proofSetId,
railId,
withCDN: true,
rootId: 'root-sanctioned',
})

await withWalletDetails(env, clientAddress, true)

await assert.rejects(
async () => await getOwnerAndValidateClient(env, clientAddress, cid),
/sanctioned/,
)
})

it('returns ownerAddress for approved owner', async () => {
const cid = 'cid-approved'
const setId = 'set-approved'
Expand Down
2 changes: 1 addition & 1 deletion retriever/test/test-data-builders.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export async function withApprovedProvider(
) {
await env.DB.prepare(
`
INSERT INTO provider_urls (address, piece_retrieval_url)
INSERT OR IGNORE INTO provider_urls (address, piece_retrieval_url)
VALUES (?, ?)
`,
)
Expand Down
Loading