Skip to content

Commit

Permalink
Added order parsing tests to test new changeset.
Browse files Browse the repository at this point in the history
  • Loading branch information
mdunnio committed Aug 29, 2021
1 parent 68c9865 commit cc5c004
Show file tree
Hide file tree
Showing 5 changed files with 158 additions and 30 deletions.
49 changes: 49 additions & 0 deletions coinbase-pro.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ library
, servant >=0.14 && <0.19
, servant-client >=0.14 && <0.19
, servant-client-core >=0.14 && <0.19
, tasty >=1.2.2
, tasty-hunit >=0.10
, text ==1.2.*
, time >=1.8 && <2.0
, transformers ==0.5.*
Expand Down Expand Up @@ -133,6 +135,8 @@ executable test-request
, servant >=0.14 && <0.19
, servant-client >=0.14 && <0.19
, servant-client-core >=0.14 && <0.19
, tasty >=1.2.2
, tasty-hunit >=0.10
, text ==1.2.*
, time >=1.8 && <2.0
, transformers ==0.5.*
Expand Down Expand Up @@ -173,6 +177,51 @@ executable test-stream
, servant >=0.14 && <0.19
, servant-client >=0.14 && <0.19
, servant-client-core >=0.14 && <0.19
, tasty >=1.2.2
, tasty-hunit >=0.10
, text ==1.2.*
, time >=1.8 && <2.0
, transformers ==0.5.*
, unagi-streams ==0.2.*
, unordered-containers ==0.2.*
, uuid ==1.3.*
, vector ==0.12.*
, websockets ==0.12.*
, wuss ==1.1.*
default-language: Haskell2010

test-suite coinbase-pro-test
type: exitcode-stdio-1.0
main-is: Test.hs
other-modules:
Paths_coinbase_pro
hs-source-dirs:
src/test
build-depends:
HsOpenSSL ==0.11.*
, aeson >=1.2 && <1.6
, aeson-casing >=0.1 && <0.3
, async >=2.1 && <2.3
, base >=4.7 && <5
, binary ==0.8.*
, bytestring ==0.10.*
, coinbase-pro
, containers >=0.5 && <0.7
, cryptonite >=0.24 && <0.30
, exceptions >=0.4 && <1.0
, http-api-data >=0.3 && <0.5
, http-client >=0.5 && <0.7
, http-client-tls ==0.3.*
, http-streams ==0.8.*
, http-types ==0.12.*
, io-streams ==1.5.*
, memory >=0.14 && <0.16
, network >=2.6 && <3.2
, servant >=0.14 && <0.19
, servant-client >=0.14 && <0.19
, servant-client-core >=0.14 && <0.19
, tasty >=1.2.2
, tasty-hunit >=0.10
, text ==1.2.*
, time >=1.8 && <2.0
, transformers ==0.5.*
Expand Down
2 changes: 2 additions & 0 deletions hie.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ cradle:
component: "coinbase-pro:exe:test-streame"
- path: "./src/lib/"
component: "coinbase-pro:lib"
- path: "./src/test/"
component: "coinbase-pro:test"
69 changes: 39 additions & 30 deletions package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,40 +19,49 @@ extra-source-files:
github: mdunnio/coinbase-pro

