Skip to content

Commit

Permalink
Update deposit wallet pure specs to include a slot to time resolver
Browse files Browse the repository at this point in the history
  • Loading branch information
paolino committed Nov 1, 2024
1 parent 3eea066 commit 26a78e4
Showing 1 changed file with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ import Cardano.Crypto.Wallet
, generate
, toXPub
)
import Cardano.Wallet.Deposit.Pure.API.TxHistory
( ResolveSlot
)
import Cardano.Wallet.Deposit.Time
( unsafeUTCTimeOfSlot
)
import Data.Ord
( Down (..)
)
import Test.Hspec
( Spec
, describe
Expand All @@ -37,6 +46,9 @@ import qualified Data.ByteString.Char8 as B8
import qualified Data.Map.Strict as Map
import qualified Data.Set as Set

resolveSlot :: ResolveSlot
resolveSlot = fmap Down . unsafeUTCTimeOfSlot

spec :: Spec
spec = do
describe "UTxO availableBalance" $ do
Expand All @@ -59,11 +71,11 @@ prop_availableBalance_rollForward_twice =
tx1 = payFromFaucet [(addr1, Write.mkAda 1)]
block1 = Read.mockNextBlock Read.GenesisPoint [tx1]
chainPoint1 = Read.getChainPoint block1
w1 = Wallet.rollForwardOne (Read.EraValue block1) w0
w1 = Wallet.rollForwardOne resolveSlot (Read.EraValue block1) w0

tx2 = payFromFaucet [(addr2, Write.mkAda 2)]
block2 = Read.mockNextBlock chainPoint1 [tx2]
w2 = Wallet.rollForwardOne (Read.EraValue block2) w1
w2 = Wallet.rollForwardOne resolveSlot (Read.EraValue block2) w1

prop_availableBalance_rollForward_rollBackward :: Property
prop_availableBalance_rollForward_rollBackward =
Expand All @@ -89,17 +101,17 @@ prop_availableBalance_rollForward_rollBackward =

tx1 = payFromFaucet [(addr1, Write.mkAda 1)]
block1 = Read.mockNextBlock chainPoint0 [tx1]
w1 = Wallet.rollForwardOne (Read.EraValue block1) w0
w1 = Wallet.rollForwardOne resolveSlot (Read.EraValue block1) w0
chainPoint1 = Read.getChainPoint block1

tx2 = payFromFaucet [(addr2, Write.mkAda 2)]
block2 = Read.mockNextBlock chainPoint1 [tx2]
chainPoint2 = Read.getChainPoint block2
w2 = Wallet.rollForwardOne (Read.EraValue block2) w1
w2 = Wallet.rollForwardOne resolveSlot (Read.EraValue block2) w1

tx3 = spendOneTxOut (Wallet.availableUTxO w2)
block3 = Read.mockNextBlock chainPoint2 [tx3]
w3 = Wallet.rollForwardOne (Read.EraValue block3) w2
w3 = Wallet.rollForwardOne resolveSlot (Read.EraValue block3) w2

emptyWalletWith17Addresses :: Wallet.WalletState
emptyWalletWith17Addresses =
Expand Down

0 comments on commit 26a78e4

Please sign in to comment.