Adjust v3 script context end-to-end tests to work with new syntax.
This commit is contained in:
parent
972e9bd763
commit
823492c27b
|
@ -46,15 +46,7 @@ pub fn eval_redeemer(
|
|||
.apply_data(redeemer.data.clone())
|
||||
.apply_data(script_context.to_plutus_data()),
|
||||
|
||||
// FIXME: Temporary, but needed until https://github.com/aiken-lang/aiken/pull/977
|
||||
// is implemented.
|
||||
ScriptContext::V3 { .. } => if let Some(datum) = datum {
|
||||
program.apply_data(datum)
|
||||
} else {
|
||||
program
|
||||
}
|
||||
.apply_data(redeemer.data.clone())
|
||||
.apply_data(script_context.to_plutus_data()),
|
||||
ScriptContext::V3 { .. } => program.apply_data(script_context.to_plutus_data()),
|
||||
};
|
||||
|
||||
let mut eval_result = if let Some(costs) = cost_mdl_opt {
|
||||
|
|
|
@ -3,31 +3,40 @@ use cardano/assets
|
|||
use cardano/credential.{Address, Script}
|
||||
use cardano/transaction.{
|
||||
InlineDatum, Input, Output, OutputReference, ScriptContext, ScriptInfo,
|
||||
ScriptPurpose, Spend, Spending,
|
||||
ScriptPurpose, Spend, Spending, Transaction,
|
||||
}
|
||||
|
||||
validator {
|
||||
fn spend(_tmp1: Void, _tmp2: Void, ctx: ScriptContext) {
|
||||
assert_transaction_id(ctx.transaction.id)
|
||||
validator simple_spend {
|
||||
spend(
|
||||
_datum: Option<Void>,
|
||||
_redeemer: Void,
|
||||
output_ref: OutputReference,
|
||||
transaction: Transaction,
|
||||
) {
|
||||
assert_transaction_id(transaction.id)
|
||||
|
||||
assert_script_info(ctx.info)
|
||||
assert_script_info(output_ref)
|
||||
|
||||
assert_inputs(ctx.transaction.inputs)
|
||||
assert_inputs(transaction.inputs)
|
||||
|
||||
expect [] = ctx.transaction.outputs
|
||||
expect [] = transaction.outputs
|
||||
|
||||
expect [] = ctx.transaction.reference_inputs
|
||||
expect [] = transaction.reference_inputs
|
||||
|
||||
expect [] = ctx.transaction.extra_signatories
|
||||
expect [] = transaction.extra_signatories
|
||||
|
||||
expect 42 == ctx.transaction.fee
|
||||
expect 42 == transaction.fee
|
||||
|
||||
assert_redeemers(ctx.transaction.redeemers)
|
||||
assert_redeemers(transaction.redeemers)
|
||||
|
||||
expect [] == dict.to_pairs(ctx.transaction.datums)
|
||||
expect [] == dict.to_pairs(transaction.datums)
|
||||
|
||||
True
|
||||
}
|
||||
|
||||
else(_ctx) {
|
||||
fail
|
||||
}
|
||||
}
|
||||
|
||||
fn assert_transaction_id(id: ByteArray) {
|
||||
|
@ -36,15 +45,12 @@ fn assert_transaction_id(id: ByteArray) {
|
|||
Void
|
||||
}
|
||||
|
||||
fn assert_script_info(info: ScriptInfo) {
|
||||
fn assert_script_info(info: OutputReference) {
|
||||
expect
|
||||
Spending(
|
||||
OutputReference {
|
||||
transaction_id: #"0000000000000000000000000000000000000000000000000000000000000000",
|
||||
output_index: 0,
|
||||
},
|
||||
Some(void()),
|
||||
) == info
|
||||
} == info
|
||||
Void
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue