OSDN Git Service

add getGasRate method to CoreConfig class
authorsuccessli <successli@outlook.com>
Thu, 31 May 2018 02:47:02 +0000 (10:47 +0800)
committersuccessli <successli@outlook.com>
Thu, 31 May 2018 02:47:02 +0000 (10:47 +0800)
src/main/java/io/bytom/api/CoreConfig.java
src/main/java/io/bytom/api/Gas.java [deleted file]
src/test/java/io/bytom/integration/CoreConfigTest.java
src/test/java/io/bytom/integration/GasTest.java [deleted file]

index 2166cca..3334773 100644 (file)
@@ -27,6 +27,22 @@ public class CoreConfig {
         return netInfo;
     }
 
+    /**
+     * Call gas-rate api
+     *
+     * @param client
+     * @return
+     * @throws BytomException
+     */
+    public static Integer getGasRate(Client client) throws BytomException {
+        Integer gas = client.requestGet("gas-rate", null, "gas_rate", Integer.class);
+
+        logger.info("gas-rate:");
+        logger.info(gas);
+
+        return gas;
+    }
+
     public static class NetInfo {
         /**
          * listening, whether the node is listening.
diff --git a/src/main/java/io/bytom/api/Gas.java b/src/main/java/io/bytom/api/Gas.java
deleted file mode 100644 (file)
index f9864db..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-package io.bytom.api;
-
-import com.google.gson.annotations.SerializedName;
-import io.bytom.common.Utils;
-import io.bytom.exception.BytomException;
-import io.bytom.http.Client;
-import org.apache.log4j.Logger;
-
-/**
- * <h1>Gas Class</h1>
- */
-public class Gas {
-
-    @SerializedName("gas_rate")
-    public Integer gasRate;
-
-    private static Logger logger = Logger.getLogger(Gas.class);
-
-    public String toJson() {
-        return Utils.serializer.toJson(this);
-    }
-
-
-    /**
-     * Call gas-rate api
-     *
-     * @param client
-     * @return
-     * @throws BytomException
-     */
-    public static Gas gasRate(Client client) throws BytomException {
-        Gas gas = client.request("gas-rate", null, Gas.class);
-
-        logger.info("gas-rate:");
-        logger.info(gas.toJson());
-
-        return gas;
-    }
-}
index f55f4b2..d656da8 100644 (file)
@@ -21,12 +21,20 @@ public class CoreConfigTest {
 
     static CoreConfig.NetInfo netInfo;
 
+    static Integer gasRate;
+
     @Test
     public void testNetInfo() throws Exception {
         netInfo = CoreConfig.getNetInfo(client);
         Assert.assertNotNull(netInfo);
     }
 
+    @Test
+    public void testGasRate() throws Exception {
+        gasRate = CoreConfig.getGasRate(client);
+        Assert.assertNotNull(gasRate);
+    }
+
 
 
 }
diff --git a/src/test/java/io/bytom/integration/GasTest.java b/src/test/java/io/bytom/integration/GasTest.java
deleted file mode 100644 (file)
index d5a87a8..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-package io.bytom.integration;
-
-import io.bytom.TestUtils;
-import io.bytom.api.Gas;
-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 GasTest {
-
-    static Client client;
-
-    static {
-        try {
-            client = TestUtils.generateClient();
-        } catch (BytomException e) {
-            e.printStackTrace();
-        }
-    }
-
-    static Gas gas;
-
-    @Test
-    public void testWalletBackUp() throws Exception {
-        gas = Gas.gasRate(client);
-        Assert.assertNotNull(gas);
-    }
-
-}