remove v2 script contexts acceptance tests.

V2 is dead. Long live V3.
This commit is contained in:
KtorZ 2024-08-16 17:19:07 +02:00
parent 6a6bf6f65f
commit 047f422d0d
No known key found for this signature in database
GPG Key ID: 33173CB6F77F4277
26 changed files with 0 additions and 572 deletions

View File

@ -1,2 +0,0 @@
*.cbor
*.log

View File

@ -1,56 +0,0 @@
# V2 Script Context Tests
This project contains a few handcrafted Plutus V2 validators and transactions
whose sole purpose is to test the interpretation of the `ScriptContext` from
within an Aiken's validators.
So validators are meant to work hand-in-hand with an associated context.
Because we can't have fully static context (since they contain the validator
and its hash), we define _templates_.
Everything is a bit clunky, but steps have been captured in a `test.sh` script
for convenience.
## How to use
```
./test.sh [VALIDATOR_TITLE]
```
## Test Coverage
- [ ] Purpose
- [x] spend
- [x] mint
- [x] withdraw
- [ ] publish
- [ ] Transaction
- [ ] inputs
- [ ] reference inputs
- [ ] outputs
- [ ] address
- [x] verification key
- [x] script
- [ ] pointer
- [x] value
- [x] datum
- [x] none
- [x] hash
- [x] inline
- [x] script
- [x] none
- [x] reference
- [x] values
- [x] pure ada
- [x] native assets
- [x] fee
- [x] mint
- [ ] certificates
- [x] withdrawals
- [x] verification key
- [x] script
- [ ] validity range
- [x] extra signatories
- [x] redeemers
- [x] datums

View File

@ -1,16 +0,0 @@
# This file was generated by Aiken
# You typically do not need to edit this file
[[requirements]]
name = "aiken-lang/stdlib"
version = "main"
source = "github"
[[packages]]
name = "aiken-lang/stdlib"
version = "main"
requirements = []
source = "github"
[etags]
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1723583483, nanos_since_epoch = 18378000 }, "5e58899446492a704d0927a43299139856bef746e697b55895ba34206fa28452"]

View File

@ -1,10 +0,0 @@
name = "script_context/v2"
version = "0.0.0"
plutus = "v2"
license = "Apache-2.0"
description = "Aiken contracts for project 'script_context/v2'"
[[dependencies]]
name = "aiken-lang/stdlib"
version = "main"
source = "github"

View File

@ -1 +0,0 @@
81825820000000000000000000000000000000000000000000000000000000000000000000

View File

@ -1 +0,0 @@
81A300581D70{{ VALIDATOR_HASH }}011A3B9ACA00028201D81843D87980

View File

@ -1 +0,0 @@
84A70081825820000000000000000000000000000000000000000000000000000000000000000000018182581D60111111111111111111111111111111111111111111111111111111111A3B9ACA0002182A0B5820FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0D818258200000000000000000000000000000000000000000000000000000000000000000001082581D60000000000000000000000000000000000000000000000000000000001A3B9ACA001101A20581840000D87980821A000F42401A05F5E1000681{{ VALIDATOR }}F5F6

View File

@ -1,34 +0,0 @@
[
{ 0:
[ [h'0000000000000000000000000000000000000000000000000000000000000000', 0]
]
, 1:
[ [h'6011111111111111111111111111111111111111111111111111111111', 1000000000]
]
, 2: 42
, 11: h'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'
, 13:
[ [h'0000000000000000000000000000000000000000000000000000000000000000', 0]
]
, 16:
[ h'6000000000000000000000000000000000000000000000000000000000', 1000000000
]
, 17: 1
},
{ 5: [[0, 0, 121([]), [1000000, 100000000]]]
, 6: [h'{{ VALIDATOR }}']
},
true,
null
]

View File

@ -1 +0,0 @@
81825820000000000000000000000000000000000000000000000000000000000000000000

View File

@ -1 +0,0 @@
81A300581D70{{ VALIDATOR_HASH }}011A000F4240028201D81843D87980

