1
0
mirror of https://github.com/oceanprotocol/ocean.js.git synced 2024-11-26 20:39:05 +01:00

wip: add marketplace flow

This commit is contained in:
arsenyjin 2020-06-24 12:45:35 +02:00
parent d9c478b71f
commit 5ca06863c2

View File

@ -13,15 +13,19 @@ describe('Marketplace flow', () => {
let owner let owner
let bob let bob
let asset let asset
let marketplace
let marketOcean
let contracts let contracts
let datatoken let datatoken
let tokenAddress let tokenAddress
let transactionId let transactionId
let service1
let service2
let alice = new Accounts() let alice = new Accounts()
const tokenAmount = 100 const tokenAmount = 100
const transferAmount = 1 const transferAmount = 2
const blob = 'http://localhost:8030/api/v1/provider/services' const blob = 'http://localhost:8030/api/v1/provider/services'
describe('#test', () => { describe('#test', () => {
@ -36,6 +40,7 @@ describe('Marketplace flow', () => {
await contracts.getAccounts() await contracts.getAccounts()
owner = contracts.accounts[0] owner = contracts.accounts[0]
bob = contracts.accounts[2] bob = contracts.accounts[2]
marketplace = contracts.accounts[3]
await alice.setId(contracts.accounts[1]) await alice.setId(contracts.accounts[1])
await alice.setPassword("0x4a608ef70ce229351d37be7b07ddd7a3ce46709911cf8c8c4bcabd8a6c563711") await alice.setPassword("0x4a608ef70ce229351d37be7b07ddd7a3ce46709911cf8c8c4bcabd8a6c563711")
@ -43,6 +48,10 @@ describe('Marketplace flow', () => {
await contracts.deployContracts(owner) await contracts.deployContracts(owner)
}) })
it('Alice publishes a datatoken contract', async () => {
tokenAddress = await datatoken.create(blob, alice.getId())
})
it('Generates metadata', async () => { it('Generates metadata', async () => {
asset = { asset = {
@ -72,22 +81,35 @@ describe('Marketplace flow', () => {
const ocean = await Ocean.getInstance(config) const ocean = await Ocean.getInstance(config)
tokenAddress = await datatoken.create(blob, alice.getId()) tokenAddress = await datatoken.create(blob, alice.getId())
await ocean.assets.create(asset, alice, [], tokenAddress) asset = await ocean.assets.create(asset, alice, [], tokenAddress)
}) })
// it('Alice mints 100 tokens', async () => { it('Alice mints 100 tokens', async () => {
// await datatoken.mint(ddo, alice, tokenAmount) await datatoken.mint(tokenAddress, alice.getId(), tokenAmount)
// }) })
// it('Bob gets 1 datatoken', async () => { it('Marketplace posts asset for sale', async () => {
// const ts = await datatoken.transfer(ddo, bob, transferAmount, alice) const config = new Config()
// transactionId = ts.transactionHash marketOcean = await Ocean.getInstance(config)
// })
// it('Bob consumes dataset', async () => { service1 = marketOcean.assets.getService('download')
// const config = new Config() service2 = marketOcean.assets.getService('access')
// const ocean = await Ocean.getInstance(config)
// await ocean.assets.download(ddo, blob, transactionId, bob) })
// })
it('Bob gets datatokens', async () => {
const ts = await datatoken.transfer(tokenAddress, bob, transferAmount, alice)
transactionId = ts.transactionHash
})
it('Bob consumes asset 1', async () => {
const config = new Config()
const ocean = await Ocean.getInstance(config)
await ocean.assets.download(asset.did, service1.index, bob, '~/my-datasets')
})
it('Bob consumes asset 2', async () => {
// TODO
})
}) })
}) })