Skip to content

Commit

Permalink
- Change log level to warn level since it may more sense for unhandle…
Browse files Browse the repository at this point in the history
…d exceptions.

- Use all activations instead of lovell
  • Loading branch information
nathanieliov committed Jan 15, 2025
1 parent f5d5546 commit 4a022ab
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions rskj-core/src/main/java/co/rsk/peg/bitcoin/BitcoinUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
public class BitcoinUtils {
protected static final byte[] WITNESS_COMMITMENT_HEADER = Hex.decode("aa21a9ed");
protected static final int WITNESS_COMMITMENT_LENGTH = WITNESS_COMMITMENT_HEADER.length + Sha256Hash.LENGTH;
private static final int MINIMUM_WITNESS_COMMITMENT_SIZE = WITNESS_COMMITMENT_LENGTH + 2; // 1 extra by for OP_RETURN and another one for data length
private static final int MINIMUM_WITNESS_COMMITMENT_SIZE = WITNESS_COMMITMENT_LENGTH + 2; // 1 extra byte for OP_RETURN and another one for data length
private static final Logger logger = LoggerFactory.getLogger(BitcoinUtils.class);
private static final int FIRST_INPUT_INDEX = 0;

Expand Down Expand Up @@ -125,7 +125,7 @@ public static Optional<Sha256Hash> findWitnessCommitment(BtcTransaction tx, Acti
return Optional.of(witnessCommitment);
}
} catch (ScriptException e) {
logger.debug(
logger.warn(
"[findWitnessCommitment] Failed to extract witness commitment from output {}. {}",
output,
e.getMessage()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class BitcoinUtilsTest {
private static final int FIRST_INPUT_INDEX = 0;

private static final ActivationConfig.ForBlock arrowHeadActivations = ActivationConfigsForTest.arrowhead600().forBlock(0);
private static final ActivationConfig.ForBlock lovellActivations = ActivationConfigsForTest.lovell700().forBlock(0);
private static final ActivationConfig.ForBlock allActivations = ActivationConfigsForTest.all().forBlock(0);

private Address destinationAddress;

Expand Down Expand Up @@ -552,7 +552,7 @@ void findWitnessCommitment_whenTxHasNoOutputs_shouldThrowException(ActivationCon
private static Stream<Arguments> activationsProvider() {
return Stream.of(
Arguments.of(arrowHeadActivations),
Arguments.of(lovellActivations)
Arguments.of(allActivations)
);
}

Expand Down Expand Up @@ -662,7 +662,7 @@ void findWitnessCommitment_withRealTransaction_shouldReturnExpectedValue(Activat

@ParameterizedTest
@MethodSource("activationsProvider")
void findWitnessCommitment_withDataLargenThanExpected_shouldReturnEmpty(ActivationConfig.ForBlock activations) {
void findWitnessCommitment_withDataLargerThanExpected_shouldReturnEmpty(ActivationConfig.ForBlock activations) {
// Arrange
BtcTransaction btcTx = BitcoinTestUtils.createCoinbaseTransaction(btcMainnetParams);

Expand Down Expand Up @@ -715,7 +715,7 @@ void findWitnessCommitment_whenMalFormedTxAfterRSKIP460_shouldIgnoreMalformedOut
BtcTransaction malFormedCoinbaseTx, Sha256Hash expectedWitnessCommitment) {
// Act
Optional<Sha256Hash> witnessCommitment = BitcoinUtils.findWitnessCommitment(
malFormedCoinbaseTx, lovellActivations);
malFormedCoinbaseTx, allActivations);

// Assert
assertTrue(witnessCommitment.isPresent());
Expand Down

0 comments on commit 4a022ab

Please sign in to comment.