2018-10-18 09:19:10 +02:00
|
|
|
import {assert} from "chai"
|
2018-10-16 14:56:18 +02:00
|
|
|
import ConfigProvider from "../../src/ConfigProvider"
|
2018-10-09 15:24:36 +02:00
|
|
|
import ContractHandler from "../../src/keeper/ContractHandler"
|
|
|
|
import Account from "../../src/ocean/Account"
|
|
|
|
import Asset from "../../src/ocean/Asset"
|
2018-10-16 14:56:18 +02:00
|
|
|
import Ocean from "../../src/ocean/Ocean"
|
2018-10-17 10:12:40 +02:00
|
|
|
import Order from "../../src/ocean/Order"
|
2018-10-17 18:24:01 +02:00
|
|
|
import ProviderProvider from "../../src/provider/ProviderProvider"
|
2018-10-16 14:56:18 +02:00
|
|
|
import config from "../config"
|
2018-10-18 09:19:10 +02:00
|
|
|
import ProviderMock from "../mocks/Provider.Mock"
|
2018-10-09 15:24:36 +02:00
|
|
|
|
2018-10-16 14:56:18 +02:00
|
|
|
const testName = "Test Asset 2"
|
|
|
|
const testDescription = "This asset is pure owange"
|
|
|
|
const testPrice = 100
|
2018-10-17 18:24:01 +02:00
|
|
|
const timeout = 100000
|
2018-10-09 15:24:36 +02:00
|
|
|
|
2018-10-16 14:56:18 +02:00
|
|
|
let ocean: Ocean
|
|
|
|
let testAsset: Asset
|
|
|
|
let accounts: Account[]
|
|
|
|
let testPublisher: Account
|
2018-10-09 15:24:36 +02:00
|
|
|
|
|
|
|
before(async () => {
|
2018-10-16 14:56:18 +02:00
|
|
|
ConfigProvider.configure(config)
|
2018-10-18 09:19:10 +02:00
|
|
|
ProviderProvider.setProvider(ProviderMock)
|
2018-10-17 18:24:01 +02:00
|
|
|
|
2018-10-16 14:56:18 +02:00
|
|
|
await ContractHandler.deployContracts()
|
|
|
|
ocean = await Ocean.getInstance(config)
|
|
|
|
accounts = await ocean.getAccounts()
|
|
|
|
testPublisher = accounts[0]
|
|
|
|
testAsset = new Asset(testName, testDescription, testPrice, testPublisher)
|
|
|
|
|
|
|
|
await ocean.register(testAsset)
|
2018-10-09 15:24:36 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
describe("Asset", () => {
|
|
|
|
|
2018-10-16 14:56:18 +02:00
|
|
|
describe("#purchase()", () => {
|
2018-10-09 15:24:36 +02:00
|
|
|
|
2018-10-16 14:56:18 +02:00
|
|
|
it("should purchase an asset", async () => {
|
2018-10-09 15:24:36 +02:00
|
|
|
|
2018-10-16 14:56:18 +02:00
|
|
|
// todo
|
2018-10-17 18:24:01 +02:00
|
|
|
const consumerAccount = accounts[5]
|
|
|
|
const order: Order = await testAsset.purchase(consumerAccount, timeout)
|
2018-10-17 10:12:40 +02:00
|
|
|
assert(order)
|
2018-10-09 15:24:36 +02:00
|
|
|
})
|
2018-10-16 14:56:18 +02:00
|
|
|
})
|
2018-10-09 15:24:36 +02:00
|
|
|
})
|