mock-server / mockserver

MockServer enables easy mocking of any system you integrate with via HTTP or HTTPS with clients written in Java, JavaScript and Ruby. MockServer also includes a proxy that introspects all proxied traffic including encrypted SSL traffic and supports Port Forwarding, Web Proxying (i.e. HTTP proxy), HTTPS Tunneling Proxying (using HTTP CONNECT) and SOCKS Proxying (i.e. dynamic port forwarding).
http://mock-server.com
Apache License 2.0
4.59k stars 1.07k forks source link

Problems handling large numbers #930

Closed HairyMike closed 2 years ago

HairyMike commented 3 years ago

Describe the issue Large numbers are reduced to their exponent values.

What you are trying to do Running tests where large numbers are returned by mockserver

MockServer version 5.11.2

To Reproduce Setup the following expectation:

{
  "httpRequest": {
    "method": "GET",
    "path": "/test"
  },
  "httpResponse": {
    "statusCode": 200,
    "reasonPhrase": "OK",
    "Content-Type": [
      "application/json"
    ],
    "body": {
      "value": 1000000000000100000001
    }
  }
}
curl http://localhost:1080/test
// { "value": 1.000000000000100000001e+21 }
  1. How you are running MockServer (i.e maven plugin, docker, etc) Docker

  2. Code you used to create expectations

            // Load expectations for this test
            const data = fs.readFileSync(fixturePath);
            const expectations = JSONBig.parse(data);
            for (const expectation of expectations) {
                /* eslint-disable no-await-in-loop */
                await mockServerClient.mockAnyResponse(expectation);
            }
  3. What error you saw No Error

Expected behaviour I'd expect to get back the request exactly as it's mocked. Instead, we get the exponent version of the large number.

MockServer Log This is kind of long. In my example above, I pulled out only the relevant bits to show the issue. Look for the httpResponse.total value to see the exponent version of the value.

2020-11-25 14:35:30 5.11.2 INFO 1081 creating expectation:

  {
    "id" : "4ae87a48-af05-4841-8ace-c95d1d78a82e",
    "priority" : 0,
    "httpRequest" : {
      "method" : "GET",
      "path" : "/v1/beth/test/txs/c72ecb786b8e39de1d896269a215c7f0bfb925b986611ed6a051b733dbcf100c",
      "queryStringParameters" : {
        "limit" : [ "1000" ],
        "instart" : [ "0" ],
        "outstart" : [ "0" ],
        "token" : [ "a6ed52da5d3c45baa1083a4481da3be1" ]
      },
      "headers" : {
        "Accept" : [ "application/json, text/plain, */*" ],
        "accept-encoding" : [ "gzip" ],
        "Content-Type" : [ "application/json" ],
        "User-Agent" : [ "axios/0.20.0" ],
        "Host" : [ "******-mock:1081" ],
        "Connection" : [ "close" ],
        "content-length" : [ "0" ]
      },
      "keepAlive" : false,
      "secure" : true
    },
    "times" : {
      "remainingTimes" : 1
    },
    "timeToLive" : {
      "unlimited" : true
    },
    "httpResponse" : {
      "statusCode" : 200,
      "reasonPhrase" : "OK",
      "headers" : {
        "Date" : [ "Wed, 25 Nov 2020 14:21:33 GMT" ],
        "Content-Type" : [ "application/json" ],
        "Connection" : [ "keep-alive" ],
        "Set-Cookie" : [ "__cfduid=d48fe04e5788d146a07e29b9e953de7441606314093; expires=Fri, 25-Dec-20 14:21:33 GMT; path=/; domain=.******.com; HttpOnly; SameSite=Lax" ],
        "Access-Control-Allow-Headers" : [ "Origin, X-Requested-With, Content-Type, Accept" ],
        "Access-Control-Allow-Methods" : [ "GET, POST, PUT, DELETE" ],
        "Access-Control-Allow-Origin" : [ "*" ],
        "X-Ratelimit-Remaining" : [ "971" ],
        "CF-Cache-Status" : [ "DYNAMIC" ],
        "cf-request-id" : [ "06a161027f0000bf1935213000000001" ],
        "Expect-CT" : [ "max-age=604800, report-uri=\"https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct\"" ],
        "Server" : [ "cloudflare" ],
        "CF-RAY" : [ "5f7c044a5b1fbf19-FRA" ]
      },
      "cookies" : {
        "__cfduid" : "d48fe04e5788d146a07e29b9e953de7441606314093"
      },
      "body" : {
        "contentType" : "application/json",
        "type" : "JSON",
        "json" : {
          "block_hash" : "23f27dd95e40c48fd9da0125f6976bcb2711329d5c3d56e06ca95c218636ce80",
          "block_height" : 2482707,
          "block_index" : 0,
          "hash" : "c72ecb786b8e39de1d896269a215c7f0bfb925b986611ed6a051b733dbcf100c",
          "addresses" : [ "0e94cf45ee5317f6780ef09c17602b31dfd5799f", "6adcbb9ee6ccf34af49ce516fa58b8f5fc1bdc49" ],
          "total" : "1.000000000000100000001e+21",
          "fees" : 275357729640000,
          "size" : 111,
          "gas_limit" : 25000,
          "gas_used" : 21000,
          "gas_price" : 13112272840,
          "relayed_by" : "52.156.52.16",
          "confirmed" : "2020-09-18T15:24:25Z",
          "received" : "2020-09-18T15:24:15.944Z",
          "ver" : 0,
          "double_spend" : false,
          "vin_sz" : 1,
          "vout_sz" : 1,
          "confirmations" : 288142,
          "confidence" : 1,
          "inputs" : [ {
            "sequence" : 2,
            "addresses" : [ "6adcbb9ee6ccf34af49ce516fa58b8f5fc1bdc49" ]
          } ],
          "outputs" : [ {
            "value" : "1.0000000000001e+21",
            "addresses" : [ "0e94cf45ee5317f6780ef09c17602b31dfd5799f" ]
          } ]
        }
      }
    }
  }

 with id:

  4ae87a48-af05-4841-8ace-c95d1d78a82e

