Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add order rejection test and unnamed client

  • Loading branch information...
commit 8fe6244f50a67823efbc39e2ee1575bd51dc7f98 1 parent 17ccb2e
Steven Gravell authored
View
19 priv/ca-api.smarkets.com.crt
@@ -0,0 +1,19 @@
+-----BEGIN CERTIFICATE-----
+MIIDIDCCAomgAwIBAgIENd70zzANBgkqhkiG9w0BAQUFADBOMQswCQYDVQQGEwJV
+UzEQMA4GA1UEChMHRXF1aWZheDEtMCsGA1UECxMkRXF1aWZheCBTZWN1cmUgQ2Vy
+dGlmaWNhdGUgQXV0aG9yaXR5MB4XDTk4MDgyMjE2NDE1MVoXDTE4MDgyMjE2NDE1
+MVowTjELMAkGA1UEBhMCVVMxEDAOBgNVBAoTB0VxdWlmYXgxLTArBgNVBAsTJEVx
+dWlmYXggU2VjdXJlIENlcnRpZmljYXRlIEF1dGhvcml0eTCBnzANBgkqhkiG9w0B
+AQEFAAOBjQAwgYkCgYEAwV2xWGcIYu6gmi0fCG2RFGiYCh7+2gRvE4RiIcPRfM6f
+BeC4AfBONOziipUEZKzxa1NfBbPLZ4C/QgKO/t0BCezhABRP/PvwDN1Dulsr4R+A
+cJkVV5MW8Q+XarfCaCMczE1ZMKxRHjuvK9buY0V7xdlfUNLjUA86iOe/FP3gx7kC
+AwEAAaOCAQkwggEFMHAGA1UdHwRpMGcwZaBjoGGkXzBdMQswCQYDVQQGEwJVUzEQ
+MA4GA1UEChMHRXF1aWZheDEtMCsGA1UECxMkRXF1aWZheCBTZWN1cmUgQ2VydGlm
+aWNhdGUgQXV0aG9yaXR5MQ0wCwYDVQQDEwRDUkwxMBoGA1UdEAQTMBGBDzIwMTgw
+ODIyMTY0MTUxWjALBgNVHQ8EBAMCAQYwHwYDVR0jBBgwFoAUSOZo+SvSspXXR9gj
+IBBPM5iQn9QwHQYDVR0OBBYEFEjmaPkr0rKV10fYIyAQTzOYkJ/UMAwGA1UdEwQF
+MAMBAf8wGgYJKoZIhvZ9B0EABA0wCxsFVjMuMGMDAgbAMA0GCSqGSIb3DQEBBQUA
+A4GBAFjOKer89961zgK5F7WF0bnj4JXMJTENAKaSbn+2kmOeUJXRmm/kEd5jhW6Y
+7qj/WsjTVbJmcVfewCHrPSqnI0kBBIZCe/zuf6IWUrVnZ9NA2zsmWLIodz2uFHdh
+1voqZiegDfqnc1zqcPGUIWVEX/r87yloqaKHee9570+sB3c4
+-----END CERTIFICATE-----
View
13 src/smk_client.erl
@@ -290,7 +290,16 @@ handle_info({connect, Opts}, StateName, #s{session=Session, cache=Cache, name=Na
end,
Cache:connecting(Name),
lager:log(info, self(), "Connecting ~p ~p ssl:~p", [Host, Port, Ssl]),
- case smk_sock:connect(Ssl, Host, Port, ?SOCK_OPTS, []) of
+ SslOpts =
+ case Host of
+ "api.smarkets.com" ->
+ [
+ {verify, verify_peer},
+ {cacertfile, "ca-api.smarkets.com.crt"}
+ ];
+ _ -> []
+ end,
+ case smk_sock:connect(Ssl, Host, Port, ?SOCK_OPTS, SslOpts) of
{ok, Sock} ->
lager:log(info, self(), "Connected ~p", [Sock]),
{ok, _, NewState} = send_call(Login, State#s{sock=Sock}),
@@ -392,7 +401,7 @@ logging_out(_Message, _From, State0) ->
%% async
awaiting_session(stop, State) ->
- {next_state, awaiting_session, State}.
+ {stop, normal, State}.
logged_in(drop_in, #s{drop_in=Drop} = State) ->
{next_state, logged_in, State#s{drop_in=Drop+1}};
View
9 src/smk_my_callbacks.erl
@@ -1,6 +1,6 @@
-module(smk_my_callbacks).
--export([start/2, cb/2]).
+-export([start/2, start_unnamed/2, cb/2]).
start(Username, Password) ->
smk_clients_sup:start_client({local, ?MODULE}, [
@@ -9,6 +9,13 @@ start(Username, Password) ->
{callback, fun ?MODULE:cb/2}
]).
+start_unnamed(Username, Password) ->
+ smk_clients_sup:start_client([
+ {username,Username},
+ {password,Password},
+ {callback, fun ?MODULE:cb/2}
+ ]).
+
cb(_Payload, _Session) ->
%io:format("Payload Received for session ~p : ~p~n", [Session, Payload]),
ok.
View
13 test/smk_client_tests.erl
@@ -130,6 +130,19 @@ order_rejected_market_not_found_test_() ->
?assertLogoutConfirmation(3)
end}.
+order_rejected_contract_not_found_test() ->
+ {ok, C} = login(),
+ ?assertLoginResponse(1),
+ Qty = 100000,
+ Px = 2500,
+ Side = buy,
+ {ok, 2} = smk_client:order(C, Qty, Px, Side, ?MARKET_ID, #seto_uuid_128{low=0}),
+ ?assertOrderRejected(2, contract_not_found, 2),
+ {ok, 3} = smk_client:logout(C),
+ ?assertLogoutConfirmation(3).
+
+
+
many_order_create_test() ->
{ok, C} = login(),
?assertLoginResponse(1),
Please sign in to comment.
Something went wrong with that request. Please try again.