OSDN Git Service

test TxFeed and UCTX class
authorsuccessli <successli@outlook.com>
Tue, 29 May 2018 05:53:50 +0000 (13:53 +0800)
committersuccessli <successli@outlook.com>
Tue, 29 May 2018 05:53:50 +0000 (13:53 +0800)
src/main/java/io/bytom/api/RawTransaction.java
src/main/java/io/bytom/api/TransactionFeed.java
src/main/java/io/bytom/api/UnconfirmedTransaction.java
src/test/java/io/bytom/integration/TransactionFeedTest.java [new file with mode: 0644]
src/test/java/io/bytom/integration/UnconfirmedTransactionTest.java [new file with mode: 0644]

index f09e006..519cf27 100644 (file)
@@ -69,7 +69,7 @@ public class RawTransaction {
         /**
          * The number of units of the asset being issued or spent.
          */
-        private Integer amount;
+        private long amount;
 
         /**
          * The definition of the asset being issued or spent (possibly null).
@@ -113,7 +113,7 @@ public class RawTransaction {
         /**
          * The number of units of the asset being controlled.
          */
-        private Integer amount;
+        private long amount;
 
         /**
          * The definition of the asset being controlled (possibly null).
index db7eefb..5d6f16a 100644 (file)
@@ -101,7 +101,7 @@ public class TransactionFeed {
         req.put("alias", alias);
         req.put("filter", filter);
         client.request("update-transaction-feed", req);
-        logger.info("update-transaction-feed");
+        logger.info("update-transaction-feed successfully");
     }
 
     /**
@@ -117,8 +117,9 @@ public class TransactionFeed {
 
         logger.info("list-transaction-feeds:");
         logger.info("size of transactionList:" + transactionFeedList.size());
-        logger.info(transactionFeedList.get(0).toJson());
-
+        for (int i =0 ;i < transactionFeedList.size();i++) {
+            logger.info(transactionFeedList.get(i).toJson());
+        }
         return transactionFeedList;
     }
 
@@ -133,7 +134,7 @@ public class TransactionFeed {
         Map<String, Object> req = new HashMap<String, Object>();
         req.put("alias", alias);
         client.request("delete-transaction-feed", req);
-        logger.info("delete-transaction-feed");
+        logger.info("delete-transaction-feed successfully");
     }
 
 
index a5db29f..67690a4 100644 (file)
@@ -112,7 +112,7 @@ public class UnconfirmedTransaction {
         /**
          * The number of units of the asset being issued or spent.
          */
-        private Integer amount;
+        private long amount;
 
         /**
          * The definition of the asset being issued or spent (possibly null).
@@ -156,7 +156,7 @@ public class UnconfirmedTransaction {
         /**
          * The number of units of the asset being controlled.
          */
-        private Integer amount;
+        private long amount;
 
         /**
          * The definition of the asset being controlled (possibly null).
diff --git a/src/test/java/io/bytom/integration/TransactionFeedTest.java b/src/test/java/io/bytom/integration/TransactionFeedTest.java
new file mode 100644 (file)
index 0000000..d1a9384
--- /dev/null
@@ -0,0 +1,66 @@
+package io.bytom.integration;
+
+import io.bytom.TestUtils;
+import io.bytom.api.TransactionFeed;
+import io.bytom.api.Wallet;
+import io.bytom.exception.BytomException;
+import io.bytom.http.Client;
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.util.List;
+
+public class TransactionFeedTest {
+
+    static Client client;
+
+    static {
+        try {
+            client = TestUtils.generateClient();
+        } catch (BytomException e) {
+            e.printStackTrace();
+        }
+    }
+
+    static TransactionFeed transactionFeed;
+
+    @Test
+    public void testTXFeedCreate() throws Exception {
+        String filter = "asset_id='57fab05b689a2b8b6738cffb5cf6cffcd0bf6156a04b7d9ba0173e384fe38c8c' AND amount_lower_limit = 50 AND amount_upper_limit = 100";
+        String alias = "test1";
+        new TransactionFeed.Builder()
+                    .setAlias(alias)
+                    .setFilter(filter)
+                    .create(client);
+    }
+
+    @Test
+    public void testTXFeedGet() throws Exception {
+        String alias = "test2";
+        transactionFeed = TransactionFeed.get(client, alias);
+
+        Assert.assertNotNull(transactionFeed);
+    }
+
+    @Test
+    public void testTXFeedUpdate() throws Exception {
+        String filter = "asset_id='57fab05b689a2b8b6738cffb5cf6cffcd0bf6156a04b7d9ba0173e384fe38c8c' AND amount_lower_limit = 50 AND amount_upper_limit = 100";
+        String alias = "test2";
+
+        TransactionFeed.update(client, alias, filter);
+    }
+
+    @Test
+    public void testTXFeedList() throws Exception {
+        List<TransactionFeed> txFeedList = TransactionFeed.list(client);
+        Assert.assertNotNull(txFeedList);
+    }
+
+    @Test
+    public void testTXFeedDelete() throws Exception {
+        String alias = "test2";
+        TransactionFeed.delete(client, alias);
+    }
+
+
+}
diff --git a/src/test/java/io/bytom/integration/UnconfirmedTransactionTest.java b/src/test/java/io/bytom/integration/UnconfirmedTransactionTest.java
new file mode 100644 (file)
index 0000000..f63ae7f
--- /dev/null
@@ -0,0 +1,39 @@
+package io.bytom.integration;
+
+import io.bytom.TestUtils;
+import io.bytom.api.UnconfirmedTransaction;
+import io.bytom.api.Wallet;
+import io.bytom.exception.BytomException;
+import io.bytom.http.Client;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class UnconfirmedTransactionTest {
+
+    static Client client;
+
+    static {
+        try {
+            client = TestUtils.generateClient();
+        } catch (BytomException e) {
+            e.printStackTrace();
+        }
+    }
+
+    static UnconfirmedTransaction unconfirmedTransaction;
+    static UnconfirmedTransaction.UTXResponse utxResponse;
+
+    @Test
+    public void testUCTXList() throws Exception {
+        utxResponse = UnconfirmedTransaction.list(client);
+        Assert.assertNotNull(utxResponse);
+    }
+
+    @Test
+    public void testUCTXGet() throws Exception {
+        utxResponse = UnconfirmedTransaction.list(client);
+        unconfirmedTransaction = UnconfirmedTransaction.get(client, utxResponse.txIds.get(0));
+        Assert.assertNotNull(unconfirmedTransaction);
+    }
+
+}