Search in sources :

Example 6 with Builder

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

the class PhasingOnlyTest method testRejectingPendingTransaction.

@Test
public void testRejectingPendingTransaction() throws Exception {
    Builder builder = new ACTestUtils.Builder("sendMoney", ALICE.getSecretPhrase()).recipient(BOB.getId()).param("amountNQT", 1 * Constants.ONE_NXT);
    setTransactionPhasingParams(builder, 4, VotingModel.ACCOUNT, null, 1L, null, null, new long[] { BOB.getId(), CHUCK.getId() });
    JSONObject sendMoneyJSON = ACTestUtils.assertTransactionSuccess(builder);
    generateBlock();
    builder = new ACTestUtils.Builder("setPhasingOnlyControl", ALICE.getSecretPhrase());
    setControlPhasingParams(builder, VotingModel.ACCOUNT, null, 1L, null, null, new long[] { DAVE.getId() }, 0, 0, 0);
    ACTestUtils.assertTransactionSuccess(builder);
    generateBlock();
    long balanceBeforeTransactionRejection = ACTestUtils.getAccountBalance(ALICE.getId(), "unconfirmedBalanceNQT");
    String fullHash = (String) sendMoneyJSON.get("fullHash");
    // approve the pending transaction
    builder = new ACTestUtils.Builder("approveTransaction", BOB.getSecretPhrase()).param("transactionFullHash", fullHash);
    ACTestUtils.assertTransactionSuccess(builder);
    generateBlock();
    // the sendMoney finish height
    generateBlock();
    // Assert the unconfirmed balance is recovered
    Assert.assertEquals(balanceBeforeTransactionRejection + 1 * Constants.ONE_NXT, ACTestUtils.getAccountBalance(ALICE.getId(), "unconfirmedBalanceNQT"));
}
Also used : JSONObject(org.json.simple.JSONObject) Builder(org.xel.http.APICall.Builder) Test(org.junit.Test) BlockchainTest(org.xel.BlockchainTest)

Example 7 with Builder

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

Aggregations

Builder (org.xel.http.APICall.Builder)7 JSONObject (org.json.simple.JSONObject)6 Test (org.junit.Test)4 BlockchainTest (org.xel.BlockchainTest)4 APICall (org.xel.http.APICall)3 PhasingParams (org.xel.PhasingParams)1