Skip to content

Commit 4fb6c08

Browse files
palasneilmayhew
authored andcommitted
Update hprop_ledger_events_propose_new_constitution to work with the new checks
1 parent 41c425e commit 4fb6c08

File tree

3 files changed

+99
-33
lines changed

3 files changed

+99
-33
lines changed

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ configuration/cardano/mainnet-byron-genesis.json text eol=lf
66
configuration/cardano/mainnet-conway-genesis.json text eol=lf
77
configuration/cardano/mainnet-shelley-genesis.json text eol=lf
88
cardano-testnet/test/cardano-testnet-test/files/sample-proposal-anchor text eol=lf
9+
cardano-testnet/test/cardano-testnet-test/files/sample-constitution-anchor text eol=lf

cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Gov/ProposeNewConstitution.hs

+48-33
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,10 @@ import Data.String
3030
import qualified Data.Text as Text
3131
import GHC.Exts (IsList (..))
3232
import Lens.Micro
33+
import System.Directory (makeAbsolute)
3334
import System.FilePath ((</>))
3435

36+
import Test.Cardano.CLI.Hash (serveFilesWhile)
3537
import Testnet.Components.Configuration
3638
import Testnet.Components.Query
3739
import Testnet.Defaults
@@ -40,7 +42,7 @@ import Testnet.Process.Cli.DRep
4042
import Testnet.Process.Cli.Keys
4143
import Testnet.Process.Cli.SPO (createStakeKeyRegistrationCertificate)
4244
import Testnet.Process.Cli.Transaction
43-
import Testnet.Process.Run (execCli', mkExecConfig)
45+
import Testnet.Process.Run (addEnvVarsToConfig, execCli', mkExecConfig)
4446
import Testnet.Property.Util (integrationWorkspace)
4547
import Testnet.Start.Types
4648
import Testnet.Types
@@ -102,21 +104,19 @@ hprop_ledger_events_propose_new_constitution = integrationWorkspace "propose-new
102104

103105
-- Create Conway constitution
104106
gov <- H.createDirectoryIfMissing $ work </> "governance"
105-
proposalAnchorFile <- H.note $ gov </> "sample-proposal-anchor"
106-
constitutionFile <- H.note $ gov </> "sample-constitution"
107107
constitutionActionFp <- H.note $ gov </> "constitution.action"
108108

109-
H.writeFile proposalAnchorFile $
110-
unlines [ "These are the reasons: " , "" , "1. First" , "2. Second " , "3. Third" ]
111-
H.copyFile
112-
"test/cardano-testnet-test/files/input/sample-constitution.txt"
113-
constitutionFile
109+
let proposalAnchorDataIpfsHash = "QmexFJuEn5RtnHEqpxDcqrazdHPzAwe7zs2RxHLfMH5gBz"
110+
proposalAnchorFile <- H.noteM $ liftIO $ makeAbsolute $ "test" </> "cardano-testnet-test" </> "files" </> "sample-proposal-anchor"
111+
let constitutionAnchorDataIpfsHash = "QmXGkenkhh3NsotVwbNGToGsPuvJLgRT9aAz5ToyKAqdWP"
112+
constitutionAnchorFile <- H.noteM $ liftIO $ makeAbsolute $ "test" </> "cardano-testnet-test" </> "files" </> "sample-proposal-anchor"
113+
114114
constitutionHash <- execCli' execConfig
115-
[ "hash", "anchor-data", "--file-text", constitutionFile
115+
[ "hash", "anchor-data", "--file-binary", constitutionAnchorFile
116116
]
117117

118118
proposalAnchorDataHash <- execCli' execConfig
119-
[ "hash", "anchor-data", "--file-text", proposalAnchorFile
119+
[ "hash", "anchor-data", "--file-binary", proposalAnchorFile
120120
]
121121

122122
-- Register stake address
@@ -169,33 +169,48 @@ hprop_ledger_events_propose_new_constitution = integrationWorkspace "propose-new
169169
, "--script-file", guardRailScriptFp
170170
]
171171

172-
minDRepDeposit <- getMinDRepDeposit epochStateView ceo
173-
void $ execCli' execConfig
174-
[ "conway", "governance", "action", "create-constitution"
175-
, "--testnet"
176-
, "--governance-action-deposit", show minDRepDeposit
177-
, "--deposit-return-stake-verification-key-file", verificationKeyFp stakeKeys
178-
, "--anchor-url", "https://tinyurl.com/3wrwb2as"
179-
, "--anchor-data-hash", proposalAnchorDataHash
180-
, "--constitution-url", "https://tinyurl.com/2pahcy6z"
181-
, "--constitution-hash", constitutionHash
182-
, "--constitution-script-hash", constitutionScriptHash
183-
, "--out-file", constitutionActionFp
184-
]
172+
let relativeUrlProposal = ["ipfs", proposalAnchorDataIpfsHash]
173+
relativeUrlConstitution = ["ipfs", constitutionAnchorDataIpfsHash]
185174

186175
txbodyFp <- H.note $ work </> "tx.body"
176+
minDRepDeposit <- getMinDRepDeposit epochStateView ceo
187177

188-
H.noteShowM_ $ waitForBlocks epochStateView 1
189-
txin2 <- findLargestUtxoForPaymentKey epochStateView sbe wallet1
190-
191-
void $ execCli' execConfig
192-
[ "conway", "transaction", "build"
193-
, "--change-address", Text.unpack $ paymentKeyInfoAddr wallet1
194-
, "--tx-in", Text.unpack $ renderTxIn txin2
195-
, "--tx-out", Text.unpack (paymentKeyInfoAddr wallet0) <> "+" <> show @Int 5_000_000
196-
, "--proposal-file", constitutionActionFp
197-
, "--out-file", txbodyFp
178+
-- Create temporary HTTP server with files required by the call to `cardano-cli`
179+
-- In this case, the server emulates an IPFS gateway
180+
serveFilesWhile
181+
[ (relativeUrlProposal, proposalAnchorFile)
182+
, (relativeUrlConstitution, constitutionAnchorFile)
198183
]
184+
( \port -> do
185+
let execConfig' = addEnvVarsToConfig execConfig [("IPFS_GATEWAY_URI", "http://localhost:" ++ show port ++ "/")]
186+
187+
void $ execCli' execConfig'
188+
[ "conway", "governance", "action", "create-constitution"
189+
, "--testnet"
190+
, "--governance-action-deposit", show minDRepDeposit
191+
, "--deposit-return-stake-verification-key-file", verificationKeyFp stakeKeys
192+
, "--anchor-url", "ipfs://" ++ proposalAnchorDataIpfsHash
193+
, "--anchor-data-hash", proposalAnchorDataHash
194+
, "--check-anchor-data"
195+
, "--constitution-url", "ipfs://" ++ constitutionAnchorDataIpfsHash
196+
, "--constitution-hash", constitutionHash
197+
, "--check-constitution-hash"
198+
, "--constitution-script-hash", constitutionScriptHash
199+
, "--out-file", constitutionActionFp
200+
]
201+
202+
H.noteShowM_ $ waitForBlocks epochStateView 1
203+
txin2 <- findLargestUtxoForPaymentKey epochStateView sbe wallet1
204+
205+
void $ execCli' execConfig'
206+
[ "conway", "transaction", "build"
207+
, "--change-address", Text.unpack $ paymentKeyInfoAddr wallet1
208+
, "--tx-in", Text.unpack $ renderTxIn txin2
209+
, "--tx-out", Text.unpack (paymentKeyInfoAddr wallet0) <> "+" <> show @Int 5_000_000
210+
, "--proposal-file", constitutionActionFp
211+
, "--out-file", txbodyFp
212+
]
213+
)
199214

200215
signedProposalTx <- signTx execConfig cEra gov "signed-proposal"
201216
(File txbodyFp) [Some $ paymentKeyInfoPair wallet1]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
Preamble
2+
3+
We, the zaniest inhabitants of the peculiar and bewildering land of Barataria, in honor of our illustrious Governor, Sancho Panza, renowned for his comically charming ordinances, do hereby present this Constitution to tickle your fancy and uphold the values of laughter, merriment, and the pursuit of hilarity for all our citizens.
4+
5+
Article I: The Right to Absurdity
6+
7+
Wine-Watering Rights: Every Baratarian shall have the inalienable right to water down their wine as they see fit, provided they can still manage a tipsy jig.
8+
9+
Fashion Freedom: Citizens are encouraged to dress inappropriately for the sheer joy of it, as long as it does not involve the use of sharp objects, poisonous animals, or explosives.
10+
11+
Article II: The Role of Government: Keeping It Lighthearted
12+
13+
Official Clown: There shall be an official court jester whose duty is to make the Governor laugh at least once a day. Failure to amuse may result in banishment to a neighboring kingdom.
14+
15+
Puns and Pranks: All government proceedings shall include at least one pun and one harmless prank per session to maintain the mirthful spirit of Barataria.
16+
17+
Article III: The Economic Circus
18+
19+
Foolish Redistribution: The government shall engage in a monthly "wealth lottery," redistributing riches by catapulting bags of gold into the air and letting them fall where they may.
20+
21+
Tax Deductions for Silly Hats: Citizens who wear absurd hats shall receive generous tax deductions, fostering creativity and fashion-forward thinking.
22+
23+
Article IV: Justice, Comedy, and the Absurd
24+
25+
Trial by Tickling: In the interest of justice and merriment, all trials shall include a "tickle test" to determine guilt or innocence. Giggles are considered a sign of innocence.
26+
27+
Innocent Until Proven Clueless: It shall be presumed that every Baratarian is innocent of any wrongdoing until they can convincingly demonstrate their utter cluelessness in court.
28+
29+
Article V: Education and Clown Colleges
30+
31+
Clown Colleges for All: Barataria shall establish Clown Colleges to ensure that every citizen has the opportunity to master the art of clowning and perform slapstick humor.
32+
33+
Silly Science: Research grants shall be awarded to projects that explore the science of whoopee cushions, banana peels, and rubber chickens.
34+
35+
Article VI: Defense and Pranks
36+
37+
Pillow Fort Defense: Barataria's defense strategy shall revolve around building impregnable pillow forts and inviting would-be invaders to epic pillow fights to resolve conflicts.
38+
39+
War Declarations through Whoopie Cushions: Before declaring war, Barataria shall send a diplomatic envoy to the offending nation armed only with whoopee cushions to express our discontent.
40+
41+
Article VII: Amendments and Clown-novations
42+
43+
Whimsical Amendments: Amendments to this Constitution shall be proposed in the form of a joke or a riddle, and they must receive a hearty laugh from at least three-quarters of the citizens to be adopted.
44+
Article VIII: Final Pratfalls
45+
46+
Ratification with a Pie in the Face: This Constitution shall be ratified in a grand ceremony involving a pie in the face of the official ratifier, ensuring a silly and sticky beginning for Barataria.
47+
48+
Effective Clowning Date: This Constitution shall come into effect immediately upon the eruption of the first uncontrollable fit of laughter.
49+
50+
In witness whereof, we, the undersigned jesters, pranksters, and merrymakers, do hereby establish and adopt this Constitution to make Barataria a haven of hilarity, where laughter reigns supreme, and seriousness is only allowed on April Fool's Day.

0 commit comments

Comments
 (0)