-
Notifications
You must be signed in to change notification settings - Fork 75
Expand file tree
/
Copy pathMirrorNodeGatewayIntegrationTests.cc
More file actions
88 lines (72 loc) · 2.7 KB
/
MirrorNodeGatewayIntegrationTests.cc
File metadata and controls
88 lines (72 loc) · 2.7 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
// SPDX-License-Identifier: Apache-2.0
#include "BaseIntegrationTest.h"
#include "impl/MirrorNodeGateway.h"
#include <gtest/gtest.h>
#include <nlohmann/json.hpp>
#include <string>
using json = nlohmann::json;
using namespace Hiero;
class MirrorNodeGatewayIntegrationTests : public BaseIntegrationTest
{
protected:
[[nodiscard]] inline const std::string& getAccountIdStr() const { return mAccountIdStr; }
[[nodiscard]] inline const std::string& getMirrorNetworkUrl() const { return mMirrorNetworkUrl; }
private:
const std::string mAccountIdStr = "0.0.2";
const std::string mMirrorNetworkUrl = "http://127.0.0.1:5551";
};
//-----
TEST_F(MirrorNodeGatewayIntegrationTests, AccountInfoQuery)
{
// Given
const std::string& accountIdStr = getAccountIdStr();
// When
json response;
ASSERT_NO_THROW(response = internal::MirrorNodeGateway::MirrorNodeQuery(
getMirrorNetworkUrl(), { accountIdStr }, internal::MirrorNodeGateway::ACCOUNT_INFO_QUERY.data()););
// Then
ASSERT_FALSE(response.empty()); // checks if any data
EXPECT_TRUE(response["_status"].empty()); // if status is in json then not found
}
//-----
TEST_F(MirrorNodeGatewayIntegrationTests, ContractInfoQuery)
{
// Given
const std::string& contractIdStr = getAccountIdStr();
// When
json response;
ASSERT_NO_THROW(
response = internal::MirrorNodeGateway::MirrorNodeQuery(
getMirrorNetworkUrl(), { contractIdStr }, internal::MirrorNodeGateway::CONTRACT_INFO_QUERY.data()););
// Then
ASSERT_FALSE(response.empty()); // checks if any data
EXPECT_FALSE(response["_status"].empty()); // no such contract exists then should have _status not found
}
//-----
TEST_F(MirrorNodeGatewayIntegrationTests, TokenRelationshipQuery)
{
// Given
const std::string& accountIdStr = getAccountIdStr();
// When
json response;
ASSERT_NO_THROW(
response = internal::MirrorNodeGateway::MirrorNodeQuery(
getMirrorNetworkUrl(), { accountIdStr }, internal::MirrorNodeGateway::TOKEN_RELATIONSHIPS_QUERY.data()););
// Then
ASSERT_FALSE(response.empty()); // checks if any data
EXPECT_TRUE(response["_status"].empty()); // if status is in json then not found
}
//-----
TEST_F(MirrorNodeGatewayIntegrationTests, TokensBalancesQuery)
{
// Given
const std::string& accountIdStr = getAccountIdStr();
// When
json response;
ASSERT_NO_THROW(
response = internal::MirrorNodeGateway::MirrorNodeQuery(
getMirrorNetworkUrl(), { accountIdStr }, internal::MirrorNodeGateway::TOKEN_BALANCES_QUERY.data()););
// Then
ASSERT_FALSE(response.empty()); // checks if any data
EXPECT_TRUE(response["_status"].empty()); // no such contract exists then should have _status not found
}