packages feed

cleveland-0.2.0: test/TestSuite/Cleveland/EmptyImplicitAddress.hs

-- SPDX-FileCopyrightText: 2022 Oxhead Alpha
-- SPDX-License-Identifier: LicenseRef-MIT-OA

-- | Calls from empty implicit addresses are disallowed
module TestSuite.Cleveland.EmptyImplicitAddress
  ( test_EmptyImplicitAddressCalls
  , test_EmptyImplicitAddressTransfers
  ) where

import Test.Tasty (TestTree)

import Test.Cleveland

import TestSuite.Util

test_EmptyImplicitAddressCalls :: TestTree
test_EmptyImplicitAddressCalls =
  testScenario "Calling a contract with empty implicit address fails" $ scenario do
    addr <- newFreshAddress auto
    contract <- originateSimple "contract" () $ idContract @() @()
    call contract CallDefault ()
      & withSender addr
      & shouldFailWithMessage "Empty implicit contract"

test_EmptyImplicitAddressTransfers :: TestTree
test_EmptyImplicitAddressTransfers =
  testScenario "Transferring from empty implicit address fails" $ scenario do
    addr <- newFreshAddress auto
    recvr <- newAddress auto
    transferMoney recvr 0
      & withSender addr
      & shouldFailWithMessage "Empty implicit contract"