2020-11-25 14:35:30 5.11.2 INFO 1081 received request:

  {
    "method" : "GET",
    "path" : "/v1/beth/test/txs/c72ecb786b8e39de1d896269a215c7f0bfb925b986611ed6a051b733dbcf100c",
    "queryStringParameters" : {
      "limit" : [ "1000" ],
      "instart" : [ "0" ],
      "outstart" : [ "0" ],
      "token" : [ "a6ed52da5d3c45baa1083a4481da3be1" ]
    },
    "headers" : {
      "Accept" : [ "application/json, text/plain, */*" ],
      "accept-encoding" : [ "gzip" ],
      "correlationid" : [ "77986f70-2f2b-11eb-8ba2-e135d3658921" ],
      "requestid" : [ "77986f71-2f2b-11eb-8ba2-e135d3658921" ],
      "x-consumer-id" : [ "9e5b907d-3368-45b7-9e75-0b794ef56e68" ],
      "Content-Type" : [ "application/json" ],
      "User-Agent" : [ "axios/0.20.0" ],
      "Host" : [ "******-mock:1081" ],
      "Connection" : [ "close" ],
      "content-length" : [ "0" ]
    },
    "keepAlive" : false,
    "secure" : true
  }

2020-11-25 14:35:30 5.11.2 INFO 1081 request:

  {
    "method" : "GET",
    "path" : "/v1/beth/test/txs/c72ecb786b8e39de1d896269a215c7f0bfb925b986611ed6a051b733dbcf100c",
    "queryStringParameters" : {
      "limit" : [ "1000" ],
      "instart" : [ "0" ],
      "outstart" : [ "0" ],
      "token" : [ "a6ed52da5d3c45baa1083a4481da3be1" ]
    },
    "headers" : {
      "Accept" : [ "application/json, text/plain, */*" ],
      "accept-encoding" : [ "gzip" ],
      "correlationid" : [ "77986f70-2f2b-11eb-8ba2-e135d3658921" ],
      "requestid" : [ "77986f71-2f2b-11eb-8ba2-e135d3658921" ],
      "x-consumer-id" : [ "9e5b907d-3368-45b7-9e75-0b794ef56e68" ],
      "Content-Type" : [ "application/json" ],
      "User-Agent" : [ "axios/0.20.0" ],
      "Host" : [ "******-mock:1081" ],
      "Connection" : [ "close" ],
      "content-length" : [ "0" ]
    },
    "keepAlive" : false,
    "secure" : true
  }

 matched expectation:

  {
    "id" : "4ae87a48-af05-4841-8ace-c95d1d78a82e",
    "priority" : 0,
    "httpRequest" : {
      "method" : "GET",
      "path" : "/v1/beth/test/txs/c72ecb786b8e39de1d896269a215c7f0bfb925b986611ed6a051b733dbcf100c",
      "queryStringParameters" : {
        "limit" : [ "1000" ],
        "instart" : [ "0" ],
        "outstart" : [ "0" ],
        "token" : [ "a6ed52da5d3c45baa1083a4481da3be1" ]
      },
      "headers" : {
        "Accept" : [ "application/json, text/plain, */*" ],
        "accept-encoding" : [ "gzip" ],
        "Content-Type" : [ "application/json" ],
        "User-Agent" : [ "axios/0.20.0" ],
        "Host" : [ "******-mock:1081" ],
        "Connection" : [ "close" ],
        "content-length" : [ "0" ]
      },
      "keepAlive" : false,
      "secure" : true
    },
    "times" : {
      "remainingTimes" : 1
    },
    "timeToLive" : {
      "unlimited" : true
    },
    "httpResponse" : {
      "statusCode" : 200,
      "reasonPhrase" : "OK",
      "headers" : {
        "Date" : [ "Wed, 25 Nov 2020 14:21:33 GMT" ],
        "Content-Type" : [ "application/json" ],
        "Connection" : [ "keep-alive" ],
        "Set-Cookie" : [ "__cfduid=d48fe04e5788d146a07e29b9e953de7441606314093; expires=Fri, 25-Dec-20 14:21:33 GMT; path=/; domain=.******.com; HttpOnly; SameSite=Lax" ],
        "Access-Control-Allow-Headers" : [ "Origin, X-Requested-With, Content-Type, Accept" ],
        "Access-Control-Allow-Methods" : [ "GET, POST, PUT, DELETE" ],
        "Access-Control-Allow-Origin" : [ "*" ],
        "X-Ratelimit-Remaining" : [ "971" ],
        "CF-Cache-Status" : [ "DYNAMIC" ],
        "cf-request-id" : [ "06a161027f0000bf1935213000000001" ],
        "Expect-CT" : [ "max-age=604800, report-uri=\"https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct\"" ],
        "Server" : [ "cloudflare" ],
        "CF-RAY" : [ "5f7c044a5b1fbf19-FRA" ]
      },
      "cookies" : {
        "__cfduid" : "d48fe04e5788d146a07e29b9e953de7441606314093"
      },
      "body" : {
        "contentType" : "application/json",
        "type" : "JSON",
        "json" : {
          "block_hash" : "23f27dd95e40c48fd9da0125f6976bcb2711329d5c3d56e06ca95c218636ce80",
          "block_height" : 2482707,
          "block_index" : 0,
          "hash" : "c72ecb786b8e39de1d896269a215c7f0bfb925b986611ed6a051b733dbcf100c",
          "addresses" : [ "0e94cf45ee5317f6780ef09c17602b31dfd5799f", "6adcbb9ee6ccf34af49ce516fa58b8f5fc1bdc49" ],
          "total" : "1.000000000000100000001e+21",
          "fees" : 275357729640000,
          "size" : 111,
          "gas_limit" : 25000,
          "gas_used" : 21000,
          "gas_price" : 13112272840,
          "relayed_by" : "52.156.52.16",
          "confirmed" : "2020-09-18T15:24:25Z",
          "received" : "2020-09-18T15:24:15.944Z",
          "ver" : 0,
          "double_spend" : false,
          "vin_sz" : 1,
          "vout_sz" : 1,
          "confirmations" : 288142,
          "confidence" : 1,
          "inputs" : [ {
            "sequence" : 2,
            "addresses" : [ "6adcbb9ee6ccf34af49ce516fa58b8f5fc1bdc49" ]
          } ],
          "outputs" : [ {
            "value" : "1.0000000000001e+21",
            "addresses" : [ "0e94cf45ee5317f6780ef09c17602b31dfd5799f" ]
          } ]
        }
      }
    }
  }

