use of org.xel.http.votingsystem.TestCreatePoll.CreatePollBuilder 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));
}
use of org.xel.http.votingsystem.TestCreatePoll.CreatePollBuilder 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"));
}
Aggregations