mirror of
https://github.com/oceanprotocol/ocean.js.git
synced 2024-11-26 20:39:05 +01:00
add compute test with published algo
This commit is contained in:
parent
2bf04170d7
commit
fdbc692064
@ -68,7 +68,9 @@ export class Compute extends Instantiable {
|
||||
algorithmMeta?: MetadataAlgorithm,
|
||||
output?: Output,
|
||||
serviceIndex?: string,
|
||||
serviceType?: string
|
||||
serviceType?: string,
|
||||
algorithmTransferTxId?: string,
|
||||
algorithmDataToken?: string
|
||||
): Promise<ComputeJob> {
|
||||
output = this.checkOutput(consumerAccount, output)
|
||||
if (did) {
|
||||
@ -83,7 +85,9 @@ export class Compute extends Instantiable {
|
||||
txId,
|
||||
serviceIndex,
|
||||
serviceType,
|
||||
tokenAddress
|
||||
tokenAddress,
|
||||
algorithmTransferTxId,
|
||||
algorithmDataToken
|
||||
)
|
||||
return computeJobsList[0] as ComputeJob
|
||||
} else return null
|
||||
|
@ -144,10 +144,11 @@ export class Provider extends Instantiable {
|
||||
txId?: string,
|
||||
serviceIndex?: string,
|
||||
serviceType?: string,
|
||||
tokenAddress?: string
|
||||
tokenAddress?: string,
|
||||
algorithmTransferTxId?: string,
|
||||
algorithmDataToken?: string
|
||||
): Promise<ComputeJob | ComputeJob[]> {
|
||||
const address = consumerAccount.getId()
|
||||
|
||||
let signatureMessage = address
|
||||
signatureMessage += jobId || ''
|
||||
signatureMessage += (did && `${noZeroX(did)}`) || ''
|
||||
@ -169,6 +170,11 @@ export class Provider extends Instantiable {
|
||||
url += (jobId && `&jobId=${jobId}`) || ''
|
||||
url += `&consumerAddress=${address}`
|
||||
url += `&transferTxId=${txId}` || ''
|
||||
url +=
|
||||
(algorithmTransferTxId &&
|
||||
`&algorithmTransferTxId=${algorithmTransferTxId}`) ||
|
||||
''
|
||||
url += (algorithmDataToken && `&algorithmDataToken=${algorithmDataToken}`) || ''
|
||||
url += `&serviceId=${serviceIndex}` || ''
|
||||
url += `&serviceType=${serviceType}` || ''
|
||||
url += `&dataToken=${tokenAddress}` || ''
|
||||
|
@ -114,7 +114,7 @@ describe('Marketplace flow', () => {
|
||||
})
|
||||
|
||||
it('Alice publishes dataset with a compute service that allows Raw Algo', async () => {
|
||||
price = 10 // in datatoken
|
||||
price = 2 // in datatoken
|
||||
cluster = ocean.compute.createClusterAttributes(
|
||||
'Kubernetes',
|
||||
'http://10.0.0.17/xxx'
|
||||
@ -337,7 +337,53 @@ describe('Marketplace flow', () => {
|
||||
)
|
||||
assert(order === null)
|
||||
})
|
||||
// it('should start a compute job with a published algo', async () => {
|
||||
it('should start a compute job with a published algo', async () => {
|
||||
const output = {}
|
||||
const serviceAlgo = algorithmAsset.findServiceByType('access')
|
||||
const orderalgo = await ocean.assets.order(
|
||||
algorithmAsset.id,
|
||||
serviceAlgo.type,
|
||||
bob.getId()
|
||||
)
|
||||
const algoOrder = JSON.parse(orderalgo)
|
||||
const algoTx = await datatoken.transfer(
|
||||
algoOrder['dataToken'],
|
||||
algoOrder['to'],
|
||||
algoOrder['numTokens'],
|
||||
algoOrder['from']
|
||||
)
|
||||
const order = await ocean.compute.order(
|
||||
bob.getId(),
|
||||
ddo.id,
|
||||
computeService.index,
|
||||
algorithmAsset.id,
|
||||
undefined
|
||||
)
|
||||
assert(order != null)
|
||||
const computeOrder = JSON.parse(order)
|
||||
const tx = await datatoken.transfer(
|
||||
computeOrder['dataToken'],
|
||||
computeOrder['to'],
|
||||
computeOrder['numTokens'],
|
||||
computeOrder['from']
|
||||
)
|
||||
const response = await ocean.compute.start(
|
||||
ddo.id,
|
||||
tx.transactionHash,
|
||||
tokenAddress,
|
||||
bob,
|
||||
undefined,
|
||||
undefined,
|
||||
algorithmMeta,
|
||||
output,
|
||||
computeService.index,
|
||||
computeService.type,
|
||||
algoTx,
|
||||
algorithmAsset.datatoken
|
||||
)
|
||||
jobId = response.jobId
|
||||
assert(response.status >= 10)
|
||||
})
|
||||
// it('Bob restarts compute job', async () => {})
|
||||
// it('Bob gets outputs', async () => {})
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user