Skip to content

Commit

Permalink
166: Add more tests to NetworkUnitTests.
Browse files Browse the repository at this point in the history
Signed-off-by: Deyan Zhekov <[email protected]>
  • Loading branch information
deyanzz committed Oct 18, 2023
1 parent 1932b5a commit cf91ebf
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 2 deletions.
1 change: 1 addition & 0 deletions sdk/tests/unit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ add_executable(${TEST_PROJECT_NAME}
HbarTransferTest.cc
KeyListTest.cc
LedgerIdTest.cc
NetworkUnitTests.cc
NetworkVersionInfoUnitTests.cc
NftIdTest.cc
NodeAddressTest.cc
Expand Down
54 changes: 52 additions & 2 deletions sdk/tests/unit/NetworkUnitTests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@
* limitations under the License.
*
*/
#include "AccountId.h"
#include "impl/Network.h"
#include <string>
#include <unordered_map>
#include <vector>

#include <gtest/gtest.h>

Expand All @@ -31,8 +35,54 @@ class NetworkUnitTests : public ::testing::Test
TEST_F(NetworkUnitTests, ConstructForMainnet)
{
// Given / When
const Hedera::internal::Network network = Hedera::internal::Network::forMainnet();
Hedera::internal::Network mainnetNetwork = Hedera::internal::Network::forMainnet();

// Then
EXPECT_EQ(network.getMaxNodeAttempts(), 0);
std::unordered_map<std::string, AccountId> networkMap;
std::vector<AccountId> nodeAccountIds;

EXPECT_NO_THROW(networkMap = mainnetNetwork.getNetwork());
EXPECT_NO_THROW(nodeAccountIds = mainnetNetwork.getNodeAccountIdsForExecute());
EXPECT_GT(networkMap.size(), 0);
EXPECT_GT(nodeAccountIds.size(), 0);

// Clean up
mainnetNetwork.close();
}

TEST_F(NetworkUnitTests, ConstructForTestnet)
{
// Given / When
Hedera::internal::Network testnetNetwork = Hedera::internal::Network::forTestnet();

// Then
std::unordered_map<std::string, AccountId> networkMap;
std::vector<AccountId> nodeAccountIds;

EXPECT_NO_THROW(networkMap = testnetNetwork.getNetwork());
EXPECT_NO_THROW(nodeAccountIds = testnetNetwork.getNodeAccountIdsForExecute());

EXPECT_GT(networkMap.size(), 0);
EXPECT_GT(nodeAccountIds.size(), 0);

// Clean up
testnetNetwork.close();
}

TEST_F(NetworkUnitTests, ConstructForPreviewnet)
{
// Given / When
Hedera::internal::Network previewnetNetwork = Hedera::internal::Network::forPreviewnet();
std::vector<AccountId> nodeAccountIds;

// Then
std::unordered_map<std::string, AccountId> networkMap;
EXPECT_NO_THROW(networkMap = previewnetNetwork.getNetwork());
EXPECT_NO_THROW(nodeAccountIds = previewnetNetwork.getNodeAccountIdsForExecute());

EXPECT_GT(networkMap.size(), 0);
EXPECT_GT(nodeAccountIds.size(), 0);

// Clean up
previewnetNetwork.close();
}

0 comments on commit cf91ebf

Please sign in to comment.