2020-11-25 14:35:30 5.11.2 INFO 1081 returning response:

  {
    "statusCode" : 200,
    "reasonPhrase" : "OK",
    "headers" : {
      "Date" : [ "Wed, 25 Nov 2020 14:21:33 GMT" ],
      "Content-Type" : [ "application/json" ],
      "Connection" : [ "keep-alive" ],
      "Set-Cookie" : [ "__cfduid=d48fe04e5788d146a07e29b9e953de7441606314093; expires=Fri, 25-Dec-20 14:21:33 GMT; path=/; domain=.******.com; HttpOnly; SameSite=Lax" ],
      "Access-Control-Allow-Headers" : [ "Origin, X-Requested-With, Content-Type, Accept" ],
      "Access-Control-Allow-Methods" : [ "GET, POST, PUT, DELETE" ],
      "Access-Control-Allow-Origin" : [ "*" ],
      "X-Ratelimit-Remaining" : [ "971" ],
      "CF-Cache-Status" : [ "DYNAMIC" ],
      "cf-request-id" : [ "06a161027f0000bf1935213000000001" ],
      "Expect-CT" : [ "max-age=604800, report-uri=\"https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct\"" ],
      "Server" : [ "cloudflare" ],
      "CF-RAY" : [ "5f7c044a5b1fbf19-FRA" ]
    },
    "cookies" : {
      "__cfduid" : "d48fe04e5788d146a07e29b9e953de7441606314093"
    },
    "body" : {
      "block_hash" : "23f27dd95e40c48fd9da0125f6976bcb2711329d5c3d56e06ca95c218636ce80",
      "block_height" : 2482707,
      "block_index" : 0,
      "hash" : "c72ecb786b8e39de1d896269a215c7f0bfb925b986611ed6a051b733dbcf100c",
      "addresses" : [ "0e94cf45ee5317f6780ef09c17602b31dfd5799f", "6adcbb9ee6ccf34af49ce516fa58b8f5fc1bdc49" ],
      "total" : "1.000000000000100000001e+21",
      "fees" : 275357729640000,
      "size" : 111,
      "gas_limit" : 25000,
      "gas_used" : 21000,
      "gas_price" : 13112272840,
      "relayed_by" : "52.156.52.16",
      "confirmed" : "2020-09-18T15:24:25Z",
      "received" : "2020-09-18T15:24:15.944Z",
      "ver" : 0,
      "double_spend" : false,
      "vin_sz" : 1,
      "vout_sz" : 1,
      "confirmations" : 288142,
      "confidence" : 1,
      "inputs" : [ {
        "sequence" : 2,
        "addresses" : [ "6adcbb9ee6ccf34af49ce516fa58b8f5fc1bdc49" ]
      } ],
      "outputs" : [ {
        "value" : "1.0000000000001e+21",
        "addresses" : [ "0e94cf45ee5317f6780ef09c17602b31dfd5799f" ]
      } ]
    }
  }

 for request:

  {
    "method" : "GET",
    "path" : "/v1/beth/test/txs/c72ecb786b8e39de1d896269a215c7f0bfb925b986611ed6a051b733dbcf100c",
    "queryStringParameters" : {
      "limit" : [ "1000" ],
      "instart" : [ "0" ],
      "outstart" : [ "0" ],
      "token" : [ "a6ed52da5d3c45baa1083a4481da3be1" ]
    },
    "headers" : {
      "Accept" : [ "application/json, text/plain, */*" ],
      "accept-encoding" : [ "gzip" ],
      "correlationid" : [ "77986f70-2f2b-11eb-8ba2-e135d3658921" ],
      "requestid" : [ "77986f71-2f2b-11eb-8ba2-e135d3658921" ],
      "x-consumer-id" : [ "9e5b907d-3368-45b7-9e75-0b794ef56e68" ],
      "Content-Type" : [ "application/json" ],
      "User-Agent" : [ "axios/0.20.0" ],
      "Host" : [ "******-mock:1081" ],
      "Connection" : [ "close" ],
      "content-length" : [ "0" ]
    },
    "keepAlive" : false,
    "secure" : true
  }

 for action:

  {
    "statusCode" : 200,
    "reasonPhrase" : "OK",
    "headers" : {
      "Date" : [ "Wed, 25 Nov 2020 14:21:33 GMT" ],
      "Content-Type" : [ "application/json" ],
      "Connection" : [ "keep-alive" ],
      "Set-Cookie" : [ "__cfduid=d48fe04e5788d146a07e29b9e953de7441606314093; expires=Fri, 25-Dec-20 14:21:33 GMT; path=/; domain=.******.com; HttpOnly; SameSite=Lax" ],
      "Access-Control-Allow-Headers" : [ "Origin, X-Requested-With, Content-Type, Accept" ],
      "Access-Control-Allow-Methods" : [ "GET, POST, PUT, DELETE" ],
      "Access-Control-Allow-Origin" : [ "*" ],
      "X-Ratelimit-Remaining" : [ "971" ],
      "CF-Cache-Status" : [ "DYNAMIC" ],
      "cf-request-id" : [ "06a161027f0000bf1935213000000001" ],
      "Expect-CT" : [ "max-age=604800, report-uri=\"https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct\"" ],
      "Server" : [ "cloudflare" ],
      "CF-RAY" : [ "5f7c044a5b1fbf19-FRA" ]
    },
    "cookies" : {
      "__cfduid" : "d48fe04e5788d146a07e29b9e953de7441606314093"
    },
    "body" : {
      "block_hash" : "23f27dd95e40c48fd9da0125f6976bcb2711329d5c3d56e06ca95c218636ce80",
      "block_height" : 2482707,
      "block_index" : 0,
      "hash" : "c72ecb786b8e39de1d896269a215c7f0bfb925b986611ed6a051b733dbcf100c",
      "addresses" : [ "0e94cf45ee5317f6780ef09c17602b31dfd5799f", "6adcbb9ee6ccf34af49ce516fa58b8f5fc1bdc49" ],
      "total" : "1.000000000000100000001e+21",
      "fees" : 275357729640000,
      "size" : 111,
      "gas_limit" : 25000,
      "gas_used" : 21000,
      "gas_price" : 13112272840,
      "relayed_by" : "52.156.52.16",
      "confirmed" : "2020-09-18T15:24:25Z",
      "received" : "2020-09-18T15:24:15.944Z",
      "ver" : 0,
      "double_spend" : false,
      "vin_sz" : 1,
      "vout_sz" : 1,
      "confirmations" : 288142,
      "confidence" : 1,
      "inputs" : [ {
        "sequence" : 2,
        "addresses" : [ "6adcbb9ee6ccf34af49ce516fa58b8f5fc1bdc49" ]
      } ],
      "outputs" : [ {
        "value" : "1.0000000000001e+21",
        "addresses" : [ "0e94cf45ee5317f6780ef09c17602b31dfd5799f" ]
      } ]
    }
  }

 from expectation:

  4ae87a48-af05-4841-8ace-c95d1d78a82e
