mirror of
https://github.com/oceanprotocol/ocean.js.git
synced 2024-11-26 20:39:05 +01:00
fix all tests
This commit is contained in:
parent
4aee155c46
commit
e563f556d1
@ -408,7 +408,7 @@ export class DataTokens {
|
||||
})
|
||||
for (let i = 0; i < events.length; i++) {
|
||||
if (
|
||||
String(events[i].returnValues.amount) === String(amount) &&
|
||||
String(events[i].returnValues.amount) === this.web3.utils.toWei(String(amount)) &&
|
||||
String(events[i].returnValues.serviceId) === String(serviceId)
|
||||
) {
|
||||
const transaction = await this.web3.eth.getTransaction(events[i].transactionHash)
|
||||
|
@ -118,7 +118,7 @@ export class Assets extends Instantiable {
|
||||
provider.setBaseUrl(providerUri)
|
||||
} else provider = this.ocean.provider
|
||||
const encryptedFiles = await provider.encrypt(
|
||||
did.getId(),
|
||||
did.getDid(),
|
||||
metadata.main.files,
|
||||
publisher
|
||||
)
|
||||
@ -494,9 +494,7 @@ export class Assets extends Instantiable {
|
||||
const balance = new BigNumber(
|
||||
await datatokens.balance(providerData.dataToken, consumerAddress)
|
||||
)
|
||||
const totalCost = new BigNumber(
|
||||
this.web3.utils.fromWei(String(providerData.numTokens))
|
||||
)
|
||||
const totalCost = new BigNumber(String(providerData.numTokens))
|
||||
if (balance.isLessThanOrEqualTo(totalCost)) {
|
||||
console.error(
|
||||
'Not enough funds. Needed ' +
|
||||
@ -508,7 +506,7 @@ export class Assets extends Instantiable {
|
||||
}
|
||||
const txid = await datatokens.startOrder(
|
||||
providerData.dataToken,
|
||||
this.web3.utils.fromWei(String(providerData.numTokens)),
|
||||
String(providerData.numTokens),
|
||||
serviceIndex,
|
||||
mpAddress,
|
||||
consumerAddress
|
||||
|
@ -29,6 +29,9 @@ describe('Compute flow', () => {
|
||||
let contracts
|
||||
let datatoken
|
||||
let tokenAddress
|
||||
let tokenAddressNoRawAlgo
|
||||
let tokenAddressWithTrustedAlgo
|
||||
let tokenAddressAlgorithm
|
||||
let price
|
||||
let ocean
|
||||
let computeService
|
||||
@ -79,7 +82,7 @@ describe('Compute flow', () => {
|
||||
await contracts.deployContracts(owner.getId())
|
||||
})
|
||||
|
||||
it('Alice deploys datatoken contract', async () => {
|
||||
it('Alice deploys datatoken contracts', async () => {
|
||||
datatoken = new DataTokens(
|
||||
contracts.factoryAddress,
|
||||
factory.abi as AbiItem[],
|
||||
@ -94,6 +97,32 @@ describe('Compute flow', () => {
|
||||
'DTA'
|
||||
)
|
||||
assert(tokenAddress != null)
|
||||
tokenAddressNoRawAlgo = await datatoken.create(
|
||||
blob,
|
||||
alice.getId(),
|
||||
'10000000000',
|
||||
'AliceDT',
|
||||
'DTA'
|
||||
)
|
||||
assert(tokenAddressNoRawAlgo != null)
|
||||
|
||||
tokenAddressWithTrustedAlgo = await datatoken.create(
|
||||
blob,
|
||||
alice.getId(),
|
||||
'10000000000',
|
||||
'AliceDT',
|
||||
'DTA'
|
||||
)
|
||||
assert(tokenAddressWithTrustedAlgo != null)
|
||||
|
||||
tokenAddressAlgorithm = await datatoken.create(
|
||||
blob,
|
||||
alice.getId(),
|
||||
'10000000000',
|
||||
'AliceDT',
|
||||
'DTA'
|
||||
)
|
||||
assert(tokenAddressAlgorithm != null)
|
||||
})
|
||||
|
||||
it('Generates metadata', async () => {
|
||||
@ -120,7 +149,7 @@ describe('Compute flow', () => {
|
||||
})
|
||||
|
||||
it('Alice publishes dataset with a compute service that allows Raw Algo', async () => {
|
||||
price = datatoken.toWei('2') // in datatoken
|
||||
price = '2' // in datatoken
|
||||
cluster = ocean.compute.createClusterAttributes('Kubernetes', 'http://10.0.0.17/xxx')
|
||||
servers = [
|
||||
ocean.compute.createServerAttributes(
|
||||
@ -165,7 +194,6 @@ describe('Compute flow', () => {
|
||||
await sleep(6000)
|
||||
})
|
||||
|
||||
// alex
|
||||
it('should publish a dataset with a compute service object that does not allow rawAlgo', async () => {
|
||||
const origComputePrivacy = {
|
||||
allowRawAlgorithm: false,
|
||||
@ -184,9 +212,9 @@ describe('Compute flow', () => {
|
||||
asset,
|
||||
alice,
|
||||
[computeService],
|
||||
tokenAddress
|
||||
tokenAddressNoRawAlgo
|
||||
)
|
||||
assert(datasetNoRawAlgo.dataToken === tokenAddress)
|
||||
assert(datasetNoRawAlgo.dataToken === tokenAddressNoRawAlgo)
|
||||
await sleep(6000)
|
||||
})
|
||||
|
||||
@ -208,9 +236,9 @@ describe('Compute flow', () => {
|
||||
asset,
|
||||
alice,
|
||||
[computeService],
|
||||
tokenAddress
|
||||
tokenAddressWithTrustedAlgo
|
||||
)
|
||||
assert(datasetWithTrustedAlgo.dataToken === tokenAddress)
|
||||
assert(datasetWithTrustedAlgo.dataToken === tokenAddressWithTrustedAlgo)
|
||||
await sleep(6000)
|
||||
})
|
||||
|
||||
@ -248,13 +276,21 @@ describe('Compute flow', () => {
|
||||
dateCreated,
|
||||
0
|
||||
)
|
||||
algorithmAsset = await ocean.assets.create(algoAsset, alice, [service1], tokenAddress)
|
||||
assert(algorithmAsset.dataToken === tokenAddress)
|
||||
algorithmAsset = await ocean.assets.create(
|
||||
algoAsset,
|
||||
alice,
|
||||
[service1],
|
||||
tokenAddressAlgorithm
|
||||
)
|
||||
assert(algorithmAsset.dataToken === tokenAddressAlgorithm)
|
||||
await sleep(6000)
|
||||
})
|
||||
|
||||
it('Alice mints 100 DTs and tranfers them to the compute marketplace', async () => {
|
||||
await datatoken.mint(tokenAddress, alice.getId(), tokenAmount)
|
||||
await datatoken.mint(tokenAddressNoRawAlgo, alice.getId(), tokenAmount)
|
||||
await datatoken.mint(tokenAddressWithTrustedAlgo, alice.getId(), tokenAmount)
|
||||
await datatoken.mint(tokenAddressAlgorithm, alice.getId(), tokenAmount)
|
||||
})
|
||||
|
||||
it('Marketplace posts compute service for sale', async () => {
|
||||
@ -270,6 +306,24 @@ describe('Compute flow', () => {
|
||||
const balance = await datatoken.balance(tokenAddress, bob.getId())
|
||||
assert(balance.toString() === dTamount.toString())
|
||||
})
|
||||
await datatoken
|
||||
.transfer(tokenAddressNoRawAlgo, bob.getId(), dTamount, alice.getId())
|
||||
.then(async () => {
|
||||
const balance = await datatoken.balance(tokenAddressNoRawAlgo, bob.getId())
|
||||
assert(balance.toString() === dTamount.toString())
|
||||
})
|
||||
await datatoken
|
||||
.transfer(tokenAddressWithTrustedAlgo, bob.getId(), dTamount, alice.getId())
|
||||
.then(async () => {
|
||||
const balance = await datatoken.balance(tokenAddressWithTrustedAlgo, bob.getId())
|
||||
assert(balance.toString() === dTamount.toString())
|
||||
})
|
||||
await datatoken
|
||||
.transfer(tokenAddressAlgorithm, bob.getId(), dTamount, alice.getId())
|
||||
.then(async () => {
|
||||
const balance = await datatoken.balance(tokenAddressAlgorithm, bob.getId())
|
||||
assert(balance.toString() === dTamount.toString())
|
||||
})
|
||||
})
|
||||
|
||||
it('Bob starts compute job with a raw Algo', async () => {
|
||||
|
@ -101,7 +101,7 @@ describe('Marketplace flow', () => {
|
||||
})
|
||||
|
||||
it('Alice publishes a dataset', async () => {
|
||||
price = datatoken.toWei('10') // in datatoken
|
||||
price = '10' // in datatoken
|
||||
const publishedDate = new Date(Date.now()).toISOString().split('.')[0] + 'Z'
|
||||
const timeout = 0
|
||||
service1 = await ocean.assets.createAccessServiceAttributes(
|
||||
@ -157,7 +157,7 @@ describe('Marketplace flow', () => {
|
||||
it('Marketplace posts asset for sale', async () => {
|
||||
accessService = await ocean.assets.getServiceByType(ddo.id, 'access')
|
||||
price = 20
|
||||
assert.equal(accessService.attributes.main.cost * price, datatoken.toWei('200'))
|
||||
assert.equal(accessService.attributes.main.cost * price, 200)
|
||||
})
|
||||
|
||||
it('Bob gets datatokens', async () => {
|
||||
@ -223,7 +223,7 @@ describe('Marketplace flow', () => {
|
||||
})
|
||||
|
||||
it('Alice publishes a dataset but passed data token is invalid', async () => {
|
||||
price = datatoken.toWei('10') // in datatoken
|
||||
price = '10' // in datatoken
|
||||
const publishedDate = new Date(Date.now()).toISOString().split('.')[0] + 'Z'
|
||||
const timeout = 0
|
||||
service1 = await ocean.assets.createAccessServiceAttributes(
|
||||
@ -238,7 +238,7 @@ describe('Marketplace flow', () => {
|
||||
})
|
||||
|
||||
it('Alice publishes a dataset but created data token is invalid', async () => {
|
||||
price = datatoken.toWei('10') // in datatoken
|
||||
price = '10' // in datatoken
|
||||
const publishedDate = new Date(Date.now()).toISOString().split('.')[0] + 'Z'
|
||||
const timeout = 0
|
||||
service1 = await ocean.assets.createAccessServiceAttributes(
|
||||
|
Loading…
x
Reference in New Issue
Block a user