Search in sources :

Example 6 with APICall

use of org.xel.http.APICall 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 7 with APICall

use of org.xel.http.APICall in project elastic-core-maven by OrdinaryDude.

the class TestCastVote method validVoteCasting.

@Test
public void validVoteCasting() {
    APICall apiCall = new CreatePollBuilder().build();
    String poll = TestCreatePoll.issueCreatePoll(apiCall, false);
    generateBlock();
    apiCall = new APICall.Builder("castVote").param("secretPhrase", ALICE.getSecretPhrase()).param("poll", poll).param("vote00", 1).param("vote01", 0).param("feeNQT", Constants.ONE_NXT).build();
    JSONObject response = apiCall.invoke();
    Logger.logMessage("voteCasting:" + response.toJSONString());
    Assert.assertNull(response.get("error"));
    generateBlock();
    apiCall = new APICall.Builder("getPollResult").param("poll", poll).build();
    JSONObject getPollResponse = apiCall.invoke();
    Logger.logMessage("getPollResultResponse:" + getPollResponse.toJSONString());
    JSONArray results = (JSONArray) getPollResponse.get("results");
    long ringoResult = Long.parseLong(getResult(results, 0));
    Assert.assertEquals(1, ringoResult);
    long paulResult = Long.parseLong(getResult(results, 1));
    Assert.assertEquals(0, paulResult);
    // John's result is empty by spec
    Assert.assertEquals("", getResult(results, 2));
}
Also used : CreatePollBuilder(org.xel.http.votingsystem.TestCreatePoll.CreatePollBuilder) JSONObject(org.json.simple.JSONObject) APICall(org.xel.http.APICall) JSONArray(org.json.simple.JSONArray) Test(org.junit.Test) BlockchainTest(org.xel.BlockchainTest)

Example 8 with APICall

use of org.xel.http.APICall in project elastic-core-maven by OrdinaryDude.

the class TestCastVote method invalidVoteCasting.

@Test
public void invalidVoteCasting() {
    APICall apiCall = new CreatePollBuilder().build();
    String poll = TestCreatePoll.issueCreatePoll(apiCall, false);
    generateBlock();
    apiCall = new APICall.Builder("castVote").param("secretPhrase", ALICE.getSecretPhrase()).param("poll", poll).param("vote1", 1).param("vote2", 1).param("vote3", 1).param("feeNQT", Constants.ONE_NXT).build();
    JSONObject response = apiCall.invoke();
    Logger.logMessage("voteCasting:" + response.toJSONString());
    Assert.assertNotNull(response.get("error"));
}
Also used : CreatePollBuilder(org.xel.http.votingsystem.TestCreatePoll.CreatePollBuilder) JSONObject(org.json.simple.JSONObject) APICall(org.xel.http.APICall) CreatePollBuilder(org.xel.http.votingsystem.TestCreatePoll.CreatePollBuilder) Test(org.junit.Test) BlockchainTest(org.xel.BlockchainTest)

Example 9 with APICall

use of org.xel.http.APICall in project elastic-core-maven by OrdinaryDude.

the class PhasingOnlyTest method setPhasingOnlyControl.

private void setPhasingOnlyControl(VotingModel votingModel, String holdingId, Long quorum, Long minBalance, MinBalanceModel minBalanceModel, long[] whitelist, long maxFees, int minDuration, int maxDuration) {
    Builder builder = new ACTestUtils.Builder("setPhasingOnlyControl", ALICE.getSecretPhrase());
    setControlPhasingParams(builder, votingModel, holdingId, quorum, minBalance, minBalanceModel, whitelist, maxFees, minDuration, maxDuration);
    APICall apiCall = builder.build();
    JSONObject response = apiCall.invoke();
    Logger.logMessage("setPhasingOnlyControl response: " + response.toJSONString());
    String result = (String) response.get("transaction");
    Assert.assertNotNull(result);
    generateBlock();
}
Also used : JSONObject(org.json.simple.JSONObject) APICall(org.xel.http.APICall) Builder(org.xel.http.APICall.Builder)

Example 10 with APICall

use of org.xel.http.APICall in project elastic-core-maven by OrdinaryDude.

the class TestCreateTwoPhased method validMoneyTransfer.

@Test
public void validMoneyTransfer() {
    APICall apiCall = new TwoPhasedMoneyTransferBuilder().build();
    issueCreateTwoPhased(apiCall, false);
}
Also used : APICall(org.xel.http.APICall) Test(org.junit.Test) BlockchainTest(org.xel.BlockchainTest)

Aggregations

APICall (org.xel.http.APICall)20 Test (org.junit.Test)18 BlockchainTest (org.xel.BlockchainTest)18 JSONObject (org.json.simple.JSONObject)16 JSONArray (org.json.simple.JSONArray)10 TwoPhasedMoneyTransferBuilder (org.xel.http.twophased.TestCreateTwoPhased.TwoPhasedMoneyTransferBuilder)5 CreatePollBuilder (org.xel.http.votingsystem.TestCreatePoll.CreatePollBuilder)2 ArrayList (java.util.ArrayList)1 Builder (org.xel.http.APICall.Builder)1