@@ -123,6 +123,78 @@ spec = describe "POOL" $ do
123
123
expectFuturePool kh (Just vrfNew)
124
124
passEpoch
125
125
expectPool kh (Just vrfNew)
126
+ expectVRFs [vrfNew]
127
+ -- now the original VRF can be reused
128
+ khNew <- freshKeyHash
129
+ registerPoolTx <$> poolParams khNew vrf >>= submitTx_
130
+ expectVRFs [vrf, vrfNew]
131
+
132
+ it " register a new pool with the VRF of a re-registered pool " $ do
133
+ pv <- getsPParams ppProtocolVersionL
134
+ (kh, _) <- registerNewPool
135
+ vrfNew <- freshKeyHashVRF
136
+ -- re-register pool with a new vrf
137
+ registerPoolTx <$> poolParams kh vrfNew >>= submitTx_
138
+ passEpoch
139
+ -- try to register a new pool with the new vrf
140
+ khNew <- freshKeyHash
141
+ registerPoolTx <$> poolParams khNew vrfNew >>= \ tx ->
142
+ if pvMajor pv < natVersion @ 11
143
+ then do
144
+ submitTx_ tx
145
+ expectPool kh (Just vrfNew)
146
+ expectPool khNew (Just vrfNew)
147
+ else
148
+ submitFailingTx tx [injectFailure $ VRFKeyHashAlreadyRegistered khNew vrfNew]
149
+
150
+ it " after the epoch changes, reuse VRFs that get overwritten" $ do
151
+ (kh, vrf) <- registerNewPool
152
+ vrf1 <- freshKeyHashVRF
153
+ registerPoolTx <$> poolParams kh vrf1 >>= submitTx_
154
+ expectVRFs [vrf, vrf1]
155
+ vrf2 <- freshKeyHashVRF
156
+ registerPoolTx <$> poolParams kh vrf2 >>= submitTx_
157
+ expectVRFs [vrf, vrf2]
158
+ vrf3 <- freshKeyHashVRF
159
+ registerPoolTx <$> poolParams kh vrf3 >>= submitTx_
160
+ expectVRFs [vrf, vrf3]
161
+ passEpoch
162
+ expectPool kh (Just vrf3)
163
+ expectVRFs [vrf3]
164
+ -- reuse VRFs that didn't get used
165
+ khNew <- freshKeyHash
166
+ registerPoolTx <$> poolParams khNew vrf1 >>= submitTx_
167
+ expectPool khNew (Just vrf1)
168
+ expectVRFs [vrf1, vrf3]
169
+ -- the original pool can be re-registered with one of the discarded VRFs too
170
+ registerPoolTx <$> poolParams kh vrf2 >>= submitTx_
171
+ expectVRFs [vrf1, vrf2, vrf3]
172
+ passEpoch
173
+ expectVRFs [vrf1, vrf2]
174
+ -- the original pool can be re-registered with the original VRF too
175
+ registerPoolTx <$> poolParams kh vrf >>= submitTx_
176
+ expectVRFs [vrf, vrf1, vrf2]
177
+ passEpoch
178
+ expectVRFs [vrf, vrf1]
179
+
180
+ it " before the epoch changes, try to reuse VRFs that get overwritten" $ do
181
+ pv <- getsPParams ppProtocolVersionL
182
+ (kh, vrf) <- registerNewPool
183
+ vrfNew <- freshKeyHashVRF
184
+ registerPoolTx <$> poolParams kh vrfNew >>= submitTx_
185
+ -- try to register a pool with the original VRF that got overwritten
186
+ khNew <- freshKeyHash
187
+ registerPoolTx <$> poolParams khNew vrf >>= \ tx ->
188
+ if pvMajor pv < natVersion @ 11
189
+ then do
190
+ submitTx_ tx
191
+ expectPool kh (Just vrf)
192
+ expectPool khNew (Just vrf)
193
+ passEpoch
194
+ expectPool kh (Just vrfNew)
195
+ expectPool khNew (Just vrf)
196
+ else do
197
+ submitFailingTx tx [injectFailure $ VRFKeyHashAlreadyRegistered khNew vrf]
126
198
127
199
describe " Retiring pools" $ do
128
200
it " retire an unregistered pool" $ do
@@ -189,14 +261,18 @@ spec = describe "POOL" $ do
189
261
expectRetiring False kh
190
262
191
263
it " re-register a retiring pool with a fresh VRF" $ do
192
- (kh, _ ) <- registerNewPool
264
+ (kh, vrf ) <- registerNewPool
193
265
retirePoolTx kh (EpochInterval 10 ) >>= submitTx_
194
266
vrfNew <- freshKeyHashVRF
195
267
registerPoolTx <$> poolParams kh vrfNew >>= submitTx_
196
268
expectRetiring False kh
197
269
expectFuturePool kh (Just vrfNew)
198
270
passEpoch
199
271
expectPool kh (Just vrfNew)
272
+ expectVRFs [vrfNew]
273
+ -- now the original VRF can be reused
274
+ khNew <- freshKeyHash
275
+ registerPoolTx <$> poolParams khNew vrf >>= submitTx_
200
276
201
277
it " register a pool with the VRF of a retiring pool" $ do
202
278
pv <- getsPParams ppProtocolVersionL
0 commit comments