use of org.xel.http.twophased.TestCreateTwoPhased.TwoPhasedMoneyTransferBuilder in project elastic-core-maven by OrdinaryDude.
the class TestGetVoterPhasedTransactions method transactionLookupAfterVote.
@Test
public void transactionLookupAfterVote() {
APICall apiCall = new TwoPhasedMoneyTransferBuilder().build();
JSONObject transactionJSON = TestCreateTwoPhased.issueCreateTwoPhased(apiCall, false);
String transactionFullHash = (String) transactionJSON.get("fullHash");
generateBlock();
long fee = Constants.ONE_NXT;
apiCall = new APICall.Builder("approveTransaction").param("secretPhrase", CHUCK.getSecretPhrase()).param("transactionFullHash", transactionFullHash).param("feeNQT", fee).build();
JSONObject response = apiCall.invoke();
Logger.logMessage("approvePhasedTransactionResponse:" + response.toJSONString());
generateBlock();
response = getVoterPhasedTransactions().invoke();
Logger.logMessage("getVoterPhasedTransactionsResponse:" + response.toJSONString());
JSONArray transactionsJson = (JSONArray) response.get("transactions");
Assert.assertFalse(TwoPhasedSuite.searchForTransactionId(transactionsJson, transactionFullHash));
}
use of org.xel.http.twophased.TestCreateTwoPhased.TwoPhasedMoneyTransferBuilder in project elastic-core-maven by OrdinaryDude.
the class TestApproveTransaction method invalidVoteCasting.
@Test
public void invalidVoteCasting() {
int duration = 10;
APICall apiCall = new TwoPhasedMoneyTransferBuilder().finishHeight(Nxt.getBlockchain().getHeight() + duration).build();
JSONObject transactionJSON = TestCreateTwoPhased.issueCreateTwoPhased(apiCall, false);
generateBlock();
apiCall = new APICall.Builder("approveTransaction").param("secretPhrase", DAVE.getSecretPhrase()).param("transactionFullHash", (String) transactionJSON.get("fullHash")).param("feeNQT", Constants.ONE_NXT).build();
JSONObject response = apiCall.invoke();
Assert.assertNotNull(response.get("error"));
generateBlock();
Assert.assertEquals("ALICE balance: ", -2 * Constants.ONE_NXT, ALICE.getBalanceDiff());
Assert.assertEquals("BOB balance: ", 0, BOB.getBalanceDiff());
Assert.assertEquals("CHUCK balance: ", 0, CHUCK.getBalanceDiff());
Assert.assertEquals("DAVE balance: ", 0, DAVE.getBalanceDiff());
generateBlocks(duration);
Assert.assertEquals("ALICE balance: ", -2 * Constants.ONE_NXT, ALICE.getBalanceDiff());
Assert.assertEquals("BOB balance: ", 0, BOB.getBalanceDiff());
Assert.assertEquals("CHUCK balance: ", 0, CHUCK.getBalanceDiff());
Assert.assertEquals("DAVE balance: ", 0, DAVE.getBalanceDiff());
}
use of org.xel.http.twophased.TestCreateTwoPhased.TwoPhasedMoneyTransferBuilder in project elastic-core-maven by OrdinaryDude.
the class TestApproveTransaction method validVoteCasting.
@Test
public void validVoteCasting() {
int duration = 10;
APICall apiCall = new TwoPhasedMoneyTransferBuilder().finishHeight(Nxt.getBlockchain().getHeight() + duration).build();
JSONObject transactionJSON = TestCreateTwoPhased.issueCreateTwoPhased(apiCall, false);
generateBlock();
apiCall = new APICall.Builder("approveTransaction").param("secretPhrase", CHUCK.getSecretPhrase()).param("transactionFullHash", (String) transactionJSON.get("fullHash")).param("feeNQT", Constants.ONE_NXT).build();
JSONObject response = apiCall.invoke();
Logger.logMessage("approvePhasedTransactionResponse:" + response.toJSONString());
Assert.assertNotNull(response.get("transaction"));
generateBlocks(duration);
Assert.assertEquals(-50 * Constants.ONE_NXT - 2 * Constants.ONE_NXT, ALICE.getBalanceDiff());
Assert.assertEquals(50 * Constants.ONE_NXT, BOB.getBalanceDiff());
Assert.assertEquals(-Constants.ONE_NXT, CHUCK.getBalanceDiff());
}
use of org.xel.http.twophased.TestCreateTwoPhased.TwoPhasedMoneyTransferBuilder 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));
}
Aggregations