jamesdbloom commented 2 years ago

It looks like something in the javascript is causing this issue because the following example using curl shows this is not happening:

$ curl -X PUT 'localhost:1080/mockserver/expectation' \
-d '{
    "httpRequest": {
        "method": "GET",
        "path": "/test"
    },
    "httpResponse": {
        "statusCode": 200,
        "reasonPhrase": "OK",
        "headers": [
            {
                "name": "Content-Type",
                "values": [
                    "application/json"
                ]
            }
        ],
        "body": {
            "value": 1000000000000100000001
        }
    }
}'
[ {
  "httpRequest" : {
    "method" : "GET",
    "path" : "/test"
  },
  "httpResponse" : {
    "statusCode" : 200,
    "reasonPhrase" : "OK",
    "headers" : {
      "Content-Type" : [ "application/json" ]
    },
    "body" : {
      "value" : 1000000000000100000001
    }
  },
  "id" : "f971a79d-4c8a-4b8d-a04b-2b31d30e5f6a",
  "priority" : 0,
  "timeToLive" : {
    "unlimited" : true
  },
  "times" : {
    "unlimited" : true
  }
} ]%                                                                                                                                                                                                           $ curl 'localhost:1080/test'
{
  "value" : 1000000000000100000001
}%    

and the corresponding MockServer logs:

