Fix remaining acceptance tests to be V3-compatible
This commit is contained in:
@@ -1,10 +1,7 @@
|
||||
use aiken/list
|
||||
use aiken/transaction.{
|
||||
Input, Mint, NoDatum, Output, OutputReference, ScriptContext, Transaction,
|
||||
TransactionId,
|
||||
}
|
||||
use aiken/transaction/credential.{Address, VerificationKeyCredential}
|
||||
use aiken/transaction/value
|
||||
use aiken/collection/list
|
||||
use cardano/assets
|
||||
use cardano/credential.{Address, VerificationKey}
|
||||
use cardano/transaction.{Input, NoDatum, Output, OutputReference, Transaction}
|
||||
|
||||
pub const own_hash = #"01020304050607080910111213140102030405060708091011121314"
|
||||
|
||||
@@ -20,17 +17,14 @@ pub fn beneficiary_address() {
|
||||
|
||||
pub fn keyhash_address(keyhash: ByteArray) {
|
||||
Address {
|
||||
payment_credential: VerificationKeyCredential(keyhash),
|
||||
payment_credential: VerificationKey(keyhash),
|
||||
stake_credential: None,
|
||||
}
|
||||
}
|
||||
|
||||
validator simple_oneshot(utxo_ref: OutputReference) {
|
||||
mint(_r: Void, oref: Data, ctx: ScriptContext) -> Bool {
|
||||
let ScriptContext { transaction, purpose } = ctx
|
||||
let Transaction { inputs, .. } = transaction
|
||||
|
||||
expect Mint(_policy_id) = purpose
|
||||
mint(_r: Void, _policy_id: ByteArray, self: Transaction) {
|
||||
let Transaction { inputs, .. } = self
|
||||
|
||||
expect Some(_input) =
|
||||
list.find(inputs, fn(input) { input.output_reference == utxo_ref })
|
||||
@@ -42,31 +36,34 @@ validator simple_oneshot(utxo_ref: OutputReference) {
|
||||
None -> False
|
||||
}
|
||||
}
|
||||
|
||||
else(_) {
|
||||
fail
|
||||
}
|
||||
}
|
||||
|
||||
test test_simple_oneshot() {
|
||||
let output =
|
||||
Output {
|
||||
address: beneficiary_address(),
|
||||
value: value.zero(),
|
||||
value: assets.zero(),
|
||||
datum: NoDatum,
|
||||
reference_script: None,
|
||||
}
|
||||
|
||||
let val =
|
||||
value.from_asset(policy_id: own_hash, asset_name: "testtoken", quantity: 1)
|
||||
let utxo =
|
||||
OutputReference { transaction_id: TransactionId(""), output_index: 0 }
|
||||
let mint =
|
||||
assets.from_asset(policy_id: own_hash, asset_name: "testtoken", quantity: 1)
|
||||
let utxo = OutputReference { transaction_id: "", output_index: 0 }
|
||||
|
||||
let input = Input { output_reference: utxo, output }
|
||||
|
||||
let tx =
|
||||
Transaction {
|
||||
..transaction.placeholder(),
|
||||
mint: value.to_minted_value(val),
|
||||
mint: mint,
|
||||
extra_signatories: [other_hash],
|
||||
inputs: [input],
|
||||
}
|
||||
let context = ScriptContext { purpose: Mint(own_hash), transaction: tx }
|
||||
simple_oneshot(utxo, Void, context) == True
|
||||
|
||||
simple_oneshot.mint(utxo, Void, own_hash, tx) == True
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user