tigerbeetle / tigerbeetle-java

TigerBeetle Java client
Apache License 2.0
2 stars 2 forks source link

Unit tests #7

Closed batiati closed 2 years ago

batiati commented 2 years ago

We achieved 96% of test coverage, only a few paths cannot be tested without tampering with the implementation itself. image

The main purpose of adding Javadocs now is to document parameters and exceptions. I will revisit them once the official docs are released.

batiati commented 2 years ago

Thank you @eatonphil for the comments.

Yes, signed types in Java are restrictive, in some places I had to use an int to represent a u16 validating the correct range. I'm not sure about the ergonomics of using BigInteger for debit/credit/amount, but it avoids footguns dealing with negative values and follows the same JDBC standard for DECIMAL.

Another point is the lack of a u128 type in Java. The UUID class was the closest thing that can be created and reinterpreted as a pair of long values, but I agree the name UUID is a bit misleading. As an alternative, we could create our own UInt128 class, something like that: https://github.com/PlatformLab/TorcDB/blob/master/src/main/java/net/ellitron/torc/util/UInt128.java

batiati commented 2 years ago

@eatonphil I'm going to submit another PR updating the javadocs once you merge your work on docs. I haven't copied any material from there yet.

I configured GHA to fail if below 95% of test coverage.

eatonphil commented 2 years ago

Ok, go for it!