2018-10-10 11:02:00 +02:00
|
|
|
import * as assert from "assert"
|
2018-10-16 14:56:18 +02:00
|
|
|
import ConfigProvider from "../../src/ConfigProvider"
|
2018-10-10 11:02:00 +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-10 11:02:00 +02:00
|
|
|
import Order from "../../src/ocean/Order"
|
2018-10-16 14:56:18 +02:00
|
|
|
import config from "../config"
|
2018-10-10 11:02:00 +02:00
|
|
|
|
2018-10-16 14:56:18 +02:00
|
|
|
const testName = "Test Asset 333"
|
|
|
|
const testDescription = "This asset is pure owange"
|
|
|
|
const testPrice = 100
|
2018-10-10 11:02:00 +02:00
|
|
|
|
2018-10-16 14:56:18 +02:00
|
|
|
let ocean: Ocean
|
|
|
|
let testAsset: Asset
|
|
|
|
let accounts: Account[]
|
|
|
|
let testPublisher: Account
|
2018-10-10 11:02:00 +02:00
|
|
|
|
|
|
|
before(async () => {
|
2018-10-16 14:56:18 +02:00
|
|
|
ConfigProvider.configure(config)
|
|
|
|
await ContractHandler.deployContracts()
|
|
|
|
ocean = await Ocean.getInstance(config)
|
|
|
|
accounts = await ocean.getAccounts()
|
|
|
|
testPublisher = accounts[0]
|
|
|
|
// register an asset to play around with
|
|
|
|
testAsset = new Asset(testName, testDescription, testPrice, testPublisher)
|
|
|
|
await ocean.register(testAsset)
|
2018-10-10 11:02:00 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
describe("Order", () => {
|
|
|
|
|
2018-10-16 14:56:18 +02:00
|
|
|
describe("#pay()", () => {
|
2018-10-10 11:02:00 +02:00
|
|
|
|
2018-10-16 14:56:18 +02:00
|
|
|
it("should pay for the order", async () => {
|
2018-10-10 11:02:00 +02:00
|
|
|
|
2018-10-16 14:56:18 +02:00
|
|
|
const order: Order = await testAsset.purchase(accounts[0], 10000)
|
|
|
|
assert(order)
|
2018-10-10 11:02:00 +02:00
|
|
|
|
2018-10-16 14:56:18 +02:00
|
|
|
await order.pay(accounts[0])
|
2018-10-10 11:02:00 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
})
|
2018-10-16 14:56:18 +02:00
|
|
|
|
2018-10-10 11:02:00 +02:00
|
|
|
})
|