View File

@ -1 +0,0 @@
84A300818258200000000000000000000000000000000000000000000000000000000000000000000182A400581D6000000000000000000000000000000000000000000000000000000000011A000F42400282005820FCAA61FB85676101D9E3398A484674E71C45C3FD41B492682F3B0054F4CF327303D81858418202583D583B0100003232323232323222253330064A22930B180080091129998030010A4C26600A6002600E0046660060066010004002AE695CDAAB9F5742AE89A3005839100000000000000000000000000000000000000000000000000000000066666666666666666666666666666666666666666666666666666666011A000F4240028201D81846D8799F182AFF0201A30482D8799FFFD8799F182AFF0581840000D87980821A000F42401A05F5E1000681{{ VALIDATOR }}F5F6

View File

@ -1,33 +0,0 @@
[
{ 0:
[ [h'0000000000000000000000000000000000000000000000000000000000000000', 0]
]
, 1:
[ { 0: h'6000000000000000000000000000000000000000000000000000000000'
, 1: 1000000
, 2: [ 0, h'fcaa61fb85676101d9e3398a484674e71c45c3fd41b492682f3b0054f4cf3273' ]
, 3: 24(h'8202583D583B0100003232323232323222253330064A22930B180080091129998030010A4C26600A6002600E0046660060066010004002AE695CDAAB9F5742AE89')
}
, { 0: h'100000000000000000000000000000000000000000000000000000000066666666666666666666666666666666666666666666666666666666'
, 1: 1000000
, 2: [ 1, 24(h'D8799F182AFF') ]
}
]
, 2: 1
},
{ 4: [121([]), 121([42])]
, 5: [[0, 0, 121([]), [1000000, 100000000]]]
, 6: [h'{{ VALIDATOR }}']
},
true,
null
]

View File

@ -1 +0,0 @@
81825820000000000000000000000000000000000000000000000000000000000000000000

View File

@ -1 +0,0 @@
81A200581D60FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF011A000F4240

View File

@ -1 +0,0 @@
84A400818258200000000000000000000000000000000000000000000000000000000000000000000180020109A1581C{{ VALIDATOR_HASH }}A143666F6F190539A20581840100D87980821A000F42401A05F5E1000681{{ VALIDATOR }}F5F6

View File

@ -1,25 +0,0 @@
[
{ 0:
[ [h'0000000000000000000000000000000000000000000000000000000000000000', 0]
]
, 1:
[]
, 2: 1
, 9:
{ h'{{ VALIDATOR_HASH }}': { h'666f6f': 1337 }
}
},
{ 5: [[1, 0, 121([]), [1000000, 100000000]]]
, 6: [h'{{ VALIDATOR }}']
},
true,
null
]

View File

@ -1 +0,0 @@
81825820000000000000000000000000000000000000000000000000000000000000000000

View File

@ -1 +0,0 @@
81A300581D70{{ VALIDATOR_HASH }}011A3B9ACA00028201D81843D87980

View File

@ -1 +0,0 @@
84A80081825820000000000000000000000000000000000000000000000000000000000000000000018182581D60111111111111111111111111111111111111111111111111111111111A3B9ACA0002182A05A2581DE022222222222222222222222222222222222222222222222222222222182A581DF0AFDDC16C18E7D8DE379FB9AAD39B3D1B5AFD27603E5EBAC818432A720E0B5820FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0D818258200000000000000000000000000000000000000000000000000000000000000000001082581D60000000000000000000000000000000000000000000000000000000001A3B9ACA001101A20582840000D87980821A000F42401A05F5E100840300D87980821A000F42401A05F5E1000682{{ VALIDATOR }}583D583B010000323232323232322253330054A22930B180080091129998030010A4C26600A6002600E0046660060066010004002AE695CDAAB9F5742AE881F5F6

View File

