Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Experimental fourmolu branch. #4061

Closed
wants to merge 5 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Reformat with fourmolu (run 2 of 2).
jonathanknowles committed Aug 4, 2023

Verified

This commit was signed with the committer’s verified signature.
jonathanknowles Jonathan Knowles
commit f3317031a7550dbf0dbdcf875c8cf9a715a3af73
3 changes: 2 additions & 1 deletion lib/delta-types/src/Data/Delta.hs
Original file line number Diff line number Diff line change
@@ -340,7 +340,8 @@ instance Semigroupoid Embedding where
pure (a, mbc `o` mab)

-- | A pair of 'Embedding's gives an embedding of pairs.
pair :: Embedding da1 db1 -> Embedding da2 db2 -> Embedding (da1, da2) (db1, db2)
pair
:: Embedding da1 db1 -> Embedding da2 db2 -> Embedding (da1, da2) (db1, db2)
pair (Embedding inject1 project1) (Embedding inject2 project2) =
Embedding {inject, project}
where
4 changes: 2 additions & 2 deletions lib/wallet/api/http/Cardano/Wallet/Api/Http/Server/Error.hs
Original file line number Diff line number Diff line change
@@ -1003,10 +1003,10 @@ instance IsServerError ErrConstructSharedWallet where
toServerError = \case
ErrConstructSharedWalletWrongScriptTemplate
(ErrScriptTemplateInvalid cred reason) ->
handleTemplateErr cred (toText reason)
handleTemplateErr cred (toText reason)
ErrConstructSharedWalletWrongScriptTemplate
(ErrScriptTemplateMissingKey cred reason) ->
handleTemplateErr cred reason
handleTemplateErr cred reason
ErrConstructSharedWalletInvalidIndex e -> toServerError e
where
handleTemplateErr cred reason =

Large diffs are not rendered by default.

Large diffs are not rendered by default.

45 changes: 23 additions & 22 deletions lib/wallet/integration/src/Test/Integration/Scenario/CLI/Port.hs
Original file line number Diff line number Diff line change
@@ -211,28 +211,29 @@ spec = describe "COMMON_CLI_PORTS" $ do
err `shouldContain` errConnectionRefused

it
"PORT_03 - Cannot omit --port when server uses random port (transaction create)" $ \_ -> do
let
addr =
"37btjrVyb4KFjfnPUjgDKLiATLxgwBbeMAEr4vxgkq4Ea5nR6evtX99x2\
\QFcF8ApLM4aqCLGvhHQyRJ4JHk4zVKxNeEtTJaPCeB86LndU2YvKUTEEm"
let
args =
[ "transaction"
, "create"
, replicate 40 '0'
, "--payment"
, "14@" <> addr
]
let
process = proc' commandName args
withCreateProcess process $ \(Just stdin) (Just _) (Just stderr) h -> do
hPutStr stdin (passphrase ++ "\n")
hFlush stdin
hClose stdin
void $ waitForProcess h
err <- T.unpack <$> TIO.hGetContents stderr
err `shouldContain` errConnectionRefused
"PORT_03 - Cannot omit --port when server uses random port (transaction create)"
$ \_ -> do
let
addr =
"37btjrVyb4KFjfnPUjgDKLiATLxgwBbeMAEr4vxgkq4Ea5nR6evtX99x2\
\QFcF8ApLM4aqCLGvhHQyRJ4JHk4zVKxNeEtTJaPCeB86LndU2YvKUTEEm"
let
args =
[ "transaction"
, "create"
, replicate 40 '0'
, "--payment"
, "14@" <> addr
]
let
process = proc' commandName args
withCreateProcess process $ \(Just stdin) (Just _) (Just stderr) h -> do
hPutStr stdin (passphrase ++ "\n")
hFlush stdin
hClose stdin
void $ waitForProcess h
err <- T.unpack <$> TIO.hGetContents stderr
err `shouldContain` errConnectionRefused

