@@ -17,6 +17,7 @@ public class HttpTestBlock001 {
1717 private HttpResponse response ;
1818 private String httpnode = Configuration .getByPath ("testng.conf" ).getStringList ("httpnode.ip.list" )
1919 .get (0 );
20+ private String httpSoliditynode = Configuration .getByPath ("testng.conf" ).getStringList ("httpnode.ip.list" ).get (2 );
2021 private Integer currentBlockNum ;
2122 private JSONObject blockContent ;
2223 private String blockId ;
@@ -46,6 +47,31 @@ public void get1NowBlock() {
4647 Assert .assertFalse (responseContent .get ("witness_address" ).toString ().isEmpty ());
4748 }
4849
50+ /**
51+ * constructor.
52+ */
53+ @ Test (enabled = true , description = "Get now block from solidity by http" )
54+ public void get1NowBlockFromSolidity () {
55+ response = HttpMethed .getNowBlockFromSolidity (httpSoliditynode );
56+ logger .info ("code is " + response .getStatusLine ().getStatusCode ());
57+ Assert .assertEquals (response .getStatusLine ().getStatusCode (), 200 );
58+ responseContent = HttpMethed .parseResponseContent (response );
59+ blockContent = responseContent ;
60+ blockId = responseContent .get ("blockID" ).toString ();
61+ HttpMethed .printJsonContent (responseContent );
62+ Assert .assertTrue (responseContent .size () >= 2 );
63+ responseContent = HttpMethed .parseStringContent (responseContent .get ("block_header" ).toString ());
64+ Assert .assertTrue (responseContent .size () >= 2 );
65+ Assert .assertFalse (responseContent .get ("witness_signature" ).toString ().isEmpty ());
66+ HttpMethed .printJsonContent (responseContent );
67+ responseContent = HttpMethed .parseStringContent (responseContent .get ("raw_data" ).toString ());
68+ HttpMethed .printJsonContent (responseContent );
69+ Assert .assertTrue (Integer .parseInt (responseContent .get ("number" ).toString ()) > 0 );
70+ currentBlockNum = Integer .parseInt (responseContent .get ("number" ).toString ());
71+ Assert .assertTrue (Long .parseLong (responseContent .get ("timestamp" ).toString ()) > 1550724114000L );
72+ Assert .assertFalse (responseContent .get ("witness_address" ).toString ().isEmpty ());
73+ }
74+
4975 /**
5076 * constructor.
5177 */
@@ -58,6 +84,18 @@ public void get2BlockByNum() {
5884
5985 }
6086
87+ /**
88+ * constructor.
89+ */
90+ @ Test (enabled = true , description = "Get block by num from solidity by http" )
91+ public void get2BlockByNumFromSolidity () {
92+ response = HttpMethed .getBlockByNumFromSolidity (httpSoliditynode , currentBlockNum );
93+ Assert .assertEquals (response .getStatusLine ().getStatusCode (), 200 );
94+ responseContent = HttpMethed .parseResponseContent (response );
95+ Assert .assertEquals (responseContent , blockContent );
96+
97+ }
98+
6199 /**
62100 * constructor.
63101 */
@@ -154,6 +192,19 @@ public void get9NodeInfo() {
154192 Assert .assertTrue (responseContent .getString ("configNodeInfo" ).contains ("\" dbVersion\" :2" ));
155193 }
156194
195+ /**
196+ * constructor.
197+ */
198+ @ Test (enabled = true , description = "Get transaction count by blocknum from solidity by http" )
199+ public void getTransactionCountByBlocknumFromSolidity () {
200+ response = HttpMethed .getTransactionCountByBlocknumFromSolidity (httpSoliditynode , currentBlockNum );
201+ Assert .assertEquals (response .getStatusLine ().getStatusCode (), 200 );
202+ responseContent = HttpMethed .parseResponseContent (response );
203+ HttpMethed .printJsonContent (responseContent );
204+ Assert .assertTrue (responseContent .size () == 1 );
205+ Assert .assertTrue (Integer .parseInt (responseContent .get ("count" ).toString ()) >= 0 );
206+ }
207+
157208 /**
158209 * constructor.
159210 */
0 commit comments