Skip to content

Commit

Permalink
Update for new test vectors.
Browse files Browse the repository at this point in the history
Signed-off-by: sappenin <sappenin@gmail.com>
  • Loading branch information
sappenin committed Oct 22, 2019
1 parent 7edf1b0 commit 077345a
Show file tree
Hide file tree
Showing 3 changed files with 848 additions and 92 deletions.
24 changes: 17 additions & 7 deletions 0029-stream/test-vectors/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,29 @@
In order to verify different implementations of the STREAM specification, we provide a series of test vectors in JSON format to compare expected vs actual ASN.1 OER encoding/decoding values.

## Valid Test Vectors
The file [ValidStreamFrameTestVectors.json](https://github.com/interledger/rfcs/tree/master/0029-stream/test-vectors/ValidStreamFrameTestVectors.json) contains a JSON array of elements representing Stream Frame values in addition to a corresponding Base64-encoded binary reprsentation of the ASN.1 OER bytes for a given frame.
The file [StreamPacketFixtures.json](https://github.com/interledger/rfcs/tree/master/0029-stream/test-vectors/StreamPacketFixtures.json) contains a JSON array of elements representing Stream packets with embedded Stream Frame values. The JSON file also includes a corresponding Base64-encoded binary representation of the ASN.1 OER bytes for a given packet/frame combination.

Tests should be written to validate that encoded Stream frames match the expected binary output in the JSON file. Conversely, tests should also be written to validate that decoded binary values match the values in the JSON test vector file.

Each array element in the JSON file contains an object whose values have the the following meanings:

* `type`: The type of the Stream Frame, as defined in [IL-RFC-29](https://github.com/interledger/rfcs/blob/master/0029-stream/0029-stream.md).
* `expectedAsn1OerBytes`: A string containing the Base64-encoded bytes that are expected when the specified Stream Frame is encoded into its ASN.1 OER encoding.
* `Misc Fields`: Each Stream Frame has its own particular fields. For example, the `ConnectionNewAddress` frame has a `sourceAddress` property, whereas other frames do not. The JSON file contains a sample value of each property available in a particular frame.
| Field | Description |
|----:|:----|
| `name` | The name of the test vector. |
| `packet` | A JSON object containing Stream Packet information. |
| `buffer` | A string containing the Base64-encoded bytes that are expected when the Stream packet and frame are encoded according to the rules of [IL-RFC-29](https://github.com/interledger/rfcs/blob/master/0029-stream/0029-stream.md). |
| `packet.sequence` | The Stream packet's sequence number |
| `packet.packetType` | The type of Stream packet represented in the test vector. |
| `packet.packetType` | The type of Stream packet represented in the test vector. |
| `packet.amount` | The Stream packet amount represented in the test vector. |
| `packet.frames` | An array of Stream Frames contained in the packet. |
| `packet.frames.type` | The type of the Stream Frame. |
| `packet.frames.name` | The common name of the Stream Frame.|
| `packet.frames.*` | Each Stream Frame has its own particular fields. For example, the `ConnectionNewAddress` frame has a `sourceAddress` property, whereas other frames do not. The JSON file contains a sample value of each property available in a particular frame. |

## Test Validations
Each implementation of STREAM should work across the test vectors defined above. The following is a link to the test coverage in various projects (please submit a PR to this file if you have an implementation not defined in this list):

* Java Stream: [ValidStreamFrameVectorsTest](https://github.com/hyperledger/quilt/blob/master/codecs-parent/codecs-stream/src/test/java/org/interledger/codecs/stream/frame/ValidStreamFrameVectorsTest.java)
* Rust Stream: TBD.
* Javascript Stream: TBD.
* Java (Hyperledger Quilt): [Fixtures](https://github.com/hyperledger/quilt/tree/master/codecs-parent/codecs-stream/src/test/resources/StreamPacketFixtures.json) | [Test Class](https://github.com/hyperledger/quilt/tree/master/codecs-parent/codecs-stream/src/test/java/org/interledger/codecs/stream/StreamPacketFixturesTest.java)
* Rust Stream: `TBD`.
* Javascript Stream: `TBD`.
Loading

0 comments on commit 077345a

Please sign in to comment.