From 475423441c1b6b3e5aa4cad09c718118fd1a9285 Mon Sep 17 00:00:00 2001 From: Maria Carmina Date: Tue, 27 Feb 2024 16:37:24 +0200 Subject: [PATCH] fix. --- src/test/integration/computeFees.test.ts | 105 ++++++++++++----------- 1 file changed, 53 insertions(+), 52 deletions(-) diff --git a/src/test/integration/computeFees.test.ts b/src/test/integration/computeFees.test.ts index a15140b55..4d006c08a 100644 --- a/src/test/integration/computeFees.test.ts +++ b/src/test/integration/computeFees.test.ts @@ -406,59 +406,60 @@ describe('Compute provider fees', async () => { resp.stream.on('end', () => { console.log('Received data:', receivedData) + try { + const receivedDataParsed = JSON.parse(receivedData) + console.log('Parsed data:', receivedDataParsed) + assert(receivedDataParsed.algorithm, 'algorithm does not exist') + assert( + receivedDataParsed.algorithm.providerFeeAddress, + 'algorithm providerFeeAddress does not exist' + ) + assert( + receivedDataParsed.algorithm.providerFeeToken, + 'algorithm providerFeeToken does not exist' + ) + assert( + receivedDataParsed.algorithm.providerFeeAmount === 0, + 'algorithm providerFeeToken does not exist' + ) // it uses the free env + assert( + receivedDataParsed.algorithm.providerFeeData, + 'algorithm providerFeeData does not exist' + ) + + assert( + receivedDataParsed.algorithm.validUntil === + initializeComputeTask.compute.validUntil / 1000, + 'algorithm providerFeeData does not exist' + ) + + assert(receivedDataParsed.datasets.length > 0, 'datasets key does not exist') + assert( + receivedDataParsed.datasets[0].providerFeeAddress, + 'algorithm providerFeeAddress does not exist' + ) + assert( + receivedDataParsed.datasets[0].providerFeeToken, + 'algorithm providerFeeToken does not exist' + ) + assert( + receivedDataParsed.datasets[0].providerFeeAmount === 0, + 'algorithm providerFeeToken does not exist' + ) // it uses the free env + assert( + receivedDataParsed.datasets[0].providerFeeData, + 'algorithm providerFeeData does not exist' + ) + + assert( + receivedDataParsed.datasets[0].validUntil === + initializeComputeTask.compute.validUntil / 1000, + 'algorithm providerFeeData does not exist' + ) + } catch (error) { + console.error('Error parsing JSON:', error) + } }) - - resp.stream.on('error', (err) => { - console.error('Stream error:', err) - }) - const receivedDataParsed = JSON.parse(receivedData) - assert(receivedDataParsed.algorithm, 'algorithm does not exist') - assert( - receivedDataParsed.algorithm.providerFeeAddress, - 'algorithm providerFeeAddress does not exist' - ) - assert( - receivedDataParsed.algorithm.providerFeeToken, - 'algorithm providerFeeToken does not exist' - ) - assert( - receivedDataParsed.algorithm.providerFeeAmount === 0, - 'algorithm providerFeeToken does not exist' - ) // it uses the free env - assert( - receivedDataParsed.algorithm.providerFeeData, - 'algorithm providerFeeData does not exist' - ) - - assert( - receivedDataParsed.algorithm.validUntil === - initializeComputeTask.compute.validUntil / 1000, - 'algorithm providerFeeData does not exist' - ) - - assert(receivedDataParsed.datasets.length > 0, 'datasets key does not exist') - assert( - receivedDataParsed.datasets[0].providerFeeAddress, - 'algorithm providerFeeAddress does not exist' - ) - assert( - receivedDataParsed.datasets[0].providerFeeToken, - 'algorithm providerFeeToken does not exist' - ) - assert( - receivedDataParsed.datasets[0].providerFeeAmount === 0, - 'algorithm providerFeeToken does not exist' - ) // it uses the free env - assert( - receivedDataParsed.datasets[0].providerFeeData, - 'algorithm providerFeeData does not exist' - ) - - assert( - receivedDataParsed.datasets[0].validUntil === - initializeComputeTask.compute.validUntil / 1000, - 'algorithm providerFeeData does not exist' - ) }) after(async () => {