package hotline
//
-//import (
+// import (
// "bytes"
// "fmt"
// "github.com/google/go-cmp/cmp"
// "strings"
// "sync"
// "testing"
-//)
+// )
//
-//type transactionTest struct {
+// type transactionTest struct {
// description string // Human understandable description
// account Account // Account struct for a user that will test transaction will execute under
// request Transaction // transaction that will be sent by the client to the server
// want Transaction // transaction that the client expects to receive in response
// setup func() // Optional setup required for the test scenario
// teardown func() // Optional teardown for test scenario
-//}
+// }
//
-//func (tt *transactionTest) Setup(srv *Server) error {
+// func (tt *transactionTest) Setup(srv *Server) error {
// if err := srv.NewUser(tt.account.Login, tt.account.Name, NegatedUserString([]byte(tt.account.Password)), tt.account.Access); err != nil {
// return err
// }
// }
//
// return nil
-//}
+// }
//
-//func (tt *transactionTest) Teardown(srv *Server) error {
+// func (tt *transactionTest) Teardown(srv *Server) error {
// if err := srv.DeleteUser(tt.account.Login); err != nil {
// return err
// }
// }
//
// return nil
-//}
+// }
//
-//// StartTestServer
-//func StartTestServer() (srv *Server, lnPort int) {
+// // StartTestServer
+// func StartTestServer() (srv *Server, lnPort int) {
// hotlineServer, _ := NewServer("test/config/")
// ln, err := net.Listen("tcp", ":0")
//
// }
// }()
// return hotlineServer, ln.Addr().(*net.TCPAddr).Port
-//}
+// }
//
-//func StartTestClient(serverPort int, login, passwd string) (*Client, error) {
+// func StartTestClient(serverPort int, login, passwd string) (*Client, error) {
// c := NewClient("")
//
// err := c.JoinServer(fmt.Sprintf(":%v", serverPort), login, passwd)
// }
//
// return c, nil
-//}
+// }
//
-//func StartTestServerWithClients(clientCount int) ([]*Client, int) {
+// func StartTestServerWithClients(clientCount int) ([]*Client, int) {
// _, serverPort := StartTestServer()
//
// var clients []*Client
// clients[0].ReadN(2)
//
// return clients, serverPort
-//}
+// }
//
-////func TestHandleTranAgreed(t *testing.T) {
-//// clients, _ := StartTestServerWithClients(2)
-////
-//// chatMsg := "Test Chat"
-////
-//// // Assert that both clients should receive the user join notification
-//// var wg sync.WaitGroup
-//// for _, client := range clients {
-//// wg.Add(1)
-//// go func(wg *sync.WaitGroup, c *Client) {
-//// defer wg.Done()
-////
-//// receivedMsg := c.ReadTransactions()[0].GetField(fieldData).Data
-////
-//// want := []byte(fmt.Sprintf("test: %s\r", chatMsg))
-//// if bytes.Compare(receivedMsg, want) != 0 {
-//// t.Errorf("%q, want %q", receivedMsg, want)
-//// }
-//// }(&wg, client)
-//// }
-////
-//// trans := clients[1].ReadTransactions()
-//// spew.Dump(trans)
-////
-//// // Send the agreement
-//// clients[1].Connection.Write(
-//// NewTransaction(
-//// tranAgreed, 0,
-//// []Field{
-//// NewField(fieldUserName, []byte("testUser")),
-//// NewField(fieldUserIconID, []byte{0x00,0x07}),
-//// },
-//// ).Payload(),
-//// )
-////
-//// wg.Wait()
-////}
-//
-//func TestChatSend(t *testing.T) {
+// //func TestHandleTranAgreed(t *testing.T) {
+// // clients, _ := StartTestServerWithClients(2)
+// //
+// // chatMsg := "Test Chat"
+// //
+// // // Assert that both clients should receive the user join notification
+// // var wg sync.WaitGroup
+// // for _, client := range clients {
+// // wg.Add(1)
+// // go func(wg *sync.WaitGroup, c *Client) {
+// // defer wg.Done()
+// //
+// // receivedMsg := c.ReadTransactions()[0].GetField(fieldData).Data
+// //
+// // want := []byte(fmt.Sprintf("test: %s\r", chatMsg))
+// // if bytes.Compare(receivedMsg, want) != 0 {
+// // t.Errorf("%q, want %q", receivedMsg, want)
+// // }
+// // }(&wg, client)
+// // }
+// //
+// // trans := clients[1].ReadTransactions()
+// // spew.Dump(trans)
+// //
+// // // Send the agreement
+// // clients[1].Connection.Write(
+// // NewTransaction(
+// // tranAgreed, 0,
+// // []Field{
+// // NewField(fieldUserName, []byte("testUser")),
+// // NewField(fieldUserIconID, []byte{0x00,0x07}),
+// // },
+// // ).Payload(),
+// // )
+// //
+// // wg.Wait()
+// //}
+//
+// func TestChatSend(t *testing.T) {
// //srvPort := StartTestServer()
// //
// //senderClient := NewClient("senderClient")
// )
//
// wg.Wait()
-//}
+// }
//
-//func TestSetClientUserInfo(t *testing.T) {
+// func TestSetClientUserInfo(t *testing.T) {
// clients, _ := StartTestServerWithClients(2)
//
// newIcon := []byte{0x00, 0x01}
// }
//
// wg.Wait()
-//}
+// }
//
-//// TestSendInstantMsg tests that client A can send an instant message to client B
-////
-//func TestSendInstantMsg(t *testing.T) {
+// // TestSendInstantMsg tests that client A can send an instant message to client B
+// //
+// func TestSendInstantMsg(t *testing.T) {
// clients, _ := StartTestServerWithClients(2)
//
// instantMsg := "Test IM"
// }
//
// wg.Wait()
-//}
+// }
//
-//func TestOldPostNews(t *testing.T) {
+// func TestOldPostNews(t *testing.T) {
// clients, _ := StartTestServerWithClients(2)
//
// newsPost := "Test News Post"
// )
//
// wg.Wait()
-//}
-//
-//// TODO: Fixme
-////func TestGetFileNameList(t *testing.T) {
-//// clients, _ := StartTestServerWithClients(2)
-////
-//// clients[0].Connection.Write(
-//// NewTransaction(
-//// tranGetFileNameList, 0,
-//// []Field{},
-//// ).Payload(),
-//// )
-////
-//// ts := clients[0].ReadTransactions()
-//// testfileSit := ReadFileNameWithInfo(ts[0].Fields[1].Data)
-////
-//// want := "testfile.sit"
-//// got := testfileSit.Name
-//// diff := cmp.Diff(want, got)
-//// if diff != "" {
-//// t.Fatalf(diff)
-//// }
-//// if testfileSit.Name != "testfile.sit" {
-//// t.Errorf("news post missing")
-//// t.Errorf("%q, want %q", testfileSit.Name, "testfile.sit")
-//// }
-////}
-//
-//func TestNewsCategoryList(t *testing.T) {
+// }
+//
+// // TODO: Fixme
+// //func TestGetFileNameList(t *testing.T) {
+// // clients, _ := StartTestServerWithClients(2)
+// //
+// // clients[0].Connection.Write(
+// // NewTransaction(
+// // tranGetFileNameList, 0,
+// // []Field{},
+// // ).Payload(),
+// // )
+// //
+// // ts := clients[0].ReadTransactions()
+// // testfileSit := ReadFileNameWithInfo(ts[0].Fields[1].Data)
+// //
+// // want := "testfile.sit"
+// // got := testfileSit.Name
+// // diff := cmp.Diff(want, got)
+// // if diff != "" {
+// // t.Fatalf(diff)
+// // }
+// // if testfileSit.Name != "testfile.sit" {
+// // t.Errorf("news post missing")
+// // t.Errorf("%q, want %q", testfileSit.Name, "testfile.sit")
+// // }
+// //}
+//
+// func TestNewsCategoryList(t *testing.T) {
// clients, _ := StartTestServerWithClients(2)
// client := clients[0]
//
// if diff != "" {
// t.Fatalf(diff)
// }
-//}
+// }
//
-//func TestNestedNewsCategoryList(t *testing.T) {
+// func TestNestedNewsCategoryList(t *testing.T) {
// clients, _ := StartTestServerWithClients(2)
// client := clients[0]
// newsPath := NewsPath{
// if diff != "" {
// t.Fatalf(diff)
// }
-//}
+// }
//
-//func TestFileDownload(t *testing.T) {
+// func TestFileDownload(t *testing.T) {
// clients, _ := StartTestServerWithClients(2)
// client := clients[0]
//
// t.Errorf("TestFileDownload: fieldTransferSize: %s: got %#v, want %#v", test.fileName, got, test.want.transferSize)
// }
// }
-//}
+// }
//
-//func TestFileUpload(t *testing.T) {
+// func TestFileUpload(t *testing.T) {
// clients, _ := StartTestServerWithClients(2)
// client := clients[0]
//
// }
// }
// }
-//}
+// }
//
-//// TODO: Make canonical
-//func TestNewUser(t *testing.T) {
+// // TODO: Make canonical
+// func TestNewUser(t *testing.T) {
// srv, port := StartTestServer()
//
// var tests = []struct {
// test.teardown()
// }
// }
-//}
+// }
//
-//func TestDeleteUser(t *testing.T) {
+// func TestDeleteUser(t *testing.T) {
// srv, port := StartTestServer()
//
// var tests = []transactionTest{
//
// test.Teardown(srv)
// }
-//}
+// }
//
-//func TestDeleteFile(t *testing.T) {
+// func TestDeleteFile(t *testing.T) {
// srv, port := StartTestServer()
//
// var tests = []transactionTest{
//
// test.Teardown(srv)
// }
-//}
+// }
//
-//func Test_authorize(t *testing.T) {
+// func Test_authorize(t *testing.T) {
// accessBitmap := big.NewInt(int64(0))
// accessBitmap.SetBit(accessBitmap, accessCreateFolder, 1)
// fmt.Printf("%v %b %x\n", accessBitmap, accessBitmap, accessBitmap)
// }
// })
// }
-//}
+// }