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(redeemer.data.clone())
|
||||||
.apply_data(script_context.to_plutus_data()),
|
.apply_data(script_context.to_plutus_data()),
|
||||||
|
|
||||||
// FIXME: Temporary, but needed until https://github.com/aiken-lang/aiken/pull/977
|
ScriptContext::V3 { .. } => program.apply_data(script_context.to_plutus_data()),
|
||||||
// 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()),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut eval_result = if let Some(costs) = cost_mdl_opt {
|
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/credential.{Address, Script}
|
||||||
use cardano/transaction.{
|
use cardano/transaction.{
|
||||||
InlineDatum, Input, Output, OutputReference, ScriptContext, ScriptInfo,
|
InlineDatum, Input, Output, OutputReference, ScriptContext, ScriptInfo,
|
||||||
ScriptPurpose, Spend, Spending,
|
ScriptPurpose, Spend, Spending, Transaction,
|
||||||
}
|
}
|
||||||
|
|
||||||
validator {
|
validator simple_spend {
|
||||||
fn spend(_tmp1: Void, _tmp2: Void, ctx: ScriptContext) {
|
spend(
|
||||||
assert_transaction_id(ctx.transaction.id)
|
_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
|
True
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else(_ctx) {
|
||||||
|
fail
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn assert_transaction_id(id: ByteArray) {
|
fn assert_transaction_id(id: ByteArray) {
|
||||||
|
@ -36,15 +45,12 @@ fn assert_transaction_id(id: ByteArray) {
|
||||||
Void
|
Void
|
||||||
}
|
}
|
||||||
|
|
||||||
fn assert_script_info(info: ScriptInfo) {
|
fn assert_script_info(info: OutputReference) {
|
||||||
expect
|
expect
|
||||||
Spending(
|
OutputReference {
|
||||||
OutputReference {
|
transaction_id: #"0000000000000000000000000000000000000000000000000000000000000000",
|
||||||
transaction_id: #"0000000000000000000000000000000000000000000000000000000000000000",
|
output_index: 0,
|
||||||
output_index: 0,
|
} == info
|
||||||
},
|
|
||||||
Some(void()),
|
|
||||||
) == info
|
|
||||||
Void
|
Void
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue