This is an automated email from the ASF dual-hosted git repository. toulmean pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-tuweni.git
The following commit(s) were added to refs/heads/master by this push: new 196e5f9 Fix for bug #186 (#188) 196e5f9 is described below commit 196e5f98b778f539f704467b3dce051939feb011 Author: Antoine Toulme <atou...@users.noreply.github.com> AuthorDate: Wed Dec 16 23:12:20 2020 -0800 Fix for bug #186 (#188) --- .../src/main/java/org/apache/tuweni/bytes/ConcatenatedBytes.java | 2 +- bytes/src/test/java/org/apache/tuweni/bytes/Bytes32Test.java | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/bytes/src/main/java/org/apache/tuweni/bytes/ConcatenatedBytes.java b/bytes/src/main/java/org/apache/tuweni/bytes/ConcatenatedBytes.java index 62362a3..fbd4dbd 100644 --- a/bytes/src/main/java/org/apache/tuweni/bytes/ConcatenatedBytes.java +++ b/bytes/src/main/java/org/apache/tuweni/bytes/ConcatenatedBytes.java @@ -131,7 +131,7 @@ final class ConcatenatedBytes extends AbstractBytes { throw new IllegalStateException("element sizes do not match total size"); } vSize = this.values[j].size(); - if (length < vSize) { + if (length < vSize + firstValue.size()) { break; } remaining -= vSize; diff --git a/bytes/src/test/java/org/apache/tuweni/bytes/Bytes32Test.java b/bytes/src/test/java/org/apache/tuweni/bytes/Bytes32Test.java index 95404c3..0a7fc20 100644 --- a/bytes/src/test/java/org/apache/tuweni/bytes/Bytes32Test.java +++ b/bytes/src/test/java/org/apache/tuweni/bytes/Bytes32Test.java @@ -20,6 +20,14 @@ import org.junit.jupiter.api.Test; class Bytes32Test { @Test + void testConcatenation() { + Bytes wrapped = Bytes.wrap(Bytes.wrap(new byte[32]), Bytes.wrap(new byte[6])); + assertEquals(37, wrapped.slice(0, 37).size()); + Bytes wrappedCopy = wrapped.slice(0, 37).copy(); + assertEquals(wrapped.slice(0, 37), wrappedCopy); + } + + @Test void testMutableBytes32WrapWithOffset() { Bytes bytes = Bytes .fromHexString( --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@tuweni.apache.org For additional commands, e-mail: commits-h...@tuweni.apache.org