Search in sources :

Example 1 with TwoPhasedMoneyTransferBuilder

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));
}
Also used : TwoPhasedMoneyTransferBuilder(org.xel.http.twophased.TestCreateTwoPhased.TwoPhasedMoneyTransferBuilder) JSONObject(org.json.simple.JSONObject) APICall(org.xel.http.APICall) JSONArray(org.json.simple.JSONArray) Test(org.junit.Test) BlockchainTest(org.xel.BlockchainTest)

Example 2 with TwoPhasedMoneyTransferBuilder

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());
}
Also used : TwoPhasedMoneyTransferBuilder(org.xel.http.twophased.TestCreateTwoPhased.TwoPhasedMoneyTransferBuilder) JSONObject(org.json.simple.JSONObject) APICall(org.xel.http.APICall) Test(org.junit.Test) BlockchainTest(org.xel.BlockchainTest)

Example 3 with TwoPhasedMoneyTransferBuilder

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());
}
Also used : TwoPhasedMoneyTransferBuilder(org.xel.http.twophased.TestCreateTwoPhased.TwoPhasedMoneyTransferBuilder) JSONObject(org.json.simple.JSONObject) APICall(org.xel.http.APICall) Test(org.junit.Test) BlockchainTest(org.xel.BlockchainTest)

Example 4 with TwoPhasedMoneyTransferBuilder

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));
}
Also used : TwoPhasedMoneyTransferBuilder(org.xel.http.twophased.TestCreateTwoPhased.TwoPhasedMoneyTransferBuilder) JSONObject(org.json.simple.JSONObject) APICall(org.xel.http.APICall) JSONArray(org.json.simple.JSONArray) Test(org.junit.Test) BlockchainTest(org.xel.BlockchainTest)

Aggregations

JSONObject (org.json.simple.JSONObject)4 Test (org.junit.Test)4 BlockchainTest (org.xel.BlockchainTest)4 APICall (org.xel.http.APICall)4 TwoPhasedMoneyTransferBuilder (org.xel.http.twophased.TestCreateTwoPhased.TwoPhasedMoneyTransferBuilder)4 JSONArray (org.json.simple.JSONArray)2