Skip to content

Commit

Permalink
fix ut
Browse files Browse the repository at this point in the history
  • Loading branch information
cyjseagull committed Sep 6, 2024
1 parent 4e6e2a0 commit 7fcd689
Show file tree
Hide file tree
Showing 15 changed files with 324 additions and 277 deletions.
1 change: 1 addition & 0 deletions cpp/cmake/IncludeDirectories.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/wedpr-computing)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/wedpr-crypto)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/wedpr-storage)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/wedpr-helper)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/wedpr-transport)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/wedpr-crypto/sdk)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/wedpr-transport/ppc-front)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/wedpr-transport/ppc-gateway)
Expand Down
1 change: 1 addition & 0 deletions cpp/ppc-framework/front/IFront.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ class IFront : virtual public IFrontClient
* @param topic the topic to unregister
*/
virtual void unRegisterTopic(std::string const& topic) = 0;

};

class IFrontBuilder
Expand Down
2 changes: 1 addition & 1 deletion cpp/wedpr-computing/ppc-cem/tests/TestCEMService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ BOOST_FIXTURE_TEST_SUITE(cMServiceTest, TestPromptFixture)
BOOST_AUTO_TEST_CASE(testCEMService)
{
auto cemService = std::make_shared<CEMService>();
std::string configPath{"../../../ppc-cem/tests/data/config.ini"};
std::string configPath{"../../../../wedpr-computing/ppc-cem/tests/data/config.ini"};
boost::property_tree::ptree pt;
boost::property_tree::read_ini(configPath, pt);
// load the cm config
Expand Down
2 changes: 1 addition & 1 deletion cpp/wedpr-computing/ppc-cem/tests/data/config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[cem]
use_mysql = false
dataset_hdfs_path = /user/ppc/admin
dataset_file_path = ../../../ppc-cem/tests/data
dataset_file_path = ../../../../wedpr-computing/ppc-cem/tests/data
ciphertext_suffix = -encrypted
read_per_batch_lines = 100000

Expand Down
2 changes: 1 addition & 1 deletion cpp/wedpr-computing/ppc-mpc/tests/TestMPCService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ BOOST_FIXTURE_TEST_SUITE(MPCServiceTest, TestPromptFixture)
BOOST_AUTO_TEST_CASE(testMPCService)
{
auto mpcService = std::make_shared<MPCService>();
std::string configPath{"../../../ppc-mpc/tests/data/config.ini"};
std::string configPath{"../../../../wedpr-computing/ppc-mpc/tests/data/config.ini"};
boost::property_tree::ptree pt;
boost::property_tree::read_ini(configPath, pt);
// load the mpc config
Expand Down
70 changes: 37 additions & 33 deletions cpp/wedpr-computing/ppc-pir/tests/FakeOtPIRFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,51 +38,55 @@ using namespace ppc::io;
using namespace ppc::front;
using namespace ppc::tools;

namespace ppc::test {

class FakeOtPIRImpl : public OtPIRImpl {
namespace ppc::test
{
class FakeOtPIRImpl : public OtPIRImpl
{
public:
using Ptr = std::shared_ptr<FakeOtPIRImpl>;
FakeOtPIRImpl(OtPIRConfig::Ptr const &_config, unsigned _idleTimeMs = 0)
: OtPIRImpl(_config, _idleTimeMs) {
m_enableOutputExists = true;
}
~FakeOtPIRImpl() override = default;
using Ptr = std::shared_ptr<FakeOtPIRImpl>;
FakeOtPIRImpl(OtPIRConfig::Ptr const& _config, unsigned _idleTimeMs = 0)
: OtPIRImpl(_config, _idleTimeMs)
{
m_enableOutputExists = true;
}
~FakeOtPIRImpl() override = default;
};

class FakeOtPIRFactory : public OtPIRFactory {
class FakeOtPIRFactory : public OtPIRFactory
{
public:
using Ptr = std::shared_ptr<FakeOtPIRFactory>;
using Ptr = std::shared_ptr<FakeOtPIRFactory>;

FakeOtPIRFactory()
FakeOtPIRFactory()
: m_front(std::make_shared<FakeFront>()),
m_dataResourceLoader(std::make_shared<DataResourceLoaderImpl>(
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr)),
m_threadPool(std::make_shared<ThreadPool>("ot-pir", 4)) {
auto hashImpl = std::make_shared<Sha512Hash>();
auto eccCrypto = std::make_shared<OpenSSLEccCrypto>(
hashImpl, ppc::protocol::ECCCurve::P256);
m_cryptoBox = std::make_shared<ppc::crypto::CryptoBox>(hashImpl, eccCrypto);
}
m_threadPool(std::make_shared<ThreadPool>("ot-pir", 4))
{
auto hashImpl = std::make_shared<Sha512Hash>();
auto eccCrypto =
std::make_shared<OpenSSLEccCrypto>(hashImpl, ppc::protocol::ECCCurve::P256);
m_cryptoBox = std::make_shared<ppc::crypto::CryptoBox>(hashImpl, eccCrypto);
}

~FakeOtPIRFactory() override = default;
~FakeOtPIRFactory() override = default;

OtPIRImpl::Ptr createOtPIR(std::string const &_selfParty) {
auto config =
std::make_shared<OtPIRConfig>(_selfParty, m_front, m_cryptoBox,
m_threadPool, m_dataResourceLoader, 1);
OtPIRImpl::Ptr createOtPIR(std::string const& _selfParty)
{
auto config = std::make_shared<OtPIRConfig>(
_selfParty, m_front, m_cryptoBox, m_threadPool, m_dataResourceLoader, 1);

return std::make_shared<FakeOtPIRImpl>(config);
}
return std::make_shared<FakeOtPIRImpl>(config);
}

DataResourceLoaderImpl::Ptr resourceLoader() { return m_dataResourceLoader; }
FakeFront::Ptr front() { return m_front; }
CryptoBox::Ptr cryptoBox() { return m_cryptoBox; }
DataResourceLoaderImpl::Ptr resourceLoader() { return m_dataResourceLoader; }
FakeFront::Ptr front() { return m_front; }
CryptoBox::Ptr cryptoBox() { return m_cryptoBox; }

private:
FakeFront::Ptr m_front;
DataResourceLoaderImpl::Ptr m_dataResourceLoader;
ThreadPool::Ptr m_threadPool;
CryptoBox::Ptr m_cryptoBox;
FakeFront::Ptr m_front;
DataResourceLoaderImpl::Ptr m_dataResourceLoader;
ThreadPool::Ptr m_threadPool;
CryptoBox::Ptr m_cryptoBox;
};
} // namespace ppc::test
} // namespace ppc::test
Loading

0 comments on commit 7fcd689

Please sign in to comment.