Merge pull request #48 from christroutner/unstable

Unstable
This commit is contained in:
Chris Troutner
2019-09-29 07:09:34 -07:00
committed by GitHub
5 changed files with 10 additions and 9 deletions
+1
View File
@@ -6,6 +6,7 @@ test-local-server
start-decatur-main
start-decatur-test
start-bitcoincom.sh
test-remote-server.sh
coverage
start-my-infra
+1 -1
View File
@@ -15,7 +15,7 @@ const RateLimit = require("express-rate-limit")
// Set max requests per minute
const maxRequests = process.env.RATE_LIMIT_MAX_REQUESTS
? parseInt(process.env.RATE_LIMIT_MAX_REQUESTS)
: 6
: 20
// Pro-tier rate limits are 10x the freemium limits.
const PRO_RPM = 10 * maxRequests
+5 -5
View File
@@ -59,12 +59,12 @@ describe("#route-ratelimits", () => {
assert.equal(next.called, true)
})
it("should trigger rate-limit handler if rate limits exceeds 15 request per minute", async () => {
it("should trigger rate-limit handler if rate limits exceeds 25 request per minute", async () => {
req.baseUrl = "/v3"
req.path = "/control/getNetworkInfo"
req.method = "GET"
for (let i = 0; i < 15; i++) {
for (let i = 0; i < 25; i++) {
next.reset() // reset the stubbed next() function.
await routeRateLimit(req, res, next)
@@ -79,7 +79,7 @@ describe("#route-ratelimits", () => {
)
})
it("should NOT trigger rate-limit handler for pro-tier at 20 RPM", async () => {
it("should NOT trigger rate-limit handler for pro-tier at 25 RPM", async () => {
// Clear the require cache before running this test.
delete require.cache[
require.resolve("../../src/middleware/route-ratelimit")
@@ -98,7 +98,7 @@ describe("#route-ratelimits", () => {
// Prepare the authorization header
//req.headers.authorization = generateAuthHeader("BITBOX")
for (let i = 0; i < 20; i++) {
for (let i = 0; i < 25; i++) {
next.reset() // reset the stubbed next() function.
await routeRateLimit(req, res, next)
@@ -134,7 +134,7 @@ describe("#route-ratelimits", () => {
// Prepare the authorization header
//req.headers.authorization = generateAuthHeader("BITBOX")
for (let i = 0; i < 100; i++) {
for (let i = 0; i < 300; i++) {
next.reset() // reset the stubbed next() function.
await routeRateLimit(req, res, next)
+3 -3
View File
@@ -496,7 +496,7 @@ describe("#SLP", () => {
.reply(200, mockData.mockSingleAddress)
}
req.params.address = "slptest:pz0qcslrqn7hr44hsszwl4lw5r6udkg6zqv7sq3kk7"
req.params.address = "slptest:qz80hhc6eucgauzmcfjzglccspdqfpl0fqx7x3lshs"
const result = await balancesForAddress(req, res)
// console.log(`result: ${util.inspect(result)}`)
@@ -578,11 +578,11 @@ describe("#SLP", () => {
if (process.env.TEST !== "unit") {
it("should get token balance for an address", async () => {
req.body.addresses = [
"slptest:pz0qcslrqn7hr44hsszwl4lw5r6udkg6zqv7sq3kk7"
"slptest:qz80hhc6eucgauzmcfjzglccspdqfpl0fqx7x3lshs"
]
const result = await balancesForAddressBulk(req, res)
console.log(`result: ${JSON.stringify(result, null, 2)}`)
// console.log(`result: ${JSON.stringify(result, null, 2)}`)
assert.isArray(result)
assert.isArray(result[0])