Skip to content

Commit

Permalink
Add ADR doc for end-to-end testing strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
James Browning committed Dec 5, 2022
1 parent 366e8df commit b420133
Showing 1 changed file with 149 additions and 0 deletions.
149 changes: 149 additions & 0 deletions doc/adr/0016- end-to-end testing-strategy.rst
@@ -0,0 +1,149 @@
.. _end_to_end_testing_strategy:

ADR 15: End-to-end testing strategy for plutus, plutus-apps, cardano-api and cardano-testnet

This comment has been minimized.

Copy link
@koslambrou

koslambrou Dec 5, 2022

Contributor

I think the end-to-end testing strategy should not include plutus-apps.

Also, I would now go with cardano-ledger-api and not cardano-api (which would be renamed to cardano-node-client). Let's talk about more in detail tomorrow.

=======================================

Date: 2022-12-02

Author(s)
---------

james-iohk <james.browning@iohk.io>

Status
------

Draft

Context
-------

End-to-end testing of Plutus functionality is curently performed by a combination of
automation and exploratory approaches. Both are performed on a Cardano testnet with a real node and
network. Automation test scenarios for Plutus are being run as part of the wider
[cardano-node-tests](https://github.com/input-output-hk/cardano-node-tests) test suite, which is
driven by a `cardano-cli`` Python wrapper. These tests focus on general node/cli functionality
and only cover a few key scenarios for core [plutus](https://github.com/input-output-hk/plutus)
functionality, such as TxInfo and SECP256k1 builtins. None of the offchain tooling in
[plutus-apps](https://github.com/input-output-hk/plutus-apps) is being covered.

This document outlines an **additional** approach to end-to-end test automation using a framework
written in Haskell. Arguments for and against the creation and maintainance of a new test framework
alongside [cardano-node-tests](https://github.com/input-output-hk/cardano-node-tests) have been
made below along with suggestions of which features and types of tests are best suited for each
framework.

The exploratory testing approach is not in the scope of this document.

Decision
--------

An end-to-end testing framework written in Haskell to be created in a new repository. It will use
[cardano-testnet](https://github.com/input-output-hk/cardano-node/tree/master/cardano-testnet)

This comment has been minimized.

Copy link
@koslambrou

koslambrou Dec 5, 2022

Contributor

If we want to do property tests, maybe also use cardano-node-emulator in plutus-apps which is a faster Node without consensus (only ledger rules)?

This comment has been minimized.

Copy link
@catch-21

catch-21 Dec 5, 2022

Contributor

Is it in plutus-apps, or will be? It sounds like something that is not a "plutus app" but useful for testing generally, so unless I misunderstand it should be in cardano-node.

This comment has been minimized.

Copy link
@koslambrou

koslambrou Dec 5, 2022

Contributor

Right now it's in plutus-apps. If we go with Conway's law, it should stay in plutus-apps. If the Node team want to maintain it, then yes it should go in cardano-node

This comment has been minimized.

Copy link
@catch-21

catch-21 Dec 6, 2022

Contributor

Ah, I missed the PR #831

to initialise a local network environment, a combination of plutus-apps and cardano-api for building
transactions to submit, and assertions can be made using the result of node and chain-follower (Marconi)

This comment has been minimized.

Copy link
@koslambrou

koslambrou Dec 5, 2022

Contributor

Marconi is arguable. If it becomes THE chain-index solution of IOG, then yes. Until then, do we want to look ourselves at queries that are supported by the consensus layer?

This comment has been minimized.

Copy link
@catch-21

catch-21 Dec 5, 2022

Contributor

Yes, we can do that, this is how cardano-node-tests does it via the cli.

queries. The aim is to cover all of `plutus` and `plutus-apps` end-to-end testing requirements,
although, this is also an oportunity to get additional coverage of other packages such as
`cardano-testnet`` and `cardano-api`.

Types of tests for the Haskell framework
----------------------------------------
All of Plutus end-to-end testing requirements will be covered in the Haskell framework. Arguments for
and against this are covered in the below section. With less friction and access to Haskell and Plutus
interfaces we are likely to cover more scenarios at this level. E.g. builtin functions, edge cases
and error scenarios. Although, it is more efficient to the wider coverage at unit and integration
levels with fewer and broader scnearios covered at the end-to-end level.

**Examples of feature areas to be included:**
- Any Plutus Core builtin function. These may be tested extensively in the unit/property/intgration
suites but there's value in having some coverage at the end-to-end level too.
- Use cases. These use a combination of tooling to be closer to realistic plutus applications than
typical end-to-end test cases.
- Latest Plutus version, which would likely introduce new changes to the cardano ledger. Perhaps

This comment has been minimized.

Copy link
@koslambrou

koslambrou Dec 5, 2022

Contributor

Would you test each Plutus version?

This comment has been minimized.

Copy link
@koslambrou

koslambrou Dec 5, 2022

Contributor

Would be limited to Plutus scripts? How about timelock scripts?

This comment has been minimized.

Copy link
@catch-21

catch-21 Dec 5, 2022

Contributor

Would you test each Plutus version?

Yes, like with the emulated integration tests, we'll want to add tests for new versions and keep tests for old Plutus versions. Although, end-to-end can be slow so there may be incentive to reduce the number of transactions using older versions over time, or mark them to run less frequently.

Would be limited to Plutus scripts? How about timelock scripts?

Initially, "yes" because I was thinking of plutus-apps being part of this and it has no support for simple scripts. If we're focusing more on testing plutus and cardano-ledger-api then "maybe" because cardano-node-tests has already got this covered in isolation (not in combination with plutus scripts). We need to decide what value it'll bring by also covering simple scripts here, i.e. does cardano-cli cover plutus-ledger-api sufficiently for this (a topic for our discussion tomorrow).

`TxInfo` is extended. It'd likely be easier and quicker to cover here than waiting for
`cardano-cli` to implement in `cardano-node-tests` or depend on repetative manual approach for
regression testing.
- A subset of integration tests for the constraint library in `plutus-apps`. More of the edge-cases
will be covered at lower levels but it is also good to check each one functioning on a real network.
- Using each of the Marconi indexers for asserting for data relating to transactions submitted using
other componenets such as `cardano-api`.

Types of tests for cardano-node-tests Python framework
------------------------------------------------------
It would still bring value to have some coverage in `cardano-node-tests` for plutus transactions.
This will mainly be to cover specific cli flags, e.g. reference inputs and custom-typed script data
in cli's json format. It is also important to test the cli's error handling with script evaluation.

**Examples of feature areas to be included:**
- Cli flags that require use of plutus scripts E.g. tx-out-reference-script-file or calculate-plutus-script-cost
- Checking cli behaviour when script evaluation passes. This could be displaying expected fee correctly.
- Checking cli behaviour when script evaluation fails. This can be how different types errors are formatted.

Argument
--------

**Pros** of building and maintaining our own test framework:
- Plutus team will have full ownership of the end-to-end test environment and its priorities.

This comment has been minimized.

Copy link
@koslambrou

koslambrou Dec 5, 2022

Contributor

Plutus and Plutus Tools team?

This comment has been minimized.

Copy link
@catch-21

catch-21 Dec 6, 2022

Contributor

Yeah, both really. Although now I'm thinking this is more important for plutus core and possibly not at all for plutus-apps.

This comment has been minimized.

Copy link
@koslambrou

koslambrou Dec 6, 2022

Contributor

True that it's more important for plutus core, but Plutus Tools will be the ones that will be able to maintain it :) Off-chain tooling is not plutus core's interest, I think

- Plutus scripts can be defined alongside test definitions. Cardano-node-tests requires pre-compiled scripts

This comment has been minimized.

Copy link
@koslambrou

koslambrou Dec 5, 2022

Contributor

That's a huge plus!

- We want an end-to-end test environment for Marconi and other plutus tooling anyway and

This comment has been minimized.

Copy link
@koslambrou

koslambrou Dec 5, 2022

Contributor

Do we? Depends on what the scope of the tests are. If it's simply to test the interaction between Plutus scripts and transactions, then we can simply work with the consensus queries, and not need Marconi.

This comment has been minimized.

Copy link
@catch-21

catch-21 Dec 6, 2022

Contributor

On second thought, we do want e2e tests for indexer sync and querying but that would use a public testnet, not a private one. But I did also think we wanted to test building transactions with constraints library in e2e environment. We can discuss.

`cardano-node-tests` cannot be used for that.
- Tests will demonstrate how these Haskell packages can be used together to guide plutus application
development using our offchain tooling. Particularly useful for less experienced haskell developers.
- Possible to define tests once and run at different levels. E.g. `plutus-apps` emulated integration
tests suite at end-to-end level.
- Benefits from use of all plutus/plutus-apps apis. E.g. using PlutusTx to produce scripts,
typed interface, Contract monad, constraint library. This is not possible with `cardano-node-tests`.

This comment has been minimized.

Copy link
@koslambrou

koslambrou Dec 5, 2022

Contributor

Do we want have this test framework work with Contract Monad and constraint library? Not exactly what external devs are using for production systems. Maybe the Contract Monad make it easier to write Plutus application for testers?

This comment has been minimized.

Copy link
@catch-21

catch-21 Dec 6, 2022

Contributor

If the tooling is intended to be production grade then we should think about including it in the e2e tests. If we intend for PlutusTx applications to be built using cardano-ledger-api and no Contract or constraints then we focus on just that.

- `cardano-cli` would not be a dependency for plutus test coverage so no risk of being blocked by that.
- Plutus-tools team is now a major contributor for `cardano-api` so this approach will motivate us to
promptly support necessery `plutus-ledger` changes for plutus end-to-end test coverage.

This comment has been minimized.

Copy link
@koslambrou

koslambrou Dec 5, 2022

Contributor

Why plutus-ledger? You mean the constraints library and Contract Monad?

This comment has been minimized.

Copy link
@catch-21

catch-21 Dec 6, 2022

Contributor

I actually meant cardano-ledger. Having a requirement to e2e test cardano-ledger-api means we'll be exposed to new changes/rules sooner and iron out any issues or complications in good time.

- Plutus team can implement and review majority of tests in Haskell rather than Python (likely the
team's preference). Also won't need to review `cardano-node-tests` much beyond a few sanity tests.
- Less friction caused by cross-team: planning, dependencies and expectations. Plutus team won't need to
wait for node test team to implement the tests. Likely that other node/cli features will often
be prioritised.
- This approach will will improve our high-level perspective of each componenent and help guide
UX improvements.
- Node team are not pressured to focus on plutus scenarios, they retain control of their priorities.

**Cons** of building and maintaining our own test framework:
- `cardano-node-tests` is well established and already has useful features such as: running tests in
different eras, transitioning between eras, and measuring deviations in script cost.
- We are proposing to add another means of spinning up a local testnet when there are already
multiple others (see notes section below)
- No major work needed to continue using `cardano-node-tests`. Node test team will continue to
upgrade/maintain it regardless.
- Some coverage of plutus tests already exist and will continue to be added in
`cardano-node-tests`, especially for testing cli functionality.
- Going forwards, many plutus tests will be mostly a copy/paste job. E.g. The existing tests for
SECP256k1 will be very similar to future tests using builtins, just with different script
and redeemer.
- Plutus team will still be required to support the node test team with defining and reviewing a
subset of plutus tests in `cardano-node-tests`.
- Node test team may grow, less delays in getting plutus tests implementd by a Python developer
- `cardano-cli` is a wrapper for `cardano-api`, so unlike plutus, that package already getting
high-level test coverage at the.

This comment has been minimized.

Copy link
@koslambrou

koslambrou Dec 5, 2022

Contributor

the what?

This comment has been minimized.

Copy link
@catch-21

catch-21 Dec 6, 2022

Contributor

Ha, not sure. But it's true that cardano-api is currently getting a lot of coverage from cardano-node-tests, and other projects that pick up new changes early such as Hydra. The point is that plutus core is getting insufficient coverage at e2e level so the focus should be on satisfying its needs (e.g. a haskell framework over python for access to PlutusTx api)


Alternatives
------------

Other than choosing to remain using `cardano-node-test`, we could look at the approach teams such as
Djed or Hydra are using to see if we can share infrastructure. I don't think either are using
`cardano-testnet`.

This comment has been minimized.

Copy link
@koslambrou

koslambrou Dec 5, 2022

Contributor

Djed, Hydra and Marlowe spin up their testnets using bash scripts afaik. They weren't aware of cardano-testnet when they started.


Instead of creating a new repository it is possible the end-to-end tests could live in `plutus-apps`.
Although, because the componenets under test span other repositories it would be restrictive and
additional work at the time when dependencies are updated in `plutus-apps`.

Notes
-----

Benchmarking hasn't been covered above because we already have a team dedicated to testing cardano-node
performance that incldues some plutus scripts. It is an automated approach using `cardano-cli`.

Other places spinning up a local testnet:
https://github.com/woofpool/cardano-private-testnet-setup
https://github.com/input-output-hk/mithril/mithril-test-lab
https://github.com/input-output-hk/hydra/hydra-cluster
https://github.com/input-output-hk/cardano-node/tree/master/scripts/byron-to-alonzo
https://github.com/input-output-hk/cardano-js-sdk/tree/master/packages/e2e/local-network
https://github.com/input-output-hk/cardano-wallet/blob/master/lib/wallet/exe/local-cluster.hs

This comment has been minimized.

Copy link
@koslambrou

koslambrou Dec 5, 2022

Contributor

There's plutip which is a cardano-testnet alternative.

0 comments on commit b420133

Please sign in to comment.