@@ -3,6 +3,10 @@ module Test.Pos.Core.ExampleHelpers
3
3
4
4
exampleAddrSpendingData_PubKey
5
5
, exampleAddress
6
+ , exampleAddress1
7
+ , exampleAddress2
8
+ , exampleAddress3
9
+ , exampleAddress4
6
10
, exampleBlockVersion
7
11
, exampleBlockVersionData
8
12
, exampleBlockVersionModifier
@@ -83,6 +87,7 @@ import Data.Fixed (Fixed (..))
83
87
import qualified Data.HashMap.Strict as HM
84
88
import Data.List (zipWith4 , (!!) )
85
89
import Data.List.NonEmpty (fromList )
90
+ import qualified Data.Map as M
86
91
import Data.Maybe (fromJust )
87
92
import qualified Data.Text as T
88
93
import Data.Time.Units (Millisecond )
@@ -99,8 +104,8 @@ import Pos.Core.Common (AddrAttributes (..), AddrSpendingData (..),
99
104
CoinPortion (.. ), IsBootstrapEraAddr (.. ), Script (.. ),
100
105
ScriptVersion , SharedSeed (.. ), SlotLeaders ,
101
106
StakeholderId , StakesList , TxFeePolicy (.. ),
102
- TxSizeLinear (.. ), addressHash , makeAddress ,
103
- makePubKeyAddress )
107
+ TxSizeLinear (.. ), addressHash , coinPortionDenominator ,
108
+ makeAddress , makePubKeyAddress , mkMultiKeyDistr )
104
109
import Pos.Core.Configuration
105
110
import Pos.Core.Delegation (HeavyDlgIndex (.. ), LightDlgIndices (.. ),
106
111
ProxySKBlockInfo , ProxySKHeavy )
@@ -564,6 +569,50 @@ exampleAddress = makeAddress exampleAddrSpendingData_PubKey attrs
564
569
attrs = AddrAttributes hap BootstrapEraDistr
565
570
hap = Just (HDAddressPayload (getBytes 32 32 ))
566
571
572
+ exampleAddress1 :: Address
573
+ exampleAddress1 = makeAddress easd attrs
574
+ where
575
+ easd = PubKeyASD pk
576
+ [pk] = examplePublicKeys 24 1
577
+ attrs = AddrAttributes hap BootstrapEraDistr
578
+ hap = Nothing
579
+
580
+ exampleAddress2 :: Address
581
+ exampleAddress2 = makeAddress easd attrs
582
+ where
583
+ easd = RedeemASD exampleRedeemPublicKey
584
+ attrs = AddrAttributes hap asd
585
+ hap = Just (HDAddressPayload (getBytes 15 32 ))
586
+ asd = SingleKeyDistr exampleStakeholderId
587
+
588
+ exampleAddress3 :: Address
589
+ exampleAddress3 = makeAddress easd attrs
590
+ where
591
+ easd = ScriptASD exampleScript
592
+ attrs = AddrAttributes hap exampleMultiKeyDistr
593
+ hap = Just (HDAddressPayload (getBytes 17 32 ))
594
+
595
+ exampleAddress4 :: Address
596
+ exampleAddress4 = makeAddress easd attrs
597
+ where
598
+ easd = UnknownASD 7 " test value"
599
+ attrs = AddrAttributes Nothing (SingleKeyDistr sId)
600
+ [sId] = exampleStakeholderIds 7 1
601
+
602
+ exampleMultiKeyDistr :: AddrStakeDistribution
603
+ exampleMultiKeyDistr = case mkMultiKeyDistr (M. fromList pairs) of
604
+ Left err -> error $
605
+ " exampleMultiKeyDistr: improperly constructed stake map: " <> show err
606
+ Right asd -> asd
607
+ where
608
+ pairs = zip stakeIds (map CoinPortion (remainderCP : coinPortions))
609
+ stakeIds = map abstractHash (examplePublicKeys 7 4 )
610
+ coinPortions = [ (10 :: Word64 ) ^ (12 :: Word64 )
611
+ , ( 7 :: Word64 ) ^ (11 :: Word64 )
612
+ , ( 6 :: Word64 ) ^ (14 :: Word64 )
613
+ ]
614
+ remainderCP = coinPortionDenominator - sum coinPortions
615
+
567
616
exampleGenesisConfiguration_GCSrc :: GenesisConfiguration
568
617
exampleGenesisConfiguration_GCSrc =
569
618
GCSrc " dRaMwdYsH3QA3dChe" (abstractHash (Raw " Test" ))
0 commit comments