test: fix acceptance tests
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
use aiken/list
|
||||
use aiken/option
|
||||
use aiken/transaction.{NoDatum, ScriptContext, Spend, TransactionId}
|
||||
use aiken/transaction/credential.{VerificationKeyCredential}
|
||||
@@ -6,13 +5,12 @@ 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),
|
||||
]
|
||||
|> list.and
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +37,7 @@ fn assert_fee(transaction) {
|
||||
fn assert_outputs(transaction) {
|
||||
when transaction.outputs is {
|
||||
[output] ->
|
||||
[
|
||||
and {
|
||||
output.value == value.from_lovelace(1000000000),
|
||||
output.address.payment_credential == VerificationKeyCredential(
|
||||
#"11111111111111111111111111111111111111111111111111111111",
|
||||
@@ -47,8 +45,7 @@ fn assert_outputs(transaction) {
|
||||
option.is_none(output.address.stake_credential),
|
||||
output.datum == NoDatum,
|
||||
output.reference_script == None,
|
||||
]
|
||||
|> list.and
|
||||
}
|
||||
_ -> fail @"unexpected number of outputs"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,16 @@
|
||||
use aiken/builtin
|
||||
use aiken/dict
|
||||
use aiken/hash.{blake2b_256}
|
||||
use aiken/list
|
||||
use aiken/transaction.{DatumHash, InlineDatum, 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),
|
||||
]
|
||||
|> list.and
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,19 +43,18 @@ fn assert_outputs(outputs) {
|
||||
}
|
||||
|
||||
fn assert_first_output(output) {
|
||||
[
|
||||
and {
|
||||
output.datum == DatumHash(
|
||||
#"fcaa61fb85676101d9e3398a484674e71c45c3fd41b492682f3b0054f4cf3273",
|
||||
),
|
||||
output.reference_script == Some(
|
||||
#"e37db487fbd58c45d059bcbf5cd6b1604d3bec16cf888f1395a4ebc4",
|
||||
),
|
||||
]
|
||||
|> list.and
|
||||
}
|
||||
}
|
||||
|
||||
fn assert_second_output(output) {
|
||||
[
|
||||
and {
|
||||
output.address.stake_credential == Some(
|
||||
Inline(
|
||||
VerificationKeyCredential(
|
||||
@@ -69,6 +66,5 @@ fn assert_second_output(output) {
|
||||
InlineDatum(_) -> True
|
||||
_ -> fail @"expected inline datum"
|
||||
},
|
||||
]
|
||||
|> list.and
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
use aiken/dict
|
||||
use aiken/list
|
||||
use aiken/transaction.{Mint, ScriptContext}
|
||||
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),
|
||||
]
|
||||
|> list.and
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
use aiken/dict
|
||||
use aiken/list
|
||||
use aiken/transaction.{ScriptContext}
|
||||
use aiken/transaction/credential.{
|
||||
Inline, ScriptCredential, VerificationKeyCredential,
|
||||
@@ -21,7 +20,7 @@ validator {
|
||||
),
|
||||
)
|
||||
|
||||
[
|
||||
and {
|
||||
when dict.get(ctx.transaction.withdrawals, alice) is {
|
||||
None -> fail @"alice's withdrawal not found"
|
||||
Some(value) -> value == 42
|
||||
@@ -31,7 +30,6 @@ validator {
|
||||
Some(value) -> value == 14
|
||||
},
|
||||
dict.keys(ctx.transaction.withdrawals) == [alice, bob],
|
||||
]
|
||||
|> list.and
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user