test(server): Initial set of tests and travis integration added
This commit is contained in:
parent
f06ace8c83
commit
53646c9191
17 changed files with 400 additions and 458 deletions
44
test/mocks/db.js
Normal file
44
test/mocks/db.js
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
'use strict';
|
||||
|
||||
var FINGERPRINT_NEW = 'XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX';
|
||||
var FINGERPRINT_FUNDS = 'YY:YY:YY:YY:YY:YY:YY:YY:YY:YY:YY:YY:YY:YY:YY:YY:YY:YY:YY:YY';
|
||||
|
||||
var txs = {};
|
||||
|
||||
|
||||
module.exports = {
|
||||
FINGERPRINT_NEW: FINGERPRINT_NEW,
|
||||
FINGERPRINT_FUNDS: FINGERPRINT_FUNDS,
|
||||
summonTransaction: function(fingerprint, tx, cb) {
|
||||
var cachedTx = txs[tx.txId];
|
||||
if (cachedTx) cb(null, cachedTx);
|
||||
else {
|
||||
txs[tx.txId] = tx;
|
||||
cb(null, null);
|
||||
}
|
||||
},
|
||||
reportTransactionError: function(tx, err, status) {
|
||||
txs[tx.txId].err = err;
|
||||
txs[tx.txId].status = status;
|
||||
calls.fail = true;
|
||||
},
|
||||
completeTransaction: function(tx, txHash) {
|
||||
calls.status = true;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
var calls = {};
|
||||
module.exports.wasErrorReported = function() {
|
||||
return calls.fail;
|
||||
};
|
||||
module.exports.wasStatusReported = function() {
|
||||
return calls.status;
|
||||
};
|
||||
module.exports.resetCalls = function() {
|
||||
calls = {
|
||||
status: false,
|
||||
fail: false
|
||||
}
|
||||
};
|
||||
module.exports.resetCalls();
|
||||
Loading…
Add table
Add a link
Reference in a new issue