use of org.xel.http.APICall in project elastic-core-maven by OrdinaryDude.
the class TestGetAccountPhasedTransactions method simpleOutgoingLookup.
@Test
public void simpleOutgoingLookup() {
APICall apiCall = new TestCreateTwoPhased.TwoPhasedMoneyTransferBuilder().build();
JSONObject transactionJSON = TestCreateTwoPhased.issueCreateTwoPhased(apiCall, false);
generateBlock();
JSONObject response = phasedTransactionsApiCall().invoke();
Logger.logMessage("getAccountPhasedTransactionsResponse:" + response.toJSONString());
JSONArray transactionsJson = (JSONArray) response.get("transactions");
Assert.assertTrue(TwoPhasedSuite.searchForTransactionId(transactionsJson, (String) transactionJSON.get("transaction")));
response = phasedTransactionsApiCall(CHUCK.getId()).invoke();
Logger.logMessage("getAccountPhasedTransactionsResponse:" + response.toJSONString());
transactionsJson = (JSONArray) response.get("transactions");
Assert.assertFalse(TwoPhasedSuite.searchForTransactionId(transactionsJson, (String) transactionJSON.get("transaction")));
}
use of org.xel.http.APICall in project elastic-core-maven by OrdinaryDude.
the class TestGetAccountPhasedTransactions method multiple.
@Test
public void multiple() {
JSONObject response = phasedTransactionsApiCall().invoke();
Logger.logMessage("getAccountPhasedTransactionsResponse:" + response.toJSONString());
JSONArray transactionsJson = (JSONArray) response.get("transactions");
int transactionsSize0 = transactionsJson.size();
APICall apiCall = new TestCreateTwoPhased.TwoPhasedMoneyTransferBuilder().build();
JSONObject transactionJSON1 = TestCreateTwoPhased.issueCreateTwoPhased(apiCall, false);
JSONObject transactionJSON2 = TestCreateTwoPhased.issueCreateTwoPhased(apiCall, false);
generateBlock();
response = phasedTransactionsApiCall().invoke();
Logger.logMessage("getAccountPhasedTransactionsResponse:" + response.toJSONString());
transactionsJson = (JSONArray) response.get("transactions");
int transactionsSize = transactionsJson.size();
Assert.assertTrue(transactionsSize - transactionsSize0 == 2);
Assert.assertTrue(TwoPhasedSuite.searchForTransactionId(transactionsJson, (String) transactionJSON1.get("transaction")));
Assert.assertTrue(TwoPhasedSuite.searchForTransactionId(transactionsJson, (String) transactionJSON2.get("transaction")));
}
use of org.xel.http.APICall in project elastic-core-maven by OrdinaryDude.
the class TestGetVoterPhasedTransactions method sorting.
@Test
public void sorting() {
for (int i = 0; i < 15; i++) {
APICall apiCall = new TestCreateTwoPhased.TwoPhasedMoneyTransferBuilder().build();
TestCreateTwoPhased.issueCreateTwoPhased(apiCall, false);
}
JSONObject response = getVoterPhasedTransactions().invoke();
Logger.logMessage("getVoterPhasedTransactionsResponse:" + response.toJSONString());
JSONArray transactionsJson = (JSONArray) response.get("transactions");
// sorting check
int prevHeight = Integer.MAX_VALUE;
for (Object transactionsJsonObj : transactionsJson) {
JSONObject transactionObject = (JSONObject) transactionsJsonObj;
int height = ((Long) transactionObject.get("height")).intValue();
Assert.assertTrue(height <= prevHeight);
prevHeight = height;
}
}
use of org.xel.http.APICall in project elastic-core-maven by OrdinaryDude.
the class TestGetVoterPhasedTransactions method simpleTransactionLookup.
@Test
public void simpleTransactionLookup() {
APICall apiCall = new TwoPhasedMoneyTransferBuilder().build();
JSONObject transactionJSON = TestCreateTwoPhased.issueCreateTwoPhased(apiCall, false);
String transactionId = (String) transactionJSON.get("transaction");
generateBlock();
JSONObject response = getVoterPhasedTransactions().invoke();
Logger.logMessage("getVoterPhasedTransactionsResponse:" + response.toJSONString());
JSONArray transactionsJson = (JSONArray) response.get("transactions");
Assert.assertTrue(TwoPhasedSuite.searchForTransactionId(transactionsJson, transactionId));
}
use of org.xel.http.APICall in project elastic-core-maven by OrdinaryDude.
the class TestGetPolls method accountPollsIncrease.
@Test
public void accountPollsIncrease() {
APICall apiCall = new APICall.Builder("getPolls").param("includeVoters", "false").param("account", Long.toUnsignedString(DAVE.getId())).param("firstIndex", 0).param("lastIndex", 100).build();
JSONObject jsonResponse = apiCall.invoke();
Logger.logMessage("getPollsResponse:" + jsonResponse.toJSONString());
JSONArray polls = (JSONArray) jsonResponse.get("polls");
int initialSize = polls.size();
APICall createPollApiCall = new TestCreatePoll.CreatePollBuilder().secretPhrase(DAVE.getSecretPhrase()).build();
String poll = TestCreatePoll.issueCreatePoll(createPollApiCall, false);
generateBlock();
jsonResponse = apiCall.invoke();
Logger.logMessage("getPollsResponse:" + jsonResponse.toJSONString());
polls = (JSONArray) jsonResponse.get("polls");
int size = polls.size();
JSONObject lastPoll = (JSONObject) polls.get(0);
Assert.assertEquals(poll, lastPoll.get("poll"));
Assert.assertEquals(size, initialSize + 1);
}
Aggregations