2022-02-09 12:27:59 5.11.3-SNAPSHOT INFO logger level is INFO, change using:
 - 'ConfigurationProperties.logLevel(String level)' in Java code,
 - '-logLevel' command line argument,
 - 'mockserver.logLevel' JVM system property or,
 - 'mockserver.logLevel' property value in 'mockserver.properties' 
2022-02-09 12:27:59 5.11.3-SNAPSHOT INFO 1080 started on port: 1080 
2022-02-09 12:28:05 5.11.3-SNAPSHOT INFO 1080 creating expectation:

  {
    "httpRequest" : {
      "method" : "GET",
      "path" : "/test"
    },
    "httpResponse" : {
      "statusCode" : 200,
      "reasonPhrase" : "OK",
      "headers" : {
        "Content-Type" : [ "application/json" ]
      },
      "body" : {
        "type" : "JSON",
        "json" : {
          "value" : 1000000000000100000001
        }
      }
    },
    "id" : "f971a79d-4c8a-4b8d-a04b-2b31d30e5f6a",
    "priority" : 0,
    "timeToLive" : {
      "unlimited" : true
    },
    "times" : {
      "unlimited" : true
    }
  }

 with id:

  f971a79d-4c8a-4b8d-a04b-2b31d30e5f6a

2022-02-09 12:28:11 5.11.3-SNAPSHOT INFO 1080 received request:

  {
    "method" : "GET",
    "path" : "/test",
    "headers" : {
      "content-length" : [ "0" ],
      "User-Agent" : [ "curl/7.77.0" ],
      "Host" : [ "localhost:1080" ],
      "Accept" : [ "*/*" ]
    },
    "keepAlive" : true,
    "secure" : false
  }

