daml/language-support
Moritz Kiefer 341fecdf86
Fix Numeric encoding and decoding in Scala bindings (#7483)
* Fix Numeric encoding and decoding in Scala bindings

fixes #7474

There are a few issues here:

1. We used toString which produces an exponential notation in some
cases which is not supported by the ledger API.

2. On the other hand, we used BigDecimal.exact for decoding which
isn’t completely wrong but more lax than what the ledger API supports

1 and 2 are fixed by switching to the respective functions in
daml-lf/data

3. The tests in ValueSpec were never executed! The tests are split
into a scala_library and a scala_test_suite and ValueSpec ended up in
the library. I’ve split out the utilities from the actual code.

4. The generator for Numeric produced things that are not valid
numerics (e.g. 92233720368547758070000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
showed up in one test) which now fails with the more strict requirements.

changelog_begin
changelog_end

* Apply suggestions from code review

Co-authored-by: Stephen Compall <stephen.compall@daml.com>

* Address review feedback

changelog_begin
changelog_end

Co-authored-by: Stephen Compall <stephen.compall@daml.com>
2020-09-28 07:58:03 +00:00
..
codegen-common set scalac -Xsource:2.13 -Ypartial-unification globally (#6469) 2020-06-24 16:51:24 -04:00
codegen-main Use com.daml as root package (#5343) 2020-04-05 19:49:57 +02:00
hs/bindings Split sandbox code into separate packages (#6695) 2020-07-17 17:06:06 +02:00
java [LF] Drop some tests for deprecated LF versions (#7449) 2020-09-21 15:36:47 +02:00
scala Fix Numeric encoding and decoding in Scala bindings (#7483) 2020-09-28 07:58:03 +00:00
ts Include JSON API logback in scala_binary (#7485) 2020-09-25 17:52:50 +02:00