Skip to content

Commit

Permalink
Merge branch 'release/1.21.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
excalq committed Nov 10, 2022
2 parents 1f4b6a7 + 87f2267 commit 4c4969d
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 3 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# 1.21.1

## What's Changed
### Bugfixes
* SDK: Fix transaction decoding with boxes by @jasonpaulos in https://github.com/algorand/java-algorand-sdk/pull/422

**Full Changelog**: https://github.com/algorand/java-algorand-sdk/compare/1.21.0...1.21.1

# 1.21.0

## What's Changed
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Maven:
<dependency>
<groupId>com.algorand</groupId>
<artifactId>algosdk</artifactId>
<version>1.21.0</version>
<version>1.21.1</version>
</dependency>
```

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>com.algorand</groupId>
<artifactId>algosdk</artifactId>
<version>1.21.0</version>
<version>1.21.1</version>
<packaging>jar</packaging>

<name>${project.groupId}:${project.artifactId}</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1585,7 +1585,7 @@ public BoxReference(
@JsonProperty("i") int appIndex,
@JsonProperty("n") byte[] name) {
this.appIndex = appIndex;
this.name = Arrays.copyOf(name, name.length);
this.name = name == null ? new byte[]{} : Arrays.copyOf(name, name.length);
}

// Foreign apps start from index 1. Index 0 is the called App ID.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,31 @@ public void testSerializationMsgpack() throws Exception {
assertEqual(o, tx);
}

@Test
public void testEmptyBoxReferenceSerializationMsgpack() throws Exception {
Transaction.BoxReference boxReference = new Transaction.BoxReference(0, new byte[]{});

byte[] encoded = Encoder.encodeToMsgPack(boxReference);
byte[] expectedEncoded = {(byte) 128};
assertThat(encoded).isEqualTo(expectedEncoded);

Transaction.BoxReference decoded = Encoder.decodeFromMsgPack(encoded, Transaction.BoxReference.class);
assertThat(decoded).isEqualTo(boxReference);
}

@Test
public void testEmptyBoxReferenceSerializationJson() throws Exception {
Transaction.BoxReference boxReference = new Transaction.BoxReference(0, new byte[]{});

ObjectMapper objectMapper = new ObjectMapper();
String encoded = objectMapper.writeValueAsString(boxReference);
String expectedEncoded = "{}";
assertThat(encoded).isEqualTo(expectedEncoded);

Transaction.BoxReference decoded = objectMapper.readValue(encoded, Transaction.BoxReference.class);
assertThat(decoded).isEqualTo(boxReference);
}

@Test
public void testMetadaHashBuilderMethods() throws Exception {
// Test that the following 3 builder methods returns the same transaction
Expand Down

0 comments on commit 4c4969d

Please sign in to comment.