feat: add end to end tests to replace acceptance tests with strict uplc comparison.
Add acceptance tests 1,2, 6 as end to end tests
This commit is contained in:
@@ -6,21 +6,29 @@
|
||||
},
|
||||
"validators": [
|
||||
{
|
||||
"title": "spend.staking",
|
||||
"datum": {
|
||||
"title": "_datum",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/Void"
|
||||
}
|
||||
},
|
||||
"title": "spend.gift_card",
|
||||
"redeemer": {
|
||||
"title": "_redeemer",
|
||||
"title": "rdmr",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/Void"
|
||||
"$ref": "#/definitions/spend~1Action"
|
||||
}
|
||||
},
|
||||
"compiledCode": "5904660100003232323232323232323232322223232323232323232323232325333014323232323232323232323375e6e98008dd300099980a1bac33019301b33019301b01648001200422533301f3375e66036603a00490000020998061bab3301b301d0024800800440052f5bded8c06660266eb0cc060c068cc060c068055200048000894ccc078cdd79980d180e1980d180e0012400490000018998059bab3301a301c3301a301c00248009200200110014bd6f7b6301980b980c800a400060400026040002602c002603a002602864a66602e66e1d20003016001100115330184912a4578706563746564206f6e20696e636f727265637420636f6e7374727563746f722076617269616e742e0016323233001375866028602c66028602c022900024000466ebccc054c05c00520000043001001222533301d00213374a900125eb804c8c94ccc06cc00c0084cdd2a40006604000497ae013330050050010033021003301f002301b00130123253330153370e9001180a00088008a9980b2492a4578706563746564206f6e20696e636f727265637420636f6e7374727563746f722076617269616e742e001633010301200d480085261622320013333008002001222325333019533301d00114a229404cdd2a400497ae013374a90001980f1ba60014bd70199980380100091119299980e19b87001480004cdd2a400497ae013374a9000198109ba80014bd7019b8000200100600322533301433720004002266e9520004bd700a99980a19b8f00200113374a900125eb804cdd2a400897ae030010012222253330190041003132323232333330090090033333300a007001002006005006005375c60340066eb4c068008c074014c06c010c0040048888894ccc0600144cc064cdd81ba9004375000697adef6c6013232323253330183375e6600a01000266e9520004bd7009980e99bb037520106ea001c02454ccc060cdc780400089919299980d19b87480000044c8c8cc084cdd81ba900c375000200e6eb4c084004c0600084014c060004ccc01802001c0084cc074cdd81ba9001375000466666601401400601000e00c00a6eb8c06400cdd6980c801180e003180d002980080091111299980a802080189919191919999804804801999998050038008010030028030029bae30160033756602c004603200a602e0086002002444444a66602800a26602a66ec0dd48021ba60034bd6f7b630099191919299980a19baf330050080013374a900025eb804cc064cdd81ba9008374c00e0122a66602866e3c0200044c8c94ccc058cdc3a4000002264646603a66ec0dd48061ba60010073756603a0026028004200a602800266600c01000e00426603266ec0dd48009ba600233333300a00a003008007006005375c602a0066eacc054008c060018c058014c00400488894ccc04000c40044c8c8cc010008cccc01801800401000cc050010c04800ccc0040052000222233330073370e00200601a4666600a00a66e000112002300f001002002230063754002460086ea80055cd2b9c5573aaae7955cfaba05742ae89",
|
||||
"hash": "0e3d18f2acce2c1fc26b5c7ede74e05f944826f2d6a0c102707b4419"
|
||||
"parameters": [
|
||||
{
|
||||
"title": "token_name",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/ByteArray"
|
||||
}
|
||||
},
|
||||
{
|
||||
"title": "utxo_ref",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/aiken~1transaction~1OutputReference"
|
||||
}
|
||||
}
|
||||
],
|
||||
"compiledCode": "5902df0100003232323232323232323232323223222232533300b323232323232323232323232323232533301f30220021323232533301d3370e90000008a99980e991919800806919baf3301c301e00148000064c0040048894ccc09400852809919299981118018010a511333005005001003302900330270021533301d3370e0049001099b8f00301714a02a6603e9201254578706563746564206f6e20696e636f727265637420626f6f6c65616e2076617269616e74001616301b012375a603e0046eb8c07400454cc0712401334c6973742f5475706c652f436f6e73747220636f6e7461696e73206d6f7265206974656d73207468616e206578706563746564001630200013200132323232533301c3370e90010008a5eb7bdb1804c8c8004dd59812000980d001180d0009980080180518008009112999810001099ba5480092f5c0264646464a66603e66e3c0140044cdd2a40006604a6e980092f5c0266600e00e00600a6eb8c08400cdd59810801181200198110011bab301e001301e001301d001301c001301b00237586032002601e00a6eb8c05c004c0354ccc03ccdc3a4000601c00220022a660229212a4578706563746564206f6e20696e636f727265637420636f6e7374727563746f722076617269616e742e00163015001301500230130013009002149858cc02cc94ccc02ccdc3a40000022a66602060120062930a99806a491d4578706563746564206e6f206669656c647320666f7220436f6e73747200161533300b3370e90010008a99980818048018a4c2a6601a92011d4578706563746564206e6f206669656c647320666f7220436f6e7374720016153300d4912b436f6e73747220696e64657820646964206e6f74206d6174636820616e7920747970652076617269616e7400163009002002375c0026600200290001111199980399b8700100300e233330050053370000890011808000801001118039baa001230053754002ae695cdab9c5573aaae7955cfaba05742ae881",
|
||||
"hash": "60a6357e1121370354de30ef09391b6b7c4a65539041b7fef805edf3"
|
||||
},
|
||||
{
|
||||
"title": "spend2.backtrace",
|
||||
@@ -41,6 +49,12 @@
|
||||
}
|
||||
],
|
||||
"definitions": {
|
||||
"ByteArray": {
|
||||
"dataType": "bytes"
|
||||
},
|
||||
"Int": {
|
||||
"dataType": "integer"
|
||||
},
|
||||
"Void": {
|
||||
"title": "Unit",
|
||||
"description": "The nullary constructor.",
|
||||
@@ -51,6 +65,61 @@
|
||||
"fields": []
|
||||
}
|
||||
]
|
||||
},
|
||||
"aiken/transaction/OutputReference": {
|
||||
"title": "OutputReference",
|
||||
"description": "An `OutputReference` is a unique reference to an output on-chain. The `output_index`\n corresponds to the position in the output list of the transaction (identified by its id)\n that produced that output",
|
||||
"anyOf": [
|
||||
{
|
||||
"title": "OutputReference",
|
||||
"dataType": "constructor",
|
||||
"index": 0,
|
||||
"fields": [
|
||||
{
|
||||
"title": "transaction_id",
|
||||
"$ref": "#/definitions/aiken~1transaction~1TransactionId"
|
||||
},
|
||||
{
|
||||
"title": "output_index",
|
||||
"$ref": "#/definitions/Int"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"aiken/transaction/TransactionId": {
|
||||
"title": "TransactionId",
|
||||
"description": "A unique transaction identifier, as the hash of a transaction body. Note that the transaction id\n isn't a direct hash of the `Transaction` as visible on-chain. Rather, they correspond to hash\n digests of transaction body as they are serialized on the network.",
|
||||
"anyOf": [
|
||||
{
|
||||
"title": "TransactionId",
|
||||
"dataType": "constructor",
|
||||
"index": 0,
|
||||
"fields": [
|
||||
{
|
||||
"title": "hash",
|
||||
"$ref": "#/definitions/ByteArray"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"spend/Action": {
|
||||
"title": "Action",
|
||||
"anyOf": [
|
||||
{
|
||||
"title": "Mint",
|
||||
"dataType": "constructor",
|
||||
"index": 0,
|
||||
"fields": []
|
||||
},
|
||||
{
|
||||
"title": "Burn",
|
||||
"dataType": "constructor",
|
||||
"index": 1,
|
||||
"fields": []
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,44 +1,37 @@
|
||||
use aiken/list.{find, foldr}
|
||||
use aiken/transaction.{Input, ScriptContext, Spend}
|
||||
use aiken/transaction.{Input, ScriptContext, Spend, OutputReference, Transaction} as tx
|
||||
use aiken/transaction/value.{add, zero}
|
||||
use aiken/dict
|
||||
|
||||
validator {
|
||||
fn staking(_datum: Void, _redeemer: Void, context: ScriptContext) -> Bool {
|
||||
expect Spend(ref) =
|
||||
context.purpose
|
||||
|
||||
expect Some(i) =
|
||||
find(context.transaction.inputs, fn(x) { x.output_reference == ref })
|
||||
let Input { output, .. } =
|
||||
i
|
||||
let staking_addr =
|
||||
output.address
|
||||
|
||||
let v_in =
|
||||
foldr(
|
||||
context.transaction.inputs,
|
||||
fn(x, y) {
|
||||
if x.output.address == staking_addr {
|
||||
add(x.output.value, y)
|
||||
} else {
|
||||
y
|
||||
}
|
||||
},
|
||||
zero(),
|
||||
)
|
||||
|
||||
let v_out =
|
||||
foldr(
|
||||
context.transaction.outputs,
|
||||
fn(x, y) {
|
||||
if x.address == staking_addr {
|
||||
add(x.value, y)
|
||||
} else {
|
||||
y
|
||||
}
|
||||
},
|
||||
zero(),
|
||||
)
|
||||
v_in == v_out
|
||||
}
|
||||
|
||||
type Action {
|
||||
Mint
|
||||
Burn
|
||||
}
|
||||
|
||||
validator(token_name: ByteArray, utxo_ref: OutputReference) {
|
||||
fn gift_card(rdmr: Action, ctx: ScriptContext) -> Bool {
|
||||
let ScriptContext { transaction, purpose } =
|
||||
ctx
|
||||
|
||||
expect tx.Mint(policy_id) =
|
||||
purpose
|
||||
|
||||
let Transaction { inputs, mint, .. } =
|
||||
transaction
|
||||
|
||||
expect [(asset_name, amount)] = mint
|
||||
|> value.tokens(policy_id)
|
||||
|> dict.to_list()
|
||||
|
||||
when rdmr is {
|
||||
Mint -> {
|
||||
expect True =
|
||||
list.any(inputs, fn(input) { input.output_reference == utxo_ref })
|
||||
amount == 1 && asset_name == token_name
|
||||
}
|
||||
Burn ->
|
||||
todo @"burn"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,18 @@
|
||||
use aiken/list
|
||||
use aiken/transaction.{Output, ScriptContext}
|
||||
// use aiken/list
|
||||
// use aiken/transaction.{Output, ScriptContext}
|
||||
|
||||
validator {
|
||||
fn backtrace(_datum: Void, _redeemer: Void, context: ScriptContext) -> Bool {
|
||||
expect Some(_) =
|
||||
list.find(context.transaction.outputs, fn(_) { True })
|
||||
let _ =
|
||||
find_stuff(context)
|
||||
True
|
||||
}
|
||||
}
|
||||
// validator {
|
||||
// fn backtrace(_datum: Void, _redeemer: Void, context: ScriptContext) -> Bool {
|
||||
// expect Some(_) =
|
||||
// list.find(context.transaction.outputs, fn(_) { True })
|
||||
// let _ =
|
||||
// find_stuff(context)
|
||||
// True
|
||||
// }
|
||||
// }
|
||||
|
||||
fn find_stuff(context) -> Output {
|
||||
expect Some(stuff) =
|
||||
list.find(context.transaction.outputs, fn(_) { True })
|
||||
stuff
|
||||
}
|
||||
// fn find_stuff(context) -> Output {
|
||||
// expect Some(stuff) =
|
||||
// list.find(context.transaction.outputs, fn(_) { True })
|
||||
// stuff
|
||||
// }
|
||||
|
||||
Reference in New Issue
Block a user