Skip to content

Commit

Permalink
[Bug] Handle empty client_oid in Websocket received calls (#185)
Browse files Browse the repository at this point in the history
  • Loading branch information
dougdellolio authored Dec 13, 2018
1 parent 0a74a70 commit 73f7cc4
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,20 +100,21 @@ public static string CreateLevel2Response()
}";
}

public static string CreateReceivedResponse()
public static string CreateReceivedResponse(string clientOid)
{
return @"
{
return $@"
{{
""type"": ""received"",
""time"": ""2014-11-07T08:19:27.028459Z"",
""product_id"": ""BTC-USD"",
""client_oid"": ""{clientOid}"",
""sequence"": 10,
""order_id"": ""d50ec984-77a8-460a-b958-66f114b0de9b"",
""size"": ""1.34"",
""price"": ""502.1"",
""side"": ""buy"",
""order_type"": ""limit""
}";
}}";
}

public static string CreateOpenResponse()
Expand Down
31 changes: 24 additions & 7 deletions CoinbasePro.Specs/WebSocket/WebSocketSpecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -257,16 +257,33 @@ class when_response_type_is_heartbeat

class when_response_type_is_received
{
Because of = () =>
class with_client_oid
{
Subject.Start(product_type_inputs, no_channel_type_inputs);
Because of = () =>
{
Subject.Start(product_type_inputs, no_channel_type_inputs);
websocket_feed.Raise(e => e.MessageReceived += null, new MessageReceivedEventArgs(WebSocketTypeResponseFixture.CreateReceivedResponse()));
};
websocket_feed.Raise(e => e.MessageReceived += null, new MessageReceivedEventArgs(WebSocketTypeResponseFixture.CreateReceivedResponse("d0c5340b-6d6c-49d9-b567-48c4bfca13d2")));
};

It should_have_invoked_received_response = () =>
The<IWebSocketFeed>().
WasToldTo(p => p.Invoke(Param.IsAny<EventHandler<WebfeedEventArgs<Received>>>(), Param.IsAny<object>(), Param.IsAny<WebfeedEventArgs<Received>>()));
It should_have_invoked_received_response = () =>
The<IWebSocketFeed>().
WasToldTo(p => p.Invoke(Param.IsAny<EventHandler<WebfeedEventArgs<Received>>>(), Param.IsAny<object>(), Param.IsAny<WebfeedEventArgs<Received>>()));
}

class with_blank_client_oid
{
Because of = () =>
{
Subject.Start(product_type_inputs, no_channel_type_inputs);
websocket_feed.Raise(e => e.MessageReceived += null, new MessageReceivedEventArgs(WebSocketTypeResponseFixture.CreateReceivedResponse(string.Empty)));
};

It should_have_invoked_received_response = () =>
The<IWebSocketFeed>().
WasToldTo(p => p.Invoke(Param.IsAny<EventHandler<WebfeedEventArgs<Received>>>(), Param.IsAny<object>(), Param.IsAny<WebfeedEventArgs<Received>>()));
}
}

class when_response_type_is_open
Expand Down
2 changes: 1 addition & 1 deletion CoinbasePro/WebSocket/Models/Response/Received.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class Received : BaseMessage

public OrderSide Side { get; set; }

public Guid ClientOid { get; set; }
public Guid? ClientOid { get; set; }

public ProductType ProductId { get; set; }

Expand Down

0 comments on commit 73f7cc4

Please sign in to comment.