Skip to content

Commit

Permalink
upgrade tests
Browse files Browse the repository at this point in the history
  • Loading branch information
martyall committed Sep 14, 2023
1 parent 5878801 commit 752fc08
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 31 deletions.
1 change: 0 additions & 1 deletion src/Network/Ethereum/Web3/Solidity/AbiEncoding.purs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import Data.Either (Either)
import Data.Functor.Tagged (Tagged, tagged, untagged)
import Data.Maybe (fromJust, maybe)
import Data.Reflectable (class Reflectable, reflectType)
import Data.String (splitAt)
import Data.Traversable (for, scanl)
import Data.Tuple (Tuple(..))
import Data.Unfoldable (replicateA)
Expand Down
2 changes: 1 addition & 1 deletion test/web3/Web3Spec/Encoding/ContainersSpec.purs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Web3Spec.Encoding.ContainersSpec (spec) where
module Web3Spec.Encoding.ContainersSpec (spec, BMPString(..)) where

import Prelude

Expand Down
30 changes: 1 addition & 29 deletions test/web3/Web3Spec/Live/Utils.purs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ module Web3Spec.Live.Utils
, joinWeb3Fork
, nullAddress
, pollTransactionReceipt
, takeEvent
) where

import Prelude
Expand All @@ -17,20 +16,16 @@ import Data.Either (Either(..))
import Data.Lens ((?~))
import Data.Maybe (fromJust)
import Data.Traversable (intercalate)
import Data.Tuple (Tuple(..))
import Effect.Aff (Aff, Milliseconds(..), Fiber, joinFiber, delay)
import Effect.Aff.AVar as AVar
import Effect.Aff.Class (class MonadAff, liftAff)
import Effect.Class.Console as C
import Network.Ethereum.Core.BigNumber (decimal, fromStringAs)
import Network.Ethereum.Core.Signatures (mkAddress)
import Network.Ethereum.Web3 (class EventFilter, Address, BigNumber, EventAction(..), HexString, Provider, TransactionOptions, TransactionReceipt(..), TransactionStatus(..), Web3, Web3Error, _gas, defaultTransactionOptions, event, eventFilter, forkWeb3', mkHexString, runWeb3)
import Network.Ethereum.Web3 (Address, BigNumber, HexString, Provider, TransactionOptions, TransactionReceipt(..), TransactionStatus(..), Web3, Web3Error, _gas, defaultTransactionOptions, mkHexString, runWeb3)
import Network.Ethereum.Web3.Api as Api
import Network.Ethereum.Web3.Solidity (class DecodeEvent)
import Network.Ethereum.Web3.Types (NoPay)
import Partial.Unsafe (unsafeCrashWith, unsafePartial)
import Test.Spec (ComputationType(..), SpecT, hoistSpec)
import Type.Proxy (Proxy)

type Logger m = String -> m Unit

Expand All @@ -44,29 +39,6 @@ go =
in
runReaderT m \logMsg -> C.log $ prefix <> "| " <> logMsg

-- | Run a `Web3` action which will dispatch a single event, wait for the event,
-- | then return the action's result and the event.
takeEvent
:: forall a ev i ni
. DecodeEvent i ni ev
=> Show ev
=> EventFilter ev
=> Proxy ev
-> Address
-> Web3 a
-> Web3 (Tuple a ev)
takeEvent prx addrs web3Action = do
var <- liftAff AVar.empty
_ <-
forkWeb3' do
event (eventFilter prx addrs)
$ \e -> do
_ <- liftAff $ AVar.put e var
pure TerminateEvent
efRes <- web3Action
event <- liftAff $ AVar.take var
pure $ Tuple efRes event

-- | Assert the `Web3` action's result, crash the program if it doesn't succeed.
assertWeb3
:: forall m a
Expand Down

0 comments on commit 752fc08

Please sign in to comment.