diff --git a/block/src/Pos/Block/Network/Logic.hs b/block/src/Pos/Block/Network/Logic.hs index 74f76c7598a..f67b67c11ab 100644 --- a/block/src/Pos/Block/Network/Logic.hs +++ b/block/src/Pos/Block/Network/Logic.hs @@ -28,7 +28,6 @@ import Serokell.Util.Text (listJson) import qualified System.Metrics.Gauge as Metrics import System.Wlog (logDebug, logInfo, logWarning) -import Pos.Binary.Txp () import Pos.Block.BlockWorkMode (BlockWorkMode) import Pos.Block.Error (ApplyBlocksException) import Pos.Block.Logic (ClassifyHeaderRes (..), classifyNewHeader, diff --git a/block/test/Test/Pos/Block/Arbitrary.hs b/block/test/Test/Pos/Block/Arbitrary.hs index 09fce2ba917..8dd6404bd3d 100644 --- a/block/test/Test/Pos/Block/Arbitrary.hs +++ b/block/test/Test/Pos/Block/Arbitrary.hs @@ -44,9 +44,9 @@ import Pos.Crypto (ProtocolMagic, PublicKey, SecretKey, createPsk, import Pos.Data.Attributes (areAttributesKnown) import Test.Pos.Core.Arbitrary (genSlotId) +import Test.Pos.Core.Arbitrary.Txp (genTxPayload) import Test.Pos.Crypto.Dummy (dummyProtocolMagic) import Test.Pos.Delegation.Arbitrary (genDlgPayload) -import Test.Pos.Txp.Arbitrary (genTxPayload) import Test.Pos.Update.Arbitrary (genUpdatePayload) newtype BodyDependsOnSlot b = BodyDependsOnSlot diff --git a/client/src/Pos/Client/Txp/Network.hs b/client/src/Pos/Client/Txp/Network.hs index 4836f791af5..4f6de5d06e9 100644 --- a/client/src/Pos/Client/Txp/Network.hs +++ b/client/src/Pos/Client/Txp/Network.hs @@ -27,14 +27,13 @@ import Pos.Communication.Message () import Pos.Communication.Types (InvOrDataTK) import Pos.Core (Address, Coin, makeRedeemAddress, mkCoin, unsafeAddCoin) -import Pos.Core.Txp (TxAux (..), TxId, TxOut (..), TxOutAux (..), - txaF) +import Pos.Core.Txp (TxAux (..), TxId, TxMsgContents (..), TxOut (..), + TxOutAux (..), txaF) import Pos.Crypto (ProtocolMagic, RedeemSecretKey, SafeSigner, hash, redeemToPublic) import Pos.Infra.Communication.Protocol (OutSpecs) import Pos.Infra.Communication.Specs (createOutSpecs) import Pos.Infra.Diffusion.Types (Diffusion (sendTx)) -import Pos.Txp.Network.Types (TxMsgContents (..)) import Pos.Util.Util (eitherToThrow) import Pos.WorkMode.Class (MinWorkMode) diff --git a/core/cardano-sl-core.cabal b/core/cardano-sl-core.cabal index b510bb76385..dd406846962 100644 --- a/core/cardano-sl-core.cabal +++ b/core/cardano-sl-core.cabal @@ -144,6 +144,7 @@ library -- Txp Pos.Core.Txp.Tx Pos.Core.Txp.TxAux + Pos.Core.Txp.TxMsg Pos.Core.Txp.TxOutAux Pos.Core.Txp.TxPayload Pos.Core.Txp.TxProof diff --git a/core/src/Pos/Core/Txp.hs b/core/src/Pos/Core/Txp.hs index bc84ce024d6..0daf521c373 100644 --- a/core/src/Pos/Core/Txp.hs +++ b/core/src/Pos/Core/Txp.hs @@ -1,6 +1,7 @@ module Pos.Core.Txp ( module Pos.Core.Txp.Tx , module Pos.Core.Txp.TxAux + , module Pos.Core.Txp.TxMsg , module Pos.Core.Txp.TxOutAux , module Pos.Core.Txp.TxPayload , module Pos.Core.Txp.TxProof @@ -10,6 +11,7 @@ module Pos.Core.Txp import Pos.Core.Txp.Tx import Pos.Core.Txp.TxAux +import Pos.Core.Txp.TxMsg import Pos.Core.Txp.TxOutAux import Pos.Core.Txp.TxPayload import Pos.Core.Txp.TxProof diff --git a/txp/src/Pos/Txp/Network/Types.hs b/core/src/Pos/Core/Txp/TxMsg.hs similarity index 72% rename from txp/src/Pos/Txp/Network/Types.hs rename to core/src/Pos/Core/Txp/TxMsg.hs index 15d7921e809..e0610e33f2c 100644 --- a/txp/src/Pos/Txp/Network/Types.hs +++ b/core/src/Pos/Core/Txp/TxMsg.hs @@ -1,14 +1,13 @@ --- | Types used for communication about transactions. - -module Pos.Txp.Network.Types +module Pos.Core.Txp.TxMsg ( TxMsgContents (..) ) where -import qualified Data.Text.Buildable as Buildable -import Formatting (bprint, (%)) import Universum -import Pos.Core.Txp (TxAux (..), txaF) +import Data.Text.Buildable (Buildable (..)) +import Formatting (bprint, (%)) + +import Pos.Core.Txp.TxAux (TxAux (..), txaF) -- | Data message. Can be used to send one transaction per message. -- Transaction is sent with auxilary data. diff --git a/txp/test/Test/Pos/Txp/Arbitrary.hs b/core/test/Test/Pos/Core/Arbitrary/Txp.hs similarity index 99% rename from txp/test/Test/Pos/Txp/Arbitrary.hs rename to core/test/Test/Pos/Core/Arbitrary/Txp.hs index 120762131c9..16fc24f63c4 100644 --- a/txp/test/Test/Pos/Txp/Arbitrary.hs +++ b/core/test/Test/Pos/Core/Arbitrary/Txp.hs @@ -4,7 +4,7 @@ -- | `Arbitrary` instances for Txp types -module Test.Pos.Txp.Arbitrary +module Test.Pos.Core.Arbitrary.Txp ( BadSigsTx (..) , DoubleInputTx (..) , GoodTx (..) diff --git a/txp/test/Test/Pos/Txp/Arbitrary/Unsafe.hs b/core/test/Test/Pos/Core/Arbitrary/Txp/Unsafe.hs similarity index 88% rename from txp/test/Test/Pos/Txp/Arbitrary/Unsafe.hs rename to core/test/Test/Pos/Core/Arbitrary/Txp/Unsafe.hs index 2c60ef2f6ff..4047d88474e 100644 --- a/txp/test/Test/Pos/Txp/Arbitrary/Unsafe.hs +++ b/core/test/Test/Pos/Core/Arbitrary/Txp/Unsafe.hs @@ -2,7 +2,7 @@ -- | 'Arbitrary' unsafe instances for some types from Txp types -module Test.Pos.Txp.Arbitrary.Unsafe () where +module Test.Pos.Core.Arbitrary.Txp.Unsafe () where import Universum diff --git a/core/test/cardano-sl-core-test.cabal b/core/test/cardano-sl-core-test.cabal index 092eda1716e..62cbbeb3a03 100644 --- a/core/test/cardano-sl-core-test.cabal +++ b/core/test/cardano-sl-core-test.cabal @@ -19,6 +19,8 @@ library Test.Pos.Core.Gen Test.Pos.Core.Arbitrary Test.Pos.Core.Arbitrary.Unsafe + Test.Pos.Core.Arbitrary.Txp + Test.Pos.Core.Arbitrary.Txp.Unsafe build-depends: QuickCheck , base diff --git a/explorer/bench/Bench/Pos/Explorer/ServerBench.hs b/explorer/bench/Bench/Pos/Explorer/ServerBench.hs index 6f7c7086345..c85914ddd2f 100644 --- a/explorer/bench/Bench/Pos/Explorer/ServerBench.hs +++ b/explorer/bench/Bench/Pos/Explorer/ServerBench.hs @@ -21,7 +21,7 @@ import Pos.Explorer.Web.ClientTypes (CBlockEntry) import Pos.Explorer.Web.Server (getBlocksPage, getBlocksTotal) import Test.Pos.Configuration (withDefConfigurations) -import Test.Pos.Txp.Arbitrary.Unsafe () +import Test.Pos.Core.Arbitrary.Txp.Unsafe () ---------------------------------------------------------------- -- Mocked functions diff --git a/explorer/cardano-sl-explorer.cabal b/explorer/cardano-sl-explorer.cabal index 5aa4d84a1c3..14280f69d41 100644 --- a/explorer/cardano-sl-explorer.cabal +++ b/explorer/cardano-sl-explorer.cabal @@ -413,6 +413,7 @@ benchmark cardano-explorer-bench build-depends: QuickCheck , base , cardano-sl + , cardano-sl-core-test , cardano-sl-explorer , cardano-sl-txp , cardano-sl-txp-test diff --git a/explorer/src/Pos/Arbitrary/Explorer.hs b/explorer/src/Pos/Arbitrary/Explorer.hs index 6badcf3a3b0..66a43df12bb 100644 --- a/explorer/src/Pos/Arbitrary/Explorer.hs +++ b/explorer/src/Pos/Arbitrary/Explorer.hs @@ -11,7 +11,7 @@ import Test.QuickCheck.Arbitrary.Generic (genericArbitrary, import Pos.Explorer.Core.Types (TxExtra (..)) import Test.Pos.Core.Arbitrary () -import Test.Pos.Txp.Arbitrary () +import Test.Pos.Core.Arbitrary.Txp () instance Arbitrary TxExtra where arbitrary = genericArbitrary diff --git a/generator/cardano-sl-generator.cabal b/generator/cardano-sl-generator.cabal index f34a6524f89..573aa64258e 100644 --- a/generator/cardano-sl-generator.cabal +++ b/generator/cardano-sl-generator.cabal @@ -129,6 +129,7 @@ test-suite cardano-generator-test , cardano-sl-block , cardano-sl-block-test , cardano-sl-core + , cardano-sl-core-test , cardano-sl-crypto , cardano-sl-crypto-test , cardano-sl-db diff --git a/generator/test/Test/Pos/Block/Logic/CreationSpec.hs b/generator/test/Test/Pos/Block/Logic/CreationSpec.hs index 43ce3e00eaf..9485479e27d 100644 --- a/generator/test/Test/Pos/Block/Logic/CreationSpec.hs +++ b/generator/test/Test/Pos/Block/Logic/CreationSpec.hs @@ -36,9 +36,9 @@ import Pos.Update.Configuration (HasUpdateConfiguration) import Test.Pos.Block.Arbitrary () import Test.Pos.Configuration (withDefConfiguration, withDefUpdateConfiguration) +import Test.Pos.Core.Arbitrary.Txp (GoodTx, goodTxToTxAux) import Test.Pos.Crypto.Dummy (dummyProtocolMagic) import Test.Pos.Delegation.Arbitrary (genDlgPayload) -import Test.Pos.Txp.Arbitrary (GoodTx, goodTxToTxAux) import Test.Pos.Util.QuickCheck (SmallGenerator (..), makeSmall) spec :: Spec diff --git a/infra/src/Pos/Infra/Communication/Types/Relay.hs b/infra/src/Pos/Infra/Communication/Types/Relay.hs index 0291889495f..17b32400893 100644 --- a/infra/src/Pos/Infra/Communication/Types/Relay.hs +++ b/infra/src/Pos/Infra/Communication/Types/Relay.hs @@ -24,6 +24,7 @@ import Formatting (bprint, build, (%)) import Pos.Binary.Class (Bi (..)) import qualified Pos.Core.Update as U import Pos.Crypto (hash) +import Pos.Core.Txp (TxMsgContents (..)) import Pos.Util.Util (cborError) -- | Inventory message. Can be used to announce the fact that you have @@ -67,6 +68,10 @@ data DataMsg contents = DataMsg { dmContents :: !contents } deriving (Generic, Show, Eq) +instance Bi (DataMsg TxMsgContents) where + encode (DataMsg (TxMsgContents txAux)) = encode txAux + decode = DataMsg <$> (TxMsgContents <$> decode) + instance Bi (DataMsg U.UpdateVote) where encode = encode . dmContents decode = DataMsg <$> decode diff --git a/txp/test/Test/Pos/Txp/Arbitrary/Network.hs b/infra/test/Test/Pos/Infra/Arbitrary/Communication.hs similarity index 53% rename from txp/test/Test/Pos/Txp/Arbitrary/Network.hs rename to infra/test/Test/Pos/Infra/Arbitrary/Communication.hs index 481dd9249f3..bb9cb21eaad 100644 --- a/txp/test/Test/Pos/Txp/Arbitrary/Network.hs +++ b/infra/test/Test/Pos/Infra/Arbitrary/Communication.hs @@ -1,10 +1,11 @@ -{-# LANGUAGE TemplateHaskell #-} +{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE TemplateHaskell #-} {-# OPTIONS_GHC -fno-warn-orphans #-} --- | 'Arbitrary' instances for 'Pos.Txp.Network' types defined in 'src' +-- | 'Arbitrary' instances for 'Pos.Infra.Communication' types defined in 'src' -module Test.Pos.Txp.Arbitrary.Network () where +module Test.Pos.Infra.Arbitrary.Communication () where import Universum @@ -12,14 +13,10 @@ import Test.QuickCheck (Arbitrary (..)) import Test.QuickCheck.Arbitrary.Generic (genericArbitrary, genericShrink) +import Pos.Core.Txp (TxMsgContents (..)) import Pos.Infra.Communication.Types.Relay (DataMsg (..)) -import Pos.Txp.Network.Types (TxMsgContents (..)) -import Test.Pos.Txp.Arbitrary () - -instance Arbitrary TxMsgContents where - arbitrary = genericArbitrary - shrink = genericShrink +import Test.Pos.Infra.Arbitrary.Txp () instance Arbitrary (DataMsg TxMsgContents) where arbitrary = DataMsg <$> arbitrary diff --git a/infra/test/Test/Pos/Infra/Arbitrary/Txp.hs b/infra/test/Test/Pos/Infra/Arbitrary/Txp.hs new file mode 100644 index 00000000000..6c6ec0633df --- /dev/null +++ b/infra/test/Test/Pos/Infra/Arbitrary/Txp.hs @@ -0,0 +1,21 @@ +{-# LANGUAGE TemplateHaskell #-} + +{-# OPTIONS_GHC -fno-warn-orphans #-} + +-- | 'Arbitrary' instances for 'Pos.Infra.Communication' types defined in 'src' + +module Test.Pos.Infra.Arbitrary.Txp () where + +import Universum + +import Test.QuickCheck (Arbitrary (..)) +import Test.QuickCheck.Arbitrary.Generic (genericArbitrary, + genericShrink) + +import Pos.Core.Txp (TxMsgContents (..)) + +import Test.Pos.Core.Arbitrary.Txp () + +instance Arbitrary TxMsgContents where + arbitrary = genericArbitrary + shrink = genericShrink diff --git a/infra/test/cardano-sl-infra-test.cabal b/infra/test/cardano-sl-infra-test.cabal index 8284ef37004..136e763c5f5 100644 --- a/infra/test/cardano-sl-infra-test.cabal +++ b/infra/test/cardano-sl-infra-test.cabal @@ -14,7 +14,9 @@ cabal-version: >=1.10 library exposed-modules: Test.Pos.Infra.Arbitrary + Test.Pos.Infra.Arbitrary.Communication Test.Pos.Infra.Arbitrary.Slotting + Test.Pos.Infra.Arbitrary.Txp Test.Pos.Infra.Gen build-depends: QuickCheck diff --git a/lib/bench/Bench/Pos/Criterion/TxSigningBench.hs b/lib/bench/Bench/Pos/Criterion/TxSigningBench.hs index a165ebf3fef..6ecd52ade6c 100644 --- a/lib/bench/Bench/Pos/Criterion/TxSigningBench.hs +++ b/lib/bench/Bench/Pos/Criterion/TxSigningBench.hs @@ -12,7 +12,7 @@ import Pos.Crypto (SecretKey, SignTag (SignTx), sign) import Pos.Ssc () import Pos.Txp (TxId, TxSig, TxSigData (..)) -import Test.Pos.Txp.Arbitrary.Unsafe () +import Test.Pos.Core.Arbitrary.Txp.Unsafe () import Test.Pos.Util.QuickCheck.Arbitrary (arbitraryUnsafe) import Bench.Configuration (benchProtocolMagic) diff --git a/lib/src/Pos/Binary.hs b/lib/src/Pos/Binary.hs index 006c05bf3c4..6e3091fd193 100644 --- a/lib/src/Pos/Binary.hs +++ b/lib/src/Pos/Binary.hs @@ -8,4 +8,3 @@ module Pos.Binary import Pos.Binary.Class import Pos.Binary.Communication () import Pos.Binary.Delegation () -import Pos.Binary.Txp () diff --git a/lib/src/Pos/Communication/Limits.hs b/lib/src/Pos/Communication/Limits.hs index 716aa9a6373..d5e425325e9 100644 --- a/lib/src/Pos/Communication/Limits.hs +++ b/lib/src/Pos/Communication/Limits.hs @@ -69,13 +69,12 @@ import Pos.Core.Block (Block, BlockHeader (..), GenesisBlock, import Pos.Core.Delegation (HeavyDlgIndex (..), LightDlgIndices (..)) import Pos.Core.Ssc (Commitment (..), InnerSharesMap, Opening (..), SignedCommitment) -import Pos.Core.Txp (TxAux) +import Pos.Core.Txp (TxAux, TxMsgContents (..)) import Pos.Core.Update (UpdateProposal (..), UpdateVote (..)) import Pos.Crypto (ProxyCert (..), ProxySecretKey (..), SecretProof (..)) import Pos.Ssc.Message (MCCommitment (..), MCOpening (..), MCShares (..), MCVssCertificate (..)) -import Pos.Txp.Network.Types (TxMsgContents (..)) import Pos.Core.Chrono (NewestFirst (..)) import Pos.Crypto.Limits (mlAbstractHash, mlDecShare, mlEncShare, diff --git a/lib/src/Pos/Communication/Message.hs b/lib/src/Pos/Communication/Message.hs index 5f6d47adde8..049f0e9c5b5 100644 --- a/lib/src/Pos/Communication/Message.hs +++ b/lib/src/Pos/Communication/Message.hs @@ -12,6 +12,7 @@ import Node.Message.Class (Message (..)) import Pos.Block.Network (MsgBlock, MsgGetBlocks, MsgGetHeaders, MsgHeaders, MsgStream, MsgStreamBlock) import Pos.Core (ProxySKHeavy) +import Pos.Core.Txp (TxMsgContents) import Pos.Core.Update (UpdateProposal, UpdateVote) import Pos.Infra.Communication.Types.Protocol (MsgSubscribe, MsgSubscribe1) @@ -19,7 +20,6 @@ import Pos.Infra.Communication.Types.Relay (DataMsg, InvMsg, InvOrData, MempoolMsg, ReqMsg, ReqOrRes) import Pos.Ssc.Message (MCCommitment, MCOpening, MCShares, MCVssCertificate) -import Pos.Txp.Network.Types (TxMsgContents) -- Why? instance Message Void where diff --git a/lib/src/Pos/Communication/Types.hs b/lib/src/Pos/Communication/Types.hs index 8fbef7bfc61..6a3311fa952 100644 --- a/lib/src/Pos/Communication/Types.hs +++ b/lib/src/Pos/Communication/Types.hs @@ -4,9 +4,7 @@ module Pos.Communication.Types ( -- * Messages and socket state module Pos.Infra.Communication.Types.Protocol , module Pos.Infra.Communication.Types.Relay - , module Pos.Txp.Network.Types ) where import Pos.Infra.Communication.Types.Protocol import Pos.Infra.Communication.Types.Relay -import Pos.Txp.Network.Types diff --git a/lib/src/Pos/Diffusion/Full/Txp.hs b/lib/src/Pos/Diffusion/Full/Txp.hs index b3c47a1f2ef..34b334ac689 100644 --- a/lib/src/Pos/Diffusion/Full/Txp.hs +++ b/lib/src/Pos/Diffusion/Full/Txp.hs @@ -12,10 +12,9 @@ import qualified Network.Broadcast.OutboundQueue as OQ import Universum import Pos.Binary.Communication () -import Pos.Binary.Txp () import Pos.Communication.Limits (mlTxMsgContents) import Pos.Communication.Message () -import Pos.Core.Txp (TxAux (..), TxId) +import Pos.Core.Txp (TxAux (..), TxId, TxMsgContents (..)) import Pos.Crypto (hash) import Pos.Infra.Communication.Protocol (EnqueueMsg, MkListeners, MsgType (..), NodeId, Origin (..), OutSpecs) @@ -25,7 +24,6 @@ import Pos.Infra.Communication.Relay (InvReqDataParams (..), import Pos.Infra.Network.Types (Bucket) import Pos.Logic.Types (Logic (..)) import qualified Pos.Logic.Types as KV (KeyVal (..)) -import Pos.Txp.Network.Types (TxMsgContents (..)) import Pos.Util.Trace (Severity, Trace) -- | Send Tx to given addresses. diff --git a/lib/src/Pos/Logic/Full.hs b/lib/src/Pos/Logic/Full.hs index 8f5c23306b9..f27c0a40c7f 100644 --- a/lib/src/Pos/Logic/Full.hs +++ b/lib/src/Pos/Logic/Full.hs @@ -26,6 +26,7 @@ import Pos.Core (Block, BlockHeader, BlockVersionData, TxAux (..), addressHash, getCertId, lookupVss) import Pos.Core.Chrono (NE, NewestFirst, OldestFirst) import Pos.Core.Ssc (getCommitmentsMap) +import Pos.Core.Txp (TxMsgContents (..)) import Pos.Core.Update (UpdateProposal (..), UpdateVote (..)) import Pos.Crypto (ProtocolMagic, hash) import qualified Pos.DB.Block as DB (getTipBlock) @@ -55,7 +56,6 @@ import Pos.Txp (MemPool (..)) import Pos.Txp.MemState (getMemPool, withTxpLocalData) import Pos.Txp.Network.Listeners (TxpMode) import qualified Pos.Txp.Network.Listeners as Txp (handleTxDo) -import Pos.Txp.Network.Types (TxMsgContents (..)) import qualified Pos.Update.Logic.Local as Update (getLocalProposalNVotes, getLocalVote, isProposalNeeded, isVoteNeeded) import Pos.Update.Mode (UpdateMode) diff --git a/lib/src/Pos/Logic/Types.hs b/lib/src/Pos/Logic/Types.hs index a0b650a9f9f..6be2fbf84a9 100644 --- a/lib/src/Pos/Logic/Types.hs +++ b/lib/src/Pos/Logic/Types.hs @@ -19,11 +19,11 @@ import Pipes.Internal (unsafeHoist) import Pos.Block.Logic (GetHashesRangeError, GetHeadersFromManyToError) -import Pos.Communication (NodeId, TxMsgContents) +import Pos.Communication (NodeId) import Pos.Core (HeaderHash, ProxySKHeavy, StakeholderId) import Pos.Core.Block (Block, BlockHeader) import Pos.Core.Chrono (NE, NewestFirst, OldestFirst (..)) -import Pos.Core.Txp (TxId) +import Pos.Core.Txp (TxId, TxMsgContents) import Pos.Core.Update (BlockVersionData, UpId, UpdateProposal, UpdateVote, VoteId) import Pos.DB.Class (SerializedBlock) diff --git a/lib/test/Test/Pos/Cbor/CborSpec.hs b/lib/test/Test/Pos/Cbor/CborSpec.hs index 2bfdfc8a7e2..de4182b93c7 100644 --- a/lib/test/Test/Pos/Cbor/CborSpec.hs +++ b/lib/test/Test/Pos/Cbor/CborSpec.hs @@ -28,6 +28,7 @@ import Pos.Communication.Limits (mlOpening, mlUpdateVote, mlVssCertificate) import Pos.Core (ProxySKHeavy, StakeholderId, VssCertificate) import qualified Pos.Core.Ssc as Ssc +import Pos.Core.Txp (TxMsgContents (..)) import Pos.Crypto.Signing (EncryptedSecretKey) import Pos.Delegation (DlgPayload, DlgUndo) import Pos.Infra.Binary () @@ -49,8 +50,8 @@ import Test.Pos.Core.Arbitrary () import Test.Pos.Crypto.Arbitrary () import Test.Pos.Delegation.Arbitrary () import Test.Pos.Infra.Arbitrary () +import Test.Pos.Infra.Arbitrary.Communication () import Test.Pos.Infra.Arbitrary.Slotting () -import Test.Pos.Txp.Arbitrary.Network () import Test.Pos.Update.Arbitrary () import Test.Pos.Util.QuickCheck (SmallGenerator) @@ -148,17 +149,17 @@ spec = withDefConfiguration $ \_ -> do binaryTest @(SmallGenerator T.TxPayload) binaryTest @T.TxpUndo describe "Network" $ do - binaryTest @(R.InvMsg (Tagged T.TxMsgContents T.TxId)) - binaryTest @(R.ReqMsg (Tagged T.TxMsgContents T.TxId)) - binaryTest @(R.MempoolMsg T.TxMsgContents) - binaryTest @(R.DataMsg T.TxMsgContents) + binaryTest @(R.InvMsg (Tagged TxMsgContents T.TxId)) + binaryTest @(R.ReqMsg (Tagged TxMsgContents T.TxId)) + binaryTest @(R.MempoolMsg TxMsgContents) + binaryTest @(R.DataMsg TxMsgContents) describe "Bi extension" $ do prop "TxInWitness" (extensionProperty @T.TxInWitness) describe "Message length limit" $ do - msgLenLimitedTest @(R.InvMsg (Tagged T.TxMsgContents T.TxId)) mlInvMsg - msgLenLimitedTest @(R.ReqMsg (Tagged T.TxMsgContents T.TxId)) mlReqMsg - msgLenLimitedTest @(R.MempoolMsg T.TxMsgContents) mlMempoolMsg - -- No check for (DataMsg T.TxMsgContents) since overal message size + msgLenLimitedTest @(R.InvMsg (Tagged TxMsgContents T.TxId)) mlInvMsg + msgLenLimitedTest @(R.ReqMsg (Tagged TxMsgContents T.TxId)) mlReqMsg + msgLenLimitedTest @(R.MempoolMsg TxMsgContents) mlMempoolMsg + -- No check for (DataMsg TxMsgContents) since overal message size -- is forcely limited describe "Update system" $ do describe "Bi instances" $ do diff --git a/lib/test/Test/Pos/Types/Identity/SafeCopySpec.hs b/lib/test/Test/Pos/Types/Identity/SafeCopySpec.hs index 9a924c11543..e9eef07cb17 100644 --- a/lib/test/Test/Pos/Types/Identity/SafeCopySpec.hs +++ b/lib/test/Test/Pos/Types/Identity/SafeCopySpec.hs @@ -13,8 +13,8 @@ import qualified Pos.Core.Txp as Txp import Test.Pos.Binary.Helpers (safeCopyTest) import Test.Pos.Configuration (withDefConfiguration) -import Test.Pos.Txp.Arbitrary () -import Test.Pos.Txp.Arbitrary.Network () +import Test.Pos.Core.Arbitrary.Txp () +import Test.Pos.Infra.Arbitrary.Txp () spec :: Spec spec = withDefConfiguration $ \_ -> describe "Types" $ do diff --git a/pkgs/default.nix b/pkgs/default.nix index af1fa720e0b..3b8f1bf784f 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -16582,6 +16582,7 @@ cpphs benchmarkHaskellDepends = [ base cardano-sl +cardano-sl-core-test cardano-sl-txp cardano-sl-txp-test criterion @@ -16608,6 +16609,7 @@ license = stdenv.lib.licenses.mit; , cardano-sl-block-test , cardano-sl-client , cardano-sl-core +, cardano-sl-core-test , cardano-sl-crypto , cardano-sl-crypto-test , cardano-sl-db @@ -16710,6 +16712,7 @@ cardano-sl-binary cardano-sl-block cardano-sl-block-test cardano-sl-core +cardano-sl-core-test cardano-sl-crypto cardano-sl-crypto-test cardano-sl-db @@ -17423,6 +17426,7 @@ license = stdenv.lib.licenses.mit; , cardano-sl-block , cardano-sl-client , cardano-sl-core +, cardano-sl-core-test , cardano-sl-crypto , cardano-sl-db , cardano-sl-infra @@ -17518,6 +17522,7 @@ cardano-sl-binary cardano-sl-block cardano-sl-client cardano-sl-core +cardano-sl-core-test cardano-sl-crypto cardano-sl-db cardano-sl-infra @@ -18594,6 +18599,7 @@ cardano-sl cardano-sl-block cardano-sl-client cardano-sl-core +cardano-sl-core-test cardano-sl-crypto cardano-sl-db cardano-sl-delegation diff --git a/tools/cardano-sl-tools.cabal b/tools/cardano-sl-tools.cabal index abfa8cea8d6..33c8b944db8 100644 --- a/tools/cardano-sl-tools.cabal +++ b/tools/cardano-sl-tools.cabal @@ -49,6 +49,7 @@ executable dbgen , cardano-sl-block , cardano-sl-client , cardano-sl-core + , cardano-sl-core-test , cardano-sl-db , cardano-sl-infra , cardano-sl-networking diff --git a/tools/src/dbgen/Lib.hs b/tools/src/dbgen/Lib.hs index dbeb12b0a97..f8a4e1624f0 100644 --- a/tools/src/dbgen/Lib.hs +++ b/tools/src/dbgen/Lib.hs @@ -53,7 +53,7 @@ import CLI (CLI (..)) import Rendering (green, renderAccountId, say) import Types (UberMonad) -import Test.Pos.Txp.Arbitrary () +import Test.Pos.Core.Arbitrary.Txp () -- -- Types diff --git a/txp/cardano-sl-txp.cabal b/txp/cardano-sl-txp.cabal index ecb8c56e338..1a4dcd60518 100644 --- a/txp/cardano-sl-txp.cabal +++ b/txp/cardano-sl-txp.cabal @@ -40,7 +40,6 @@ library Pos.Txp.Logic.Local Pos.Txp.Network - Pos.Txp.Network.Types Pos.Txp.Network.Listeners Pos.Txp.MemState @@ -61,9 +60,6 @@ library Pos.Aeson.Txp - Pos.Binary.Txp - Pos.Binary.Txp.Network - build-depends: aeson , base , bytestring @@ -147,8 +143,7 @@ test-suite test type: exitcode-stdio-1.0 hs-source-dirs: test main-is: Test.hs - other-modules: Test.Pos.Txp.Arbitrary - Test.Pos.Txp.CoreSpec + other-modules: Test.Pos.Txp.CoreSpec Test.Pos.Txp.Toil.UtxoSpec build-depends: base , cardano-sl-binary diff --git a/txp/src/Pos/Binary/Txp.hs b/txp/src/Pos/Binary/Txp.hs deleted file mode 100644 index 1e2ca78acf1..00000000000 --- a/txp/src/Pos/Binary/Txp.hs +++ /dev/null @@ -1,9 +0,0 @@ --- | Binary serialization of Txp types. -{-# OPTIONS_GHC -Wno-unused-imports #-} -{-# OPTIONS_GHC -Wno-dodgy-exports #-} - -module Pos.Binary.Txp - ( module Pos.Binary.Txp.Network - ) where - -import Pos.Binary.Txp.Network diff --git a/txp/src/Pos/Binary/Txp/Network.hs b/txp/src/Pos/Binary/Txp/Network.hs deleted file mode 100644 index 4672e576f37..00000000000 --- a/txp/src/Pos/Binary/Txp/Network.hs +++ /dev/null @@ -1,21 +0,0 @@ -{-# OPTIONS_GHC -fno-warn-orphans #-} - --- | Binary serialization of network Txp types. - -module Pos.Binary.Txp.Network - ( - ) where - -import Universum - -import Pos.Binary.Class (Bi (..)) -import Pos.Infra.Communication.Types.Relay (DataMsg (..)) -import Pos.Txp.Network.Types (TxMsgContents (..)) - ----------------------------------------------------------------------------- --- Network ----------------------------------------------------------------------------- - -instance Bi (DataMsg TxMsgContents) where - encode (DataMsg (TxMsgContents txAux)) = encode txAux - decode = DataMsg <$> (TxMsgContents <$> decode) diff --git a/txp/src/Pos/Txp.hs b/txp/src/Pos/Txp.hs index 4d697ddfaa2..46363e35622 100644 --- a/txp/src/Pos/Txp.hs +++ b/txp/src/Pos/Txp.hs @@ -14,7 +14,6 @@ module Pos.Txp , module Pos.Txp.GenesisUtxo ) where -import Pos.Binary.Txp () import Pos.Core.Txp import Pos.Txp.Base import Pos.Txp.Configuration diff --git a/txp/src/Pos/Txp/Network.hs b/txp/src/Pos/Txp/Network.hs index c261f88c071..9df02e7f3e0 100644 --- a/txp/src/Pos/Txp/Network.hs +++ b/txp/src/Pos/Txp/Network.hs @@ -1,9 +1,7 @@ -- | Txp communication layer re-exports. module Pos.Txp.Network - ( module Pos.Txp.Network.Types - , module Pos.Txp.Network.Listeners + ( module Pos.Txp.Network.Listeners ) where import Pos.Txp.Network.Listeners -import Pos.Txp.Network.Types diff --git a/txp/src/Pos/Txp/Network/Listeners.hs b/txp/src/Pos/Txp/Network/Listeners.hs index 0ce3f6dc39c..bf9104e0237 100644 --- a/txp/src/Pos/Txp/Network/Listeners.hs +++ b/txp/src/Pos/Txp/Network/Listeners.hs @@ -18,14 +18,12 @@ import Node.Message.Class (Message) import System.Wlog (WithLogger, logInfo) import Universum -import Pos.Binary.Txp () -import Pos.Core.Txp (TxAux (..), TxId) +import Pos.Core.Txp (TxAux (..), TxId, TxMsgContents (..)) import Pos.Crypto (ProtocolMagic, hash) import qualified Pos.Infra.Communication.Relay as Relay import Pos.Infra.Util.JsonLog.Events (JLEvent (..), JLTxR (..)) import Pos.Txp.MemState (MempoolExt, MonadTxpLocal, MonadTxpMem, txpProcessTx) -import Pos.Txp.Network.Types (TxMsgContents (..)) -- Real tx processing -- CHECK: @handleTxDo diff --git a/txp/test/Test/Pos/Txp/CoreSpec.hs b/txp/test/Test/Pos/Txp/CoreSpec.hs index 5f533e7ae5b..f1590459fb9 100644 --- a/txp/test/Test/Pos/Txp/CoreSpec.hs +++ b/txp/test/Test/Pos/Txp/CoreSpec.hs @@ -25,7 +25,7 @@ import Pos.Data.Attributes (mkAttributes) import Pos.Txp.Topsort (topsortTxs) import Pos.Util (_neHead) -import Test.Pos.Txp.Arbitrary () +import Test.Pos.Core.Arbitrary.Txp () import Test.Pos.Util.QuickCheck.Arbitrary (sublistN) spec :: Spec diff --git a/txp/test/Test/Pos/Txp/Toil/UtxoSpec.hs b/txp/test/Test/Pos/Txp/Toil/UtxoSpec.hs index 5de01f09c43..d838c81d853 100644 --- a/txp/test/Test/Pos/Txp/Toil/UtxoSpec.hs +++ b/txp/test/Test/Pos/Txp/Toil/UtxoSpec.hs @@ -39,8 +39,8 @@ import Pos.Txp (ToilVerFailure (..), Utxo, VTxContext (..), evalUtxoM, execUtxoM, utxoGet, utxoToLookup, verifyTxUtxo) import qualified Pos.Util.Modifier as MM -import Test.Pos.Txp.Arbitrary (BadSigsTx (..), DoubleInputTx (..), - GoodTx (..)) +import Test.Pos.Core.Arbitrary.Txp (BadSigsTx (..), + DoubleInputTx (..), GoodTx (..)) import Test.Pos.Util.QuickCheck.Arbitrary (SmallGenerator (..), nonrepeating, runGen) import Test.Pos.Util.QuickCheck.Property (qcIsLeft, qcIsRight) diff --git a/txp/test/cardano-sl-txp-test.cabal b/txp/test/cardano-sl-txp-test.cabal index a8f235fd53e..3fbdd019979 100644 --- a/txp/test/cardano-sl-txp-test.cabal +++ b/txp/test/cardano-sl-txp-test.cabal @@ -13,9 +13,6 @@ cabal-version: >=1.10 library exposed-modules: - Test.Pos.Txp.Arbitrary - Test.Pos.Txp.Arbitrary.Network - Test.Pos.Txp.Arbitrary.Unsafe build-depends: QuickCheck , base diff --git a/wallet-new/cardano-sl-wallet-new.cabal b/wallet-new/cardano-sl-wallet-new.cabal index e4b91a62db5..08bbbac4f48 100755 --- a/wallet-new/cardano-sl-wallet-new.cabal +++ b/wallet-new/cardano-sl-wallet-new.cabal @@ -447,6 +447,7 @@ test-suite wallet-unit-tests , cardano-sl-block , cardano-sl-client , cardano-sl-core + , cardano-sl-core-test , cardano-sl-crypto , cardano-sl-db , cardano-sl-delegation diff --git a/wallet-new/test/unit/Test/Spec/Submission.hs b/wallet-new/test/unit/Test/Spec/Submission.hs index 5ace72b4429..407c24802c4 100644 --- a/wallet-new/test/unit/Test/Spec/Submission.hs +++ b/wallet-new/test/unit/Test/Spec/Submission.hs @@ -31,7 +31,7 @@ import Pos.Crypto.Hashing (hash) import Pos.Crypto.Signing (deterministicKeyGen) import Pos.Data.Attributes (Attributes (..), UnparsedFields (..)) import Serokell.Util.Text (listJsonIndent) -import qualified Test.Pos.Txp.Arbitrary as Core +import qualified Test.Pos.Core.Arbitrary.Txp as Core import Cardano.Wallet.Kernel.Util (disjoint) import Test.QuickCheck (Gen, Property, arbitrary, choose, conjoin, diff --git a/wallet/test/Test/Pos/Wallet/MigrationSpec.hs b/wallet/test/Test/Pos/Wallet/MigrationSpec.hs index 560acc97e1d..a36c7349d40 100644 --- a/wallet/test/Test/Pos/Wallet/MigrationSpec.hs +++ b/wallet/test/Test/Pos/Wallet/MigrationSpec.hs @@ -32,7 +32,7 @@ import Pos.Wallet.Web.State.State (askWalletSnapshot) import Pos.Wallet.Web.State.Storage import Test.Pos.Core.Arbitrary () -import Test.Pos.Txp.Arbitrary () +import Test.Pos.Core.Arbitrary.Txp () -------------------------------------------------------------------------------- -- Reverse migrations diff --git a/wallet/test/Test/Pos/Wallet/Web/Util.hs b/wallet/test/Test/Pos/Wallet/Web/Util.hs index e8ad0be90fd..55841f8561d 100644 --- a/wallet/test/Test/Pos/Wallet/Web/Util.hs +++ b/wallet/test/Test/Pos/Wallet/Web/Util.hs @@ -64,7 +64,7 @@ import Pos.Infra.Util.JsonLog.Events (MemPoolModifyReason (ApplyBlock)) import Test.Pos.Block.Logic.Util (EnableTxPayload, InplaceDB, genBlockGenParams) -import Test.Pos.Txp.Arbitrary () +import Test.Pos.Core.Arbitrary.Txp () import Test.Pos.Util.QuickCheck.Property (assertProperty, maybeStopProperty) import Test.Pos.Wallet.Web.Mode (WalletProperty)