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:
@@ -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