Skip to content

Commit 02e7aac

Browse files
committed
feat(test): add test for hashcode and web3_clientVersion
1 parent a64a866 commit 02e7aac

2 files changed

Lines changed: 34 additions & 0 deletions

File tree

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package org.tron.common.utils;
2+
3+
import java.util.Objects;
4+
import org.junit.Assert;
5+
import org.junit.Test;
6+
import org.tron.core.capsule.AccountCapsule;
7+
import org.tron.core.vm.repository.Type;
8+
import org.tron.core.vm.repository.Value;
9+
import org.tron.protos.Protocol;
10+
11+
public class HashCodeTest {
12+
13+
@Test
14+
public void test() {
15+
Type type = new Type();
16+
type.setType(Type.NORMAL);
17+
Assert.assertEquals(Integer.valueOf(Type.NORMAL).hashCode(), type.hashCode());
18+
Protocol.Account account = Protocol.Account.newBuilder().setBalance(100).build();
19+
Value<Protocol.Account> value = Value.create(new AccountCapsule(account.toByteArray()));
20+
Assert.assertEquals(Integer.valueOf(
21+
type.hashCode() + Objects.hashCode(account)).hashCode(), value.hashCode());
22+
}
23+
}

framework/src/test/java/org/tron/core/jsonrpc/JsonrpcServiceTest.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -969,4 +969,15 @@ public void testNewFilterFinalizedBlock() {
969969
Assert.assertEquals("invalid block range params", e.getMessage());
970970
}
971971
}
972+
973+
@Test
974+
public void testWeb3ClientVersion() {
975+
try {
976+
String[] versions = tronJsonRpc.web3ClientVersion().split("/");
977+
String javaVersion = versions[versions.length - 1];
978+
Assert.assertTrue("Java1.8".equals(javaVersion) || "Java17".equals(javaVersion));
979+
} catch (Exception e) {
980+
Assert.fail();
981+
}
982+
}
972983
}

0 commit comments

Comments
 (0)