Internal Answer topic function var settings make this transacts FundHa

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
'Internal Answer': {
topic: function () {
var settings = make(this, transacts.FundHandler);
fill_request(settings, ValidPayment);
settings.event_bus.on(consts.events.EVENT_INTERNAL_TO_SEND, function (msg) {
try {
var answer = new registry.account.TransactionAnswer({
amount: msg.args.fund,
tid: uuid.v4(),
state: consts.transaction.STATE_FINISHED
}, {id: msg.id});
answer.validate()
} catch (e) {
console.log("ERR", e);
}
settings.internal_bus.emit(answer.data.id, answer.data);
}.bind(this));
settings.response.on("end", this.callback)
settings.handler.main()
},
'finished request': function (req, state) {
assert.isUndefined(state);
assert.isObject(req);
assert.equal(req.status, 200);
var resp = JSON.parse(req.body);
var trn = resp.transaction;
assert.isObject(trn);
assert.isString(trn.tid);
assert.isString(trn.eid);
assert.isNumber(trn.state);
}
}