Skip to content

Commit e83b0c0

Browse files
committed
Update hprop_ledger_events_treasury_withdrawal to work with the new checks
1 parent a62a0d9 commit e83b0c0

File tree

1 file changed

+41
-28
lines changed

1 file changed

+41
-28
lines changed

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

Lines changed: 41 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,14 @@ import qualified Data.Map.Strict as M
3535
import qualified Data.Text as Text
3636
import GHC.Stack
3737
import Lens.Micro
38+
import System.Directory (makeAbsolute)
3839
import System.FilePath ((</>))
3940

41+
import Test.Cardano.CLI.Hash (serveFilesWhile)
4042
import Testnet.Components.Query
4143
import Testnet.Defaults
4244
import Testnet.Process.Cli.Keys (cliStakeAddressKeyGen)
43-
import Testnet.Process.Run (execCli', mkExecConfig)
45+
import Testnet.Process.Run (addEnvVarsToConfig, execCli', mkExecConfig)
4446
import Testnet.Property.Util (integrationRetryWorkspace)
4547
import Testnet.Start.Types
4648
import Testnet.Types
@@ -87,13 +89,14 @@ hprop_ledger_events_treasury_withdrawal = integrationRetryWorkspace 2 "treasury
8789
H.note_ $ "Foldblocks config file: " <> unFile configurationFile
8890

8991
gov <- H.createDirectoryIfMissing $ work </> "governance"
90-
proposalAnchorFile <- H.note $ work </> gov </> "sample-proposal-anchor"
91-
treasuryWithdrawalActionFp <- H.note $ work </> gov </> "treasury-withdrawal.action"
9292

93-
H.writeFile proposalAnchorFile "dummy anchor data"
93+
let proposalAnchorDataIpfsHash = "QmexFJuEn5RtnHEqpxDcqrazdHPzAwe7zs2RxHLfMH5gBz"
94+
proposalAnchorFile <- H.noteM $ liftIO $ makeAbsolute $ "test" </> "cardano-testnet-test" </> "files" </> "sample-proposal-anchor"
95+
96+
treasuryWithdrawalActionFp <- H.note $ work </> gov </> "treasury-withdrawal.action"
9497

9598
proposalAnchorDataHash <- execCli' execConfig
96-
[ "hash", "anchor-data", "--file-text", proposalAnchorFile
99+
[ "hash", "anchor-data", "--file-binary", proposalAnchorFile
97100
]
98101

99102
txin2 <- findLargestUtxoForPaymentKey epochStateView sbe wallet1
@@ -145,35 +148,45 @@ hprop_ledger_events_treasury_withdrawal = integrationRetryWorkspace 2 "treasury
145148
-- {{{ Create treasury withdrawal
146149
let withdrawalAmount = 3_300_777 :: Integer
147150
govActionDeposit <- getMinDRepDeposit epochStateView ceo
148-
void $ execCli' execConfig
149-
[ eraName, "governance", "action", "create-treasury-withdrawal"
150-
, "--testnet"
151-
, "--anchor-url", "https://tinyurl.com/3wrwb2as"
152-
, "--anchor-data-hash", proposalAnchorDataHash
153-
, "--governance-action-deposit", show govActionDeposit
154-
, "--deposit-return-stake-verification-key-file", stakeVkeyFp
155-
, "--transfer", show withdrawalAmount
156-
, "--funds-receiving-stake-verification-key-file", stakeVkeyFp
157-
, "--out-file", treasuryWithdrawalActionFp
158-
]
159151

152+
let relativeUrl = ["ipfs", proposalAnchorDataIpfsHash]
160153

161154
txbodyFp <- H.note $ work </> "tx.body"
162155
txbodySignedFp <- H.note $ work </> "tx.body.signed"
163156

164-
-- wait for one block before using wallet0 again
165-
_ <- waitForBlocks epochStateView 1
166157

167-
txin3 <- findLargestUtxoForPaymentKey epochStateView sbe wallet0
168-
169-
void $ execCli' execConfig
170-
[ eraName, "transaction", "build"
171-
, "--change-address", Text.unpack $ paymentKeyInfoAddr wallet0
172-
, "--tx-in", Text.unpack $ renderTxIn txin3
173-
, "--tx-out", Text.unpack (paymentKeyInfoAddr wallet1) <> "+" <> show @Int 5_000_000
174-
, "--proposal-file", treasuryWithdrawalActionFp
175-
, "--out-file", txbodyFp
176-
]
158+
-- Create temporary HTTP server with files required by the call to `cardano-cli`
159+
-- In this case, the server emulates an IPFS gateway
160+
serveFilesWhile
161+
[(relativeUrl, proposalAnchorFile)]
162+
( \port -> do
163+
let execConfig' = addEnvVarsToConfig execConfig [("IPFS_GATEWAY_URI", "http://localhost:" ++ show port ++ "/")]
164+
void $ execCli' execConfig'
165+
[ eraName, "governance", "action", "create-treasury-withdrawal"
166+
, "--testnet"
167+
, "--anchor-url", "ipfs://" ++ proposalAnchorDataIpfsHash
168+
, "--anchor-data-hash", proposalAnchorDataHash
169+
, "--governance-action-deposit", show govActionDeposit
170+
, "--deposit-return-stake-verification-key-file", stakeVkeyFp
171+
, "--transfer", show withdrawalAmount
172+
, "--funds-receiving-stake-verification-key-file", stakeVkeyFp
173+
, "--out-file", treasuryWithdrawalActionFp
174+
]
175+
176+
-- wait for one block before using wallet0 again
177+
_ <- waitForBlocks epochStateView 1
178+
179+
txin3 <- findLargestUtxoForPaymentKey epochStateView sbe wallet0
180+
181+
void $ execCli' execConfig'
182+
[ eraName, "transaction", "build"
183+
, "--change-address", Text.unpack $ paymentKeyInfoAddr wallet0
184+
, "--tx-in", Text.unpack $ renderTxIn txin3
185+
, "--tx-out", Text.unpack (paymentKeyInfoAddr wallet1) <> "+" <> show @Int 5_000_000
186+
, "--proposal-file", treasuryWithdrawalActionFp
187+
, "--out-file", txbodyFp
188+
]
189+
)
177190

178191
void $ execCli' execConfig
179192
[ eraName, "transaction", "sign"

0 commit comments

Comments
 (0)