diff --git a/lib/core/src/Cardano/Wallet.hs b/lib/core/src/Cardano/Wallet.hs index 5f465987d1a..3139be77bc1 100644 --- a/lib/core/src/Cardano/Wallet.hs +++ b/lib/core/src/Cardano/Wallet.hs @@ -546,7 +546,7 @@ newWalletLayer -> BlockHeader -> IO () restoreSleep t wid slot = - let halfSlotLengthDelay = fromIntegral $ (diffTimeToPicoseconds slotLength `div` 500000) in do + let halfSlotLengthDelay = fromIntegral (diffTimeToPicoseconds slotLength `div` 2000000) in do threadDelay halfSlotLengthDelay runExceptT (networkTip nw) >>= \case Left e -> do diff --git a/lib/jormungandr/cardano-wallet-jormungandr.cabal b/lib/jormungandr/cardano-wallet-jormungandr.cabal index 55ad8b1c9ab..3ae16c1340b 100644 --- a/lib/jormungandr/cardano-wallet-jormungandr.cabal +++ b/lib/jormungandr/cardano-wallet-jormungandr.cabal @@ -96,6 +96,7 @@ test-suite unit , QuickCheck , text , text-class + , time , transformers build-tools: hspec-discover diff --git a/lib/jormungandr/test/integration/Main.hs b/lib/jormungandr/test/integration/Main.hs index 37eb302f715..19fd0893498 100644 --- a/lib/jormungandr/test/integration/Main.hs +++ b/lib/jormungandr/test/integration/Main.hs @@ -36,14 +36,12 @@ import Cardano.Wallet.Jormungandr.Compatibility ( Jormungandr, Network (..) ) import Cardano.Wallet.Jormungandr.Network ( BaseUrl (..), JormungandrLayer (..), Scheme (..), mkJormungandrLayer ) -import Cardano.Wallet.Jormungandr.Primitive.Types - ( Tx (..) ) import Cardano.Wallet.Network ( NetworkLayer (..), defaultRetryPolicy, waitForConnection ) import Cardano.Wallet.Primitive.Fee ( FeePolicy (..) ) import Cardano.Wallet.Primitive.Types - ( Block (..), Hash (..), SlotLength ) + ( Hash (..) ) import Cardano.Wallet.Unsafe ( unsafeFromHex, unsafeRunExceptT ) import Control.Concurrent @@ -182,7 +180,8 @@ cardanoWalletServer cardanoWalletServer mlisten = do logConfig <- CM.empty tracer <- initTracer Info "serve" - (nl, bp) <- newNetworkLayer jormungandrUrl block0H + (nl, bp@(BlockchainParameters _ feePolicy _) ) <- + newNetworkLayer jormungandrUrl block0H (sqlCtx, db) <- Sqlite.newDBLayer @_ @network logConfig tracer Nothing mvar <- newEmptyMVar handle <- async $ do @@ -206,17 +205,15 @@ cardanoWalletServer mlisten = do newNetworkLayer :: BaseUrl -> Hash "Genesis" - -> IO (NetworkLayer (Jormungandr n) IO, Block Tx, FeePolicy, SlotLength) + -> IO (NetworkLayer (Jormungandr n) IO, BlockchainParameters (Jormungandr n)) newNetworkLayer url block0H = do mgr <- newManager defaultManagerSettings let jormungandr = mkJormungandrLayer mgr url let nl = Jormungandr.mkNetworkLayer jormungandr waitForConnection nl defaultRetryPolicy - block0 <- unsafeRunExceptT $ - getBlock jormungandr (coerce block0H) - (feePolicy, slotLength) <- unsafeRunExceptT $ + blockchainParams <- unsafeRunExceptT $ getInitialBlockchainParameters jormungandr (coerce block0H) - return (nl, block0, feePolicy, slotLength) + return (nl, blockchainParams) mkFeeEstimator :: FeePolicy -> TxDescription -> (Natural, Natural) mkFeeEstimator policy (TxDescription nInps nOuts) = diff --git a/lib/jormungandr/test/unit/Cardano/Wallet/Jormungandr/BinarySpec.hs b/lib/jormungandr/test/unit/Cardano/Wallet/Jormungandr/BinarySpec.hs index d17798d4bf1..e095ad1f0d1 100644 --- a/lib/jormungandr/test/unit/Cardano/Wallet/Jormungandr/BinarySpec.hs +++ b/lib/jormungandr/test/unit/Cardano/Wallet/Jormungandr/BinarySpec.hs @@ -64,6 +64,8 @@ import Data.Proxy ( Proxy (..) ) import Data.Quantity ( Quantity (..) ) +import Data.Time.Clock + ( secondsToDiffTime ) import Data.Word ( Word8 ) import GHC.Generics @@ -120,7 +122,7 @@ spec = do , Discrimination Testnet , Consensus BFT , SlotsPerEpoch (Quantity 2160) - , SlotDuration (Quantity 15) + , SlotDuration (secondsToDiffTime 15) , EpochStabilityDepth (Quantity 10) , AddBftLeader $ LeaderId $ unsafeFromHex "30a694b80dbba2d1b8a4b55652b03d96\ @@ -173,7 +175,7 @@ spec = do , Discrimination Mainnet , Consensus BFT , SlotsPerEpoch (Quantity 500) - , SlotDuration (Quantity 10) + , SlotDuration (secondsToDiffTime 10) , EpochStabilityDepth (Quantity 10) , AddBftLeader $ LeaderId $ unsafeFromHex "b216ee388fc25596cf43fbca815c463c\ diff --git a/nix/.stack.nix/cardano-wallet-jormungandr.nix b/nix/.stack.nix/cardano-wallet-jormungandr.nix index 70b54f944ac..02b11fe4855 100644 --- a/nix/.stack.nix/cardano-wallet-jormungandr.nix +++ b/nix/.stack.nix/cardano-wallet-jormungandr.nix @@ -65,6 +65,7 @@ (hsPkgs.QuickCheck) (hsPkgs.text) (hsPkgs.text-class) + (hsPkgs.time) (hsPkgs.transformers) ]; build-tools = [ @@ -113,4 +114,4 @@ }; }; }; - } // rec { src = (pkgs.lib).mkDefault ../.././lib/jormungandr; } \ No newline at end of file + } // rec { src = (pkgs.lib).mkDefault ../.././lib/jormungandr; }