Skip to content

Commit

Permalink
wip add assets.create
Browse files Browse the repository at this point in the history
  • Loading branch information
arseneeth committed Jun 23, 2020
1 parent dca6340 commit d9c478b
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/brizo/Brizo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Account from '../ocean/Account'
import { noZeroX } from '../utils'
import { Instantiable, InstantiableConfig } from '../Instantiable.abstract'

const apiPath = '/api/v1/brizo/services'
const apiPath = '/api/v1/provider/services'

/**
* Provides an interface for provider service.
Expand Down
55 changes: 39 additions & 16 deletions test/integration/Marketplaceflow.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,24 @@ import { TestContractHandler } from '../TestContractHandler'
import { DataTokens } from '../../src/datatokens/Datatokens'
import { Ocean } from '../../src/ocean/Ocean'
import { Config } from '../../src/models/Config'
import Accounts from "../../src/ocean/Account" // ??

const Web3 = require('web3')
const web3 = new Web3('http://127.0.0.1:8545')
const factory = require('@oceanprotocol/contracts/artifacts/development/Factory.json')
const datatokensTemplate = require('@oceanprotocol/contracts/artifacts/development/DataTokenTemplate.json')

describe('Marketplace flow', () => {
let ddo
let owner
let bob
let alice
let asset
let contracts
let datatoken
let tokenAddress
let transactionId

let alice = new Accounts()

const tokenAmount = 100
const transferAmount = 1
const blob = 'http://localhost:8030/api/v1/provider/services'
Expand All @@ -32,11 +35,30 @@ describe('Marketplace flow', () => {
)
await contracts.getAccounts()
owner = contracts.accounts[0]
alice = contracts.accounts[1]
bob = contracts.accounts[2]

await alice.setId(contracts.accounts[1])
await alice.setPassword("0x4a608ef70ce229351d37be7b07ddd7a3ce46709911cf8c8c4bcabd8a6c563711")

await contracts.deployContracts(owner)
})

it('Generates metadata', async () => {

asset = {
main: {
type: 'dataset',
name: 'test-dataset',
dateCreated:
new Date(Date.now())
.toISOString()
.split('.')[0] + 'Z', // remove milliseconds
author: 'oceanprotocol-team',
license: 'MIT'
}
}
})

it('Alice publishes a dataset', async () => {
// Alice creates a Datatoken
datatoken = new DataTokens(
Expand All @@ -49,22 +71,23 @@ describe('Marketplace flow', () => {
const config = new Config()
const ocean = await Ocean.getInstance(config)

ddo = await ocean.assets.createSimpleAsset(datatoken, alice, blob)
tokenAddress = await datatoken.create(blob, alice.getId())
await ocean.assets.create(asset, alice, [], tokenAddress)
})

it('Alice mints 100 tokens', async () => {
await datatoken.mint(ddo, alice, tokenAmount)
})
// it('Alice mints 100 tokens', async () => {
// await datatoken.mint(ddo, alice, tokenAmount)
// })

it('Bob gets 1 datatoken', async () => {
const ts = await datatoken.transfer(ddo, bob, transferAmount, alice)
transactionId = ts.transactionHash
})
// it('Bob gets 1 datatoken', async () => {
// const ts = await datatoken.transfer(ddo, bob, transferAmount, alice)
// transactionId = ts.transactionHash
// })

it('Bob consumes dataset', async () => {
const config = new Config()
const ocean = await Ocean.getInstance(config)
await ocean.assets.download(ddo, blob, transactionId, bob)
})
// it('Bob consumes dataset', async () => {
// const config = new Config()
// const ocean = await Ocean.getInstance(config)
// await ocean.assets.download(ddo, blob, transactionId, bob)
// })
})
})

0 comments on commit d9c478b

Please sign in to comment.