dependencies:
- base >= 4.7 && < 5
- HsOpenSSL >= 0.11 && < 0.12
- aeson >= 1.2 && < 1.6
- aeson-casing >= 0.1 && < 0.3
- async >= 2.1 && < 2.3
- binary >= 0.8 && < 0.9
- bytestring >= 0.10 && < 0.11
- containers >= 0.5 && < 0.7
- cryptonite >= 0.24 && < 0.30
- exceptions >= 0.4 && < 1.0
- http-api-data >= 0.3 && < 0.5
- http-client >= 0.5 && < 0.7
- http-client-tls >= 0.3 && < 0.4
- http-streams >= 0.8 && < 0.9
- http-types >= 0.12 && < 0.13
- io-streams >= 1.5 && < 1.6
- memory >= 0.14 && < 0.16
- network >= 2.6 && < 3.2
- servant >= 0.14 && < 0.19
- servant-client >= 0.14 && < 0.19
- servant-client-core >= 0.14 && < 0.19
- text >= 1.2 && < 1.3
- time >= 1.8 && < 2.0
- transformers >= 0.5 && < 0.6
- unagi-streams >= 0.2 && < 0.3
- unordered-containers >= 0.2 && < 0.3
- uuid >= 1.3 && < 1.4
- vector >= 0.12 && < 0.13
- websockets >= 0.12 && < 0.13
- wuss >= 1.1 && < 1.2
- base >= 4.7 && < 5
- HsOpenSSL >= 0.11 && < 0.12
- aeson >= 1.2 && < 1.6
- aeson-casing >= 0.1 && < 0.3
- async >= 2.1 && < 2.3
- binary >= 0.8 && < 0.9
- bytestring >= 0.10 && < 0.11
- containers >= 0.5 && < 0.7
- cryptonite >= 0.24 && < 0.30
- exceptions >= 0.4 && < 1.0
- http-api-data >= 0.3 && < 0.5
- http-client >= 0.5 && < 0.7
- http-client-tls >= 0.3 && < 0.4
- http-streams >= 0.8 && < 0.9
- http-types >= 0.12 && < 0.13
- io-streams >= 1.5 && < 1.6
- memory >= 0.14 && < 0.16
- network >= 2.6 && < 3.2
- servant >= 0.14 && < 0.19
- servant-client >= 0.14 && < 0.19
- servant-client-core >= 0.14 && < 0.19
- tasty >= 1.2.2
- tasty-hunit >= 0.10
- text >= 1.2 && < 1.3
- time >= 1.8 && < 2.0
- transformers >= 0.5 && < 0.6
- unagi-streams >= 0.2 && < 0.3
- unordered-containers >= 0.2 && < 0.3
- uuid >= 1.3 && < 1.4
- vector >= 0.12 && < 0.13
- websockets >= 0.12 && < 0.13
- wuss >= 1.1 && < 1.2

library:
source-dirs: src/lib/

tests:
coinbase-pro-test:
main: Test.hs
source-dirs: src/test
dependencies:
- coinbase-pro

executables:
test-request:
main: Main.hs
Expand Down
18 changes: 18 additions & 0 deletions src/test/Test.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import Data.Aeson (decode')
import qualified Data.ByteString.Lazy as B
import Data.Maybe (isJust)
import Test.Tasty
import Test.Tasty.HUnit

import CoinbasePro.Authenticated.Orders (Order)


main :: IO ()
main = defaultMain listOrderParse


listOrderParse :: TestTree
listOrderParse = testCase "parse orders" $ do
bytes <- B.readFile "./src/test/data/list-orders.json"
let orders = (decode' bytes :: Maybe [Order])
assertBool "failed to parse" $ isJust orders
50 changes: 50 additions & 0 deletions src/test/data/list-orders.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
[
{
"id": "d0c5340b-6d6c-49d9-b567-48c4bfca13d2",
"price": "0.10000000",
"size": "0.01000000",
"product_id": "BTC-USD",
"side": "buy",
"stp": "dc",
"type": "limit",
"time_in_force": "GTC",
"post_only": false,
"created_at": "2016-12-08T20:02:28.53864Z",
"fill_fees": "0.0000000000000000",
"filled_size": "0.00000000",
"executed_value": "0.0000000000000000",
"status": "open",
"settled": false
},
{
"id": "8b99b139-58f2-4ab2-8e7a-c11c846e3022",
"price": "1.00000000",
"size": "1.00000000",
"product_id": "BTC-USD",
"side": "buy",
"stp": "dc",
"type": "limit",
"time_in_force": "GTC",
"post_only": false,
"created_at": "2016-12-08T20:01:19.038644Z",
"fill_fees": "0.0000000000000000",
"filled_size": "0.00000000",
"executed_value": "0.0000000000000000",
"status": "open",
"settled": false
},
{
"id": "b227e691-365c-470f-a860-a9b4a37dd1d8",
"price": "1.00000000",
"size": "1.00000000",
"product_id": "BTC-USD",
"side": "buy",
"type": "limit",
"created_at": "2016-12-08T20:01:19.038644Z",
"fill_fees": "0.0000000000000000",
"filled_size": "0.00000000",
"executed_value": "0.0000000000000000",
"status": "pending",
"settled": false
}
]

0 comments on commit cc5c004

Please sign in to comment.