it "PORT_03 - Cannot omit --port when server uses random port (address list)" $ \_ -> do
let
Original file line number Diff line number Diff line change
@@ -1082,44 +1082,45 @@ spec = describe "SHELLEY_CLI_TRANSACTIONS" $ do
c2 `shouldBe` ExitFailure 1

it
"TRANS_DELETE_01 - Cannot forget pending transaction when not pending anymore via CLI" $ \ctx -> runResourceT $ do
wSrc <- fixtureWallet ctx
wDest <- emptyWallet ctx
let
wSrcId = T.unpack (wSrc ^. walletId)
"TRANS_DELETE_01 - Cannot forget pending transaction when not pending anymore via CLI"
$ \ctx -> runResourceT $ do
wSrc <- fixtureWallet ctx
wDest <- emptyWallet ctx
let
wSrcId = T.unpack (wSrc ^. walletId)

-- post transaction
txJson <-
postTxViaCLI ctx wSrc wDest (minUTxOValue (_mainEra ctx)) Nothing Nothing
verify
txJson
[ expectCliField (#direction . #getApiT) (`shouldBe` Outgoing)
, expectCliField (#status . #getApiT) (`shouldBe` Pending)
]
let
txId = getTxId txJson
-- post transaction
txJson <-
postTxViaCLI ctx wSrc wDest (minUTxOValue (_mainEra ctx)) Nothing Nothing
verify
txJson
[ expectCliField (#direction . #getApiT) (`shouldBe` Outgoing)
, expectCliField (#status . #getApiT) (`shouldBe` Pending)
]
let
txId = getTxId txJson

eventually "Tx is in ledger" $ do
listTransactionsViaCLI ctx TxMetadataDetailedSchema [wSrcId]
>>= expectValidJSON (Proxy @([ApiTransaction n])) . fromStdout
>>= flip
verify
[ expectCliListField
0
(#direction . #getApiT)
(`shouldBe` Outgoing)
, expectCliListField
0
(#status . #getApiT)
(`shouldBe` InLedger)
]
eventually "Tx is in ledger" $ do
listTransactionsViaCLI ctx TxMetadataDetailedSchema [wSrcId]
>>= expectValidJSON (Proxy @([ApiTransaction n])) . fromStdout
>>= flip
verify
[ expectCliListField
0
(#direction . #getApiT)
(`shouldBe` Outgoing)
, expectCliListField
0
(#status . #getApiT)
(`shouldBe` InLedger)
]

-- Try Forget transaction once it's no longer pending
(Exit c2, Stdout out2, Stderr err2) <-
deleteTransactionViaCLI ctx wSrcId txId
err2 `shouldContain` errMsg403AlreadyInLedger (T.pack txId)
out2 `shouldBe` ""
c2 `shouldBe` ExitFailure 1
-- Try Forget transaction once it's no longer pending
(Exit c2, Stdout out2, Stderr err2) <-
deleteTransactionViaCLI ctx wSrcId txId
err2 `shouldContain` errMsg403AlreadyInLedger (T.pack txId)
out2 `shouldBe` ""
c2 `shouldBe` ExitFailure 1

it "TRANS_DELETE_03 - Cannot forget tx that is not found via CLI" $ \ctx -> runResourceT $ do
wid <- fixtureWallet' ctx
Original file line number Diff line number Diff line change
@@ -404,38 +404,40 @@ spec = describe "SHELLEY_CLI_WALLETS" $ do
\ or 24 words are expected."

describe
"WALLETS_CREATE_06 - Can create wallet with different mnemonic snd factor sizes" $ do
forM_ ["9", "12"] $ \(size) -> it size $ \ctx -> runResourceT $ do
let
name = "Wallet created via CLI"
Stdout m1 <- generateMnemonicsViaCLI []
Stdout m2 <- generateMnemonicsViaCLI ["--size", size]
let
pwd = "Secure passphrase"
(c, out, err) <- createWalletViaCLI ctx [name] m1 m2 pwd
c `shouldBe` ExitSuccess
T.unpack err `shouldContain` cmdOk
j <- expectValidJSON (Proxy @ApiWallet) out
expectCliField
(#name . #getApiT . #getWalletName)
(`shouldBe` T.pack name)
j
"WALLETS_CREATE_06 - Can create wallet with different mnemonic snd factor sizes"
$ do
forM_ ["9", "12"] $ \(size) -> it size $ \ctx -> runResourceT $ do
let
name = "Wallet created via CLI"
Stdout m1 <- generateMnemonicsViaCLI []
Stdout m2 <- generateMnemonicsViaCLI ["--size", size]
let
pwd = "Secure passphrase"
(c, out, err) <- createWalletViaCLI ctx [name] m1 m2 pwd
c `shouldBe` ExitSuccess
T.unpack err `shouldContain` cmdOk
j <- expectValidJSON (Proxy @ApiWallet) out
expectCliField
(#name . #getApiT . #getWalletName)
(`shouldBe` T.pack name)
j

describe
"WALLETS_CREATE_06 - Can't create wallet with wrong size of mnemonic snd factor" $ do
forM_ ["15", "18", "21", "24"] $ \(size) -> it size $ \ctx -> runResourceT $ do
let
name = "Wallet created via CLI"
Stdout m1 <- generateMnemonicsViaCLI ["--size", size]
Stdout m2 <- generateMnemonicsViaCLI ["--size", size]
let
pwd = "Secure passphrase"
(c, out, err) <- createWalletViaCLI ctx [name] m1 m2 pwd
c `shouldBe` (ExitFailure 1)
out `shouldBe` ""
T.unpack err
`shouldContain` "Invalid number of words: 9 or 12\
\ words are expected."
"WALLETS_CREATE_06 - Can't create wallet with wrong size of mnemonic snd factor"
$ do
forM_ ["15", "18", "21", "24"] $ \(size) -> it size $ \ctx -> runResourceT $ do
let
name = "Wallet created via CLI"
Stdout m1 <- generateMnemonicsViaCLI ["--size", size]
Stdout m2 <- generateMnemonicsViaCLI ["--size", size]
let
pwd = "Secure passphrase"
(c, out, err) <- createWalletViaCLI ctx [name] m1 m2 pwd
c `shouldBe` (ExitFailure 1)
out `shouldBe` ""
T.unpack err
`shouldContain` "Invalid number of words: 9 or 12\
\ words are expected."

describe "WALLETS_CREATE_07 - Passphrase is valid" $ do
let
3 changes: 2 additions & 1 deletion lib/wallet/src/Cardano/Wallet/Shelley/Network/Node.hs
Original file line number Diff line number Diff line change
@@ -1428,7 +1428,8 @@ data Log where
MsgDestroyCursor :: ThreadId -> Log
MsgWillQueryRewardsForStake :: W.Coin -> Log
MsgFetchStakePoolsData :: Maybe StakePoolsSummary -> Log
MsgFetchStakePoolsDataSummary :: Int
MsgFetchStakePoolsDataSummary
:: Int
-> Int
-> Log
-- ^ Number of pools in stake distribution, and rewards map,
2 changes: 1 addition & 1 deletion lib/wallet/src/Cardano/Wallet/Write/Tx.hs
Original file line number Diff line number Diff line change
@@ -813,7 +813,7 @@ fromCardanoTx = \case
Cardano.ShelleyTx _era tx ->
tx
Cardano.ByronTx {} ->
case (recentEra @era) of
case (recentEra @era) of {}

toCardanoTx
:: forall era
Original file line number Diff line number Diff line change
@@ -141,29 +141,30 @@ spec = do
"Using derivePolicyKeyAndHash returns same private key as using derivePolicyPrivateKey"
$ property prop_keyDerivationRelation
it
"Deriving a policy key with cardano-address returns same result as cardano-wallet" $ do
unit_comparePolicyKeys
goldenTestMnemonic
(Index 0x80000000)
"acct_xsk1tqqqnvtppk994fxm05wtlvp6uuu58srue9st8ew29vr5mxxf89tj2ze05pm8qjkyfetpzl58jkgx6dd3s96szhyxfajpc2gxv22xef0ems2cnvh5d5xjemgghg9m8489v6c9rvnt9za2pruyrtkp5y77l5ujxeug"
-- Child key 1855H/1815H/0H generated by cardano-address CLI
-- from test mnemonic
unit_comparePolicyKeyHashes
goldenTestMnemonic
(Index 0x80000000)
"6adb501348b99cd38172f355615d7c1d0b9d1e3fc69b565b85a98127"
-- Hash of child key 1855H/1815H/0H generated by cardano-address
-- CLI from test mnemonic
unit_comparePolicyKeys
goldenTestMnemonic
(Index 0x80000010)
"acct_xsk1rprds8krzhspy8xhkupk2270hzkexmkdga98zv5ns4x9d9kf89t4qp438a26sn62wsfldthkrvnwe6vnetuehgxyxt4hm46zsw03mknuwef0afcljmultpjjwx8zqm0ftnfkqucwvf5qr4gved6h3gnyeqcsur4p"
-- Child key 1855H/1815H/16H generated by cardano-address CLI
-- from test mnemonic
unit_comparePolicyKeyHashes
goldenTestMnemonic
(Index 0x80000010)
"1f07b91d27ca1cbf911ccfba254315733b3c908575ce2fc29d4c6965"
"Deriving a policy key with cardano-address returns same result as cardano-wallet"
$ do
unit_comparePolicyKeys
goldenTestMnemonic
(Index 0x80000000)
"acct_xsk1tqqqnvtppk994fxm05wtlvp6uuu58srue9st8ew29vr5mxxf89tj2ze05pm8qjkyfetpzl58jkgx6dd3s96szhyxfajpc2gxv22xef0ems2cnvh5d5xjemgghg9m8489v6c9rvnt9za2pruyrtkp5y77l5ujxeug"
-- Child key 1855H/1815H/0H generated by cardano-address CLI
-- from test mnemonic
unit_comparePolicyKeyHashes
goldenTestMnemonic
(Index 0x80000000)
"6adb501348b99cd38172f355615d7c1d0b9d1e3fc69b565b85a98127"
-- Hash of child key 1855H/1815H/0H generated by cardano-address
-- CLI from test mnemonic
unit_comparePolicyKeys
goldenTestMnemonic
(Index 0x80000010)
"acct_xsk1rprds8krzhspy8xhkupk2270hzkexmkdga98zv5ns4x9d9kf89t4qp438a26sn62wsfldthkrvnwe6vnetuehgxyxt4hm46zsw03mknuwef0afcljmultpjjwx8zqm0ftnfkqucwvf5qr4gved6h3gnyeqcsur4p"
-- Child key 1855H/1815H/16H generated by cardano-address CLI
-- from test mnemonic
unit_comparePolicyKeyHashes
goldenTestMnemonic
(Index 0x80000010)
"1f07b91d27ca1cbf911ccfba254315733b3c908575ce2fc29d4c6965"
-- Hash of child key 1855H/1815H/16H generated by
-- cardano-address CLI from test mnemonic

Original file line number Diff line number Diff line change
@@ -330,8 +330,9 @@ propSpec = describe "Random Address Discovery Properties" $ do
it "GenChange address always satisfies isOurs" $ do
property prop_changeAddressesBelongToUs
it
"each address discovered by isOurs is in forbidden addresses and different than change address" $ do
property prop_forbiddenAddresses
"each address discovered by isOurs is in forbidden addresses and different than change address"
$ do
property prop_forbiddenAddresses
it "address that are discovered via isOurs are marked as 'Used'" $ do
property prop_oursAreUsed