2022-02-09 12:28:11 5.11.3-SNAPSHOT INFO 1080 request:

  {
    "method" : "GET",
    "path" : "/test",
    "headers" : {
      "content-length" : [ "0" ],
      "User-Agent" : [ "curl/7.77.0" ],
      "Host" : [ "localhost:1080" ],
      "Accept" : [ "*/*" ]
    },
    "keepAlive" : true,
    "secure" : false
  }

 matched expectation:

  {
    "httpRequest" : {
      "method" : "GET",
      "path" : "/test"
    },
    "httpResponse" : {
      "statusCode" : 200,
      "reasonPhrase" : "OK",
      "headers" : {
        "Content-Type" : [ "application/json" ]
      },
      "body" : {
        "type" : "JSON",
        "json" : {
          "value" : 1000000000000100000001
        }
      }
    },
    "id" : "f971a79d-4c8a-4b8d-a04b-2b31d30e5f6a",
    "priority" : 0,
    "timeToLive" : {
      "unlimited" : true
    },
    "times" : {
      "unlimited" : true
    }
  }

2022-02-09 12:28:11 5.11.3-SNAPSHOT INFO 1080 returning response:

  {
    "statusCode" : 200,
    "reasonPhrase" : "OK",
    "headers" : {
      "Content-Type" : [ "application/json" ]
    },
    "body" : {
      "value" : 1000000000000100000001
    }
  }

 for request:

  {
    "method" : "GET",
    "path" : "/test",
    "headers" : {
      "content-length" : [ "0" ],
      "User-Agent" : [ "curl/7.77.0" ],
      "Host" : [ "localhost:1080" ],
      "Accept" : [ "*/*" ]
    },
    "keepAlive" : true,
    "secure" : false
  }

 for action:

  {
    "statusCode" : 200,
    "reasonPhrase" : "OK",
    "headers" : {
      "Content-Type" : [ "application/json" ]
    },
    "body" : {
      "value" : 1000000000000100000001
    }
  }

 from expectation:

  f971a79d-4c8a-4b8d-a04b-2b31d30e5f6a

It looks like node is doing this conversion because when I create a JSON object with a large number it is converted to the exponent form, as follows:

Screenshot 2022-02-09 at 12 38 16

One way to solve this is as follows:

Number.prototype.toFixedSpecial = function(n) {
    var str = this.toFixed(n);
    if (str.indexOf('e+') === -1)
        return str;

    // if number is in scientific notation, pick (b)ase and (p)ower
    str = str.replace('.', '').split('e+').reduce(function(b, p) {
        return b + Array(p - b.length + 2).join(0);
    });

    if (n > 0)
        str += '.' + Array(n + 1).join(0);

    return str;
};

var mockServerClient = require('mockserver-client').mockServerClient;
let largeNumber = 1000000000000100000001;
let expectation = {
    "httpRequest": {
        "method": "GET",
        "path": "/test"
    },
    "httpResponse": {
        "statusCode": 200,
        "reasonPhrase": "OK",
        "headers": [
            {
                "name": "Content-Type",
                "values": [
                    "application/json"
                ]
            }
        ],
        "body": {
            "value": largeNumber.toFixedSpecial(0)
        }
    }
};
mockServerClient("localhost", 1080)
    .mockAnyResponse(expectation)
    .then(
        function () {
            console.log("expectation created");
        },
        function (error) {
            console.log(error);
        }
    );
HairyMike commented 2 years ago

thanks for the thorough investigation @jamesdbloom 👍