Fix remaining acceptance tests to be V3-compatible

This commit is contained in:
KtorZ
2024-08-27 18:58:50 +02:00
parent d615b4f889
commit 48535636ed
59 changed files with 357 additions and 277 deletions

View File

@@ -3,14 +3,14 @@
[[requirements]]
name = "aiken-lang/stdlib"
version = "main"
version = "v2"
source = "github"
[[packages]]
name = "aiken-lang/stdlib"
version = "main"
version = "v2"
requirements = []
source = "github"
[etags]
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1723158435, nanos_since_epoch = 937845000 }, "5e58899446492a704d0927a43299139856bef746e697b55895ba34206fa28452"]
"aiken-lang/stdlib@v2" = [{ secs_since_epoch = 1724776982, nanos_since_epoch = 146951000 }, "cdbbce58b61deb385e7ea787a2e0fc2dc8fe94db9999e0e6275bc9c70e5796be"]

View File

@@ -4,5 +4,5 @@ description = ""
[[dependencies]]
name = 'aiken-lang/stdlib'
version = 'main'
version = 'v2'
source = 'github'

View File

@@ -1,7 +1,6 @@
use aiken/cbor
use aiken/transaction.{Datum, InlineDatum, NoDatum, Output}
use aiken/transaction/credential.{Address, VerificationKeyCredential}
use aiken/transaction/value.{from_lovelace}
use cardano/assets.{from_lovelace}
use cardano/credential.{Address, VerificationKey}
use cardano/transaction.{Datum, InlineDatum, NoDatum, Output}
type SmallOracleState {
Thing(Int)
@@ -18,7 +17,7 @@ fn create_output(
let x =
Output {
address: Address {
payment_credential: VerificationKeyCredential(payment_key),
payment_credential: VerificationKey(payment_key),
stake_credential: None,
},
value: from_lovelace(value),

View File

@@ -5,12 +5,12 @@
"plutusVersion": "v2",
"compiler": {
"name": "Aiken",
"version": "v1.0.31-alpha+6e4a16d"
"version": "v1.0.31-alpha+4003343"
}
},
"validators": [
{
"title": "test2.simple_oneshot",
"title": "test2.simple_oneshot.mint",
"redeemer": {
"title": "_r",
"schema": {
@@ -21,12 +21,25 @@
{
"title": "utxo_ref",
"schema": {
"$ref": "#/definitions/aiken~1transaction~1OutputReference"
"$ref": "#/definitions/cardano~1transaction~1OutputReference"
}
}
],
"compiledCode": "58d8010000323232323232322232322533300632325333008300530093754601a601c00426464a666014600e60166ea8cc00400c8cdd7980198069baa00100a1533300a3007300b375466002006466ebcc00cc034dd50008050a5114a02c44646600200200644a6660200022980103d87a800013232533300f300500213374a90001980980125eb804cc010010004c050008c0480048c03800458dd6180618049baa300c0013008375400229309b2b2999802180098029baa00215333007300637540042930b0b1b87480015cd2ab9d5573caae7d5d02ba15745",
"hash": "0934dd37409ea743705a7340769acd8c84843fec54013e9f0ced9251"
"compiledCode": "58f00100003232323232323222533300332323232325332330093001300a375400426464646464a66601c600c601e6ea8cc00400c8cdd7980198089baa00100e1533300e3006300f375466002006466ebcc00cc044dd50008070a5114a02c44646600200200644a666028002298103d87a8000132325333013300500213374a90001980b80125eb804cc010010004c060008c0580048c048004dd6180818069baa007533300a3002300b37540082a66601a60186ea80105261616375c601c60166ea8008dc3a40002c6018601a004601600260160046012002600a6ea8004526136565734aae7555cf2ab9f5740ae855d101",
"hash": "6f67a4f89e77e01da00ed12f89b15baa823791e83757d5ac97843e91"
},
{
"title": "test2.simple_oneshot.else",
"parameters": [
{
"title": "utxo_ref",
"schema": {
"$ref": "#/definitions/cardano~1transaction~1OutputReference"
}
}
],
"compiledCode": "58f00100003232323232323222533300332323232325332330093001300a375400426464646464a66601c600c601e6ea8cc00400c8cdd7980198089baa00100e1533300e3006300f375466002006466ebcc00cc044dd50008070a5114a02c44646600200200644a666028002298103d87a8000132325333013300500213374a90001980b80125eb804cc010010004c060008c0580048c048004dd6180818069baa007533300a3002300b37540082a66601a60186ea80105261616375c601c60166ea8008dc3a40002c6018601a004601600260160046012002600a6ea8004526136565734aae7555cf2ab9f5740ae855d101",
"hash": "6f67a4f89e77e01da00ed12f89b15baa823791e83757d5ac97843e91"
}
],
"definitions": {
@@ -47,7 +60,7 @@
}
]
},
"aiken/transaction/OutputReference": {
"cardano/transaction/OutputReference": {
"title": "OutputReference",
"description": "An `OutputReference` is a unique reference to an output on-chain. The `output_index`\n corresponds to the position in the output list of the transaction (identified by its id)\n that produced that output",
"anyOf": [
@@ -58,7 +71,7 @@
"fields": [
{
"title": "transaction_id",
"$ref": "#/definitions/aiken~1transaction~1TransactionId"
"$ref": "#/definitions/ByteArray"
},
{
"title": "output_index",
@@ -67,23 +80,6 @@
]
}
]
},
"aiken/transaction/TransactionId": {
"title": "TransactionId",
"description": "A unique transaction identifier, as the hash of a transaction body. Note that the transaction id\n isn't a direct hash of the `Transaction` as visible on-chain. Rather, they correspond to hash\n digests of transaction body as they are serialized on the network.",
"anyOf": [
{
"title": "TransactionId",
"dataType": "constructor",
"index": 0,
"fields": [
{
"title": "hash",
"$ref": "#/definitions/ByteArray"
}
]
}
]
}
}
}

View File

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