-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #48 from mojaloop/feature/three-stage-transfers
Feature/three stage transfers
- Loading branch information
Showing
7 changed files
with
608 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/************************************************************************** | ||
* (C) Copyright ModusBox Inc. 2019 - All rights reserved. * | ||
* * | ||
* This file is made available under the terms of the license agreement * | ||
* specified in the corresponding source code repository. * | ||
* * | ||
* ORIGINAL AUTHOR: * | ||
* James Bush - james.bush@modusbox.com * | ||
**************************************************************************/ | ||
|
||
'use strict'; | ||
|
||
const util = require('util'); | ||
const EventEmitter = require('events'); | ||
|
||
|
||
class MockMojaloopRequests extends EventEmitter { | ||
constructor(config) { | ||
super(); | ||
console.log('MockMojaloopRequests constructed'); | ||
this.config = config; | ||
} | ||
|
||
getParties(...args) { | ||
console.log(`MockMojaloopRequests.getParties called with args: ${util.inspect(args)}`); | ||
setImmediate(() => { this.emit('getParties'); }); | ||
return Promise.resolve(null); | ||
} | ||
|
||
postQuotes(...args) { | ||
console.log(`MockMojaloopRequests.postQuotes called with args: ${util.inspect(args)}`); | ||
setImmediate(() => { this.emit('postQuotes'); }); | ||
return Promise.resolve(null); | ||
} | ||
|
||
postTransfers(...args) { | ||
console.log(`MockMojaloopRequests.postTransfers called with args: ${util.inspect(args)}`); | ||
setImmediate(() => { this.emit('postTransfers'); }); | ||
return Promise.resolve(null); | ||
} | ||
} | ||
|
||
|
||
class MockIlp { | ||
constructor(config) { | ||
console.log('MockIlp constructed'); | ||
this.config = config; | ||
} | ||
} | ||
|
||
|
||
module.exports = { | ||
MojaloopRequests: MockMojaloopRequests, | ||
Ilp: MockIlp | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/************************************************************************** | ||
* (C) Copyright ModusBox Inc. 2019 - All rights reserved. * | ||
* * | ||
* This file is made available under the terms of the license agreement * | ||
* specified in the corresponding source code repository. * | ||
* * | ||
* ORIGINAL AUTHOR: * | ||
* James Bush - james.bush@modusbox.com * | ||
**************************************************************************/ | ||
|
||
'use strict'; | ||
|
||
const EventEmitter = require('events'); | ||
|
||
class MockClient extends EventEmitter { | ||
constructor() { | ||
super(); | ||
console.log('MockClient constructed'); | ||
} | ||
|
||
subscribe(key) { | ||
console.log(`MockClient got subscription for key: ${key}`); | ||
} | ||
|
||
unsubscribe(key, callback) { | ||
console.log(`MockClient got unsubscribe for key: ${key}`); | ||
|
||
if(callback) { | ||
return callback(); | ||
} | ||
} | ||
|
||
emitMessage(data) { | ||
process.nextTick(() => { | ||
console.log(`MockClient emitting event data: ${data}`); | ||
this.emit('message', 'channel', data); | ||
}); | ||
} | ||
} | ||
|
||
|
||
class MockCache { | ||
constructor() { | ||
console.log('MockCache constructed'); | ||
|
||
this.data = {}; | ||
} | ||
|
||
async set(key, value) { | ||
this.data[key] = value; | ||
return Promise.resolve('OK'); | ||
} | ||
|
||
async get(key) { | ||
return Promise.resolve(this.data[key]); | ||
} | ||
|
||
emitMessage(data) { | ||
this.client.emitMessage(data); | ||
} | ||
|
||
async getClient() { | ||
if(!this.client) { | ||
this.client = new MockClient(); | ||
} | ||
return Promise.resolve(this.client); | ||
} | ||
} | ||
|
||
|
||
module.exports = MockCache; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.