-
Notifications
You must be signed in to change notification settings - Fork 163
/
Copy pathConway.hs
230 lines (228 loc) · 11.5 KB
/
Conway.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
module Test.Cardano.Db.Mock.Unit.Conway (unitTests) where
import Cardano.Mock.ChainSync.Server (IOManager ())
import Cardano.Prelude
import qualified Test.Cardano.Db.Mock.Unit.Conway.CommandLineArg.ConfigFile as ConfigFile
import qualified Test.Cardano.Db.Mock.Unit.Conway.CommandLineArg.EpochDisabled as EpochDisabled
import qualified Test.Cardano.Db.Mock.Unit.Conway.Config.JsonbInSchema as Config
import qualified Test.Cardano.Db.Mock.Unit.Conway.Config.MigrateConsumedPruneTxOut as MigrateConsumedPruneTxOut
import qualified Test.Cardano.Db.Mock.Unit.Conway.Config.Parse as Config
import qualified Test.Cardano.Db.Mock.Unit.Conway.Governance as Governance
import qualified Test.Cardano.Db.Mock.Unit.Conway.InlineAndReference as InlineRef
import qualified Test.Cardano.Db.Mock.Unit.Conway.Other as Other
import qualified Test.Cardano.Db.Mock.Unit.Conway.Plutus as Plutus
import qualified Test.Cardano.Db.Mock.Unit.Conway.Reward as Reward
import qualified Test.Cardano.Db.Mock.Unit.Conway.Rollback as Rollback
import qualified Test.Cardano.Db.Mock.Unit.Conway.Simple as Simple
import qualified Test.Cardano.Db.Mock.Unit.Conway.Stake as Stake
import qualified Test.Cardano.Db.Mock.Unit.Conway.Tx as Tx
import Test.Cardano.Db.Mock.Validate (expectFailSilent)
import Test.Tasty (TestTree (), testGroup)
import Test.Tasty.HUnit (Assertion (), testCase)
import Prelude (String ())
unitTests :: IOManager -> [(Text, Text)] -> TestTree
unitTests iom knownMigrations =
testGroup
"Conway unit tests"
[ testGroup
"config"
[ testCase "conway genesis and hash" Config.conwayGenesis
, testCase "missing conway genesis file" Config.missingConwayGenesis
, testCase "no conway genesis file" Config.noConwayGenesis
, testCase "no conway genesis hash" Config.noConwayGenesisHash
, testCase "mismatched conway genesis hash" Config.wrongConwayGenesisHash
, testCase "default insert config" Config.defaultInsertConfig
, testCase "insert config" Config.insertConfig
, testGroup
"jsonb-in-schema"
[ test "jsonb in schema true" Config.configRemoveJsonbFromSchemaEnabled
, test "jsonb in schema false" Config.configRemoveJsonbFromSchemaDisabled
, test
"remove jsonb from schema and add back"
Config.configJsonbInSchemaShouldRemoveThenAdd
]
, testGroup
"tx-out"
[ test "consumed_by_tx_id column check" MigrateConsumedPruneTxOut.txConsumedColumnCheck
, test "basic prune" MigrateConsumedPruneTxOut.basicPrune
, test "prune with simple rollback" MigrateConsumedPruneTxOut.pruneWithSimpleRollback
, test "prune with full tx rollback" MigrateConsumedPruneTxOut.pruneWithFullTxRollback
, test "pruning should keep some tx" MigrateConsumedPruneTxOut.pruningShouldKeepSomeTx
, test "prune and rollback one block" MigrateConsumedPruneTxOut.pruneAndRollBackOneBlock
, test "no pruning and rollback" MigrateConsumedPruneTxOut.noPruneAndRollBack
, test "prune same block" MigrateConsumedPruneTxOut.pruneSameBlock
, test "no pruning same block" MigrateConsumedPruneTxOut.noPruneSameBlock
, expectFailSilent
"restart with new consumed set to false"
$ MigrateConsumedPruneTxOut.migrateAndPruneRestart iom knownMigrations
, expectFailSilent
"set prune flag, restart missing prune flag"
$ MigrateConsumedPruneTxOut.pruneRestartMissingFlag iom knownMigrations
, expectFailSilent
"set bootstrap flag, restart missing bootstrap flag"
$ MigrateConsumedPruneTxOut.bootstrapRestartMissingFlag iom knownMigrations
]
]
, testGroup
"simple"
[ test "simple forge blocks" Simple.forgeBlocks
, test "sync one block" Simple.addSimple
, test "sync small chain" Simple.addSimpleChain
, test "restart db-sync" Simple.restartDBSync
, test "node restart" Simple.nodeRestart
, test "node restart boundary" Simple.nodeRestartBoundary
]
, testGroup
"Command Line Arguments"
[ testGroup
"config"
[ expectFailSilent
"fails if incorrect config file given"
$ ConfigFile.checkConfigFileArg iom knownMigrations
]
, testGroup
"disable-epoch"
[ test "Epoch doesn't update when disabled" EpochDisabled.checkEpochDisabledArg
, test "Epoch updates when enabled" EpochDisabled.checkEpochEnabled
]
]
, testGroup
"rollbacks"
[ test "simple rollback" Rollback.simpleRollback
, test "sync bigger chain" Rollback.bigChain
, test "rollback while db-sync is off" Rollback.restartAndRollback
, test "big rollback executed lazily" Rollback.lazyRollback
, test "lazy rollback on restart" Rollback.lazyRollbackRestart
, test "rollback while rollbacking" Rollback.doubleRollback
, test "rollback stake address cache" Rollback.stakeAddressRollback
, test "rollback change order of txs" Rollback.rollbackChangeTxOrder
, test "rollback full tx" Rollback.rollbackFullTx
]
, testGroup
"different configs"
[ test "genesis config without pool" Other.configNoPools
, test "genesis config without stakes" Other.configNoStakes
]
, testGroup
"blocks with txs"
[ test "simple tx" Tx.addSimpleTx
, test "simple tx in Shelley era" Tx.addSimpleTxShelley
, test "simple tx with ledger disabled" Tx.addSimpleTxNoLedger
, test "tx with treasury donation" Tx.addTxTreasuryDonation
, test "consume utxo same block" Tx.consumeSameBlock
, test "tx with metadata" Tx.addTxMetadata
, test "tx with metadata disabled" Tx.addTxMetadataDisabled
, test "tx with metadata whitelist" Tx.addTxMetadataWhitelist
]
, testGroup
"stake addresses"
[ test "(de)registrations" Stake.registrationTx
, test "(de)registrations in same block" Stake.registrationsSameBlock
, test "(de)registrations in same tx" Stake.registrationsSameTx
, test "stake address pointers" Stake.stakeAddressPtr
, test "stake address pointers deregistration" Stake.stakeAddressPtrDereg
, test "stake address pointers. Use before registering." Stake.stakeAddressPtrUseBefore
, test "register stake creds" Stake.registerStakeCreds
, test "register stake creds with shelley disabled" Stake.registerStakeCredsNoShelley
]
, testGroup
"stake distribution"
[ test "stake distribution from genesis" Stake.stakeDistGenesis
, test "2000 delegations" Stake.delegations2000
, test "2001 delegations" Stake.delegations2001
, test "8000 delegations" Stake.delegations8000
, test "many delegations" Stake.delegationsMany
, test "many delegations, sparse chain" Stake.delegationsManyNotDense
]
, testGroup
"rewards"
[ test "rewards simple" Reward.simpleRewards
, test "shelley rewards from multiple sources" Reward.rewardsShelley
, test "rollback on epoch boundary" Reward.rollbackBoundary
]
, testGroup
"plutus send scripts"
[ test "simple script lock" Plutus.simpleScript
, test "unlock script in same block" Plutus.unlockScriptSameBlock
, test "unlock script with plutus disabled" Plutus.unlockScriptNoPlutus
, test "failed script" Plutus.failedScript
, test "failed script fees" Plutus.failedScriptFees
, test "failed script in same block" Plutus.failedScriptSameBlock
, test "multiple scripts unlocked" Plutus.multipleScripts
, test "multiple scripts unlocked rollback" Plutus.multipleScriptsRollback
, test "multiple scripts unlocked same block" Plutus.multipleScriptsSameBlock
, test "multiple scripts failed" Plutus.multipleScriptsFailed
, test "multiple scripts failed same block" Plutus.multipleScriptsFailedSameBlock
]
, testGroup
"plutus cert scripts"
[ test "stake scripts" Plutus.registrationScriptTx
, test "stake scripts deregistration" Plutus.deregistrationScriptTx
, test "multiple stake scripts deregistration" Plutus.deregistrationsScriptTxs
, test "multiple stake scripts in same tx" Plutus.deregistrationScriptTx
, test
"multiple stake scripts deregistration in same tx missing redeemer 1"
Plutus.deregistrationsScriptTx'
, test
"multiple stake scripts deregistration in same tx missing redeemer 2"
Plutus.deregistrationsScriptTx''
]
, testGroup
"MultiAssets plutus scripts"
[ test "mint simple multi asset" Plutus.mintMultiAsset
, test "mint many multi assets" Plutus.mintMultiAssets
, test "swap many multi assets" Plutus.swapMultiAssets
, test "swap with multi assets disabled" Plutus.swapMultiAssetsDisabled
]
, testGroup
"Pools and smash"
[ test "pool registration" Other.poolReg
, test "query pool that's not registered" Other.nonexistentPoolQuery
, test "pool deregistration" Other.poolDeReg
, test "multiple deregistration" Other.poolDeRegMany
, test "delist pool" Other.poolDelist
]
, testGroup
"Inline and reference"
[ test "spend inline datum" InlineRef.unlockDatumOutput
, test "spend inline datum same block" InlineRef.unlockDatumOutputSameBlock
, test "inline datum with noncanonical CBOR" InlineRef.inlineDatumCBOR
, test "spend reference script" InlineRef.spendRefScript
, test "spend reference script same block" InlineRef.spendRefScriptSameBlock
, test "spend collateral output of invalid tx" InlineRef.spendCollateralOutput
, test
"spend collateral output of invalid tx rollback"
InlineRef.spendCollateralOutputRollback
, test
"spend collateral output of invalid tx same block"
InlineRef.spendCollateralOutputSameBlock
, test
"reference input to output which is not spent"
InlineRef.referenceInputUnspend
, test
"supply and run script which is both reference and in witnesses"
InlineRef.supplyScriptsTwoWays
, test
"supply and run script which is both reference and in witnesses same block"
InlineRef.supplyScriptsTwoWaysSameBlock
, test "reference script as minting" InlineRef.referenceMintingScript
, test "reference script as delegation" InlineRef.referenceDelegation
]
, testGroup
"Hard Fork"
[ test "fork from Babbage to Conway fixed epoch" Other.forkFixedEpoch
, test "fork from Babbage to Conway and rollback" Other.rollbackFork
, test "fork with protocol change proposal" Other.forkParam
]
, testGroup
"Governance"
[ test "drep distribution" Governance.drepDistr
, test "new committee member" Governance.newCommittee
, test "update constitution" Governance.updateConstitution
, test "treasury withdrawal" Governance.treasuryWithdrawal
, test "protocol parameter change" Governance.paramChange
, test "hardfork initiation" Governance.hardFork
]
]
where
test :: String -> (IOManager -> [(Text, Text)] -> Assertion) -> TestTree
test str action = testCase str (action iom knownMigrations)