Closed kincaidoneil closed 4 years ago
Merging #136 into master will decrease coverage by
2.17%
. The diff coverage is97.05%
.
@@ Coverage Diff @@
## master #136 +/- ##
==========================================
- Coverage 91.26% 89.09% -2.18%
==========================================
Files 14 14
Lines 1500 1733 +233
Branches 108 268 +160
==========================================
+ Hits 1369 1544 +175
+ Misses 112 111 -1
- Partials 19 78 +59
Impacted Files | Coverage Δ | |
---|---|---|
src/index.ts | 83.33% <ø> (-1.97%) |
:arrow_down: |
src/pool.ts | 100.00% <ø> (ø) |
|
src/connection.ts | 88.25% <94.73%> (-1.75%) |
:arrow_down: |
src/crypto.ts | 100.00% <100.00%> (ø) |
|
src/server.ts | 85.71% <100.00%> (-1.79%) |
:arrow_down: |
src/util/rational.ts | 75.00% <0.00%> (-6.64%) |
:arrow_down: |
src/stream.ts | 87.45% <0.00%> (-4.41%) |
:arrow_down: |
src/util/congestion.ts | 80.95% <0.00%> (-4.05%) |
:arrow_down: |
src/util/data-offset-sorter.ts | 91.66% <0.00%> (-1.89%) |
:arrow_down: |
... and 7 more |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact)
,ø = not affected
,? = missing data
Powered by Codecov. Last update d2c6b14...85070e0. Read the comment docs.
A couple changes:
totalReceived
before calling shouldFulfill
, which resolves the overflow issue and prevents a race condition.shouldFulfill
so it's provided a unique packet ID, which is generated via hmac(sharedSecret, "ilp_stream_packet_id" + sequence)
. This allows shouldFulfill
to be used even if there's no connection tag, is a little more intuitive for developers, and maybe resolves #131.Ready for re-review.
Right now the packetId
is serialized as UTF-8. Should it be serialized differently (base64? hex?) or should the callback just be given the buffer directly so it the developer can choose how they want to serialize it?
Right now the packetId is serialized as UTF-8
This seems fine to be so long as it has a reasonable text representation. If there are values that don't represent actual character values then let's use a buffer rather than base64 or hex
Improvements:
Server.close()
. Also added a test that attempts to create this race condition.shouldFulfill
callback function to be passed to the connection or server, which will be called last before fulfilling an incoming ILP Prepare with money. This enables applications to perform async operations to account for the incoming packet in their own system, and/or choose to fulfill or reject any individual packet. A couple minor questions:totalReceived
so it no longer throws if there's an overflow, since that's the only case where the packet wouldn't actually be fulfilled ifshouldFulfill
resolved successfully. Is this behavior okay?connectionId
(last segment of ILP address, including the connection tag) and sequence number are passed to the callback. Should the connection tag be passed to the callback instead?Also: fixes vulnerabilities, and updates the logging so the same connection ID is used between the client & server, by using the token in the destination ILP address.