1
0
mirror of https://github.com/oceanprotocol-archive/squid-js.git synced 2024-02-02 15:31:51 +01:00

added test of registration of service agreement templates

This commit is contained in:
Pedro Gutiérrez 2019-02-11 23:43:41 +01:00 committed by Pedro Gutiérrez
parent 575b45b68a
commit 8bce68a3a5
3 changed files with 30 additions and 2 deletions

View File

@ -3,4 +3,4 @@
--full-trace
--exit
--timeout 300000
integration/**/*.test.ts
integration/ocean/RegisterServiceAgreementTemplates.test.ts integration/**/*.test.ts

View File

@ -0,0 +1,28 @@
import { assert } from 'chai'
import { config } from "../config"
import { Ocean, Account, ServiceAgreementTemplate, Templates } from '../../src' // @oceanprotocol/squid
describe("Register Service Agreement Templates", () => {
let ocean: Ocean
let templateOwner: Account
before(async () => {
ocean = await Ocean.getInstance(config)
// Accounts
templateOwner = (await ocean.accounts.list())[0]
})
it("should regiester a template", async () => {
const serviceAgreementTemplate = new ServiceAgreementTemplate(new Templates.Access())
const serviceAgreementRegistered = await serviceAgreementTemplate.register(templateOwner.getId())
try {
// It can fail because is already created
assert.isTrue(serviceAgreementRegistered, "Service agreement template not registered correctly")
} catch (e) { }
})
})

View File

@ -51,7 +51,7 @@ export default class ServiceAgreementTemplate extends OceanBase {
return false
}
if (!owner.getId().startsWith("0x0")) {
if (!owner.getId().startsWith("0x00000")) {
Logger.error(`Template with id "${this.template.id}" already registered by someone else.`)
return false
}