Skip to content

Commit

Permalink
final fix
Browse files Browse the repository at this point in the history
fix jormungandr unit tests

hlint
  • Loading branch information
paweljakubas committed Jul 12, 2019
1 parent cd7e11a commit 7cbdc6a
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion lib/core/src/Cardano/Wallet.hs
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions lib/jormungandr/cardano-wallet-jormungandr.cabal
Expand Up @@ -96,6 +96,7 @@ test-suite unit
, QuickCheck
, text
, text-class
, time
, transformers
build-tools:
hspec-discover
Expand Down
15 changes: 6 additions & 9 deletions lib/jormungandr/test/integration/Main.hs
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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) =
Expand Down
Expand Up @@ -64,6 +64,8 @@ import Data.Proxy
( Proxy (..) )
import Data.Quantity
( Quantity (..) )
import Data.Time.Clock
( secondsToDiffTime )
import Data.Word
( Word8 )
import GHC.Generics
Expand Down Expand Up @@ -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\
Expand Down Expand Up @@ -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\
Expand Down
3 changes: 2 additions & 1 deletion nix/.stack.nix/cardano-wallet-jormungandr.nix

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7cbdc6a

Please sign in to comment.