@@ -66,6 +66,101 @@ TEST(api, test_block) { // NOLINT
6666
6767/* */
6868
69+ TEST (api, test_block_first) { // NOLINT
70+ Ark::Client::Connection<MockApi> connection (tIp, tPort);
71+
72+ const std::string expected_response = R"( {
73+ "data": {
74+ "id": "13114381566690093367",
75+ "version": 0,
76+ "height": 1,
77+ "previous": "0",
78+ "forged": {
79+ "reward": "0",
80+ "fee": "0",
81+ "total": "0",
82+ "amount": "12500000000000000"
83+ },
84+ "payload": {
85+ "hash": "2a44f340d76ffc3df204c5f38cd355b7496c9065a1ade2ef92071436bd72e867",
86+ "length": 11395
87+ },
88+ "generator": {
89+ "address": "D6Z26L69gdk9qYmTv5uzk3uGepigtHY4ax",
90+ "publicKey": "03d3fdad9c5b25bf8880e6b519eb3611a5c0b31adebc8455f0e096175b28321aff"
91+ },
92+ "signature": "3044022035694a9b99a9236655c658eb07fc3b02ce5edcc24b76424a7287c54ed3822b0602203621e92defb360490610f763d85e94c2db2807a4bd7756cc8a6a585463ef7bae",
93+ "confirmations": 4346566,
94+ "transactions": 52,
95+ "timestamp": {
96+ "epoch": 0,
97+ "unix": 1490101200,
98+ "human": "2017-03-21T13:00:00.000Z"
99+ }
100+ }
101+ })" ;
102+
103+ EXPECT_CALL (connection.api .blocks , first ())
104+ .Times (1 )
105+ .WillOnce (Return (expected_response));
106+
107+ const auto block = connection.api .blocks .first ();
108+
109+ auto responseMatches = strcmp (expected_response.c_str (),
110+ block.c_str ()) == 0 ;
111+ ASSERT_TRUE (responseMatches);
112+ }
113+
114+ /* */
115+
116+ TEST (api, test_block_last) { // NOLINT
117+ Ark::Client::Connection<MockApi> connection (tIp, tPort);
118+
119+ const std::string expected_response = R"( {
120+ "data": {
121+ "id": "5768900e27621b95dc201fc4e6ce16e72a39e0c625a1c659a23e83eac69605e0",
122+ "version": 0,
123+ "height": 4346647,
124+ "previous": "4deae70324c919d3a79f0f065cfa085a475a7245bcd04d4e558d3205658fc706",
125+ "forged": {
126+ "reward": "200000000",
127+ "fee": "10000000",
128+ "total": "210000000",
129+ "amount": "900000000"
130+ },
131+ "payload": {
132+ "hash": "b48f23356cc70d13b0a0c0ba6811be0144a9fc673cc9f723f036187c3bb67f2d",
133+ "length": 32
134+ },
135+ "generator": {
136+ "username": "genesis_40",
137+ "address": "D8xN3Nsa3KfC3H68Ek9xnkfdSwzv8Kkh3q",
138+ "publicKey": "026a423b3323de175dd82788c7eab57850c6a37ea6a470308ebadd7007baf8ceb3"
139+ },
140+ "signature": "304402203b6251780c8baead56882aa5aee188f85f8941a1bca272ef6ff3bf9d26cfeed602207634d5268a130937603b774a7282e44065370785dc4b809cf0e98f0e56252bcc",
141+ "confirmations": 0,
142+ "transactions": 1,
143+ "timestamp": {
144+ "epoch": 92536208,
145+ "unix": 1582637408,
146+ "human": "2020-02-25T13:30:08.000Z"
147+ }
148+ }
149+ })" ;
150+
151+ EXPECT_CALL (connection.api .blocks , last ())
152+ .Times (1 )
153+ .WillOnce (Return (expected_response));
154+
155+ const auto block = connection.api .blocks .last ();
156+
157+ auto responseMatches = strcmp (expected_response.c_str (),
158+ block.c_str ()) == 0 ;
159+ ASSERT_TRUE (responseMatches);
160+ }
161+
162+ /* */
163+
69164TEST (api, test_block_transactions) { // NOLINT
70165 Ark::Client::Connection<MockApi> connection (tIp, tPort);
71166
0 commit comments