hashgraph / hedera-services

Crypto, token, consensus, file, and smart contract services for the Hedera public ledger
Apache License 2.0
266 stars 119 forks source link

Repeatable `@HapiTest`s #13994

Closed tinker-michaelj closed 6 days ago

tinker-michaelj commented 1 week ago

Problem

@HapiTests would be stronger as a regression suite if they could be run in a completely deterministic mode.

A developer could then take a snapshot of records produced by, say, running all ScheduleService tests; do a refactor; and then verify no unintentional side effects of the change by repeating those tests and looking at the record running hash.

But there are several non-repeatable ingredients in the current @HapiTests:

  1. They choose TransactionID valid start times based on wall clock time. (This is, of course, necessary when running against a SubProcessNetwork; but not for an EmbeddedNetwork.)
  2. They always generate new cryptographic keys.
  3. (Occasionally) They use additional concurrency not controlled by JUnit Jupiter execution modes.

Solution

1️⃣ Use synthetic time

2️⃣ Use well-known keys

3️⃣ Switch inParallel to blocking order in embedded mode

4️⃣ Add a testRepeatable task that is analogous to testEmbedded but disables all JUnit Jupiter parallelism.

Alternatives

No response