2023-01-24 04:59:56 +00:00
|
|
|
const { Assertion } = require("chai")
|
|
|
|
|
2023-01-16 15:31:04 +00:00
|
|
|
const RequestState = {
|
|
|
|
New: 0,
|
|
|
|
Started: 1,
|
|
|
|
Cancelled: 2,
|
|
|
|
Finished: 3,
|
|
|
|
Failed: 4,
|
|
|
|
}
|
|
|
|
|
|
|
|
const SlotState = {
|
|
|
|
Free: 0,
|
|
|
|
Filled: 1,
|
|
|
|
Finished: 2,
|
2023-01-18 14:26:21 +00:00
|
|
|
Failed: 3,
|
|
|
|
Paid: 4,
|
2023-10-16 09:14:02 +00:00
|
|
|
Cancelled: 5,
|
2023-01-16 15:31:04 +00:00
|
|
|
}
|
|
|
|
|
2023-01-24 04:59:56 +00:00
|
|
|
const enableRequestAssertions = function () {
|
|
|
|
// language chain method
|
|
|
|
Assertion.addMethod("request", function (request) {
|
|
|
|
var actual = this._obj
|
|
|
|
|
|
|
|
this.assert(
|
|
|
|
actual.client === request.client,
|
|
|
|
"expected request #{this} to have client #{exp} but got #{act}",
|
|
|
|
"expected request #{this} to not have client #{act}, expected #{exp}",
|
|
|
|
request.client, // expected
|
|
|
|
actual.client // actual
|
|
|
|
)
|
|
|
|
this.assert(
|
|
|
|
actual.expiry == request.expiry,
|
|
|
|
"expected request #{this} to have expiry #{exp} but got #{act}",
|
|
|
|
"expected request #{this} to not have expiry #{act}, expected #{exp}",
|
|
|
|
request.expiry, // expected
|
|
|
|
actual.expiry // actual
|
|
|
|
)
|
|
|
|
this.assert(
|
|
|
|
actual.nonce === request.nonce,
|
|
|
|
"expected request #{this} to have nonce #{exp} but got #{act}",
|
|
|
|
"expected request #{this} to not have nonce #{act}, expected #{exp}",
|
|
|
|
request.nonce, // expected
|
|
|
|
actual.nonce // actual
|
|
|
|
)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = { RequestState, SlotState, enableRequestAssertions }
|