Skip to content
Merged
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
30 changes: 15 additions & 15 deletions packages/synapse-sdk/src/test/sp-registry-service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,26 +55,13 @@ describe('SPRegistryService', () => {
}
throw new Error('Provider not found')
},
getProviderProducts: async (id: number) => {
if (id === 1) {
return [
{
productType: 0, // PDP
isActive: true,
capabilityKeys: [],
productData: '0x', // Encoded PDP offering
},
]
}
return []
},
providerHasProduct: async (id: number, productType: number) => {
return id === 1 && productType === 0
},
getPDPService: async (id: number) => {
if (id === 1) {
return {
offering: {
pdpOffering: {
serviceURL: 'https://provider.example.com',
minPieceSizeInBytes: SIZE_CONSTANTS.KiB,
maxPieceSizeInBytes: SIZE_CONSTANTS.GiB,
Expand Down Expand Up @@ -406,7 +393,20 @@ describe('SPRegistryService', () => {
// Override to return provider without products
;(service as any)._getRegistryContract = () => ({
...createMockContract(),
getProviderProducts: async () => [],
getPDPService: async () => ({
pdpOffering: {
serviceURL: '',
minPieceSizeInBytes: 0,
maxPieceSizeInBytes: 0,
ipniPiece: false,
ipniIpfs: false,
minProvingPeriodInEpochs: 0,
storagePricePerTibPerMonth: 0,
location: '',
},
capabilityKeys: [],
isActive: false,
}),
})

const provider = await service.getProvider(1)
Expand Down
41 changes: 0 additions & 41 deletions packages/synapse-sdk/src/test/test-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -806,47 +806,6 @@ export function setupProviderRegistryMocks(
)
}

// Mock getProviderProducts(uint256) - returns products for provider
if (data?.startsWith('0xb5eb46e1')) {
const providerId = parseInt(data.slice(10, 74), 16)
const provider = providers.find((p) => p.id === providerId)
if (provider?.products?.PDP) {
const pdp = provider.products.PDP

// Encode PDP product data (simplified for testing)
const encodedPDP = ethers.AbiCoder.defaultAbiCoder().encode(
['string', 'uint256', 'uint256', 'bool', 'bool', 'uint256', 'uint256', 'string', 'address'],
[
pdp.data.serviceURL,
pdp.data.minPieceSizeInBytes,
pdp.data.maxPieceSizeInBytes,
pdp.data.ipniPiece,
pdp.data.ipniIpfs,
pdp.data.storagePricePerTibPerMonth,
pdp.data.minProvingPeriodInEpochs,
pdp.data.location || '',
pdp.data.paymentTokenAddress,
]
)

return ethers.AbiCoder.defaultAbiCoder().encode(
['tuple(uint8,bool,bytes32[],bytes)[]'],
[
[
[
0, // productType: PDP
pdp.isActive,
pdp.capabilities ?? [], // capabilityKeys (empty for simplicity)
encodedPDP,
],
],
]
)
}
// Return empty products array
return ethers.AbiCoder.defaultAbiCoder().encode(['tuple(uint8,bool,bytes32[],bytes)[]'], [[]])
}

// Mock decodePDPOffering(bytes) - decode PDP product data
if (data?.startsWith('0xdeb0e462')) {
// For simplicity, return a default PDP offering
Expand Down
Loading