packages feed

cleveland-0.1.0: test/TestSuite/Cleveland/WithMoneybag.hs

-- SPDX-FileCopyrightText: 2021 Tocqueville Group
--
-- SPDX-License-Identifier: LicenseRef-MIT-TQ

module TestSuite.Cleveland.WithMoneybag
  ( test_withMoneybag
  ) where

import Test.Tasty

import Test.Cleveland

test_withMoneybag :: TestTree
test_withMoneybag =
  testScenario "withMoneybag overrides the funder of new accounts" $ scenario do
    newMoneybag <- newFreshAddress "newMoneybag"
    transferMoney newMoneybag 4_e6

    -- At the end of this test, we want to check that `newAddress` transfers funds from "newMoneybag" to "testAccount".
    -- However, this will only happen if:
    --   1. the "testAccount" alias is not yet known to tezos-client
    --   2. or, it is known, but it has less than 0.5 XTZ.
    -- We use `newFreshAddress` here to ensure "testAccount" is a known alias with 0 XTZ.
    _ <- newFreshAddress "testAccount"

    -- Check that "testAccount" was funded with "newMoneybag"'s tez.
    b0 <- getBalance newMoneybag
    withMoneybag newMoneybag $ newAddress "testAccount"
    b1 <- getBalance newMoneybag
    checkCompares b1 (<) b0