add regression tests for inline GAT datum hashing
This commit is contained in:
parent
8c9b184ea4
commit
311e656c52
2 changed files with 37 additions and 2 deletions
|
|
@ -24,6 +24,7 @@ module Sample.Proposal.Advance (
|
||||||
mkValidToNextStateBundle,
|
mkValidToNextStateBundle,
|
||||||
mkValidToNextStateBundles,
|
mkValidToNextStateBundles,
|
||||||
mkValidToFailedStateBundles,
|
mkValidToFailedStateBundles,
|
||||||
|
mkValidToFinishedInlineGATDatumBundles,
|
||||||
mkInsufficientVotesBundle,
|
mkInsufficientVotesBundle,
|
||||||
mkAmbiguousWinnerBundle,
|
mkAmbiguousWinnerBundle,
|
||||||
mkFromFinishedBundles,
|
mkFromFinishedBundles,
|
||||||
|
|
@ -199,6 +200,8 @@ data AuthorityTokenParameters = forall
|
||||||
, invalidTokenName :: Bool
|
, invalidTokenName :: Bool
|
||||||
-- ^ If set to true, GATs won't be tagged by their corresponding effect
|
-- ^ If set to true, GATs won't be tagged by their corresponding effect
|
||||||
-- hashes.
|
-- hashes.
|
||||||
|
, shouldInlineDatum :: Bool
|
||||||
|
-- ^ If set to true, the effect datum will be inlined.
|
||||||
}
|
}
|
||||||
|
|
||||||
-- | Represent the winning effect group(s).
|
-- | Represent the winning effect group(s).
|
||||||
|
|
@ -476,7 +479,7 @@ mkAuthorityTokenBuilder ::
|
||||||
CombinableBuilder b =>
|
CombinableBuilder b =>
|
||||||
AuthorityTokenParameters ->
|
AuthorityTokenParameters ->
|
||||||
b
|
b
|
||||||
mkAuthorityTokenBuilder ps@AuthorityTokenParameters {carryDatum} =
|
mkAuthorityTokenBuilder ps@AuthorityTokenParameters {carryDatum, shouldInlineDatum} =
|
||||||
let tn =
|
let tn =
|
||||||
case (ps.invalidTokenName, ps.carryAuthScript) of
|
case (ps.invalidTokenName, ps.carryAuthScript) of
|
||||||
(True, Just _) -> "deadbeef"
|
(True, Just _) -> "deadbeef"
|
||||||
|
|
@ -486,12 +489,13 @@ mkAuthorityTokenBuilder ps@AuthorityTokenParameters {carryDatum} =
|
||||||
ac = Tagged @AuthorityTokenTag $ AssetClass authorityTokenSymbol tn
|
ac = Tagged @AuthorityTokenTag $ AssetClass authorityTokenSymbol tn
|
||||||
minted = assetClassValue ac 1
|
minted = assetClassValue ac 1
|
||||||
value = sortValue $ minAda <> minted
|
value = sortValue $ minAda <> minted
|
||||||
|
withDatum' = if shouldInlineDatum then withInlineDatum else withDatum
|
||||||
in mconcat
|
in mconcat
|
||||||
[ mint minted
|
[ mint minted
|
||||||
, output $
|
, output $
|
||||||
mconcat
|
mconcat
|
||||||
[ script ps.mintGATsFor
|
[ script ps.mintGATsFor
|
||||||
, maybe mempty withDatum carryDatum
|
, maybe mempty withDatum' carryDatum
|
||||||
, withValue value
|
, withValue value
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
|
@ -833,6 +837,7 @@ mkValidToNextStateBundle nCosigners nEffects authScript from =
|
||||||
, carryDatum = Just dummyDatum
|
, carryDatum = Just dummyDatum
|
||||||
, carryAuthScript = authScript
|
, carryAuthScript = authScript
|
||||||
, invalidTokenName = False
|
, invalidTokenName = False
|
||||||
|
, shouldInlineDatum = False
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
(effects !! winner)
|
(effects !! winner)
|
||||||
|
|
@ -859,6 +864,30 @@ mkValidToNextStateBundles nCosigners nEffects =
|
||||||
[True, False]
|
[True, False]
|
||||||
[Draft, VotingReady, Locked]
|
[Draft, VotingReady, Locked]
|
||||||
|
|
||||||
|
mkValidToFinishedInlineGATDatumBundles ::
|
||||||
|
Word ->
|
||||||
|
Word ->
|
||||||
|
[ParameterBundle]
|
||||||
|
mkValidToFinishedInlineGATDatumBundles nCosigners nEffects =
|
||||||
|
let templates =
|
||||||
|
liftA2
|
||||||
|
(mkValidToNextStateBundle nCosigners nEffects)
|
||||||
|
[True, False]
|
||||||
|
[Locked]
|
||||||
|
|
||||||
|
modifyTemplate template =
|
||||||
|
template
|
||||||
|
{ authorityTokenParameters =
|
||||||
|
modifyAuthorityParameters
|
||||||
|
<$> template.authorityTokenParameters
|
||||||
|
}
|
||||||
|
|
||||||
|
modifyAuthorityParameters params =
|
||||||
|
params
|
||||||
|
{ shouldInlineDatum = True
|
||||||
|
}
|
||||||
|
in modifyTemplate <$> templates
|
||||||
|
|
||||||
mkValidToFailedStateBundles ::
|
mkValidToFailedStateBundles ::
|
||||||
-- | Number of cosigners
|
-- | Number of cosigners
|
||||||
Word ->
|
Word ->
|
||||||
|
|
@ -1066,6 +1095,7 @@ mkGATsWithWrongDatumBundle nCosigners nEffects =
|
||||||
(Just (1 :: Integer))
|
(Just (1 :: Integer))
|
||||||
aut.carryAuthScript
|
aut.carryAuthScript
|
||||||
False
|
False
|
||||||
|
False
|
||||||
)
|
)
|
||||||
<$> template.authorityTokenParameters
|
<$> template.authorityTokenParameters
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -254,6 +254,11 @@ specs =
|
||||||
mkName
|
mkName
|
||||||
(Advance.mkValidToFailedStateBundles cs es)
|
(Advance.mkValidToFailedStateBundles cs es)
|
||||||
allValid
|
allValid
|
||||||
|
, Advance.mkTestTree'
|
||||||
|
"to finished state with inline datum"
|
||||||
|
mkName
|
||||||
|
(Advance.mkValidToFinishedInlineGATDatumBundles cs es)
|
||||||
|
allValid
|
||||||
]
|
]
|
||||||
, group
|
, group
|
||||||
"illegal"
|
"illegal"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue