2018-10-18 09:19:10 +02:00
|
|
|
import ConfigProvider from "../../src/ConfigProvider"
|
|
|
|
import ContractHandler from "../../src/keeper/ContractHandler"
|
|
|
|
import config from "../config"
|
2018-10-18 13:12:23 +02:00
|
|
|
import ContractBaseMock from "../mocks/ContractBase.Mock"
|
2018-10-18 09:19:10 +02:00
|
|
|
|
2018-10-18 13:12:23 +02:00
|
|
|
const wrappedContract = new ContractBaseMock("OceanToken")
|
2018-10-18 09:19:10 +02:00
|
|
|
|
|
|
|
describe("ContractWrapperBase", () => {
|
|
|
|
|
2018-10-26 10:40:46 +02:00
|
|
|
before(async () => {
|
|
|
|
ConfigProvider.setConfig(config)
|
|
|
|
await ContractHandler.deployContracts()
|
|
|
|
wrappedContract.initMock()
|
|
|
|
})
|
|
|
|
|
2018-10-18 09:19:10 +02:00
|
|
|
describe("#call()", () => {
|
|
|
|
|
|
|
|
it("should fail to call on an unknown contract function", (done) => {
|
|
|
|
|
|
|
|
wrappedContract.callMock("balanceOfxxx", [])
|
|
|
|
.catch(() => {
|
|
|
|
|
|
|
|
done()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
it("should fail to call on an contract function with wrong set of parameters", (done) => {
|
|
|
|
|
|
|
|
wrappedContract.callMock("balanceOf", [])
|
|
|
|
.catch(() => {
|
|
|
|
|
|
|
|
done()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
it("should fail to call on an unknown contract function", (done) => {
|
|
|
|
|
|
|
|
wrappedContract.sendMock("balanceOfxxx", "0x00", ["0x00"])
|
|
|
|
.catch(() => {
|
|
|
|
|
|
|
|
done()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
it("should fail to call on an contract function with wrong set of parameters", (done) => {
|
|
|
|
|
|
|
|
wrappedContract.sendMock("approve", "0x000", [])
|
|
|
|
.catch(() => {
|
|
|
|
|
|
|
|
done()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
describe("#getEventData()", () => {
|
|
|
|
|
|
|
|
it("should fail on unknown event", (done) => {
|
|
|
|
|
|
|
|
wrappedContract.getEventData("crazyevent", {})
|
|
|
|
.catch(() => {
|
|
|
|
|
|
|
|
done()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
})
|