diff --git a/examples/acceptance_tests/062/plutus.json b/examples/acceptance_tests/062/plutus.json deleted file mode 100644 index 89e8f7ce..00000000 --- a/examples/acceptance_tests/062/plutus.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "preamble": { - "title": "aiken-lang/acceptance_test_062", - "version": "0.0.0" - }, - "validators": [ - { - "title": "basic", - "purpose": "spend", - "datum": { - "title": "Unit", - "description": "The nullary constructor.", - "anyOf": [ - { - "dataType": "constructor", - "index": 0, - "fields": [] - } - ] - }, - "redeemer": { - "title": "Unit", - "description": "The nullary constructor.", - "anyOf": [ - { - "dataType": "constructor", - "index": 0, - "fields": [] - } - ] - }, - "compiledCode": "5903dd010000323232323232323232323222253330063232323232300200132323232323301533300f323253330113370e002900109919299980999baf3300c300d0014800130126d8799f58200000000000000000000000000000000000000000000000000000000000000000ff0013370e6eb4cc030c034005200248000528180c80098058010a99809a491c73637269707420707572706f73652069736e277420275370656e6427001630133754002660106012014900126103d87a80004c0103d87980003301533300f32325333016001153301349011c756e6578706563746564206e756d626572206f66206f7574707574730016132533301700113232300b001330193330133375e6e98dd5998061806800a40046e98c0152080a8d6b9074c103d87a80004c0103d8798000330193330133375e66018601a66018601a002900024000980122d8799f581c11111111111111111111111111111111111111111111111111111111ff004c0103d87a80004c0103d879800033019333013323253330153370e0029000099250300f00214a2602e6ea8004cc030c034cc030c034005200048009300103d87a80004c0103d87980004bd70180c8010a9980a2491c756e6578706563746564206e756d626572206f66206f757470757473001630190013758660126014002900219804180480524000980103d87a80004c0103d87980003301533300f323375e6e98dd5998049805000a400c6e98c009205433008300900a4800130103d87a80004c0103d87980004bd7011999111919000999911199804801801000a5eb7bdb180010004ccc888ccc02800c0080052f5bded8c0004002910100488100001300100122225333015003133016337606ea4008dd3000a5eb7bdb1804c8c8c8c94ccc050cdc800300089980d19bb0375200c6e9801401c54ccc050cdc780300089980d19bb0375200c6e9801400c4cc068cdd81ba9001374c004666601001000600c00a6eb8c05800cdd5980b001180c802180b80198008009111299980980189980a19bb037520046ea00052f5bded8c0264646464a66602466e400180044cc060cdd81ba9006375000a00e2a66602466e3c0180044cc060cdd81ba9006375000a00626603066ec0dd48009ba80023333008008003006005375c60280066eb4c050008c05c010c05400cc004004894ccc03c0045288991929998060010998020020008a5030130023370e900118069baa301100122323330010014800000c888cccc030cdc3802001009919980200219b8000348008c0540040048c02cdd50008a4c2c6002002444a666012004293099802980098058011998018019806001000ab9a5736ae7155ceaab9e5573eae815d0aba201", - "hash": "0a7d654e443b18df327a2710a65bd9eee74dc7a9e26b1aca91bac9e5" - } - ] -} \ No newline at end of file diff --git a/examples/acceptance_tests/ci b/examples/acceptance_tests/ci index 4a93a982..26ec60f4 100755 --- a/examples/acceptance_tests/ci +++ b/examples/acceptance_tests/ci @@ -1,5 +1,3 @@ -for scenario in $(find . -maxdepth 1 -mindepth 1 -type d) -do - ./run $scenario +for scenario in $(find . -maxdepth 1 -mindepth 1 -regex ".*[0-9]\{3\}" -type d); do + ./run $scenario done - diff --git a/examples/acceptance_tests/062/.gitignore b/examples/acceptance_tests/script_context/.gitignore similarity index 100% rename from examples/acceptance_tests/062/.gitignore rename to examples/acceptance_tests/script_context/.gitignore diff --git a/examples/acceptance_tests/062/aiken.lock b/examples/acceptance_tests/script_context/aiken.lock similarity index 100% rename from examples/acceptance_tests/062/aiken.lock rename to examples/acceptance_tests/script_context/aiken.lock diff --git a/examples/acceptance_tests/062/aiken.toml b/examples/acceptance_tests/script_context/aiken.toml similarity index 100% rename from examples/acceptance_tests/062/aiken.toml rename to examples/acceptance_tests/script_context/aiken.toml diff --git a/examples/acceptance_tests/062/data/basic/inputs.cbor.template b/examples/acceptance_tests/script_context/data/basic/inputs.cbor.template similarity index 100% rename from examples/acceptance_tests/062/data/basic/inputs.cbor.template rename to examples/acceptance_tests/script_context/data/basic/inputs.cbor.template diff --git a/examples/acceptance_tests/062/data/basic/outputs.cbor.template b/examples/acceptance_tests/script_context/data/basic/outputs.cbor.template similarity index 100% rename from examples/acceptance_tests/062/data/basic/outputs.cbor.template rename to examples/acceptance_tests/script_context/data/basic/outputs.cbor.template diff --git a/examples/acceptance_tests/062/data/basic/tx.cbor.template b/examples/acceptance_tests/script_context/data/basic/tx.cbor.template similarity index 100% rename from examples/acceptance_tests/062/data/basic/tx.cbor.template rename to examples/acceptance_tests/script_context/data/basic/tx.cbor.template diff --git a/examples/acceptance_tests/062/data/basic/tx.diag.template b/examples/acceptance_tests/script_context/data/basic/tx.diag.template similarity index 100% rename from examples/acceptance_tests/062/data/basic/tx.diag.template rename to examples/acceptance_tests/script_context/data/basic/tx.diag.template diff --git a/examples/acceptance_tests/script_context/data/withdrawals/inputs.cbor.template b/examples/acceptance_tests/script_context/data/withdrawals/inputs.cbor.template new file mode 100644 index 00000000..e7f75b49 --- /dev/null +++ b/examples/acceptance_tests/script_context/data/withdrawals/inputs.cbor.template @@ -0,0 +1 @@ +81825820000000000000000000000000000000000000000000000000000000000000000000 diff --git a/examples/acceptance_tests/script_context/data/withdrawals/outputs.cbor.template b/examples/acceptance_tests/script_context/data/withdrawals/outputs.cbor.template new file mode 100644 index 00000000..71a0de30 --- /dev/null +++ b/examples/acceptance_tests/script_context/data/withdrawals/outputs.cbor.template @@ -0,0 +1 @@ +81A300581D70{{ VALIDATOR_HASH }}011A3B9ACA00028201D81843D87980 diff --git a/examples/acceptance_tests/script_context/data/withdrawals/tx.cbor.template b/examples/acceptance_tests/script_context/data/withdrawals/tx.cbor.template new file mode 100644 index 00000000..62f86104 --- /dev/null +++ b/examples/acceptance_tests/script_context/data/withdrawals/tx.cbor.template @@ -0,0 +1 @@ +84A80081825820000000000000000000000000000000000000000000000000000000000000000000018182581D60111111111111111111111111111111111111111111111111111111111A3B9ACA0002182A05A2581DE022222222222222222222222222222222222222222222222222222222182A581DF05E1E8FA84F2B557DDC362329413CAA3FD89A1BE26BFD24BE05CE0A020E0B5820FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0D818258200000000000000000000000000000000000000000000000000000000000000000001082581D60000000000000000000000000000000000000000000000000000000001A3B9ACA001101A20582840000D87980821A000F42401A05F5E100840301D87980821A000F42401A05F5E1000682{{ VALIDATOR }}58AF58AD0100003232322225333004323253330063372E646E64004DD7198009801002240009210D48656C6C6F2C20576F726C64210013233300100137586600460066600460060089000240206EB8CC008C00C019200022253335573E004294054CCC024CDC79BAE300A00200114A226660060066016004002294088C8CCC0040052000003222333300A3370E008004016466600800866E0000D2002300D001001235573C6EA8004526165734AE855D11F5F6 diff --git a/examples/acceptance_tests/script_context/data/withdrawals/tx.diag.template b/examples/acceptance_tests/script_context/data/withdrawals/tx.diag.template new file mode 100644 index 00000000..787cabbe --- /dev/null +++ b/examples/acceptance_tests/script_context/data/withdrawals/tx.diag.template @@ -0,0 +1,40 @@ +[ + { 0: + [ [h'0000000000000000000000000000000000000000000000000000000000000000', 0] + ] + + , 1: + [ [h'6011111111111111111111111111111111111111111111111111111111', 1000000000] + ] + + , 2: 42 + + , 5: + { h'e022222222222222222222222222222222222222222222222222222222': 42 + , h'f05e1e8fa84f2b557ddc362329413caa3fd89a1be26bfd24be05ce0a02': 14 + } + + , 11: h'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF' + + , 13: + [ [h'0000000000000000000000000000000000000000000000000000000000000000', 0] + ] + + , 16: + [ h'6000000000000000000000000000000000000000000000000000000000', 1000000000 + ] + + , 17: 1 + }, + + { 5: + [ [0, 0, 121([]), [1000000, 100000000]] + , [3, 1, 121([]), [1000000, 100000000]] + ] + + , 6: [ h'58ad0100003232322225333004323253330063372e646e64004dd7198009801002240009210d48656c6c6f2c20576f726c64210013233300100137586600460066600460060089000240206eb8cc008c00c019200022253335573e004294054ccc024cdc79bae300a00200114a226660060066016004002294088c8ccc0040052000003222333300a3370e008004016466600800866e0000d2002300d001001235573c6ea8004526165734ae855d11' ] + + }, + true, + null +] diff --git a/examples/acceptance_tests/script_context/plutus.json b/examples/acceptance_tests/script_context/plutus.json new file mode 100644 index 00000000..1250babe --- /dev/null +++ b/examples/acceptance_tests/script_context/plutus.json @@ -0,0 +1,64 @@ +{ + "preamble": { + "title": "aiken-lang/acceptance_test_062", + "version": "0.0.0" + }, + "validators": [ + { + "title": "withdrawals", + "purpose": "spend", + "datum": { + "title": "Unit", + "description": "The nullary constructor.", + "anyOf": [ + { + "dataType": "constructor", + "index": 0, + "fields": [] + } + ] + }, + "redeemer": { + "title": "Unit", + "description": "The nullary constructor.", + "anyOf": [ + { + "dataType": "constructor", + "index": 0, + "fields": [] + } + ] + }, + "compiledCode": "5902d80100003232323232323232323232222533300632323232323001003300100122533301000114a226464a66601a0042660080080022940c050008cdc3a4004601c6ea8c048004c8c8c8cc044ccc02cc8c94ccc034cdc3800a40042a6601e9211c616c6963652773207769746864726177616c206e6f7420666f756e640016132323370e002902a1bad30150013007002300f3754002660026eaccc010c014cc010c01401920004803130126d8799fd8799f581c22222222222222222222222222222222222222222222222222222222ffff004c0103d87a80004c0103d87980003301133300b3232533300d3370e00290010a99807a491a626f622773207769746864726177616c206e6f7420666f756e640016132323370e002900e1bad30150013007002300f3754002660026eaccc010c014cc010c01401920004803130126d8799fd87a9f581c5e1e8fa84f2b557ddc362329413caa3fd89a1be26bfd24be05ce0a02ffff004c0103d87a80004c0103d87980003301133300b3375e6e9cc8c8c8c008004dd599803180399803180380424000900618008009129998090008a5eb804c8c8c8c8cc05c004cc01801800cc04c00cdd69809801180b001180a0009ba7330114c0126d8799fd8799f581c22222222222222222222222222222222222222222222222222222222ffff00330114c126d8799fd87a9f581c5e1e8fa84f2b557ddc362329413caa3fd89a1be26bfd24be05ce0a02ffff004bd7026103d87a80004c0103d87980004bd70111980180100098008009112999808001099ba5480092f5c0264646464a66601e66ebc0140044cdd2a40006602a6ea00092f5c0266600e00e00600a60220066eb4c044008c05000cc04800888c8ccc0040052000003222333300c3370e008004026466600800866e0000d200230150010012300b37540022930b180080091129998048010a4c26600a600260160046660060066018004002ae695cdab9c5573aaae7955cfaba05742ae89", + "hash": "26dca991cde0d8e0554e3019488f4576e6f4b91c46dd14bd91053281" + }, + { + "title": "basic", + "purpose": "spend", + "datum": { + "title": "Unit", + "description": "The nullary constructor.", + "anyOf": [ + { + "dataType": "constructor", + "index": 0, + "fields": [] + } + ] + }, + "redeemer": { + "title": "Unit", + "description": "The nullary constructor.", + "anyOf": [ + { + "dataType": "constructor", + "index": 0, + "fields": [] + } + ] + }, + "compiledCode": "59042a010000323232323232323232323222253330063232323232300200132323232323233016333010323253330123370e002900109919299980a19baf3300d300e0014800130126d8799f58200000000000000000000000000000000000000000000000000000000000000000ff0013370e6eb4cc034c038005200248000528180d00098060010a9980a2491c73637269707420707572706f73652069736e277420275370656e6427001630143754002660126014016900126103d87a80004c0103d87980003301633301032325333017001153301449011c756e6578706563746564206e756d626572206f66206f7574707574730016132533301800113232300c0013301a3330143375e6e98dd5998069807000a40046e98c0152080a8d6b9074c103d87a80004c0103d87980003301a3330143375e6601a601c6601a601c002900024000980122d8799f581c11111111111111111111111111111111111111111111111111111111ff004c0103d87a80004c0103d87980003301a333014323253330163370e0029000099250301000214a260306ea8004cc034c038cc034c038005200048009300103d87a80004c0103d87980004bd70180d0010a9980aa491c756e6578706563746564206e756d626572206f66206f7574707574730016301a00137586601460160029002198049805005a4000980103d87a80004c0103d879800033016333010323375e6e98dd5998051805800a400c6e98c009205433009300a00b4800130103d87a80004c0103d87980004bd7011999111919000999991111999805002001801000a5eb7bdb180010004020cccc8888cccc03001000c0080052f5bded8c000400200e9101004881000013001001222225333017004133018337606ea400cdd300125eb7bdb1804c8c8c8c94ccc058cdd79980280380099ba5480012f5c026603866ec0dd48039ba6006008153330163371e00e00226603866ec0dd48039ba600600313301c337606ea4004dd3001199998048048018038030029bae301800337566030004603600a603200844a66601c66e400080044cdd2a400097ae01533300e3371e004002266e9520024bd70099ba5480112f5c0600200244444a66602800826602a66ec0dd48019ba80024bd6f7b630099191919299980999baf330050070013374a900025eb804cc064cdd81ba9007375000c0102a66602666e3c01c0044cc064cdd81ba9007375000c00626603266ec0dd48009ba800233333009009003007006005375c602a0066eb4c054008c060014c058010c004004894ccc03c0045288991929998060010998020020008a5030130023370e900118069baa301100122323330010014800000c888cccc030cdc3802001009919980200219b8000348008c0540040048c02cdd50008a4c2c6002002444a666012004293099802980098058011998018019806001000ab9a5736ae7155ceaab9e5573eae815d0aba201", + "hash": "1afe9a73274c140722127c27511395d861b5ed8e0bee1e7e9171c47a" + } + ] +} \ No newline at end of file diff --git a/examples/acceptance_tests/062/test.sh b/examples/acceptance_tests/script_context/test.sh similarity index 92% rename from examples/acceptance_tests/062/test.sh rename to examples/acceptance_tests/script_context/test.sh index 2dc83d9e..fb0d90fb 100755 --- a/examples/acceptance_tests/062/test.sh +++ b/examples/acceptance_tests/script_context/test.sh @@ -39,4 +39,4 @@ cp data/$TITLE/inputs.cbor.template data/$TITLE/inputs.cbor sed "s/{{ VALIDATOR_HASH }}/$VALIDATOR_HASH/" data/$TITLE/outputs.cbor.template > data/$TITLE/outputs.cbor sed "s/{{ VALIDATOR }}/$VALIDATOR/" data/$TITLE/tx.cbor.template > data/$TITLE/tx.cbor -aiken tx simulate data/$TITLE/tx.cbor data/$TITLE/inputs.cbor data/$TITLE/outputs.cbor +cargo run -- tx simulate data/$TITLE/tx.cbor data/$TITLE/inputs.cbor data/$TITLE/outputs.cbor diff --git a/examples/acceptance_tests/062/validators/basic.ak b/examples/acceptance_tests/script_context/validators/basic.ak similarity index 100% rename from examples/acceptance_tests/062/validators/basic.ak rename to examples/acceptance_tests/script_context/validators/basic.ak diff --git a/examples/acceptance_tests/script_context/validators/withdrawals.ak b/examples/acceptance_tests/script_context/validators/withdrawals.ak new file mode 100644 index 00000000..36fafe50 --- /dev/null +++ b/examples/acceptance_tests/script_context/validators/withdrawals.ak @@ -0,0 +1,35 @@ +use aiken/dict +use aiken/list +use aiken/transaction.{ScriptContext} +use aiken/transaction/credential.{ + Inline, ScriptCredential, VerificationKeyCredential, +} + +fn spend(_datum: Void, _redeemer: Void, ctx: ScriptContext) { + let alice = + Inline( + VerificationKeyCredential( + #"22222222222222222222222222222222222222222222222222222222", + )) + + + let bob = + Inline( + ScriptCredential( + #"5e1e8fa84f2b557ddc362329413caa3fd89a1be26bfd24be05ce0a02", + )) + + + [ + when dict.get(ctx.transaction.withdrawals, alice) is { + None -> error("alice's withdrawal not found") + Some(value) -> value == 42 + }, + when dict.get(ctx.transaction.withdrawals, bob) is { + None -> error("bob's withdrawal not found") + Some(value) -> value == 14 + }, + dict.keys(ctx.transaction.withdrawals) == [alice, bob], + ] + |> list.and +}