2018-10-29 17:28:40 +01:00
|
|
|
import {assert} from "chai"
|
|
|
|
import ConfigProvider from "../../src/ConfigProvider"
|
|
|
|
import ContractHandler from "../../src/keeper/ContractHandler"
|
|
|
|
import Account from "../../src/ocean/Account"
|
|
|
|
import Ocean from "../../src/ocean/Ocean"
|
2018-11-05 14:56:14 +01:00
|
|
|
import ServiceAgreementTemplate from "../../src/ocean/ServiceAgreements/ServiceAgreementTemplate"
|
2018-11-05 17:50:56 +01:00
|
|
|
import Access from "../../src/ocean/ServiceAgreements/Templates/Access"
|
2018-10-29 17:28:40 +01:00
|
|
|
import config from "../config"
|
|
|
|
|
|
|
|
let ocean: Ocean
|
|
|
|
let accounts: Account[]
|
|
|
|
|
|
|
|
describe("ServiceAgreementTemplate", () => {
|
|
|
|
|
|
|
|
before(async () => {
|
|
|
|
ConfigProvider.setConfig(config)
|
|
|
|
await ContractHandler.deployContracts()
|
|
|
|
ocean = await Ocean.getInstance(config)
|
|
|
|
accounts = await ocean.getAccounts()
|
|
|
|
})
|
|
|
|
|
|
|
|
describe("#registerServiceAgreementsTemplate()", () => {
|
|
|
|
it("should setup an agreement template", async () => {
|
|
|
|
|
2018-11-01 08:31:21 +01:00
|
|
|
const templateOwner = accounts[0]
|
2018-10-29 17:28:40 +01:00
|
|
|
const serviceAgreementTemplate: ServiceAgreementTemplate =
|
2018-11-05 17:50:56 +01:00
|
|
|
await ServiceAgreementTemplate.registerServiceAgreementsTemplate(Access.templateName, Access.Methods,
|
2018-11-05 14:56:14 +01:00
|
|
|
templateOwner)
|
2018-11-01 09:18:34 +01:00
|
|
|
|
2018-10-29 17:28:40 +01:00
|
|
|
assert(serviceAgreementTemplate)
|
|
|
|
assert(serviceAgreementTemplate.getId())
|
2018-11-01 08:31:21 +01:00
|
|
|
assert(serviceAgreementTemplate.getOwner().getId() === templateOwner.getId())
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
describe("#getStatus()", () => {
|
|
|
|
it("should get the status of a newly deployed agreement template", async () => {
|
|
|
|
|
|
|
|
const publisherAccount = accounts[0]
|
|
|
|
const serviceAgreementTemplate: ServiceAgreementTemplate =
|
2018-11-05 17:50:56 +01:00
|
|
|
await ServiceAgreementTemplate.registerServiceAgreementsTemplate(Access.templateName, Access.Methods,
|
2018-11-05 14:56:14 +01:00
|
|
|
publisherAccount)
|
2018-11-01 09:18:34 +01:00
|
|
|
assert(serviceAgreementTemplate)
|
2018-11-01 08:31:21 +01:00
|
|
|
|
|
|
|
const templateStatus = await serviceAgreementTemplate.getStatus()
|
|
|
|
assert(templateStatus === true)
|
2018-10-29 17:28:40 +01:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
})
|