2023-01-24 15:59:56 +11:00
|
|
|
const { Assertion } = require("chai")
|
|
|
|
|
|
2023-01-16 16:31:04 +01:00
|
|
|
const RequestState = {
|
|
|
|
|
New: 0,
|
|
|
|
|
Started: 1,
|
|
|
|
|
Cancelled: 2,
|
|
|
|
|
Finished: 3,
|
|
|
|
|
Failed: 4,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const SlotState = {
|
2025-06-20 16:05:57 +02:00
|
|
|
Free: 0n,
|
|
|
|
|
Filled: 1n,
|
|
|
|
|
Finished: 2n,
|
|
|
|
|
Failed: 3n,
|
|
|
|
|
Paid: 4n,
|
|
|
|
|
Cancelled: 5n,
|
|
|
|
|
Repair: 6n,
|
2023-01-16 16:31:04 +01:00
|
|
|
}
|
|
|
|
|
|
2024-10-08 09:38:19 +02:00
|
|
|
function enableRequestAssertions() {
|
2023-01-24 15:59:56 +11:00
|
|
|
// 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
|
2025-06-20 16:05:57 +02:00
|
|
|
actual.client, // actual
|
2023-01-24 15:59:56 +11:00
|
|
|
)
|
|
|
|
|
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
|
2025-06-20 16:05:57 +02:00
|
|
|
actual.expiry, // actual
|
2023-01-24 15:59:56 +11:00
|
|
|
)
|
|
|
|
|
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
|
2025-06-20 16:05:57 +02:00
|
|
|
actual.nonce, // actual
|
2023-01-24 15:59:56 +11:00
|
|
|
)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-06 15:13:32 +02:00
|
|
|
module.exports = {
|
|
|
|
|
RequestState,
|
|
|
|
|
SlotState,
|
|
|
|
|
enableRequestAssertions,
|
|
|
|
|
}
|