-
Notifications
You must be signed in to change notification settings - Fork 3
Add basic sc-tools test #207
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
versioningScriptAddress :: C.TxIn -> C.AddressInEra C.ConwayEra | ||
versioningScriptAddress genesisUtxo = Utils.scriptAddress Defaults.networkId $ appliedVersioningValidator genesisUtxo | ||
|
||
initializeGovernance :: HUnit.Assertion |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
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 () |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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" |
Prereview checklist
changie new