mirror of
https://github.com/openstf/stf
synced 2025-10-04 18:29:17 +02:00
Add a utility to produce transaction responses.
This commit is contained in:
parent
e4b701df5d
commit
90b39306a8
1 changed files with 30 additions and 0 deletions
|
@ -37,6 +37,36 @@ var wireutil = {
|
||||||
)
|
)
|
||||||
.encodeNB()
|
.encodeNB()
|
||||||
}
|
}
|
||||||
|
, response: function(source) {
|
||||||
|
var seq = 0
|
||||||
|
return {
|
||||||
|
okay: function(data, body) {
|
||||||
|
return wireutil.envelope(new wire.TransactionDoneMessage(
|
||||||
|
source
|
||||||
|
, seq++
|
||||||
|
, true
|
||||||
|
, data
|
||||||
|
, body ? JSON.stringify(body) : null
|
||||||
|
))
|
||||||
|
}
|
||||||
|
, fail: function(data) {
|
||||||
|
return wireutil.envelope(new wire.TransactionDoneMessage(
|
||||||
|
source
|
||||||
|
, seq++
|
||||||
|
, false
|
||||||
|
, data
|
||||||
|
))
|
||||||
|
}
|
||||||
|
, progress: function(data, progress) {
|
||||||
|
return wireutil.envelope(new wire.TransactionProgressMessage(
|
||||||
|
source
|
||||||
|
, seq++
|
||||||
|
, data
|
||||||
|
, progress
|
||||||
|
))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = wireutil
|
module.exports = wireutil
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue