ArdanaLabs / dUSD

5 stars 3 forks source link

CTL and plutip (local testnet) integration #146

Closed marijanp closed 2 years ago

marijanp commented 2 years ago

Introduction

I'm opening this issue to document my research on finding a way to do local e2e tests with CTL.

The current state of testing of CTL offchain code

The current state is to connect to launch a runtime i.e. a network of docker-containsers, including one for cardano-node, which connects to testnet in the background, and then run your ctl application. This is obviously impure, stateful and inpractical.

A temporary quick solution

There is a project called plutip maintained by mlabs which provides a library that implements a tasty-like test hook called withCluster which launches a local cluster on every test-case. It also exports an executable local-cluster which is a standalone local testnet launcher. Using this local-cluster executable in the previously mentioned runtime we are at least able to get a pure testing environment. We will be able to write a custom hook for our tests, which launches that runtime and tears it down for every test-case.

There are already some efforts (see) towards integrating plutip. Please take a look at my comment to see what changes would be required to make that temporary solution work.

marijanp commented 2 years ago

UPDATE I received an answer to my proposal. Somebody is already working on a nice integrated solution using a monadic wrapper around CTLs Contract monad see

marijanp commented 2 years ago

@CSVdB @epiro-ps I connected with Vitaly today (he is actively working on this) and I will start to help him out starting tomorrow.

marijanp commented 2 years ago

@CSVdB @epiro-ps From what I've seen today this plutip integration will also abstract away the proper runtime configuration. This means that the code in the above mentioned branch launches all the required runtime dependencies like ogmios, ogmios-datum-cache, etc. and configures them properly (no docker involved, everything runs in separate processes). And everything will be usable in PS through a monad.

epiro-ps commented 2 years ago

I marked this as blocked as it's pending CTL maintainers to merge this PR. Let me know if this is incorrect.

https://github.com/Plutonomicon/cardano-transaction-lib/pull/470

epiro-ps commented 2 years ago

I just posted a comment on the CTL discord asking them to communicate remaining tasks. It's not clear what the current status is on their end.

https://discord.com/channels/922576618424250418/940666072208662628

epiro-ps commented 2 years ago

This is a more granular blocker:

https://github.com/Plutonomicon/cardano-transaction-lib/pull/663

epiro-ps commented 2 years ago

At last the plutip integration is merged!

https://github.com/Plutonomicon/cardano-transaction-lib/pull/470