@@ -16,7 +16,8 @@ module Test.Integration.Scenario.API.Byron.Transactions
16
16
import Prelude
17
17
18
18
import Cardano.Wallet.Api.Types
19
- ( ApiAsset (.. )
19
+ ( ApiAddress
20
+ , ApiAsset (.. )
20
21
, ApiByronWallet
21
22
, ApiFee (.. )
22
23
, ApiT (.. )
@@ -41,25 +42,27 @@ import Cardano.Wallet.Primitive.Types.TokenPolicy
41
42
import Cardano.Wallet.Primitive.Types.Tx
42
43
( Direction (.. ), TxStatus (.. ) )
43
44
import Cardano.Wallet.Unsafe
44
- ( unsafeFromText )
45
+ ( unsafeFromHex , unsafeFromText )
45
46
import Control.Monad
46
- ( forM_ )
47
+ ( forM_ , void )
47
48
import Control.Monad.IO.Class
48
49
( liftIO )
49
50
import Control.Monad.Trans.Resource
50
51
( runResourceT )
51
52
import Data.Bifunctor
52
53
( bimap )
53
54
import Data.Generics.Internal.VL.Lens
54
- ( (^.) )
55
+ ( view , (^.) )
55
56
import Data.Quantity
56
57
( Quantity (.. ) )
58
+ import Data.Text
59
+ ( Text )
57
60
import Data.Text.Class
58
61
( fromText )
59
62
import Numeric.Natural
60
63
( Natural )
61
64
import Test.Hspec
62
- ( SpecWith , describe )
65
+ ( ActionWith , SpecWith , describe , pendingWith )
63
66
import Test.Hspec.Expectations.Lifted
64
67
( shouldBe , shouldNotBe )
65
68
import Test.Hspec.Extra
@@ -69,6 +72,8 @@ import Test.Integration.Framework.DSL
69
72
, Headers (.. )
70
73
, Payload (.. )
71
74
, between
75
+ , emptyByronWalletFromXPrvWith
76
+ , emptyByronWalletWith
72
77
, emptyIcarusWallet
73
78
, emptyRandomWallet
74
79
, emptyWallet
@@ -99,11 +104,12 @@ import Test.Integration.Framework.DSL
99
104
, request
100
105
, toQueryString
101
106
, verify
107
+ , waitForTxImmutability
102
108
, walletId
103
109
, (.>=)
104
110
)
105
111
import Test.Integration.Framework.Request
106
- ( RequestException )
112
+ ( RequestException , unsafeRequest )
107
113
import Test.Integration.Framework.TestData
108
114
( errMsg400StartTimeLaterThanEndTime
109
115
, errMsg404NoAsset
@@ -117,6 +123,7 @@ import qualified Cardano.Wallet.Primitive.Types.TokenPolicy as TokenPolicy
117
123
import qualified Data.ByteString as BS
118
124
import qualified Data.ByteString.Char8 as B8
119
125
import qualified Data.Text as T
126
+ import qualified Data.Text.Encoding as T
120
127
import qualified Network.HTTP.Types.Status as HTTP
121
128
122
129
data TestCase a = TestCase
@@ -595,3 +602,88 @@ spec = describe "BYRON_TRANSACTIONS" $ do
595
602
r <- request @ ([ApiTransaction n ]) ctx link Default Empty
596
603
expectResponseCode HTTP. status404 r
597
604
expectErrorMessage (errMsg404NoWallet $ w ^. walletId) r
605
+
606
+ -- Golden from https://github.com/input-output-hk/cardano-sl/pull/4278#issuecomment-600553878
607
+ it " BYRON_SCRYPT_TRANS_CREATE_01 - wallet with password" $ \ ctx -> do
608
+ flip runByronScryptGolden ctx $ ByronScryptGolden
609
+ { mnemonic = T. words
610
+ " inhale arm pilot fitness ceiling october donate \
611
+ \between language all limit taxi"
612
+ , encryptedRootXPrv =
613
+ " f6e79f49b8999a39d7e970e42d0a91224ecacefc3aa1edb342f34eb8bc6c2f\
614
+ \c63e743b862b312a6f92ba0161d4d53c3ee5a2bd8085476d9575765c49dcee\
615
+ \cbe54b34ec47daf9b7ebc6bdb706622616451c000e85ba81c7449ae436a8cb\
616
+ \bf3aab98e5cc704977bd11bb0ba8d5b5571a705704cb9334d27a048532eab4\
617
+ \9a698c2d"
618
+ , passwordHash =
619
+ " 31347c387c317c5743413633702f6a487a5777575278756756344e31685479\
620
+ \3470646c6d4f76665177653863775a575472784f79773d3d7c796341722f61\
621
+ \326f4f777a736e4e746f4e655049416e4f6b7978426549494a6b59623039574\
622
+ \b564a7159493d"
623
+ , password = T. pack . B8. unpack $ unsafeFromHex
624
+ " 00000000000000000000000000000000000000\
625
+ \50415441544520504154415445"
626
+ }
627
+ -- Golden from https://github.com/input-output-hk/cardano-sl/pull/4278#issuecomment-600553878
628
+ it " BYRON_SCRYPT_TRANS_CREATE_02 - wallet without password" $
629
+ runByronScryptGolden ByronScryptGolden
630
+ { mnemonic = T. words
631
+ " marriage blouse orbit quarter treat series release sing lava \
632
+ \spice surface rule"
633
+ , encryptedRootXPrv =
634
+ " 38e8de9c583441213fe34eecc4e28265267466877ba4048e3ab1fa99563669\
635
+ \47aefaf5ba9779db67eead7fc9cd1354b994a5d8d9cd40ab874bfeb1b33649\
636
+ \280cd33651377731e0e59e0233425a55257782c5adaa768da0567f43c1c6c0\
637
+ \c18766ed0a547bb34eb472c120b170a8640279832ddf18002887f03c15dea5\
638
+ \9705422d"
639
+ , passwordHash =
640
+ " 31347c387c317c574342652b796362417576356c2b4258676a344a314c6343\
641
+ \675375414c2f5653393661364e576a2b7550766655513d3d7c6f7846366549\
642
+ \39734151444e6f38395147747366324e653937426338372b484b6b41377567\
643
+ \72752f5970673d"
644
+ , password = " "
645
+ }
646
+ where
647
+ runByronScryptGolden :: ByronScryptGolden -> ActionWith Context
648
+ runByronScryptGolden golden ctx = runResourceT $ do
649
+ wFaucet <- fixtureRandomWallet ctx
650
+
651
+ wMnemonic <- emptyByronWalletWith ctx " random"
652
+ (" Random Wallet" , mnemonic golden, fixturePassphrase)
653
+
654
+ let pay amt pwd src dest = do
655
+ addr <- view # id . snd
656
+ <$> unsafeRequest @ (ApiAddress n ) ctx
657
+ (Link. postRandomAddress dest)
658
+ (Json [json | { "passphrase": #{fixturePassphrase} }|])
659
+
660
+ payload <- mkTxPayloadMA @ n addr amt [] pwd
661
+ rtx <- request @ (ApiTransaction n ) ctx
662
+ (Link. createTransactionOld @ 'Byron src) Default payload
663
+ expectResponseCode HTTP. status202 rtx
664
+
665
+ let ada = 1_000_000
666
+
667
+ pay (100 * ada) fixturePassphrase wFaucet wMnemonic
668
+
669
+ void $ request @ () ctx
670
+ (Link. deleteWallet @ 'Byron wMnemonic) Default Empty
671
+
672
+ wKey <- emptyByronWalletFromXPrvWith ctx " random"
673
+ (" Random Wallet" , encryptedRootXPrv golden, passwordHash golden)
674
+
675
+ liftIO $ waitForTxImmutability ctx
676
+
677
+ pay (99 * ada) (password golden) wKey wFaucet
678
+
679
+ data ByronScryptGolden = ByronScryptGolden
680
+ { encryptedRootXPrv :: Text
681
+ -- ^ Encrypted XPrv extracted from cardano-sl
682
+ , passwordHash :: Text
683
+ -- ^ Password hash extracted from cardano-sl
684
+ , password :: Text
685
+ -- ^ Password used when spending funds.
686
+ , mnemonic :: [Text ]
687
+ -- ^ Corresponding mnemonic for reference
688
+ }
689
+
0 commit comments