@@ -7,11 +7,8 @@ module Test.Cardano.Db.Mock.Unit.Conway.Tx (
7
7
consumeSameBlock ,
8
8
addTxMetadata ,
9
9
addTxMetadataDisabled ,
10
- addTxMetadataWhitelist ,
11
- addTxMetadataWhitelistMultiple ,
12
10
) where
13
11
14
- import Cardano.Api.Ledger (Coin (.. ))
15
12
import Cardano.DbSync.Config (SyncNodeConfig (.. ))
16
13
import Cardano.DbSync.Config.Types (MetadataConfig (.. ), SyncInsertOptions (.. ))
17
14
import Cardano.Ledger.Shelley.TxAuxData (Metadatum (.. ))
@@ -21,7 +18,6 @@ import qualified Cardano.Mock.Forging.Tx.Shelley as Shelley
21
18
import Cardano.Mock.Forging.Types (UTxOIndex (.. ))
22
19
import Cardano.Mock.Query (queryNullTxDepositExists , queryTxMetadataCount )
23
20
import Cardano.Prelude hiding (head )
24
- import Data.List.NonEmpty (fromList )
25
21
import qualified Data.Map as Map
26
22
import Test.Cardano.Db.Mock.Config
27
23
import qualified Test.Cardano.Db.Mock.UnifiedApi as UnifiedApi
@@ -167,85 +163,3 @@ addTxMetadataDisabled ioManager metadata = do
167
163
initConfigFile
168
164
{ dncInsertOptions = dncInsertOptions' {sioMetadata = MetadataDisable }
169
165
}
170
-
171
- -- 2 blocks each with 4 metadata entries.
172
- -- The whitelist has one tx metadata key which is in the first block
173
- -- so only the TX in the first block should have tx metadata kept.
174
- addTxMetadataWhitelist :: IOManager -> [(Text , Text )] -> Assertion
175
- addTxMetadataWhitelist ioManager metadata = do
176
- syncNodeConfig <- mksNodeConfig
177
- withCustomConfigAndDropDB args (Just syncNodeConfig) cfgDir testLabel action ioManager metadata
178
- where
179
- action = \ interpreter mockServer dbSync -> do
180
- startDBSync dbSync
181
- -- Add transactions with metadata
182
- void $ do
183
- UnifiedApi. withConwayFindLeaderAndSubmitTx interpreter mockServer $ \ _ ->
184
- let txBody = Conway. mkDummyTxBodyWithFee $ Coin 1_000
185
- auxData = Map. fromList [(1 , I 1 ), (2 , I 2 ), (3 , I 3 ), (4 , I 4 )]
186
- in Right (Conway. mkAuxDataTx True txBody auxData)
187
- void $ do
188
- UnifiedApi. withConwayFindLeaderAndSubmitTx interpreter mockServer $ \ _ ->
189
- let txBody = Conway. mkDummyTxBodyWithFee $ Coin 2_000
190
- auxData = Map. fromList [(5 , I 5 ), (6 , I 6 ), (7 , I 7 ), (8 , I 8 )]
191
- in Right (Conway. mkAuxDataTx True txBody auxData)
192
-
193
- assertBlockNoBackoff dbSync 2
194
- -- Should have first block's tx metadata
195
- assertEqBackoff dbSync queryTxMetadataCount 4 [] " Expected tx metadata"
196
-
197
- args = initCommandLineArgs {claFullMode = False }
198
- testLabel = " conwayConfigMetadataWhitelist"
199
-
200
- cfgDir = conwayConfigDir
201
-
202
- -- match all metadata keys of value 1
203
- mksNodeConfig :: IO SyncNodeConfig
204
- mksNodeConfig = do
205
- initConfigFile <- mkSyncNodeConfig cfgDir args
206
- let dncInsertOptions' = dncInsertOptions initConfigFile
207
- pure $
208
- initConfigFile
209
- { dncInsertOptions = dncInsertOptions' {sioMetadata = MetadataKeys $ fromList [1 ]}
210
- }
211
-
212
- -- 2 blocks each with 4 metadata entries
213
- -- The whitelist is set to keys [1,6] each key in in different TX
214
- -- so all TxMetadata should be kept from both blocks.
215
- addTxMetadataWhitelistMultiple :: IOManager -> [(Text , Text )] -> Assertion
216
- addTxMetadataWhitelistMultiple ioManager metadata = do
217
- syncNodeConfig <- mksNodeConfig
218
- withCustomConfigAndDropDB args (Just syncNodeConfig) cfgDir testLabel action ioManager metadata
219
- where
220
- action = \ interpreter mockServer dbSync -> do
221
- startDBSync dbSync
222
- -- Add transactions with metadata
223
- void $ do
224
- UnifiedApi. withConwayFindLeaderAndSubmitTx interpreter mockServer $ \ _ ->
225
- let txBody = Conway. mkDummyTxBodyWithFee $ Coin 1_000
226
- auxData = Map. fromList [(1 , I 1 ), (2 , I 2 ), (3 , I 3 ), (4 , I 4 )]
227
- in Right (Conway. mkAuxDataTx True txBody auxData)
228
- void $ do
229
- UnifiedApi. withConwayFindLeaderAndSubmitTx interpreter mockServer $ \ _ ->
230
- let txBody = Conway. mkDummyTxBodyWithFee $ Coin 2_000
231
- auxData = Map. fromList [(5 , I 5 ), (6 , I 6 ), (7 , I 7 ), (8 , I 8 )]
232
- in Right (Conway. mkAuxDataTx True txBody auxData)
233
-
234
- assertBlockNoBackoff dbSync 2
235
- -- Should have both block's tx metadata
236
- assertEqBackoff dbSync queryTxMetadataCount 8 [] " Expected tx metadata"
237
-
238
- args = initCommandLineArgs {claFullMode = False }
239
- testLabel = " conwayConfigMetadataWhitelist"
240
-
241
- cfgDir = conwayConfigDir
242
-
243
- -- match all metadata keys of value 1
244
- mksNodeConfig :: IO SyncNodeConfig
245
- mksNodeConfig = do
246
- initConfigFile <- mkSyncNodeConfig cfgDir args
247
- let dncInsertOptions' = dncInsertOptions initConfigFile
248
- pure $
249
- initConfigFile
250
- { dncInsertOptions = dncInsertOptions' {sioMetadata = MetadataKeys $ fromList [1 , 6 ]}
251
- }
0 commit comments