DamlLedgerClient vs DefaultLedgerClient

G-d willing

In my Java application, in order to use the DamlLedgerClient imported from the com.daml.ledger.rxjava.DamlLedgerClient;
But for doing tests, I need to use the DefaultLedgerClient imported from the com.daml.extensions.testing.ledger

The objects do not share any inheritance from other objects, So what is the reason for having both? Can’t one suffice, or at maybe one extending from the other (in some way)?

The one in com.daml.extensions is part of the testing library you are using with specific additions to be used in the context of the testing framework. Note that that is an open-source community-driven project, not part of the DA product offering.

As @stefanobaghino-da mentioned com.daml.extensions.testing.ledger.DefaultLedgerAdapter is tailored for testing. It offers an API for testing.

Use can use com.daml.ledger.rxjava.DamlLedgerClient for testing as well, if you’d like. I think you will likely end up with similar constructs that are in the testing library.

Both can be considered “ledger clients”, both use the Ledger API under the hood. I suppose we could have reused com.daml.ledger.rxjava.DamlLedgerClient to implement the functionalities offered by the testing API, however using the Ledger API directly seems simpler. Some features (e.g. party allocation) are possible using only the Ledger API.

@stefanobaghino-da I am aware that com.daml.extensions is part of the testing library.
I was more wondering why it couldn’t be implemented as part of the com.daml.ledger.rxjava.DamlLedgerClient where we end up with one library that can do it all.

@Tamas_Kalcza why party allocation cannot be included in the DamlLedgerClient as well? Isn’t it using Ledger API under the hood?

In theory you are right. I don’t know the exact reason why some parts of the Ledger API are not exposed through DamlLedgerClient. It looks like management related APIs (e.g. party allocation, DAR upload) are left out, and I can only assume it was intentional.

Maybe @stefanobaghino-da or someone from the language team can answer this better.