@ -1,42 +0,0 @@
[
{ 0:
[ [h'0000000000000000000000000000000000000000000000000000000000000000', 0]
]
, 1:
[ [h'6011111111111111111111111111111111111111111111111111111111', 1000000000]
]
, 2: 42
, 5:
{ h'e022222222222222222222222222222222222222222222222222222222': 42
, h'f0afddc16c18e7d8de379fb9aad39b3d1b5afd27603e5ebac818432a72': 14
}
, 11: h'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'
, 13:
[ [h'0000000000000000000000000000000000000000000000000000000000000000', 0]
]
, 16:
[ h'6000000000000000000000000000000000000000000000000000000000', 1000000000
]
, 17: 1
},
{ 5:
[ [0, 0, 121([]), [1000000, 100000000]]
, [3, 0, 121([]), [1000000, 100000000]]
]
, 6: [ {{ VALIDATOR }}, h'583b010000323232323232322253330054a22930b180080091129998030010a4c26600a6002600e0046660060066010004002ae695cdaab9f5742ae881' ]
},
true,
null
]

View File

@ -1,94 +0,0 @@
{
"preamble": {
"title": "script_context/v2",
"description": "Aiken contracts for project 'script_context/v2'",
"version": "0.0.0",
"plutusVersion": "v2",
"compiler": {
"name": "Aiken",
"version": "v1.0.31-alpha+fe5c565"
},
"license": "Apache-2.0"
},
"validators": [
{
"title": "basic.spend",
"datum": {
"title": "_datum",
"schema": {
"$ref": "#/definitions/Void"
}
},
"redeemer": {
"title": "_redeemer",
"schema": {
"$ref": "#/definitions/Void"
}
},
"compiledCode": "5903fb01000032323232323232323232322533333300c00115332330053001300737540042a66601260106ea8008494cccccc03800454ccc018c008c020dd50008a99980518049baa0011253330073253330083330083375e601c601e601e601e601e601e601e601e601e601e601e601e60166ea8c004c02cdd500126126d8799f58200000000000000000000000000000000000000000000000000000000000000000ff004a09444c94ccc024c94ccc028cdc3a400460186ea80044c94ccc02ccdd7980218071baa0014c0126d8799f58200000000000000000000000000000000000000000000000000000000000000000ff0013007375a6006601c6ea8004528180818069baa001153300b4911c73637269707420707572706f73652069736e277420275370656e642700163001300c375400626464a6660166464a6660220022a6601c92011c756e6578706563746564206e756d626572206f66206f7574707574730016153330113014001132533300e3375e600c60226ea8004dd318022410151ad720e2a66601c66ebcc01cc044dd5180398089baa0014c0122d8799f581c11111111111111111111111111111111111111111111111111111111ff001533300e533300e300a30103754600c60226ea8c01cc044dd50008a5014a22a66601c66ebcc00cc044dd5000a60103d879800013375e600a60226ea800530103d87a800014a029405280a503013001153300e4911c756e6578706563746564206e756d626572206f66206f757470757473001637586002601e6ea8c014c03cdd50031180918099809800899baf3002300e37546008601c6ea8014dd31800a40a8294094ccc02cc01c00452f5bded8c0264646600200297adef6c6022533301200113301333760981014000374c00697adef6c60132323232533301233720910100002133017337609801014000374c00e00a2a66602466e3d22100002133017337609801014000374c00e00626602e66ec0dd48011ba600133006006003375660280066eb8c048008c058008c050004c8cc0040052f5bded8c044a66602200226602466ec13001014000375000697adef6c60132323232533301133720910100002133016337609801014000375000e00a2a66602266e3d22100002133016337609801014000375000e00626602c66ec0dd48011ba800133006006003375a60260066eb8c044008c054008c04c0048c040c044c044c0440045281180798080008a502300e001149854cc0212411856616c696461746f722072657475726e65642066616c73650013656004004004004004004004370e90000018018018018018a99801a4810f5f72656465656d65723a20566f6964001615330024910c5f646174756d3a20566f696400165734ae7155ceaab9e5573eae815d0aba257481",
"hash": "1c6c13a9a56cbcb9ed18c312c9e9e9996b0545b7230b7cf81cbe012d"
},
{
"title": "deploy.spend",
"datum": {
"title": "datum",
"schema": {
"$ref": "#/definitions/Data"
}
},
"redeemer": {
"title": "_redeemer",
"schema": {
"$ref": "#/definitions/Data"
}
},
"compiledCode": "59039801000032323232323232323232222533300553330053375e00698103d8798000132533300633232232533300a3370e900018061baa00113253333330130011533300b3370e900018069baa001132533301000100b132533333301500100c00c00c132533301230150031533300e3375e980106d8799f182aff0000413370e600e00c90020a5000d375a0020186024002601c6ea8004028028028028028c040c034dd50008a99805a495865787065637420536f6d6528646174756d29203d0a20202020646963742e67657428646174756d732c20626c616b6532625f323536286275696c74696e2e73657269616c6973655f64617461286d795f646174756d292929001632323300100100322533301000114c0103d87a800013232323253330103372200e0042a66602066e3c01c0084cdd2a40006602a00297ae014c0103d87a80001330060060033012003375c6020004602800460240026e50dd9a6106d8799f182aff00300100122533300c0011480004cdc02400466004004601e0026eacc030c034c034c034c034c034c034c034c034c034c034c024dd5180098049baa00213232533300c00115330094901316578706563746564207472616e73616374696f6e20746f206861766520286174206c65617374292032206f7574707574730016132533300d001153300a4901316578706563746564207472616e73616374696f6e20746f206861766520286174206c65617374292032206f7574707574730016132533300a32533300b3375e600a601c6ea800530126d87a9f5820fcaa61fb85676101d9e3398a484674e71c45c3fd41b492682f3b0054f4cf3273ff0013375e6022602460246024601c6ea800530122d8799f581ce37db487fbd58c45d059bcbf5cd6b1604d3bec16cf888f1395a4ebc4ff0014a060200062a66601466ebcc040c044c034dd5180298069baa0014c012ad8799fd8799fd8799f581c66666666666666666666666666666666666666666666666666666666ffffff001533300a3370e900218061baa3004300d3754002294454cc02d24115657870656374656420696e6c696e6520646174756d001614a02940c03c004c03c004dd6180098051baa3002300a37540064601a601c601c00229408c0300045280a4c2a6600c92011856616c696461746f722072657475726e65642066616c73650013656153300249011d65787065637420646174756d3a204d79446174756d203d20646174756d00165734ae7155ceaab9e5573eae815d0aba257481",
"hash": "66a5272eb58aed0097083185588ef1e8b3888a3bc2e03c061f09c898"
},
{
"title": "mint.mint",
"redeemer": {
"title": "redeemer",
"schema": {
"$ref": "#/definitions/Data"
}
},
"compiledCode": "590496010000323232323232323232225333004323232323253323300a3232533301000100b13253330113014002132533300e300530103754002266e3c008dd7180a18089baa001153300f49124657870656374204d696e7428706f6c6963795f696429203d206374782e707572706f736500163008301037540140186eb8c048004cc004004cc010c00cdd5980298071baa3007300e375401091010022533301000114bd70099808980718090009980100118098008a999191980619912999807180298081baa002132533300f3005301137540022a6602092010f746f6b656e206e6f7420666f756e64001613370e6eb4c054c048dd5000a41e428646600200264a666020600c60246ea800452f5bded8c026eacc058c04cdd500099191980080098049bab300b3014375400844a66602c002298103d87a800013232323253330163372200e0042a66602c66e3c01c0084c02ccc06cdd3000a5eb80530103d87a8000133006006003375660300066eb8c058008c068008c060004dd7180a98091baa00322533301400114c103d87a800013232323253330143372291103666f6f00002153330143371e910103666f6f000021300933019375000297ae014c0103d87a8000133006006003375a602c0066eb8c050008c060008c05800454cc03d24120657870656374204d696e7428706f6c6963795f696429203d20707572706f736500163007300f37540126010601e6ea80244c8c8c8c94ccc040c01cc048dd50008a99980819baf00e30133233760602e002602e60300026eb0c058c04cdd50008980318011bab300430133754601860266ea80345280a99808a496b65787065637420536f6d652850616972285f2c2072656465656d65722929203d0a202020206c6973742e66696e64286374782e7472616e73616374696f6e2e72656465656d6572732c20666e286b7629207b206b762e317374203d3d206374782e707572706f7365207d29001632330010013756600860266ea8c030c04cdd500691299980a8008a6103d87a80001323253330133375e602a004601c602c6ea80404c020cc060dd39980c180a8011980c180b00125eb812f5c02660080080026032004602e002600200244a66602600229000099b8048008cc008008c0580048c04cc050c050c050c050c050c050c050c050c050004dd2a40006e1d200214a06e1d200014a046600400291010022323300100100322533300f00114bd6f7b630099191919299980799b910070021533300f3371e00e0042006200a26602866ec0dd48011ba600133006006003375660220066eb8c03c008c04c008c0440048c034c038c038c038c0380048c030c0340048c02c00452615330054911856616c696461746f722072657475726e65642066616c736500136561533002490189657870656374205b6d795f706f6c6963795f69645d203d0a202020206374782e7472616e73616374696f6e2e6d696e740a2020202020207c3e2076616c75652e66726f6d5f6d696e7465645f76616c75650a2020202020207c3e2076616c75652e776974686f75745f6c6f76656c6163650a2020202020207c3e2076616c75652e706f6c696369657300165734ae7155ceaab9e5573eae815d0aba21",
"hash": "8372367de2b0391b1bec0489dc72cb65de1a791f4e9712b9149d6392"
},
{
"title": "withdrawals.spend",
"datum": {
"title": "_datum",
"schema": {
"$ref": "#/definitions/Void"
}
},
"redeemer": {
"title": "_redeemer",
"schema": {
"$ref": "#/definitions/Void"
}
},
"compiledCode": "5902de01000032323232323232323232322533333300c001153330043370e900018031baa001153330083007375400224a66666601a0022a66600a66e1d2000300737540022a66601260106ea8004494ccc018c8c8c94ccc024c94ccc028cdc3a400460186ea800454cc02d2411c616c6963652773207769746864726177616c206e6f7420666f756e64001613370e6eb4c034c8cdd81808800980898090009bac3010300d3754002902a198009bab3002300c3754600660186ea80108cdd79806000a6126d8799fd8799f581c22222222222222222222222222222222222222222222222222222222ffff001533300932533300a3370e900118061baa001153300b49011a626f622773207769746864726177616c206e6f7420666f756e64001613370e6eb4c034c8cdd81808800980898090009bac3010300d3754002900e198009bab3002300c3754600660186ea80108cdd79806000a6126d8799fd87a9f581cafddc16c18e7d8de379fb9aad39b3d1b5afd27603e5ebac818432a72ffff0013375e6e9cc8cc004004dd5980198069baa3004300d375400a44a66601e002297ae0133010300d3011001330020023012001374e6601c98126d8799fd87a9f581cafddc16c18e7d8de379fb9aad39b3d1b5afd27603e5ebac818432a72ffff003300e4c126d8799fd8799f581c22222222222222222222222222222222222222222222222222222222ffff004bd700a5014a044646600200200644a666020002298103d87a800013232533300e300500213374a9000198099ba73301330100023301330110024bd7025eb804cc010010004c050008c0480048c038c03cc03cc03cc03cc03cc03c0048c03400452615330074911856616c696461746f722072657475726e65642066616c73650013656003003003003003003003003003003003003153300349010f5f72656465656d65723a20566f6964001615330024910c5f646174756d3a20566f696400165734ae7155ceaab9e5573eae815d0aba257481",
"hash": "4f44caf93e36ee884b6d03b1e1c93bf8cda516fd39f7113823508571"
}
],
"definitions": {
"Data": {
"title": "Data",
"description": "Any Plutus data."
},
"Void": {
"title": "Unit",
"description": "The nullary constructor.",
"anyOf": [
{
"dataType": "constructor",
"index": 0,
"fields": []
}
]
}
}
}

