Skip to content

Conversation

jankun4
Copy link
Contributor

@jankun4 jankun4 commented Jul 10, 2025

Prereview checklist

  • Changes have been documented by running changie new
  • All tests pass in CI
  • PR was self-reviewed

versioningScriptAddress :: C.TxIn -> C.AddressInEra C.ConwayEra
versioningScriptAddress genesisUtxo = Utils.scriptAddress Defaults.networkId $ appliedVersioningValidator genesisUtxo

initializeGovernance :: HUnit.Assertion
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question as above: what do we actually test here? Do we test if the governance was actually created? What assurance do we have when this test passes?


initGovernanceFailsWithoutSpendingGenesisUtxo :: HUnit.Assertion
initGovernanceFailsWithoutSpendingGenesisUtxo = flip
MockChainUtils.mockchainFails
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a small suggestion so we don't have to keep on repeating this one and repeating error strings..

shouldFailWithErrorPolicy :: String -> MockChain.MockchainIO C.ConwayEra a -> HUnit.Assertion
shouldFailWithErrorPolicy str action =
  MockChainUtils.mockchainFails
    action
    ( \case
        e | str `List.isInfixOf` show e -> return ()
        e -> error $ "Expected a '" ++ str ++ "' but got '" ++ show e ++ "'"
    )

so we then just do ...

initGovernanceFailsWithoutSpendingGenesisUtxo :: HUnit.Assertion
initGovernanceFailsWithoutSpendingGenesisUtxo = shouldFailWithErrorPolicy "ERROR-VERSION-POLICY-01" $
  Utils.failOnError $
    do

Comment on lines +360 to +368
initGovernanceSucceeds = MockChainUtils.mockchainSucceeds $ Utils.failOnError $ do
(genesisUtxo, _, governanceReferenceScript) <- initGovernance
let VersioningTestSetup{..} = mkVersioningTestSetup genesisUtxo Wallet.w1

case governanceReferenceScript == vtsGovernanceScript of
True -> return ()
False -> error "Governance reference script is not the expected script"

return ()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
initGovernanceSucceeds = MockChainUtils.mockchainSucceeds $ Utils.failOnError $ do
(genesisUtxo, _, governanceReferenceScript) <- initGovernance
let VersioningTestSetup{..} = mkVersioningTestSetup genesisUtxo Wallet.w1
case governanceReferenceScript == vtsGovernanceScript of
True -> return ()
False -> error "Governance reference script is not the expected script"
return ()
initGovernanceSucceeds = MockChainUtils.mockchainSucceeds $ Utils.failOnError $ void do
(genesisUtxo, _, governanceReferenceScript) <- initGovernance
let VersioningTestSetup{..} = mkVersioningTestSetup genesisUtxo Wallet.w1
unless (governanceReferenceScript == vtsGovernanceScript) $
error "Governance reference script is not the expected script"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants