This is an automated email from the ASF dual-hosted git repository.

toulmean pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-tuweni.git


The following commit(s) were added to refs/heads/master by this push:
     new 375b760  Add more tests to cover Gas (#98)
375b760 is described below

commit 375b7601e691e73a678eba509350eee8cab51fa1
Author: Antoine Toulme <atou...@users.noreply.github.com>
AuthorDate: Sat Jun 27 01:23:41 2020 -0700

    Add more tests to cover Gas (#98)
---
 .../org/apache/tuweni/units/ethereum/GasTest.java  | 38 ++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/units/src/test/java/org/apache/tuweni/units/ethereum/GasTest.java 
b/units/src/test/java/org/apache/tuweni/units/ethereum/GasTest.java
index f09abcd..0dc5b6e 100644
--- a/units/src/test/java/org/apache/tuweni/units/ethereum/GasTest.java
+++ b/units/src/test/java/org/apache/tuweni/units/ethereum/GasTest.java
@@ -17,6 +17,9 @@ import static org.junit.jupiter.api.Assertions.assertNotSame;
 import static org.junit.jupiter.api.Assertions.assertSame;
 import static org.junit.jupiter.api.Assertions.assertThrows;
 
+import org.apache.tuweni.bytes.Bytes;
+import org.apache.tuweni.units.bigints.UInt256;
+
 import java.math.BigInteger;
 import java.util.ArrayList;
 import java.util.List;
@@ -41,6 +44,12 @@ class GasTest {
   }
 
   @Test
+  void testToLong() {
+    Gas gas = Gas.valueOf(32L);
+    assertEquals(32L, gas.toLong());
+  }
+
+  @Test
   void testGetWeiPrice() {
     Gas gas = Gas.valueOf(5L);
     Wei result = gas.priceFor(Wei.valueOf(3L));
@@ -83,4 +92,33 @@ class GasTest {
     });
   }
 
+  @Test
+  void testConstantReuse() {
+    Gas gas = Gas.valueOf(UInt256.valueOf(1L));
+    Gas otherGas = Gas.valueOf(UInt256.valueOf(1L));
+    assertSame(gas, otherGas);
+  }
+
+  @Test
+  void testOverflowUInt256() {
+    assertThrows(IllegalArgumentException.class, () -> {
+      Gas.valueOf(UInt256.MAX_VALUE);
+    });
+  }
+
+  @Test
+  void testToBytes() {
+    assertEquals(Bytes.fromHexString("0x0000000000000001"), 
Gas.valueOf(1L).toBytes());
+  }
+
+  @Test
+  void testToMinimalBytes() {
+    assertEquals(Bytes.fromHexString("0x01"), 
Gas.valueOf(1L).toMinimalBytes());
+  }
+
+  @Test
+  void testCompareTo() {
+    assertEquals(-1, (Gas.valueOf(1L)).compareTo(2L));
+  }
+
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@tuweni.apache.org
For additional commands, e-mail: commits-h...@tuweni.apache.org

Reply via email to