Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions exonum-java-binding/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- The specification of `Configurable` operations and `Service#initialize`
to require throwing `ExecutionException` instead of
`IllegalArgumentException`.
- Transaction index in block type changed from `long` to `int`. (#1348)

### Removed
- Classes supporting no longer used tree-like list proof representation.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,8 @@ public final class CallInBlocks {
* @throws IndexOutOfBoundsException if position is negative or greater than
* {@value Integer#MAX_VALUE}
*/
public static CallInBlock transaction(/* todo: change to int once ECR-4083 is integrated */
long txPosition) {
checkElementIndex(Math.toIntExact(txPosition), Integer.MAX_VALUE, "txPosition");
public static CallInBlock transaction(int txPosition) {
checkElementIndex(txPosition, Integer.MAX_VALUE, "txPosition");
return CallInBlock.newBuilder()
.setTransaction(txPosition)
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
@AutoValue
public abstract class TransactionLocation {

public static TransactionLocation valueOf(long height, long indexInBlock) {
public static TransactionLocation valueOf(long height, int indexInBlock) {
return new AutoValue_TransactionLocation(height, indexInBlock);
}

Expand All @@ -42,7 +42,7 @@ public static TransactionLocation valueOf(long height, long indexInBlock) {
* order of these indices.
*/
@SerializedName("position_in_block")
public abstract long getIndexInBlock();
public abstract int getIndexInBlock();

/**
* Provides a Gson type adapter for this class.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@
class CallInBlocksTest {

@ParameterizedTest
@ValueSource(longs = {0, 1, Integer.MAX_VALUE - 1})
void transaction(long txPosition) {
@ValueSource(ints = {0, 1, Integer.MAX_VALUE - 1})
void transaction(int txPosition) {
CallInBlock transaction = CallInBlocks.transaction(txPosition);
assertThat(transaction.getTransaction()).isEqualTo(txPosition);
}

@ParameterizedTest
@ValueSource(longs = {/* Negative: */ Integer.MIN_VALUE, -2, -1,
@ValueSource(ints = {/* Negative: */ Integer.MIN_VALUE, -2, -1,
/* Too big: */ Integer.MAX_VALUE})
void transactionInvalidPositions(long txPosition) {
void transactionInvalidPositions(int txPosition) {
assertThrows(IndexOutOfBoundsException.class, () -> CallInBlocks.transaction(txPosition));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ void roundTrip(TransactionLocation expected) {
private static Stream<TransactionLocation> testSource() {
return Stream.of(
TransactionLocation.valueOf(1, 1),
TransactionLocation.valueOf(Long.MAX_VALUE, Long.MAX_VALUE));
TransactionLocation.valueOf(Long.MAX_VALUE, Integer.MAX_VALUE));
}

}