-
Notifications
You must be signed in to change notification settings - Fork 51
/
Integration.purs
89 lines (83 loc) · 3.31 KB
/
Integration.purs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
module Test.Ctl.Integration (main, testPlan, stakingSuite) where
import Prelude
import Cardano.AsCbor (decodeCbor)
import Contract.Address (Ed25519KeyHash)
import Contract.Backend.Ogmios (getPoolParameters)
import Contract.Config (testnetConfig)
import Contract.Monad (runContract)
import Contract.Prim.ByteArray (hexToByteArrayUnsafe)
import Contract.Staking (getPoolIds, getPubKeyHashDelegationsAndRewards)
import Contract.Test (ContractTest, noWallet)
import Contract.Test.Mote (TestPlanM, interpretWithConfig)
import Contract.Test.Utils (exitCode, interruptOnSignal)
import Contract.Time (getEraSummaries, getSystemStart)
import Ctl.Internal.Contract.Monad (wrapQueryM)
import Data.Maybe (Maybe(Just, Nothing), fromJust)
import Data.Newtype (wrap)
import Data.Posix.Signal (Signal(SIGINT))
import Data.Time.Duration (Milliseconds(Milliseconds))
import Data.Traversable (traverse)
import Effect (Effect)
import Effect.Aff (Aff, cancelWith, effectCanceler, launchAff)
import Effect.Class (liftEffect)
import Mote (group, skip, test)
import Mote.Monad (mapTest)
import Partial.Unsafe (unsafePartial)
import Test.Ctl.BalanceTx.Collateral as Collateral
import Test.Ctl.BalanceTx.Time as BalanceTx.Time
import Test.Ctl.Fixtures (ed25519KeyHash1)
import Test.Ctl.Logging as Logging
import Test.Ctl.PrivateKey as PrivateKey
import Test.Ctl.QueryM.AffInterface as QueryM.AffInterface
import Test.Ctl.Types.Interval as Types.Interval
import Test.Spec.Assertions (shouldEqual)
import Test.Spec.Runner (defaultConfig)
-- Run with `spago test --main Test.Ctl.Integration`
main :: Effect Unit
main = interruptOnSignal SIGINT =<< launchAff do
flip cancelWith (effectCanceler (exitCode 1)) do
interpretWithConfig
defaultConfig { timeout = Just $ Milliseconds 450_000.0, exit = true }
testPlan
-- Requires external services listed in README.md
testPlan :: TestPlanM (Aff Unit) Unit
testPlan = do
mapTest runQueryM' QueryM.AffInterface.suite
-- These tests depend on assumptions about testnet history.
-- We disabled them during transition from `testnet` to `preprod` networks.
-- https://github.com/Plutonomicon/cardano-transaction-lib/issues/945
skip $ flip mapTest Types.Interval.suite \f -> runContract
testnetConfig { suppressLogs = true }
do
eraSummaries <- getEraSummaries
sysStart <- getSystemStart
liftEffect $ f eraSummaries sysStart
mapTest (runContract testnetConfig) do
group "Pools" do
test "get metadata for all pools" do
poolIds <- getPoolIds
void $ traverse getPoolParameters poolIds
Collateral.suite
PrivateKey.suite
Logging.suite
BalanceTx.Time.suite
where
runQueryM' =
runContract (testnetConfig { suppressLogs = true }) <<< wrapQueryM
stakingSuite :: TestPlanM ContractTest Unit
stakingSuite = do
group "Staking" do
test "getPoolIds" do
noWallet do
void $ getPoolIds
test "getPubKeyHashDelegationsAndRewards #1" do
noWallet do
res <- getPubKeyHashDelegationsAndRewards ed25519KeyHash1
res `shouldEqual` Nothing
test "getPubKeyHashDelegationsAndRewards #2" do
noWallet do
void $ getPubKeyHashDelegationsAndRewards ed25519KeyHash2
ed25519KeyHash2 :: Ed25519KeyHash
ed25519KeyHash2 = unsafePartial $ fromJust $ decodeCbor $ wrap $
hexToByteArrayUnsafe
"541d6a23b07ebe1363671f49c833f6c33176ec968de1482fdf15cc1f"