File tree 1 file changed +31
-0
lines changed
cardano-api/gen/Test/Gen/Cardano/Api 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -139,6 +139,11 @@ module Test.Gen.Cardano.Api.Typed
139
139
, genMintWitnessable
140
140
, genPlutusScriptWitness
141
141
, genIndexedPlutusScriptWitness
142
+
143
+ , genBlockNo
144
+ , genBlockHeader
145
+ , genBlockHeaderAt
146
+ , genBlockHeaderHash
142
147
)
143
148
where
144
149
@@ -1468,3 +1473,29 @@ genScriptWitnessForMint sbe = do
1468
1473
scriptRedeemer
1469
1474
<$> genExecutionUnits
1470
1475
1476
+ genBlockNo :: Gen BlockNo
1477
+ genBlockNo = BlockNo <$> Gen. word64 Range. constantBounded
1478
+
1479
+ -- | Fully arbitrary block header with completely random hash.
1480
+ genBlockHeader :: Gen BlockHeader
1481
+ genBlockHeader = genSlotNo >>= genBlockHeaderAt
1482
+
1483
+ -- | Generate a random block header with completely random hash, but at a
1484
+ -- certain slot.
1485
+ genBlockHeaderAt :: SlotNo -> Gen BlockHeader
1486
+ genBlockHeaderAt slotNo = BlockHeader slotNo <$> genBlockHeaderHash <*> geBlockNo
1487
+
1488
+ -- | Generate a random block header hash.
1489
+ genBlockHeaderHash :: Gen (Hash BlockHeader )
1490
+ genBlockHeaderHash =
1491
+ unsafeBlockHeaderHashFromBytes . BS. pack <$> Gen. list (Range. singleton 32 ) Q. arbitrary
1492
+ where
1493
+ unsafeBlockHeaderHashFromBytes bytes =
1494
+ case deserialiseFromRawBytes (proxyToAsType Proxy ) bytes of
1495
+ Left e ->
1496
+ error $
1497
+ " unsafeBlockHeaderHashFromBytes: failed on bytes "
1498
+ <> show bytes
1499
+ <> " with error "
1500
+ <> show e
1501
+ Right h -> h
You can’t perform that action at this time.
0 commit comments