use of org.xel.http.APICall in project elastic-core-maven by OrdinaryDude.
the class TestCreateTwoPhased method invalidMoneyTransfer.
@Test
public void invalidMoneyTransfer() {
int height = Nxt.getBlockchain().getHeight();
APICall apiCall = new TwoPhasedMoneyTransferBuilder().finishHeight(height).build();
issueCreateTwoPhased(apiCall, true);
apiCall = new TwoPhasedMoneyTransferBuilder().finishHeight(height + 100000).build();
issueCreateTwoPhased(apiCall, true);
apiCall = new TwoPhasedMoneyTransferBuilder().quorum(0).build();
issueCreateTwoPhased(apiCall, true);
apiCall = new TwoPhasedMoneyTransferBuilder().noWhitelist().build();
issueCreateTwoPhased(apiCall, true);
apiCall = new TwoPhasedMoneyTransferBuilder().whitelisted(0).build();
issueCreateTwoPhased(apiCall, true);
/*apiCall = new TwoPhasedMoneyTransferBuilder().votingModel(VoteWeighting.VotingModel.ASSET.getCode()).build();
issueCreateTwoPhased(apiCall, true);
apiCall = new TwoPhasedMoneyTransferBuilder().votingModel(VoteWeighting.VotingModel.ASSET.getCode())
.minBalance(50, VoteWeighting.MinBalanceModel.ASSET.getCode())
.build();
issueCreateTwoPhased(apiCall, true);*/
}
use of org.xel.http.APICall in project elastic-core-maven by OrdinaryDude.
the class TestCreateTwoPhased method unconfirmed.
@Test
public void unconfirmed() {
List<String> transactionIds = new ArrayList<>(10);
for (int i = 0; i < 10; i++) {
APICall apiCall = new TwoPhasedMoneyTransferBuilder().build();
JSONObject transactionJSON = issueCreateTwoPhased(apiCall, false);
String idString = (String) transactionJSON.get("transaction");
transactionIds.add(idString);
}
APICall apiCall = new TwoPhasedMoneyTransferBuilder().build();
apiCall.invoke();
JSONObject response = TestGetAccountPhasedTransactions.phasedTransactionsApiCall().invoke();
Logger.logMessage("getAccountPhasedTransactionsResponse:" + response.toJSONString());
JSONArray transactionsJson = (JSONArray) response.get("transactions");
for (String idString : transactionIds) {
Assert.assertTrue(TwoPhasedSuite.searchForTransactionId(transactionsJson, idString));
}
}
use of org.xel.http.APICall in project elastic-core-maven by OrdinaryDude.
the class TestGetPhasingPoll method transactionVotes.
@Test
public void transactionVotes() {
APICall apiCall = new TestCreateTwoPhased.TwoPhasedMoneyTransferBuilder().quorum(1).build();
JSONObject transactionJSON = TestCreateTwoPhased.issueCreateTwoPhased(apiCall, false);
String fullHash = (String) transactionJSON.get("fullHash");
String transactionId = (String) transactionJSON.get("transaction");
generateBlock();
long fee = Constants.ONE_NXT;
apiCall = new APICall.Builder("approveTransaction").param("secretPhrase", CHUCK.getSecretPhrase()).param("transactionFullHash", fullHash).param("feeNQT", fee).build();
JSONObject response = apiCall.invoke();
Logger.logMessage("approveTransactionResponse:" + response.toJSONString());
generateBlock();
apiCall = new APICall.Builder("getPhasingPoll").param("transaction", transactionId).param("countVotes", "true").build();
response = apiCall.invoke();
Logger.logMessage("getPhasingPollResponse:" + response.toJSONString());
Assert.assertNull(response.get("errorCode"));
Assert.assertEquals(1, Integer.parseInt((String) response.get("result")));
}
use of org.xel.http.APICall in project elastic-core-maven by OrdinaryDude.
the class TestGetAccountPhasedTransactions method simpleIngoingLookup.
@Test
public void simpleIngoingLookup() {
APICall apiCall = new TestCreateTwoPhased.TwoPhasedMoneyTransferBuilder().build();
JSONObject transactionJSON = TestCreateTwoPhased.issueCreateTwoPhased(apiCall, false);
generateBlock();
JSONObject response = phasedTransactionsApiCall(BOB.getId()).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 sorting.
@Test
public void sorting() {
for (int i = 0; i < 15; i++) {
APICall apiCall = new TestCreateTwoPhased.TwoPhasedMoneyTransferBuilder().build();
TestCreateTwoPhased.issueCreateTwoPhased(apiCall, false);
}
JSONObject response = phasedTransactionsApiCall().invoke();
Logger.logMessage("getAccountPhasedTransactionsResponse:" + 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;
}
}
Aggregations