Re: [Yxa-devel] [PATCH] Fix bug in transactionstatelist clean-up

2010-01-20 Thread Fredrik Thulin
On Sun, 2010-01-10 at 21:49 +0100, Mikael Magnusson wrote:
> Fix bug introduced when cleaning up transactionsatelist. Correct
> transaction id when adding client transaction state.
> 
> Add add_client_transaction/5 and get_client_transaction/2 testcases.

Thanks! Applied right away since you even included a test case =).

I'm making progress on the github topic - I got management approval, so
now I just have to do it too.

/Fredrik


___
Yxa-devel mailing list
Yxa-devel@lists.su.se
https://lists.su.se/mailman/listinfo/yxa-devel


[Yxa-devel] [PATCH] Fix bug in transactionstatelist clean-up

2010-01-10 Thread Mikael Magnusson
Fix bug introduced when cleaning up transactionsatelist. Correct
transaction id when adding client transaction state.

Add add_client_transaction/5 and get_client_transaction/2 testcases.

Patch attached and on github:
http://github.com/mikma/yxa/commit/1b22b22baa48c4cbcaaacb21cec311dcdfd5dd5c

/Mikael

 src/transactionlayer/transactionstatelist.erl |   42 -
 1 files changed, 41 insertions(+), 1 deletions(-)

diff --git a/src/transactionlayer/transactionstatelist.erl b/src/transactionlayer/transactionstatelist.erl
index c5818a6..d337d17 100644
--- a/src/transactionlayer/transactionstatelist.erl
+++ b/src/transactionlayer/transactionstatelist.erl
@@ -159,7 +159,9 @@ add_client_transaction(Method, Branch, Pid, Desc)
 
 add_client_transaction(Tables, Method, Branch, Pid, Desc)
   when is_list(Method), is_list(Branch), is_pid(Pid), is_list(Desc) ->
-Id = {Branch, Method},
+Id = #rfc3261_client_id{branch = Branch,
+			cseq_method = Method
+			   },
 add(Tables, client, Id, none, Pid, Desc).
 
 %%
@@ -1324,6 +1326,44 @@ test() ->
 ok = test_compare_records(GetUsingReq1_Result1, GetToCancel3_Result, []),
 
 
+%% add_client_transaction(Method, Branch, Pid, Desc)
+%%
+autotest:mark(?LINE, "add_client_transaction/5 - 1"),
+Message4Method = "TEST",
+Message4Branch = "z9hG4bK-yxa-unittest-add_client_transaction3",
+Request4Description = "TEST client request 4",
+ok = add_client_transaction(TestTables, Message4Method, Message4Branch, self(), Request4Description),
+
+%% build response
+Response4Header = keylist:from_list([
+	{"Via",	["SIP/2.0/UDP sip.example.org:5060;branch=" ++ Message4Branch]},
+	{"From",	[";tag=f-abc"]},
+	{"To",	[";tag=t-abc"]},
+	{"Call-ID", ["3c26722ce...@192.0.2.111"]},
+	{"CSeq",	["2 " ++ Message4Method]}
+	   ]),
+
+Response4 = #response{status=200, reason="Foo", header=Response4Header, body = <<>>},
+
+autotest:mark(?LINE, "add_client_transaction/5 - 2"),
+%% try to add the same request again, should fail
+{duplicate, _} = add_client_transaction(TestTables, Message4Method, Message4Branch, self(), Request4Description),
+
+autotest:mark(?LINE, "get_client_transaction/2 - 1.0"),
+%% try to fetch the TEST transaction
+GetUsingReq4_Expected1 =
+	#transactionstate{type		= client,
+			  id		= get_client_transaction_id(Response4),
+			  description	= Request4Description,
+			  pid		= self()
+			 },
+autotest:mark(?LINE, "get_client_transaction/2 - 1.1"),
+GetUsingReq4_Result1 = get_client_transaction(TestTables,
+		  Response4),
+autotest:mark(?LINE, "get_client_transaction/2 - 1.2"),
+ok = test_compare_records(GetUsingReq4_Expected1, GetUsingReq4_Result1, [ref, expire]),
+
+
 
 
 %% clean up
-- 
1.6.3.3

___
Yxa-devel mailing list
Yxa-devel@lists.su.se
https://lists.su.se/mailman/listinfo/yxa-devel