This is intense, as we still want to preserve the serializer for V1 &
V2, and I've tried as much as possible to avoid polluting the
application layer with many enum types such as:
```
pub enum TxOut {
V1(TransactionOutput),
V2(TransactionOutput),
V3(TransactionOutput),
}
```
Those types make working with the script context cumbersome, and are
only truly required to provide different serialisation strategies. So
instead, we keep one top-level `TxInfo V1/V2/V3` type, and we ensure
to pass serialization strategies as type wrappers.
This way, the strategy propagates through the structure up until it's
eliminated when it reaches the relevant types.
All-in-all, this strikes a correct balance between maintainability and
repetition; and it makes it possible to define _different but mostly
identical_ encoders for the various versions.
With it, I've been able to successfully encode a V3 script context and
match it against one produced using the Haskell libraries. More to
come.
32 lines
689 B
Bash
Executable File
32 lines
689 B
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
AIKEN=${1:-"cargo run -r --quiet --"}
|
|
|
|
TESTS=()
|
|
for lang in $(ls script_context); do
|
|
for interaction in $(find script_context/$lang/validators -type f); do
|
|
title=$(basename $interaction)
|
|
title="${title%.*}"
|
|
cd script_context/$lang
|
|
./test.sh $title "$AIKEN" &
|
|
TESTS+=("$title,$lang,$!")
|
|
cd - 1>/dev/null
|
|
done
|
|
done
|
|
|
|
for args in ${TESTS[@]}; do
|
|
IFS=',' read title lang pid <<< "${args}"
|
|
wait $pid
|
|
code=("$?")
|
|
log="script_context/$lang/$title.log"
|
|
if [ $code -ne 0 ]; then
|
|
echo "=== $title ❌ (code=$code)"
|
|
cat $log && rm -f $log
|
|
exit $code
|
|
else
|
|
echo "=== $title ✅"
|
|
cat $log && rm -f $log
|
|
fi
|
|
echo ""
|
|
done
|