View File

@ -1,47 +0,0 @@
#!/usr/bin/env bash
TITLE=$1
if [ -z $TITLE ]; then
echo -e "\033[31mMissing argument: \033[1mVALIDATOR_TITLE\033[0m"
echo ""
echo -e "\033[1mUsage: \033[0m"
echo " test.sh {ACCEPTANCE_TEST}"
echo ""
echo -e "\033[1mExample: \033[0m"
echo " test.sh basic"
exit 1
fi
AIKEN=${2:-"cargo run -r --quiet --"}
if ! command -v jq &> /dev/null
then
echo "\033[1mjq\033[0m missing from system but required."
exit 1
fi
if ! command -v cbor-diag &> /dev/null
then
echo "\033[1mcbor-diag\033[0m missing from system but required."
exit 1
fi
$AIKEN build --filter-traces all -t verbose
if [ $? -ne 0 ]; then
exit $?
fi
BLUEPRINT=$(jq ".validators[] | select(.title|contains(\"$TITLE\"))" plutus.json)
VALIDATOR_HASH=$(echo $BLUEPRINT | jq .hash | sed s/\"//g)
VALIDATOR=$(echo $BLUEPRINT | jq .compiledCode | sed s/\"//g)
VALIDATOR=$(cbor-diag --to hex --from diag <<< "h'$VALIDATOR'")
cp ctx/$TITLE/inputs.cbor.template ctx/$TITLE/inputs.cbor
sed "s/{{ VALIDATOR_HASH }}/$VALIDATOR_HASH/" ctx/$TITLE/outputs.cbor.template > ctx/$TITLE/outputs.cbor
sed "s/{{ VALIDATOR }}/$VALIDATOR/" ctx/$TITLE/tx.cbor.template | sed "s/{{ VALIDATOR_HASH }}/$VALIDATOR_HASH/" > ctx/$TITLE/tx.cbor
$AIKEN tx simulate \
ctx/$TITLE/tx.cbor \
ctx/$TITLE/inputs.cbor \
ctx/$TITLE/outputs.cbor

View File

@ -1,51 +0,0 @@
use aiken/option
use aiken/transaction.{NoDatum,
ScriptContext, Spend, Transaction, TransactionId}
use aiken/transaction/credential.{VerificationKeyCredential}
use aiken/transaction/value
validator {
fn spend(_datum: Void, _redeemer: Void, ctx: ScriptContext) {
and {
assert_id(ctx.transaction),
assert_purpose(ctx.purpose),
assert_outputs(ctx.transaction),
assert_fee(ctx.transaction),
}
}
}
fn assert_id(transaction: Transaction) {
transaction.id != TransactionId(
#"0000000000000000000000000000000000000000000000000000000000000000",
)
}
fn assert_purpose(purpose) {
when purpose is {
Spend(ref) ->
ref.transaction_id == TransactionId(
#"0000000000000000000000000000000000000000000000000000000000000000",
) && ref.output_index == 0
_ -> fail @"script purpose isn't 'Spend'"
}
}
fn assert_fee(transaction: Transaction) {
transaction.fee == value.from_lovelace(42)
}
fn assert_outputs(transaction: Transaction) {
when transaction.outputs is {
[output] -> and {
output.value == value.from_lovelace(1000000000),
output.address.payment_credential == VerificationKeyCredential(
#"11111111111111111111111111111111111111111111111111111111",
),
option.is_none(output.address.stake_credential),
output.datum == NoDatum,
output.reference_script == None,
}
_ -> fail @"unexpected number of outputs"
}
}

View File

@ -1,70 +0,0 @@
use aiken/builtin
use aiken/dict.{Dict}
use aiken/hash.{blake2b_256}
use aiken/transaction.{DatumHash, InlineDatum, Output, ScriptContext}
use aiken/transaction/credential.{Inline, VerificationKeyCredential}
validator {
fn spend(datum: Data, _redeemer: Data, ctx: ScriptContext) {
and {
assert_datum(datum),
assert_datums(ctx.transaction.datums),
assert_outputs(ctx.transaction.outputs),
}
}
}
fn assert_datum(datum) {
let my_datum: Data = Void
datum == my_datum
}
type MyDatum {
MyDatum(Int)
}
fn assert_datums(datums: Dict<ByteArray, Data>) {
let my_datum = MyDatum(42)
expect Some(datum) =
dict.get(datums, blake2b_256(builtin.serialise_data(my_datum)))
expect datum: MyDatum = datum
my_datum == datum && dict.size(datums) == 2
}
fn assert_outputs(outputs) {
when outputs is {
[output_1, output_2, ..] ->
assert_first_output(output_1) && assert_second_output(output_2)
_ -> fail @"expected transaction to have (at least) 2 outputs"
}
}
fn assert_first_output(output: Output) {
and {
output.datum == DatumHash(
#"fcaa61fb85676101d9e3398a484674e71c45c3fd41b492682f3b0054f4cf3273",
),
output.reference_script == Some(
#"e37db487fbd58c45d059bcbf5cd6b1604d3bec16cf888f1395a4ebc4",
),
}
}
fn assert_second_output(output: Output) {
and {
output.address.stake_credential == Some(
Inline(
VerificationKeyCredential(
#"66666666666666666666666666666666666666666666666666666666",
),
),
),
when output.datum is {
InlineDatum(_) -> True
_ -> fail @"expected inline datum"
},
}
}

View File

@ -1,43 +0,0 @@
use aiken/dict
use aiken/list
use aiken/transaction.{Mint, ScriptContext, Transaction}
use aiken/transaction/value
validator {
fn mint(redeemer: Data, ctx: ScriptContext) {
and {
assert_purpose(ctx),
assert_mint(ctx.purpose, ctx.transaction),
assert_redeemers(ctx, redeemer),
}
}
}
fn assert_purpose(ctx: ScriptContext) {
expect [my_policy_id] =
ctx.transaction.mint
|> value.from_minted_value
|> value.without_lovelace
|> value.policies
expect Mint(policy_id) = ctx.purpose
my_policy_id == policy_id
}
fn assert_mint(purpose, transaction: Transaction) {
expect Mint(policy_id) = purpose
let tokens =
value.tokens(transaction.mint |> value.from_minted_value, policy_id)
when dict.get(tokens, #"666f6f") is {
None -> fail @"token not found"
Some(quantity) -> quantity == 1337
}
}
fn assert_redeemers(ctx: ScriptContext, my_redeemer) {
expect Some(Pair(_, redeemer)) =
list.find(ctx.transaction.redeemers, fn(kv) { kv.1st == ctx.purpose })
my_redeemer == redeemer && list.length(ctx.transaction.redeemers) == 1
}

View File

@ -1,37 +0,0 @@
use aiken/list
use aiken/transaction.{ScriptContext}
use aiken/transaction/credential.{
Inline, ScriptCredential, VerificationKeyCredential,
}
validator {
fn spend(_datum: Void, _redeemer: Void, ctx: ScriptContext) {
let alice =
Inline(
VerificationKeyCredential(
#"22222222222222222222222222222222222222222222222222222222",
),
)
let bob =
Inline(
ScriptCredential(
#"afddc16c18e7d8de379fb9aad39b3d1b5afd27603e5ebac818432a72",
),
)
and {
when
list.find(ctx.transaction.withdrawals, fn(kv) { kv.1st == alice })
is {
None -> fail @"alice's withdrawal not found"
Some(value) -> value.2nd == 42
},
when list.find(ctx.transaction.withdrawals, fn(kv) { kv.1st == bob }) is {
None -> fail @"bob's withdrawal not found"
Some(value) -> value.2nd == 14
},
list.map(ctx.transaction.withdrawals, fn(kv) { kv.1st }) == [bob, alice],
}
}
}