From 46490f71b7c8f10ed9ae7eee0fc60b39cfd3b373 Mon Sep 17 00:00:00 2001 From: Gabriel Masclef Date: Mon, 7 Oct 2024 15:04:12 -0300 Subject: [PATCH 1/4] Feat: Simplex off-ramp integration --- packages/bitcore-wallet-client/src/lib/api.ts | 22 +++++ .../bws.example.config.js | 20 ++++- packages/bitcore-wallet-service/src/config.ts | 20 ++++- .../src/lib/expressapp.ts | 26 ++++++ .../bitcore-wallet-service/src/lib/server.ts | 86 ++++++++++++++++++- 5 files changed, 165 insertions(+), 9 deletions(-) diff --git a/packages/bitcore-wallet-client/src/lib/api.ts b/packages/bitcore-wallet-client/src/lib/api.ts index 3c933e9ce09..172d920559e 100644 --- a/packages/bitcore-wallet-client/src/lib/api.ts +++ b/packages/bitcore-wallet-client/src/lib/api.ts @@ -3447,6 +3447,15 @@ export class API extends EventEmitter { }); } + simplexGetSellQuote(data): Promise { + return new Promise((resolve, reject) => { + this.request.post('/v1/service/simplex/sellQuote', data, (err, data) => { + if (err) return reject(err); + return resolve(data); + }); + }); + } + simplexPaymentRequest(data): Promise { return new Promise((resolve, reject) => { this.request.post( @@ -3460,6 +3469,19 @@ export class API extends EventEmitter { }); } + simplexSellPaymentRequest(data): Promise { + return new Promise((resolve, reject) => { + this.request.post( + '/v1/service/simplex/sellPaymentRequest', + data, + (err, data) => { + if (err) return reject(err); + return resolve(data); + } + ); + }); + } + simplexGetEvents(data): Promise { return new Promise((resolve, reject) => { let qs = []; diff --git a/packages/bitcore-wallet-service/bws.example.config.js b/packages/bitcore-wallet-service/bws.example.config.js index a4e49bc28d4..7dff9a02620 100644 --- a/packages/bitcore-wallet-service/bws.example.config.js +++ b/packages/bitcore-wallet-service/bws.example.config.js @@ -165,6 +165,10 @@ module.exports = { moonpay: { disabled: false, removed: false + }, + simplex: { + disabled: false, + removed: false } }, swapCrypto: { @@ -285,22 +289,30 @@ module.exports = { // sandbox: { // apiKey: 'simplex_sandbox_api_key_here', // api: 'https://sandbox.test-simplexcc.com', - // appProviderId: 'simplex_provider_id_here' + // apiSell: 'https://sell-checkout-waf.sandbox.test-simplexcc.com', + // appProviderId: 'simplex_provider_id_here', + // appSellRefId: 'simplex_sell_ref_id_here', // }, // production: { // apiKey: 'simplex_production_api_key_here', // api: 'https://backend-wallet-api.simplexcc.com', - // appProviderId: 'simplex_provider_id_here' + // apiSell: 'https://sell-checkout-widget.simplex.com', + // appProviderId: 'simplex_provider_id_here', + // appSellRefId: 'simplex_sell_ref_id_here', // }, // sandboxWeb: { // apiKey: 'simplex_sandbox_web_api_key_here', // api: 'https://sandbox.test-simplexcc.com', - // appProviderId: 'simplex_web_provider_id_here' + // apiSell: 'https://sell-checkout-waf.sandbox.test-simplexcc.com', + // appProviderId: 'simplex_web_provider_id_here', + // appSellRefId: 'simplex_web_sell_ref_id_here', // }, // productionWeb: { // apiKey: 'simplex_production_web_api_key_here', // api: 'https://backend-wallet-api.simplexcc.com', - // appProviderId: 'simplex_web_provider_id_here' + // apiSell: 'https://sell-checkout-widget.simplex.com', + // appProviderId: 'simplex_web_provider_id_here', + // appSellRefId: 'simplex_web_sell_ref_id_here', // } // }, // thorswap : { diff --git a/packages/bitcore-wallet-service/src/config.ts b/packages/bitcore-wallet-service/src/config.ts index 5881387e0a9..1214982b189 100644 --- a/packages/bitcore-wallet-service/src/config.ts +++ b/packages/bitcore-wallet-service/src/config.ts @@ -184,6 +184,10 @@ const Config = (): any => { moonpay: { disabled: false, removed: false + }, + simplex: { + disabled: false, + removed: false } }, swapCrypto: { @@ -304,22 +308,30 @@ const Config = (): any => { // sandbox: { // apiKey: 'simplex_sandbox_api_key_here', // api: 'https://sandbox.test-simplexcc.com', - // appProviderId: 'simplex_provider_id_here' + // apiSell: 'https://sell-checkout-waf.sandbox.test-simplexcc.com', + // appProviderId: 'simplex_provider_id_here', + // appSellRefId: 'simplex_sell_ref_id_here', // }, // production: { // apiKey: 'simplex_production_api_key_here', // api: 'https://backend-wallet-api.simplexcc.com', - // appProviderId: 'simplex_provider_id_here' + // apiSell: 'https://sell-checkout-widget.simplex.com', + // appProviderId: 'simplex_provider_id_here', + // appSellRefId: 'simplex_sell_ref_id_here', // }, // sandboxWeb: { // apiKey: 'simplex_sandbox_web_api_key_here', // api: 'https://sandbox.test-simplexcc.com', - // appProviderId: 'bitpaywidget' + // apiSell: 'https://sell-checkout-waf.sandbox.test-simplexcc.com', + // appProviderId: 'simplex_web_provider_id_here', + // appSellRefId: 'simplex_web_sell_ref_id_here', // }, // productionWeb: { // apiKey: 'simplex_production_web_api_key_here', // api: 'https://backend-wallet-api.simplexcc.com', - // appProviderId: 'simplex_web_provider_id_here' + // apiSell: 'https://sell-checkout-widget.simplex.com', + // appProviderId: 'simplex_web_provider_id_here', + // appSellRefId: 'simplex_web_sell_ref_id_here', // } // }, // thorswap : { diff --git a/packages/bitcore-wallet-service/src/lib/expressapp.ts b/packages/bitcore-wallet-service/src/lib/expressapp.ts index 2167053322d..d3dfea22ba3 100644 --- a/packages/bitcore-wallet-service/src/lib/expressapp.ts +++ b/packages/bitcore-wallet-service/src/lib/expressapp.ts @@ -1809,6 +1809,19 @@ export class ExpressApp { }); }); + router.post('/v1/service/simplex/sellQuote', (req, res) => { + getServerWithAuth(req, res, server => { + server + .simplexGetSellQuote(req) + .then(response => { + res.json(response); + }) + .catch(err => { + return returnError(err ?? 'unknown', res, req); + }); + }); + }); + router.post('/v1/service/simplex/paymentRequest', (req, res) => { getServerWithAuth(req, res, server => { server @@ -1822,6 +1835,19 @@ export class ExpressApp { }); }); + router.post('/v1/service/simplex/sellPaymentRequest', (req, res) => { + getServerWithAuth(req, res, server => { + server + .simplexSellPaymentRequest(req) + .then(response => { + res.json(response); + }) + .catch(err => { + return returnError(err ?? 'unknown', res, req); + }); + }); + }); + router.get('/v1/service/simplex/events', (req, res) => { getServerWithAuth(req, res, server => { const opts = { env: req.query.env }; diff --git a/packages/bitcore-wallet-service/src/lib/server.ts b/packages/bitcore-wallet-service/src/lib/server.ts index 70ef22876f4..dcfdcdb3313 100644 --- a/packages/bitcore-wallet-service/src/lib/server.ts +++ b/packages/bitcore-wallet-service/src/lib/server.ts @@ -5905,8 +5905,10 @@ export class WalletService implements IWalletService { const keys = { API: config.simplex[env].api, + API_SELL: config.simplex[env].apiSell, API_KEY: config.simplex[env].apiKey, - APP_PROVIDER_ID: config.simplex[env].appProviderId + APP_PROVIDER_ID: config.simplex[env].appProviderId, + APP_SELL_REF_ID: config.simplex[env].appSellRefId }; return keys; @@ -5951,6 +5953,48 @@ export class WalletService implements IWalletService { }); } + simplexGetSellQuote(req): Promise { + return new Promise((resolve, reject) => { + const keys = this.simplexGetKeys(req); + + const API = keys.API_SELL; + const API_KEY = keys.API_KEY; + + if (!checkRequired(req.body, ['base_currency', 'base_amount', 'quote_currency', 'pp_payment_method'])) { + return reject(new ClientError("Simplex's request missing arguments")); + } + + const headers = { + 'Content-Type': 'application/json', + Authorization: 'ApiKey ' + API_KEY, + 'x-country-code': 'LT', // TODO: send the real country code + }; + + let qs = []; + qs.push('base_currency=' + req.body.base_currency); + qs.push('base_amount=' + req.body.base_amount); + qs.push('quote_currency=' + req.body.quote_currency); + qs.push('pp_payment_method=' + req.body.pp_payment_method); + + const URL: string = API + `/v3/quote?${qs.join('&')}`; + + this.request.get( + URL, + { + headers, + json: true + }, + (err, data) => { + if (err) { + return reject(err.body ? err.body : err); + } else { + return resolve(data.body ? data.body : data); + } + } + ); + }); + } + simplexPaymentRequest(req): Promise { return new Promise((resolve, reject) => { const keys = this.simplexGetKeys(req); @@ -6012,6 +6056,46 @@ export class WalletService implements IWalletService { }); } + simplexSellPaymentRequest(req): Promise { + return new Promise((resolve, reject) => { + const keys = this.simplexGetKeys(req); + + const API = keys.API_SELL; + const API_KEY = keys.API_KEY; + const appSellRefId = keys.APP_SELL_REF_ID; + + if ( + !checkRequired(req.body, ['referer_url', 'return_url']) && + !checkRequired(req.body.txn_details, ['quote_id']) + ) { + return reject(new ClientError("Simplex's request missing arguments")); + } + + const headers = { + 'Content-Type': 'application/json', + Authorization: 'ApiKey ' + API_KEY, + 'x-country-code': 'LT', // TODO: send the real country code + }; + + this.request.post( + API + '/v3/initiate-sell/widget', + { + headers, + body: req.body, + json: true + }, + (err, data) => { + if (err) { + return reject(err.body ? err.body : err); + } else { + data.body.app_sell_ref_id = appSellRefId; + return resolve(data.body); + } + } + ); + }); + } + simplexGetEvents(req): Promise { return new Promise((resolve, reject) => { if (!config.simplex) return reject(new Error('Simplex missing credentials')); From 1810557858d7bf99cc4c50aa54dba0797503f48a Mon Sep 17 00:00:00 2001 From: Gabriel Masclef Date: Tue, 22 Oct 2024 15:16:12 -0300 Subject: [PATCH 2/4] Simplex getCurrencies endpoint added --- .../bws.example.config.js | 4 +++ packages/bitcore-wallet-service/src/config.ts | 4 +++ .../src/lib/expressapp.ts | 18 +++++++++++ .../bitcore-wallet-service/src/lib/server.ts | 30 +++++++++++++++++++ 4 files changed, 56 insertions(+) diff --git a/packages/bitcore-wallet-service/bws.example.config.js b/packages/bitcore-wallet-service/bws.example.config.js index 7dff9a02620..caaac4810c4 100644 --- a/packages/bitcore-wallet-service/bws.example.config.js +++ b/packages/bitcore-wallet-service/bws.example.config.js @@ -292,6 +292,7 @@ module.exports = { // apiSell: 'https://sell-checkout-waf.sandbox.test-simplexcc.com', // appProviderId: 'simplex_provider_id_here', // appSellRefId: 'simplex_sell_ref_id_here', + // publicKey: 'simplex_sandbox_public_key_here', // }, // production: { // apiKey: 'simplex_production_api_key_here', @@ -299,6 +300,7 @@ module.exports = { // apiSell: 'https://sell-checkout-widget.simplex.com', // appProviderId: 'simplex_provider_id_here', // appSellRefId: 'simplex_sell_ref_id_here', + // publicKey: 'simplex_public_key_here', // }, // sandboxWeb: { // apiKey: 'simplex_sandbox_web_api_key_here', @@ -306,6 +308,7 @@ module.exports = { // apiSell: 'https://sell-checkout-waf.sandbox.test-simplexcc.com', // appProviderId: 'simplex_web_provider_id_here', // appSellRefId: 'simplex_web_sell_ref_id_here', + // publicKey: 'simplex_web_sandbox_public_key_here', // }, // productionWeb: { // apiKey: 'simplex_production_web_api_key_here', @@ -313,6 +316,7 @@ module.exports = { // apiSell: 'https://sell-checkout-widget.simplex.com', // appProviderId: 'simplex_web_provider_id_here', // appSellRefId: 'simplex_web_sell_ref_id_here', + // publicKey: 'simplex_web_public_key_here', // } // }, // thorswap : { diff --git a/packages/bitcore-wallet-service/src/config.ts b/packages/bitcore-wallet-service/src/config.ts index 1214982b189..f98c29ff18b 100644 --- a/packages/bitcore-wallet-service/src/config.ts +++ b/packages/bitcore-wallet-service/src/config.ts @@ -311,6 +311,7 @@ const Config = (): any => { // apiSell: 'https://sell-checkout-waf.sandbox.test-simplexcc.com', // appProviderId: 'simplex_provider_id_here', // appSellRefId: 'simplex_sell_ref_id_here', + // publicKey: 'simplex_sandbox_public_key_here', // }, // production: { // apiKey: 'simplex_production_api_key_here', @@ -318,6 +319,7 @@ const Config = (): any => { // apiSell: 'https://sell-checkout-widget.simplex.com', // appProviderId: 'simplex_provider_id_here', // appSellRefId: 'simplex_sell_ref_id_here', + // publicKey: 'simplex_public_key_here', // }, // sandboxWeb: { // apiKey: 'simplex_sandbox_web_api_key_here', @@ -325,6 +327,7 @@ const Config = (): any => { // apiSell: 'https://sell-checkout-waf.sandbox.test-simplexcc.com', // appProviderId: 'simplex_web_provider_id_here', // appSellRefId: 'simplex_web_sell_ref_id_here', + // publicKey: 'simplex_web_sandbox_public_key_here', // }, // productionWeb: { // apiKey: 'simplex_production_web_api_key_here', @@ -332,6 +335,7 @@ const Config = (): any => { // apiSell: 'https://sell-checkout-widget.simplex.com', // appProviderId: 'simplex_web_provider_id_here', // appSellRefId: 'simplex_web_sell_ref_id_here', + // publicKey: 'simplex_web_public_key_here', // } // }, // thorswap : { diff --git a/packages/bitcore-wallet-service/src/lib/expressapp.ts b/packages/bitcore-wallet-service/src/lib/expressapp.ts index d3dfea22ba3..093fe3f5ea7 100644 --- a/packages/bitcore-wallet-service/src/lib/expressapp.ts +++ b/packages/bitcore-wallet-service/src/lib/expressapp.ts @@ -1796,6 +1796,24 @@ export class ExpressApp { }); }); + router.post('/v1/service/simplex/getCurrencies', (req, res) => { + let server; + try { + server = getServer(req, res); + } catch (ex) { + return returnError(ex, res, req); + } + + server + .simplexGetCurrencies(req) + .then(response => { + res.json(response); + }) + .catch(err => { + return returnError(err ?? 'unknown', res, req); + }); + }); + router.post('/v1/service/simplex/quote', (req, res) => { getServerWithAuth(req, res, server => { server diff --git a/packages/bitcore-wallet-service/src/lib/server.ts b/packages/bitcore-wallet-service/src/lib/server.ts index dcfdcdb3313..8352b4d59ec 100644 --- a/packages/bitcore-wallet-service/src/lib/server.ts +++ b/packages/bitcore-wallet-service/src/lib/server.ts @@ -5907,6 +5907,7 @@ export class WalletService implements IWalletService { API: config.simplex[env].api, API_SELL: config.simplex[env].apiSell, API_KEY: config.simplex[env].apiKey, + PUBLIC_KEY: config.simplex[env].publicKey, APP_PROVIDER_ID: config.simplex[env].appProviderId, APP_SELL_REF_ID: config.simplex[env].appSellRefId }; @@ -5914,6 +5915,35 @@ export class WalletService implements IWalletService { return keys; } + simplexGetCurrencies(req): Promise { + return new Promise((resolve, reject) => { + const keys = this.simplexGetKeys(req); + const API = keys.API; + const PUBLIC_KEY = keys.PUBLIC_KEY; + + const headers = { + 'Content-Type': 'application/json' + }; + + const URL = API + `/v2/supported_crypto_currencies?public_key=${PUBLIC_KEY}`; + + this.request.get( + URL, + { + headers, + json: true + }, + (err, data) => { + if (err) { + return reject(err.body ? err.body : err); + } else { + return resolve(data.body ? data.body : data); + } + } + ); + }); + } + simplexGetQuote(req): Promise { return new Promise((resolve, reject) => { const keys = this.simplexGetKeys(req); From 4c33a0286c001f8ca864f701a6d9cd67cf8007ab Mon Sep 17 00:00:00 2001 From: Gabriel Masclef Date: Mon, 18 Nov 2024 18:13:12 -0300 Subject: [PATCH 3/4] req header fix and unit tests for simplexSell --- .../bitcore-wallet-service/src/lib/server.ts | 12 +- .../test/integration/server.js | 148 ++++++++++++++++++ 2 files changed, 157 insertions(+), 3 deletions(-) diff --git a/packages/bitcore-wallet-service/src/lib/server.ts b/packages/bitcore-wallet-service/src/lib/server.ts index 8352b4d59ec..daace9d6ec4 100644 --- a/packages/bitcore-wallet-service/src/lib/server.ts +++ b/packages/bitcore-wallet-service/src/lib/server.ts @@ -5997,9 +5997,12 @@ export class WalletService implements IWalletService { const headers = { 'Content-Type': 'application/json', Authorization: 'ApiKey ' + API_KEY, - 'x-country-code': 'LT', // TODO: send the real country code }; + if (req.body.userCountry && typeof req.body.userCountry === 'string') { + headers['x-country-code'] = req.body.userCountry.toUpperCase(); + } + let qs = []; qs.push('base_currency=' + req.body.base_currency); qs.push('base_amount=' + req.body.base_amount); @@ -6095,7 +6098,7 @@ export class WalletService implements IWalletService { const appSellRefId = keys.APP_SELL_REF_ID; if ( - !checkRequired(req.body, ['referer_url', 'return_url']) && + !checkRequired(req.body, ['referer_url', 'return_url']) || !checkRequired(req.body.txn_details, ['quote_id']) ) { return reject(new ClientError("Simplex's request missing arguments")); @@ -6104,9 +6107,12 @@ export class WalletService implements IWalletService { const headers = { 'Content-Type': 'application/json', Authorization: 'ApiKey ' + API_KEY, - 'x-country-code': 'LT', // TODO: send the real country code }; + if (req.body.userCountry && typeof req.body.userCountry === 'string') { + headers['x-country-code'] = req.body.userCountry.toUpperCase(); + } + this.request.post( API + '/v3/initiate-sell/widget', { diff --git a/packages/bitcore-wallet-service/test/integration/server.js b/packages/bitcore-wallet-service/test/integration/server.js index b6ded6c6c7b..6d1e558e832 100644 --- a/packages/bitcore-wallet-service/test/integration/server.js +++ b/packages/bitcore-wallet-service/test/integration/server.js @@ -11113,6 +11113,10 @@ describe('Wallet service', function() { moonpay: { disabled: false, removed: false + }, + simplex: { + disabled: false, + removed: false } }, swapCrypto: { @@ -13234,6 +13238,83 @@ describe('Wallet service', function() { }); }); + describe.only('#simplexGetSellQuote', () => { + beforeEach(() => { + req = { + headers: {}, + body: { + env: 'sandbox', + userCountry: 'LT', + base_currency: 'BTC', + base_amount: 1000000, + quote_currency: 'EUR', + pp_payment_method: 'sepa' + } + } + }); + + it('should work properly if req is OK', async () => { + server.request = fakeRequest; + try { + const data = await server.simplexGetSellQuote(req); + should.exist(data); + } catch (err) { + should.not.exist(err); + } + }); + + it('should work properly if req is OK for web', async () => { + req.body.context = 'web'; + server.request = fakeRequest; + try { + const data = await server.simplexGetSellQuote(req); + should.exist(data); + } catch (err) { + should.not.exist(err); + } + }); + + it('should return error if get returns error', async () => { + const fakeRequest2 = { + get: (_url, _opts, _cb) => { return _cb(new Error('Error'), null) }, + }; + + server.request = fakeRequest2; + try { + const data = await server.simplexGetSellQuote(req); + should.not.exist(data); + } catch (err) { + should.exist(err); + err.message.should.equal('Error'); + }; + }); + + it('should return error if there is some missing arguments', async () => { + delete req.body.base_amount; + server.request = fakeRequest; + try { + const data = await server.simplexGetSellQuote(req); + should.not.exist(data); + } catch (err) { + should.exist(err); + err.message.should.equal('Simplex\'s request missing arguments'); + } + }); + + it('should return error if simplex is commented in config', async () => { + config.simplex = undefined; + + server.request = fakeRequest; + try { + const data = await server.simplexGetSellQuote(req); + should.not.exist(data); + } catch (err) { + should.exist(err); + err.message.should.equal('Simplex missing credentials'); + } + }); + }); + describe('#simplexPaymentRequest', () => { beforeEach(() => { req = { @@ -13303,6 +13384,73 @@ describe('Wallet service', function() { }); }); + describe.only('#simplexSellPaymentRequest', () => { + beforeEach(() => { + req = { + headers: {}, + body: { + env: 'production', + userCountry: 'LT', + referer_url: 'https://referer_url.com/', + return_url: 'https://return_url.com/', + txn_details: {quote_id: 'quote_id_1'}, + }, + ip: '1.2.3.4' + } + + fakeRequest = { + post: (_url, _opts, _cb) => { return _cb(null, { body: {} }) }, + }; + }); + + it('should work properly if req is OK', () => { + server.request = fakeRequest; + server.simplexSellPaymentRequest(req).then(data => { + should.exist(data); + }).catch(err => { + should.not.exist(err); + }); + }); + + it('should return error if post returns error', () => { + const fakeRequest2 = { + post: (_url, _opts, _cb) => { return _cb(new Error('Error'), null) }, + }; + + server.request = fakeRequest2; + server.simplexSellPaymentRequest(req).then(data => { + should.not.exist(data); + }).catch(err => { + should.exist(err); + err.message.should.equal('Error'); + }); + }); + + it('should return error if there is some missing arguments', () => { + delete req.body.return_url; + + server.request = fakeRequest; + server.simplexSellPaymentRequest(req).then(data => { + should.not.exist(data); + }).catch(err => { + should.exist(err); + err.message.should.equal('Simplex\'s request missing arguments'); + }); + }); + + it('should return error if simplex is commented in config', () => { + config.simplex = undefined; + + server.request = fakeRequest; + server.simplexSellPaymentRequest(req).then(data => { + should.not.exist(data); + }).catch(err => { + should.exist(err); + err.message.should.equal('Simplex missing credentials'); + }); + }); + }); + describe('#simplexGetEvents', () => { beforeEach(() => { req = { From e33c62d0ac426be81335931bebb68b18c1cfa0fe Mon Sep 17 00:00:00 2001 From: Gabriel Masclef Date: Tue, 19 Nov 2024 10:37:30 -0300 Subject: [PATCH 4/4] unit tests for simplexGetCurrencies --- .../test/integration/server.js | 60 ++++++++++++++++++- 1 file changed, 58 insertions(+), 2 deletions(-) diff --git a/packages/bitcore-wallet-service/test/integration/server.js b/packages/bitcore-wallet-service/test/integration/server.js index 6d1e558e832..cdc057cb588 100644 --- a/packages/bitcore-wallet-service/test/integration/server.js +++ b/packages/bitcore-wallet-service/test/integration/server.js @@ -13181,6 +13181,62 @@ describe('Wallet service', function() { }); }); + describe('#simplexGetCurrencies', () => { + beforeEach(() => { + req = { + headers: {}, + body: { + env: 'sandbox' + }, + } + }); + + it('should work properly if req is OK', () => { + server.request = fakeRequest; + server.simplexGetCurrencies(req).then(data => { + should.exist(data); + }).catch(err => { + should.not.exist(err); + }); + }); + + it('should work properly if req is OK for web', () => { + req.body.context = 'web'; + server.request = fakeRequest; + server.simplexGetCurrencies(req).then(data => { + should.exist(data); + }).catch(err => { + should.not.exist(err); + }); + }); + + it('should return error if get returns error', () => { + const fakeRequest2 = { + get: (_url, _opts, _cb) => { return _cb(new Error('Error'), null) }, + }; + + server.request = fakeRequest2; + server.simplexGetCurrencies(req).then(data => { + should.not.exist(data); + }).catch(err => { + should.exist(err); + err.message.should.equal('Error'); + }); + }); + + it('should return error if simplex is commented in config', () => { + config.simplex = undefined; + + server.request = fakeRequest; + server.simplexGetCurrencies(req).then(data => { + should.not.exist(data); + }).catch(err => { + should.exist(err); + err.message.should.equal('Simplex missing credentials'); + }); + }); + }); + describe('#simplexGetQuote', () => { beforeEach(() => { req = { @@ -13238,7 +13294,7 @@ describe('Wallet service', function() { }); }); - describe.only('#simplexGetSellQuote', () => { + describe('#simplexGetSellQuote', () => { beforeEach(() => { req = { headers: {}, @@ -13384,7 +13440,7 @@ describe('Wallet service', function() { }); }); - describe.only('#simplexSellPaymentRequest', () => { + describe('#simplexSellPaymentRequest', () => { beforeEach(() => { req = { headers: {},