Fix script context translations for withdrawals and validity intervals.
This commit is contained in:
@@ -44,7 +44,7 @@ for convenience. The test still assumes a few things. For any
|
||||
- Purpose
|
||||
- [x] spend
|
||||
- [x] mint
|
||||
- [ ] withdraw
|
||||
- [x] withdraw
|
||||
- [x] publish
|
||||
- [x] voting
|
||||
- [x] proposing
|
||||
@@ -79,11 +79,11 @@ for convenience. The test still assumes a few things. For any
|
||||
- [x] Retire CC
|
||||
- withdrawals
|
||||
- [x] none
|
||||
- [ ] some
|
||||
- [ ] validity range
|
||||
- [x] some
|
||||
- [x] validity range
|
||||
- extra signatories
|
||||
- [x] none
|
||||
- [ ] some
|
||||
- [x] some
|
||||
- [x] redeemers
|
||||
- [x] datums
|
||||
- votes
|
||||
@@ -102,10 +102,10 @@ for convenience. The test still assumes a few things. For any
|
||||
- Address
|
||||
- [x] type-0 (key | key)
|
||||
- [x] type-1 (script | key)
|
||||
- [ ] type-2 (key | script)
|
||||
- [ ] type-3 (script | script)
|
||||
- [ ] type-4 (key | ptr)
|
||||
- [ ] type-5 (script | ptr)
|
||||
- [x] type-2 (key | script)
|
||||
- [x] type-3 (script | script)
|
||||
- [x] type-4 (key | ptr)
|
||||
- [x] type-5 (script | ptr)
|
||||
- [x] type-6 (key | ø)
|
||||
- [x] type-7 (key | ø)
|
||||
|
||||
@@ -205,5 +205,5 @@ for convenience. The test still assumes a few things. For any
|
||||
- [x] no confidence
|
||||
|
||||
- Boundary
|
||||
- [ ] closed
|
||||
- [ ] open
|
||||
- [x] closed
|
||||
- [x] open
|
||||
|
||||
@@ -2,15 +2,15 @@
|
||||
# You typically do not need to edit this file
|
||||
|
||||
[[requirements]]
|
||||
name = "logicalmechanism/stdlib"
|
||||
version = "plutus-v3"
|
||||
name = "aiken-lang/stdlib"
|
||||
version = "v2"
|
||||
source = "github"
|
||||
|
||||
[[packages]]
|
||||
name = "logicalmechanism/stdlib"
|
||||
version = "plutus-v3"
|
||||
name = "aiken-lang/stdlib"
|
||||
version = "v2"
|
||||
requirements = []
|
||||
source = "github"
|
||||
|
||||
[etags]
|
||||
"logicalmechanism/stdlib@plutus-v3" = [{ secs_since_epoch = 1723394635, nanos_since_epoch = 36770000 }, "097396ab7dedd5e38c558f35b2fb34a2d0f058bb0da0635949f5fcbb36f1310e"]
|
||||
"aiken-lang/stdlib@v2" = [{ secs_since_epoch = 1723583491, nanos_since_epoch = 208977000 }, "cdbbce58b61deb385e7ea787a2e0fc2dc8fe94db9999e0e6275bc9c70e5796be"]
|
||||
|
||||
@@ -3,9 +3,9 @@ version = "0.0.0"
|
||||
compiler = "v1.0.31-alpha"
|
||||
plutus = "v3"
|
||||
license = "Apache-2.0"
|
||||
description = "Aiken contracts for project 'script_context/v3'"
|
||||
description = "End-to-end testing of standard lib script context, for Plutus v3"
|
||||
|
||||
[[dependencies]]
|
||||
name = "logicalmechanism/stdlib"
|
||||
version = "plutus-v3"
|
||||
name = "aiken-lang/stdlib"
|
||||
version = "v2"
|
||||
source = "github"
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
[
|
||||
{ 0: h'30{{ withdraw.spend.hash }}{{ withdraw.spend.hash }}'
|
||||
, 1: 1000000
|
||||
, 2: [1, 24(h'd87980')]
|
||||
, 3: 24(h'8203{{ withdraw.spend.cbor }}')
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,42 @@
|
||||
[
|
||||
{ 0:
|
||||
[ [h'0000000000000000000000000000000000000000000000000000000000000000', 0]
|
||||
]
|
||||
|
||||
, 1:
|
||||
[ { 0: h'200000000000000000000000000000000000000000000000000000000011111111111111111111111111111111111111111111111111111111'
|
||||
, 1: 1000000
|
||||
}
|
||||
|
||||
, { 0: h'40000000000000000000000000000000000000000000000000000000008198bd431b03'
|
||||
, 1: 1000000
|
||||
}
|
||||
|
||||
, { 0: h'50111111111111111111111111111111111111111111111111111111118198bd431b03'
|
||||
, 1: 1000000
|
||||
}
|
||||
]
|
||||
|
||||
, 2: 42
|
||||
|
||||
, 3: 4492801
|
||||
|
||||
, 5:
|
||||
{ h'E000000000000000000000000000000000000000000000000000000000': 14
|
||||
, h'F0{{ withdraw.withdraw.hash }}': 0
|
||||
}
|
||||
|
||||
, 14:
|
||||
[ h'00000000000000000000000000000000000000000000000000000000'
|
||||
]
|
||||
},
|
||||
|
||||
{ 5: [ [0, 0, 122([121([])]), [1000000, 100000000]]
|
||||
, [3, 0, 121([]), [1000000, 100000000]]
|
||||
]
|
||||
},
|
||||
|
||||
true,
|
||||
|
||||
null
|
||||
]
|
||||
File diff suppressed because one or more lines are too long
@@ -45,9 +45,10 @@ for ITEM in ${VALIDATORS[@]}; do
|
||||
VALIDATOR_NAME=$(echo $ITEM | jq -r .title)
|
||||
VALIDATOR_HASH=$(echo $ITEM | jq -r .hash)
|
||||
VALIDATOR=$(echo $ITEM | jq -r .compiledCode)
|
||||
VALIDATOR_CBOR=$(echo "h'$VALIDATOR'" | cbor-diag --to hex --from diag)
|
||||
|
||||
RESOLVED_INPUTS=$(echo $RESOLVED_INPUTS \
|
||||
| sed "s/{{ $VALIDATOR_NAME.cbor }}/$VALIDATOR/g" \
|
||||
| sed "s/{{ $VALIDATOR_NAME.cbor }}/$VALIDATOR_CBOR/g" \
|
||||
| sed "s/{{ $VALIDATOR_NAME.hash }}/$VALIDATOR_HASH/g")
|
||||
|
||||
TRANSACTION=$(echo $TRANSACTION \
|
||||
@@ -59,9 +60,7 @@ echo $RESOLVED_INPUTS | cbor-diag --to hex --from diag > ctx/$TITLE/resolved_inp
|
||||
|
||||
echo $TRANSACTION | cbor-diag --to hex --from diag > ctx/$TITLE/tx.cbor
|
||||
|
||||
# ogmios inspect transaction $(cat ctx/$TITLE/tx.cbor) | jq ".votes"
|
||||
|
||||
$AIKEN tx simulate \
|
||||
$AIKEN tx simulate 1>$TITLE.log 2>&1 \
|
||||
ctx/$TITLE/tx.cbor \
|
||||
ctx/inputs.cbor \
|
||||
ctx/$TITLE/resolved_inputs.cbor
|
||||
|
||||
@@ -16,7 +16,7 @@ const void_hash =
|
||||
#"923918e403bf43c34b4ef6b48eb2ee04babed17320d8d1b9ff9ad086e86f44ec"
|
||||
|
||||
validator {
|
||||
fn mint_1(_tmp2: Void, ctx: ScriptContext) {
|
||||
fn mint_1(_tmp2: Data, ctx: ScriptContext) {
|
||||
let our_policy_id = assert_script_info(ctx.info)
|
||||
let other_policy_id = assert_redeemers(ctx.transaction.redeemers)
|
||||
assert_outputs(ctx.transaction.outputs, our_policy_id, other_policy_id)
|
||||
|
||||
@@ -22,7 +22,7 @@ const only9s =
|
||||
#"9999999999999999999999999999999999999999999999999999999999999999"
|
||||
|
||||
validator {
|
||||
fn script(_tmp0: Void, ctx: ScriptContext) {
|
||||
fn script(_tmp0: Data, ctx: ScriptContext) {
|
||||
assert_redeemer(ctx.redeemer)
|
||||
|
||||
let votes = ctx.transaction.votes
|
||||
@@ -35,18 +35,14 @@ validator {
|
||||
|
||||
expect
|
||||
Some(
|
||||
Pair(
|
||||
ConstitutionalCommitteeMember(VerificationKey(only0s)),
|
||||
[
|
||||
Pair(
|
||||
GovernanceActionId {
|
||||
transaction: only9s,
|
||||
proposal_procedure: 152,
|
||||
},
|
||||
No,
|
||||
),
|
||||
],
|
||||
),
|
||||
Pair(ConstitutionalCommitteeMember(VerificationKey(only0s)),
|
||||
[
|
||||
Pair(GovernanceActionId {
|
||||
transaction: only9s,
|
||||
proposal_procedure: 152,
|
||||
},
|
||||
No),
|
||||
]),
|
||||
) == list.at(votes, 1)
|
||||
|
||||
expect Some(Pair(DelegateRepresentative(Script(..)), [_, ..])) =
|
||||
@@ -54,23 +50,15 @@ validator {
|
||||
|
||||
expect
|
||||
Some(
|
||||
Pair(
|
||||
DelegateRepresentative(VerificationKey(only0s)),
|
||||
[
|
||||
Pair(
|
||||
GovernanceActionId { transaction: only7s, proposal_procedure: 2 },
|
||||
Abstain,
|
||||
),
|
||||
Pair(
|
||||
GovernanceActionId { transaction: only8s, proposal_procedure: 1 },
|
||||
Abstain,
|
||||
),
|
||||
Pair(
|
||||
GovernanceActionId { transaction: only9s, proposal_procedure: 0 },
|
||||
Abstain,
|
||||
),
|
||||
],
|
||||
),
|
||||
Pair(DelegateRepresentative(VerificationKey(only0s)),
|
||||
[
|
||||
Pair(GovernanceActionId { transaction: only7s, proposal_procedure: 2 },
|
||||
Abstain),
|
||||
Pair(GovernanceActionId { transaction: only8s, proposal_procedure: 1 },
|
||||
Abstain),
|
||||
Pair(GovernanceActionId { transaction: only9s, proposal_procedure: 0 },
|
||||
Abstain),
|
||||
]),
|
||||
) == list.at(votes, 3)
|
||||
|
||||
expect Some(Pair(StakePool(pool_id), [_, ..])) = list.at(votes, 4)
|
||||
@@ -83,8 +71,10 @@ validator {
|
||||
fn assert_redeemer(data: Data) {
|
||||
let is_valid =
|
||||
if data is Foo(42): Foo {
|
||||
trace data
|
||||
True
|
||||
} else if data is Void {
|
||||
trace data
|
||||
True
|
||||
} else {
|
||||
False
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
use aiken/collection/list
|
||||
use aiken/interval
|
||||
use cardano/credential.{Address, Inline, Pointer, Script, VerificationKey}
|
||||
use cardano/transaction.{ScriptContext, Withdrawing}
|
||||
|
||||
const only0s = #"00000000000000000000000000000000000000000000000000000000"
|
||||
|
||||
const only1s = #"11111111111111111111111111111111111111111111111111111111"
|
||||
|
||||
validator {
|
||||
fn spend(_tmp0: Void, _tmp1: Void, _ctx: Data) {
|
||||
True
|
||||
}
|
||||
|
||||
fn withdraw(_tmp0: Void, ctx: ScriptContext) {
|
||||
expect Withdrawing(Script(my_script_hash)) = ctx.info
|
||||
|
||||
expect
|
||||
interval.entirely_before(1596059092000) == ctx.transaction.validity_range
|
||||
|
||||
let addresses = list.map(ctx.transaction.outputs, fn(out) { out.address })
|
||||
|
||||
expect
|
||||
Some(
|
||||
Address {
|
||||
payment_credential: VerificationKey(only0s),
|
||||
stake_credential: Some(Inline(Script(only1s))),
|
||||
},
|
||||
) == list.at(addresses, 0)
|
||||
|
||||
expect
|
||||
Some(
|
||||
Address {
|
||||
payment_credential: VerificationKey(only0s),
|
||||
stake_credential: Some(Pointer(2498243, 27, 3)),
|
||||
},
|
||||
) == list.at(addresses, 1)
|
||||
|
||||
expect
|
||||
Some(
|
||||
Address {
|
||||
payment_credential: Script(only1s),
|
||||
stake_credential: Some(Pointer(2498243, 27, 3)),
|
||||
},
|
||||
) == list.at(addresses, 2)
|
||||
|
||||
expect
|
||||
[Pair(Script(my_script_hash), 0), Pair(VerificationKey(only0s), 14)] == ctx.transaction.withdrawals
|
||||
|
||||
True
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user