Skip to content

Commit

Permalink
Test too few outputs in fee payment
Browse files Browse the repository at this point in the history
  • Loading branch information
alvasw committed Jan 15, 2024
1 parent 05dfbca commit ba09db4
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,24 @@ void checkFeeAddressBtcNoTooFewVin() throws IOException {
assertThat(txValidator1.getStatus(), is(FeeValidationStatus.NACK_JSON_ERROR));
}

@ParameterizedTest
@ValueSource(ints = {0, 1})
void checkFeeAddressBtcNoTooFewVout(int numberOfVouts) throws IOException {
JsonObject json = MakerTxValidatorSanityCheckTests.getValidBtcMakerFeeMempoolJsonResponse();

var jsonArray = new JsonArray(numberOfVouts);
for (int i = 0; i < numberOfVouts; i++) {
jsonArray.add(i);
}
json.add("vout", jsonArray);
assertThat(json.get("vout").getAsJsonArray().size(), is(numberOfVouts));

String jsonContent = new Gson().toJson(json);
TxValidator txValidator1 = txValidator.parseJsonValidateMakerFeeTx(jsonContent,
MakerTxValidatorSanityCheckTests.FEE_RECEIVER_ADDRESSES);

assertThat(txValidator1.getStatus(), is(FeeValidationStatus.NACK_JSON_ERROR));
}

@Test
void responseHasDifferentTxId() throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,25 @@ void checkFeeAddressBtcNoTooFewVin() throws IOException {
assertThat(txValidator1.getStatus(), is(FeeValidationStatus.NACK_JSON_ERROR));
}

@ParameterizedTest
@ValueSource(ints = {0, 1})
void checkFeeAddressBtcNoTooFewVout(int numberOfVouts) throws IOException {
JsonObject json = MakerTxValidatorSanityCheckTests.getValidBtcMakerFeeMempoolJsonResponse();

var jsonArray = new JsonArray(numberOfVouts);
for (int i = 0; i < numberOfVouts; i++) {
jsonArray.add(i);
}
json.add("vout", jsonArray);
assertThat(json.get("vout").getAsJsonArray().size(), is(numberOfVouts));

String jsonContent = new Gson().toJson(json);
TxValidator txValidator1 = txValidator.parseJsonValidateMakerFeeTx(jsonContent,
MakerTxValidatorSanityCheckTests.FEE_RECEIVER_ADDRESSES);

assertThat(txValidator1.getStatus(), is(FeeValidationStatus.NACK_JSON_ERROR));
}

@Test
void responseHasDifferentTxId() throws IOException {
String differentTxId = "abcde971ead7d03619e3a9eeaa771ed5adba14c448839e0299f857f7bb4ec07";
Expand Down

0 comments on commit ba09db4

Please sign in to comment.