|
24 | 24 | import io.carbynestack.httpclient.CsHttpClient;
|
25 | 25 | import io.carbynestack.httpclient.CsHttpClientException;
|
26 | 26 | import io.carbynestack.httpclient.CsResponseEntity;
|
27 |
| - |
28 | 27 | import java.io.ByteArrayOutputStream;
|
29 | 28 | import java.io.File;
|
| 29 | +import java.io.IOException; |
30 | 30 | import java.net.URI;
|
31 | 31 | import java.nio.file.Files;
|
32 | 32 | import java.util.ArrayList;
|
@@ -100,28 +100,38 @@ void givenSslConfiguration_whenBuildClient_thenInitializeCsHttpClientAccordingly
|
100 | 100 |
|
101 | 101 | @SneakyThrows
|
102 | 102 | @Test
|
103 |
| - void givenSuccessfulRequest_whenDownloadTripleSharesAsBytes_thenReturnExpectedContent(){ |
| 103 | + void givenSuccessfulRequest_whenDownloadTripleSharesAsBytes_thenReturnExpectedContent() { |
104 | 104 | UUID requestId = UUID.fromString("3dc08ff2-5eed-49a9-979e-3a3ac0e4a2cf");
|
105 | 105 | int expectedCount = 2;
|
106 | 106 | TupleList<MultiplicationTriple<Field.Gfp>, Field.Gfp> expectedTripleList =
|
107 |
| - new TupleList(MultiplicationTriple.class, GFP); |
| 107 | + new TupleList(MultiplicationTriple.class, GFP); |
| 108 | + |
108 | 109 | expectedTripleList.add(new MultiplicationTriple(GFP, testShare, testShare, testShare));
|
109 | 110 | expectedTripleList.add(new MultiplicationTriple(GFP, testShare, testShare, testShare));
|
| 111 | + ByteArrayOutputStream tripeListAsBytes = new ByteArrayOutputStream(); |
| 112 | + expectedTripleList.forEach( |
| 113 | + tuple -> { |
| 114 | + try { |
| 115 | + tuple.writeTo(tripeListAsBytes); |
| 116 | + } catch (IOException e) { |
| 117 | + throw new RuntimeException(e); |
| 118 | + } |
| 119 | + }); |
110 | 120 | CsResponseEntity<String, byte[]> givenResponseEntity =
|
111 |
| - CsResponseEntity.success(HttpStatus.SC_OK, expectedTripleList.toByteArray()); |
| 121 | + CsResponseEntity.success(HttpStatus.SC_OK, tripeListAsBytes.toByteArray()); |
112 | 122 |
|
113 | 123 | CastorServiceUri serviceUri = new CastorServiceUri(serviceAddress);
|
114 | 124 |
|
115 | 125 | doReturn(givenResponseEntity)
|
116 |
| - .when(csHttpClientMock) |
117 |
| - .getForEntity( |
| 126 | + .when(csHttpClientMock) |
| 127 | + .getForEntity( |
118 | 128 | serviceUri.getIntraVcpRequestTuplesUri(
|
119 |
| - requestId, TupleType.MULTIPLICATION_TRIPLE_GFP, expectedCount), |
| 129 | + requestId, TupleType.MULTIPLICATION_TRIPLE_GFP, expectedCount), |
120 | 130 | Collections.emptyList(),
|
121 | 131 | byte[].class);
|
122 | 132 | TupleList actualTripleList =
|
123 |
| - castorIntraVcpClient.downloadTupleShares( |
124 |
| - requestId, TupleType.MULTIPLICATION_TRIPLE_GFP, expectedCount); |
| 133 | + castorIntraVcpClient.downloadTupleShares( |
| 134 | + requestId, TupleType.MULTIPLICATION_TRIPLE_GFP, expectedCount); |
125 | 135 |
|
126 | 136 | assertEquals(expectedTripleList, actualTripleList);
|
127 | 137 | }
|
|
0 commit comments