Fix GetLimitOrders listener and add GetLimitOrders and GetTradeHistory API tests
This commit is contained in:
parent
a824d8fc40
commit
158c9604b8
2 changed files with 95 additions and 4 deletions
|
@ -44,9 +44,9 @@ public class GetLimitOrders extends BaseGrapheneHandler {
|
|||
/**
|
||||
* Default Constructor
|
||||
*
|
||||
* @param a id of asset being sold
|
||||
* @param b id of asset being purchased
|
||||
* @param limit maximum number of orders to retrieve
|
||||
* @param a id of asset being sold
|
||||
* @param b id of asset being purchased
|
||||
* @param limit maximum number of orders to retrieve
|
||||
* @param oneTime boolean value indicating if WebSocket must be closed (true) or not
|
||||
* (false) after the response
|
||||
* @param listener A class implementing the WitnessResponseListener interface. This should
|
||||
|
@ -59,7 +59,7 @@ public class GetLimitOrders extends BaseGrapheneHandler {
|
|||
this.b = b;
|
||||
this.limit = limit;
|
||||
this.mOneTime = oneTime;
|
||||
this.mListener = mListener;
|
||||
this.mListener = listener;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -18,6 +18,7 @@ import de.bitsharesmunich.graphenej.api.GetBlockHeader;
|
|||
import de.bitsharesmunich.graphenej.api.GetKeyReferences;
|
||||
import de.bitsharesmunich.graphenej.api.GetLimitOrders;
|
||||
import de.bitsharesmunich.graphenej.api.GetRequiredFees;
|
||||
import de.bitsharesmunich.graphenej.api.GetTradeHistory;
|
||||
import de.bitsharesmunich.graphenej.errors.RepeatedRequestIdException;
|
||||
import de.bitsharesmunich.graphenej.errors.MalformedAddressException;
|
||||
import de.bitsharesmunich.graphenej.interfaces.WitnessResponseListener;
|
||||
|
@ -42,6 +43,7 @@ public class NodeConnectionTest {
|
|||
private String ACCOUNT_NAME = System.getenv("ACCOUNT_NAME");
|
||||
private long BlOCK_TEST_NUMBER = Long.parseLong(System.getenv("BlOCK_TEST_NUMBER"));
|
||||
private Asset BTS = new Asset("1.3.0");
|
||||
private Asset BLOCKPAY = new Asset("1.3.1072");
|
||||
private Asset BITDOLAR = new Asset("1.3.121"); //USD Smartcoin
|
||||
private Asset BITEURO = new Asset("1.3.120"); //EUR Smartcoin
|
||||
private NodeConnection nodeConnection;
|
||||
|
@ -450,6 +452,49 @@ public class NodeConnectionTest {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for GetLimitOrders Handler.
|
||||
*
|
||||
* Request for a limit orders between two assets
|
||||
*/
|
||||
@Test
|
||||
public void testGetLimitOrdersRequest(){
|
||||
nodeConnection = NodeConnection.getInstance();
|
||||
nodeConnection.addNodeUrl(NODE_URL_1);
|
||||
nodeConnection.connect("", "", false, mErrorListener);
|
||||
|
||||
String asset_sold_id = BLOCKPAY.getBitassetId();
|
||||
String asset_purchased_id = BTS.getBitassetId();
|
||||
int limit = 10;
|
||||
|
||||
System.out.println("Adding GetLimitOrders request");
|
||||
try{
|
||||
nodeConnection.addRequestHandler(new GetLimitOrders(asset_sold_id, asset_purchased_id, limit, true, new WitnessResponseListener(){
|
||||
@Override
|
||||
public void onSuccess(WitnessResponse response) {
|
||||
System.out.println("GetLimitOrders.onSuccess");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(BaseResponse.Error error) {
|
||||
System.out.println("GetLimitOrders.onError. Msg: "+ error.message);
|
||||
}
|
||||
}));
|
||||
}catch(RepeatedRequestIdException e){
|
||||
System.out.println("RepeatedRequestIdException. Msg: "+e.getMessage());
|
||||
}
|
||||
|
||||
|
||||
try{
|
||||
// Holding this thread while we get update notifications
|
||||
synchronized (this){
|
||||
wait();
|
||||
}
|
||||
}catch(InterruptedException e){
|
||||
System.out.println("InterruptedException. Msg: "+e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for GetMarketHistory Handler.
|
||||
*
|
||||
|
@ -542,6 +587,52 @@ public class NodeConnectionTest {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for GetRequiredFees Handler.
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void testGetTradeHistoryRequest(){
|
||||
nodeConnection = NodeConnection.getInstance();
|
||||
nodeConnection.addNodeUrl(NODE_URL_1);
|
||||
nodeConnection.connect("", "", false, mErrorListener);
|
||||
|
||||
UserAccount userAccount_from = new UserAccount(ACCOUNT_ID_1);
|
||||
UserAccount userAccount_to = new UserAccount(ACCOUNT_ID_2);
|
||||
|
||||
|
||||
String asset_sold_id = BLOCKPAY.getBitassetId();
|
||||
String asset_purchased_id = BTS.getBitassetId();
|
||||
int limit = 10;
|
||||
|
||||
System.out.println("Adding GetRequiredFees request");
|
||||
try{
|
||||
nodeConnection.addRequestHandler(new GetTradeHistory(asset_sold_id, asset_purchased_id, "", "", limit, true, new WitnessResponseListener(){
|
||||
@Override
|
||||
public void onSuccess(WitnessResponse response) {
|
||||
System.out.println("GetRequiredFees.onSuccess");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(BaseResponse.Error error) {
|
||||
System.out.println("GetRequiredFees.onError. Msg: "+ error.message);
|
||||
}
|
||||
}));
|
||||
}catch(RepeatedRequestIdException e){
|
||||
System.out.println("RepeatedRequestIdException. Msg: "+e.getMessage());
|
||||
}
|
||||
|
||||
|
||||
try{
|
||||
// Holding this thread while we get update notifications
|
||||
synchronized (this){
|
||||
wait();
|
||||
}
|
||||
}catch(InterruptedException e){
|
||||
System.out.println("InterruptedException. Msg: "+e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private WitnessResponseListener mErrorListener = new WitnessResponseListener() {
|
||||
|
||||
|
|
Loading…
Reference in a new issue