MCPcopy Create free account
hub / github.com/ReversecLabs/C3 / TestEcho

Method TestEcho

Src/ChannelLinter/ChannelLinter.cpp:153–170  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

151 }
152
153 void ChannelLinter::TestEcho(MockDeviceBridge& channel, MockDeviceBridge& complementary)
154 {
155 size_t packetLen = 8;
156 std::cout << "Testing channel echo with " << packetLen << " bytes of data ... " << std::flush;
157 auto data = ByteVector(FSecure::Utils::GenerateRandomData(packetLen));
158 if (channel.GetDevice()->OnSendToChannelInternal(data) != data.size())
159 throw std::runtime_error{ "Failed to send echo packet" };
160 auto echo = std::static_pointer_cast<FSecure::C3::AbstractChannel>(channel.GetDevice())->OnReceiveFromChannelInternal();
161 if (!echo.empty())
162 throw std::runtime_error{ "Channel read it's own message" };
163
164 // clean channel
165 auto received = std::static_pointer_cast<FSecure::C3::AbstractChannel>(complementary.GetDevice())->OnReceiveFromChannelInternal();
166 if (received.empty() || received.size() > 1 || received[0] != data)
167 throw std::runtime_error{ "Receive error" };
168
169 std::cout << "OK" << std::endl;
170 }
171
172 void ChannelLinter::TestChannelMTU(MockDeviceBridge& channel, MockDeviceBridge& complementary, bool overlapped)
173 {

Callers

nothing calls this directly

Calls 7

ByteVectorClass · 0.85
GenerateRandomDataFunction · 0.85
GetDeviceMethod · 0.45
sizeMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected