From 6c2fb20b1c96ac48ff04fcf0b8f1f5fba3f256f8 Mon Sep 17 00:00:00 2001 From: Noah Metz Date: Sun, 7 Apr 2024 13:29:17 -0600 Subject: [PATCH] Added test for session_close --- packet_test.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/packet_test.go b/packet_test.go index 3972f78..d37b979 100644 --- a/packet_test.go +++ b/packet_test.go @@ -110,3 +110,26 @@ func TestSessionData(t *testing.T) { t.Fatalf("Parsed message(%s) != test message(%s)", parsed_message, message) } } + +func TestSessionClose(t *testing.T) { + _, client_key, err := ed25519.GenerateKey(rand.Reader) + fatalErr(t, err) + + _, server_key, err := ed25519.GenerateKey(rand.Reader) + fatalErr(t, err) + + client_so, client_ecdh, err := NewSessionOpen(client_key) + fatalErr(t, err) + + server_so, server_ecdh, err := NewSessionOpen(server_key) + fatalErr(t, err) + + server_session, err := ParseSessionOpen(server_ecdh, client_so[COMMAND_LENGTH:]) + fatalErr(t, err) + + client_session, err := ParseSessionOpen(client_ecdh, server_so[COMMAND_LENGTH:]) + fatalErr(t, err) + + session_close := NewSessionClose(&client_session) + fatalErr(t, ParseSessionClose(&server_session, session_close[COMMAND_LENGTH+ID_LENGTH:])) +}