From 3d76343d37b493dad402e891d0f69b5d962899ba Mon Sep 17 00:00:00 2001 From: Daniel Bengtsson Date: Sat, 12 Nov 2022 12:32:01 +0100 Subject: [PATCH] Change the initiate_peer_connections default #38 (#59) --- src/global_config.hpp | 2 +- tests/test_global_config.cpp | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/global_config.hpp b/src/global_config.hpp index 340a0de..d69207b 100644 --- a/src/global_config.hpp +++ b/src/global_config.hpp @@ -55,7 +55,7 @@ class Config { protected: // Default values for all settings std::map m_bool_settings{ - {BoolSetting::INITIATE_PEER_CONNECTIONS, true}}; + {BoolSetting::INITIATE_PEER_CONNECTIONS, false}}; std::map m_int_settings{ {IntSetting::LISTENING_PORT, 20001}, diff --git a/tests/test_global_config.cpp b/tests/test_global_config.cpp index 61b8c66..c93147d 100644 --- a/tests/test_global_config.cpp +++ b/tests/test_global_config.cpp @@ -19,7 +19,7 @@ TEST_F(FileConfigTest, EmptyFile) { const auto config_file = tmp_dir() / ".zit"; write_file(config_file, ""); const auto config = FileConfig{config_file}; - EXPECT_TRUE(config.get(BoolSetting::INITIATE_PEER_CONNECTIONS)); + EXPECT_FALSE(config.get(BoolSetting::INITIATE_PEER_CONNECTIONS)); EXPECT_EQ(config.get(IntSetting::LISTENING_PORT), 20001); EXPECT_EQ(config.get(IntSetting::CONNECTION_PORT), 20000); } @@ -28,16 +28,16 @@ TEST_F(FileConfigTest, InvalidFile) { const auto config_file = tmp_dir() / ".zit"; write_file(config_file, "foo=bar\nlistening_port=nan"); const auto config = FileConfig{config_file}; - EXPECT_TRUE(config.get(BoolSetting::INITIATE_PEER_CONNECTIONS)); + EXPECT_FALSE(config.get(BoolSetting::INITIATE_PEER_CONNECTIONS)); } TEST_F(FileConfigTest, CorrectFile) { const auto config_file = tmp_dir() / ".zit"; write_file(config_file, - "initiate_peer_connections=false\nlistening_port=123\nconnection_" + "initiate_peer_connections=true\nlistening_port=123\nconnection_" "port=321"); const auto config = FileConfig{config_file}; - EXPECT_FALSE(config.get(BoolSetting::INITIATE_PEER_CONNECTIONS)); + EXPECT_TRUE(config.get(BoolSetting::INITIATE_PEER_CONNECTIONS)); EXPECT_EQ(config.get(IntSetting::LISTENING_PORT), 123); EXPECT_EQ(config.get(IntSetting::CONNECTION_PORT), 321); }