@@ -196,6 +196,46 @@ class CandidateGeneratorPropSpec extends ErgoCorePropertyTest {
196
196
197
197
}
198
198
199
+ property(" should break up fee inputs into multiple transactions if there are too many" ) {
200
+ val bh = boxesHolderGen.sample.get
201
+ val us = createUtxoState(bh,parameters)
202
+ val height = us.stateContext.currentHeight
203
+
204
+ // Generate a large number of fee boxes
205
+ val feeBoxes = (1 to 1000 ).map(_ =>
206
+ val value = Gen .choose(1 ,100 ).sample.get(100L , 10000L ).sample.get
207
+ createBox(value,feeProp, creationHeight = Some (height))
208
+ )
209
+
210
+ // Create transactions spending these fee boxes
211
+ val feeTransactions = feeBoxes.map { box =>
212
+ val input = Input (box.id, ProverResult .empty)
213
+ val output = new ErgoBoxCandidate (box.value, feeProp, height)
214
+ new ErgoTransaction (IndexedSeq (input), IndexedSeq (output))
215
+
216
+ val txs = CandidateGenerator .collectFees(height, feeTransactions, defaultMinerPk, emptyStateContext).toSeq
217
+
218
+ // check that multiple transactions were created
219
+ txs.length shouldBe > (1 )
220
+
221
+ // check that each transacton does not exceed a reasonable input limit
222
+ val maxInputsPerTx = 100
223
+ txs.foreach { tx =>
224
+ tx.inputs.size should be <= maxInputsPerTx
225
+ }
226
+
227
+ // Check that all fee inputs were collected
228
+ val collectedInputs = txs.flatMap(_.inputs).map(_.boxId).toSet
229
+ val originalInputs = feeTransactions.flatMap(_.inputs).map(_.boxId).toSet
230
+ collectedInputs should equal(originalInputs)
231
+ }
232
+
233
+ // Check that all outputs go to the miner
234
+ txs.flatMap(_.outputs).foreach { output =>
235
+ output.propositionBytes shouldEqual expectedRewardOutputScriptBytes(defaultMinerPk)
236
+ }
237
+ }
238
+
199
239
property(" should not be able to spend recent fee boxes" ) {
200
240
201
241
val delta = 1
0 commit comments