-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathrwtest.cpp
42 lines (33 loc) · 889 Bytes
/
rwtest.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/*
* readwrite.cpp
* serp++
*
* Created by Victor Grishchenko on 3/19/09.
* Copyright 2009 Delft University of Technology. All rights reserved.
*
*/
#include <gtest/gtest.h>
#include "p2tp.h"
TEST(P2TP, ConnectTest) {
P2File("");
p2tp_init(7001);
int tf = p2tp_open("test_file",NULL);
int tb = p2tp_open("test_file_copy",p2tp_file_info(tf)->hash_data);
struct sockaddr_in addr;
addr.sin_family = AF_INET;
addr.sin_port = htons(7001);
addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
p2tp_add_peer(tb,addr,0); // TRICK: will open a channel to the first file
p2tp_loop(P2TP::now()+TINT1SEC/10);
while (count=copy.read(bytes)) {
read(orig,bytes2,count);
ASSERT_EQ ( 0, memcmp(bytes,bytes2,count) );
}
p2tp_close(tb);
p2tp_close(tf);
}
int main (int argc, char** argv) {
P2TP::init();
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}