diff --git a/core/src/main/java/org/web3j/crypto/Wallet.java b/core/src/main/java/org/web3j/crypto/Wallet.java index 3f058daff..e5ffd4f11 100644 --- a/core/src/main/java/org/web3j/crypto/Wallet.java +++ b/core/src/main/java/org/web3j/crypto/Wallet.java @@ -72,6 +72,8 @@ public class Wallet { static final String AES_128_CTR = "pbkdf2"; static final String SCRYPT = "scrypt"; + private Wallet() {} + public static WalletFile create(String password, ECKeyPair ecKeyPair, int n, int p) throws CipherException { diff --git a/core/src/main/java/org/web3j/ens/Contracts.java b/core/src/main/java/org/web3j/ens/Contracts.java index 0b3ad45a6..6e01224f3 100644 --- a/core/src/main/java/org/web3j/ens/Contracts.java +++ b/core/src/main/java/org/web3j/ens/Contracts.java @@ -16,7 +16,6 @@ /** ENS registry contract addresses. */ public class Contracts { - public static final String MAINNET = "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e"; public static final String ROPSTEN = "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e"; public static final String RINKEBY = "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e"; @@ -26,6 +25,8 @@ public class Contracts { public static final String LINEA = "0x50130b669B28C339991d8676FA73CF122a121267"; public static final String LINEA_SEPOLIA = "0x5B2636F0f2137B4aE722C01dd5122D7d3e9541f7"; + private Contracts() {} + public static String resolveRegistryContract(String chainId) { final Long chainIdLong = Long.parseLong(chainId); if (chainIdLong.equals(ChainIdLong.MAINNET)) { diff --git a/core/src/main/java/org/web3j/ens/NameHash.java b/core/src/main/java/org/web3j/ens/NameHash.java index d97b847f5..9e24de122 100644 --- a/core/src/main/java/org/web3j/ens/NameHash.java +++ b/core/src/main/java/org/web3j/ens/NameHash.java @@ -32,6 +32,8 @@ public static byte[] nameHashAsBytes(String ensName) { return Numeric.hexStringToByteArray(nameHash(ensName)); } + private NameHash() {} + public static String nameHash(String ensName) { String normalisedEnsName = normalise(ensName); return Numeric.toHexString(nameHash(normalisedEnsName.split("\\."))); diff --git a/core/src/main/java/org/web3j/ens/contracts/generated/ENS.java b/core/src/main/java/org/web3j/ens/contracts/generated/ENS.java index edc060c1b..76f3e1c91 100644 --- a/core/src/main/java/org/web3j/ens/contracts/generated/ENS.java +++ b/core/src/main/java/org/web3j/ens/contracts/generated/ENS.java @@ -66,23 +66,18 @@ public class ENS extends Contract { public static final Event APPROVALFORALL_EVENT = new Event("ApprovalForAll", Arrays.>asList(new TypeReference
(true) {}, new TypeReference
(true) {}, new TypeReference() {})); - ; public static final Event NEWOWNER_EVENT = new Event("NewOwner", Arrays.>asList(new TypeReference(true) {}, new TypeReference(true) {}, new TypeReference
() {})); - ; public static final Event NEWRESOLVER_EVENT = new Event("NewResolver", Arrays.>asList(new TypeReference(true) {}, new TypeReference
() {})); - ; public static final Event NEWTTL_EVENT = new Event("NewTTL", Arrays.>asList(new TypeReference(true) {}, new TypeReference() {})); - ; public static final Event TRANSFER_EVENT = new Event("Transfer", Arrays.>asList(new TypeReference(true) {}, new TypeReference
() {})); - ; @Deprecated protected ENS(String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) { @@ -139,7 +134,7 @@ public Flowable approvalForAllEventFlowable(Default public List getNewOwnerEvents(TransactionReceipt transactionReceipt) { List valueList = extractEventParametersWithLog(NEWOWNER_EVENT, transactionReceipt); - ArrayList responses = new ArrayList(valueList.size()); + ArrayList responses = new ArrayList<>(valueList.size()); for (Contract.EventValuesWithLog eventValues : valueList) { NewOwnerEventResponse typedResponse = new NewOwnerEventResponse(); typedResponse.log = eventValues.getLog(); @@ -174,7 +169,7 @@ public Flowable newOwnerEventFlowable(DefaultBlockParamet public List getNewResolverEvents(TransactionReceipt transactionReceipt) { List valueList = extractEventParametersWithLog(NEWRESOLVER_EVENT, transactionReceipt); - ArrayList responses = new ArrayList(valueList.size()); + ArrayList responses = new ArrayList<>(valueList.size()); for (Contract.EventValuesWithLog eventValues : valueList) { NewResolverEventResponse typedResponse = new NewResolverEventResponse(); typedResponse.log = eventValues.getLog(); @@ -207,7 +202,7 @@ public Flowable newResolverEventFlowable(DefaultBlockP public List getNewTTLEvents(TransactionReceipt transactionReceipt) { List valueList = extractEventParametersWithLog(NEWTTL_EVENT, transactionReceipt); - ArrayList responses = new ArrayList(valueList.size()); + ArrayList responses = new ArrayList<>(valueList.size()); for (Contract.EventValuesWithLog eventValues : valueList) { NewTTLEventResponse typedResponse = new NewTTLEventResponse(); typedResponse.log = eventValues.getLog(); diff --git a/core/src/main/java/org/web3j/ens/contracts/generated/ENSRegistryWithFallbackContract.java b/core/src/main/java/org/web3j/ens/contracts/generated/ENSRegistryWithFallbackContract.java index 1f8d93a34..6511b8184 100644 --- a/core/src/main/java/org/web3j/ens/contracts/generated/ENSRegistryWithFallbackContract.java +++ b/core/src/main/java/org/web3j/ens/contracts/generated/ENSRegistryWithFallbackContract.java @@ -68,23 +68,18 @@ public class ENSRegistryWithFallbackContract extends Contract { public static final Event APPROVALFORALL_EVENT = new Event("ApprovalForAll", Arrays.>asList(new TypeReference
(true) {}, new TypeReference
(true) {}, new TypeReference() {})); - ; public static final Event NEWOWNER_EVENT = new Event("NewOwner", Arrays.>asList(new TypeReference(true) {}, new TypeReference(true) {}, new TypeReference
() {})); - ; public static final Event NEWRESOLVER_EVENT = new Event("NewResolver", Arrays.>asList(new TypeReference(true) {}, new TypeReference
() {})); - ; public static final Event NEWTTL_EVENT = new Event("NewTTL", Arrays.>asList(new TypeReference(true) {}, new TypeReference() {})); - ; public static final Event TRANSFER_EVENT = new Event("Transfer", Arrays.>asList(new TypeReference(true) {}, new TypeReference
() {})); - ; @Deprecated protected ENSRegistryWithFallbackContract(String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) { @@ -106,7 +101,7 @@ protected ENSRegistryWithFallbackContract(String contractAddress, Web3j web3j, T public List getApprovalForAllEvents(TransactionReceipt transactionReceipt) { List valueList = extractEventParametersWithLog(APPROVALFORALL_EVENT, transactionReceipt); - ArrayList responses = new ArrayList(valueList.size()); + ArrayList responses = new ArrayList<>(valueList.size()); for (Contract.EventValuesWithLog eventValues : valueList) { ApprovalForAllEventResponse typedResponse = new ApprovalForAllEventResponse(); typedResponse.log = eventValues.getLog(); @@ -141,7 +136,7 @@ public Flowable approvalForAllEventFlowable(Default public List getNewOwnerEvents(TransactionReceipt transactionReceipt) { List valueList = extractEventParametersWithLog(NEWOWNER_EVENT, transactionReceipt); - ArrayList responses = new ArrayList(valueList.size()); + ArrayList responses = new ArrayList<>(valueList.size()); for (Contract.EventValuesWithLog eventValues : valueList) { NewOwnerEventResponse typedResponse = new NewOwnerEventResponse(); typedResponse.log = eventValues.getLog(); @@ -176,7 +171,7 @@ public Flowable newOwnerEventFlowable(DefaultBlockParamet public List getNewResolverEvents(TransactionReceipt transactionReceipt) { List valueList = extractEventParametersWithLog(NEWRESOLVER_EVENT, transactionReceipt); - ArrayList responses = new ArrayList(valueList.size()); + ArrayList responses = new ArrayList<>(valueList.size()); for (Contract.EventValuesWithLog eventValues : valueList) { NewResolverEventResponse typedResponse = new NewResolverEventResponse(); typedResponse.log = eventValues.getLog(); @@ -209,7 +204,7 @@ public Flowable newResolverEventFlowable(DefaultBlockP public List getNewTTLEvents(TransactionReceipt transactionReceipt) { List valueList = extractEventParametersWithLog(NEWTTL_EVENT, transactionReceipt); - ArrayList responses = new ArrayList(valueList.size()); + ArrayList responses = new ArrayList<>(valueList.size()); for (Contract.EventValuesWithLog eventValues : valueList) { NewTTLEventResponse typedResponse = new NewTTLEventResponse(); typedResponse.log = eventValues.getLog(); @@ -242,7 +237,7 @@ public Flowable newTTLEventFlowable(DefaultBlockParameter s public List getTransferEvents(TransactionReceipt transactionReceipt) { List valueList = extractEventParametersWithLog(TRANSFER_EVENT, transactionReceipt); - ArrayList responses = new ArrayList(valueList.size()); + ArrayList responses = new ArrayList<>(valueList.size()); for (Contract.EventValuesWithLog eventValues : valueList) { TransferEventResponse typedResponse = new TransferEventResponse(); typedResponse.log = eventValues.getLog(); diff --git a/core/src/main/java/org/web3j/ens/contracts/generated/OffchainResolverContract.java b/core/src/main/java/org/web3j/ens/contracts/generated/OffchainResolverContract.java index 2c4561566..e6c78ce48 100644 --- a/core/src/main/java/org/web3j/ens/contracts/generated/OffchainResolverContract.java +++ b/core/src/main/java/org/web3j/ens/contracts/generated/OffchainResolverContract.java @@ -60,7 +60,6 @@ public class OffchainResolverContract extends PublicResolver { public static final Event NEWSIGNERS_EVENT = new Event("NewSigners", Arrays.>asList(new TypeReference>() {})); - ; public OffchainResolverContract(String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) { super(contractAddress, web3j, credentials, gasPrice, gasLimit); @@ -80,7 +79,7 @@ public OffchainResolverContract(String contractAddress, Web3j web3j, Transaction public List getNewSignersEvents(TransactionReceipt transactionReceipt) { List valueList = extractEventParametersWithLog(NEWSIGNERS_EVENT, transactionReceipt); - ArrayList responses = new ArrayList(valueList.size()); + ArrayList responses = new ArrayList<>(valueList.size()); for (Contract.EventValuesWithLog eventValues : valueList) { NewSignersEventResponse typedResponse = new NewSignersEventResponse(); typedResponse.log = eventValues.getLog(); diff --git a/core/src/main/java/org/web3j/ens/contracts/generated/PublicResolver.java b/core/src/main/java/org/web3j/ens/contracts/generated/PublicResolver.java index abba14eef..d08c64d8b 100644 --- a/core/src/main/java/org/web3j/ens/contracts/generated/PublicResolver.java +++ b/core/src/main/java/org/web3j/ens/contracts/generated/PublicResolver.java @@ -104,47 +104,36 @@ public class PublicResolver extends Contract { public static final Event ADDRESSCHANGED_EVENT = new Event("AddressChanged", Arrays.>asList(new TypeReference(true) {}, new TypeReference() {}, new TypeReference() {})); - ; public static final Event APPROVALFORALL_EVENT = new Event("ApprovalForAll", Arrays.>asList(new TypeReference
(true) {}, new TypeReference
(true) {}, new TypeReference() {})); - ; public static final Event CONTENTHASHCHANGED_EVENT = new Event("ContenthashChanged", Arrays.>asList(new TypeReference(true) {}, new TypeReference() {})); - ; public static final Event DNSRECORDCHANGED_EVENT = new Event("DNSRecordChanged", Arrays.>asList(new TypeReference(true) {}, new TypeReference() {}, new TypeReference() {}, new TypeReference() {})); - ; public static final Event DNSRECORDDELETED_EVENT = new Event("DNSRecordDeleted", Arrays.>asList(new TypeReference(true) {}, new TypeReference() {}, new TypeReference() {})); - ; public static final Event DNSZONECLEARED_EVENT = new Event("DNSZoneCleared", Arrays.>asList(new TypeReference(true) {})); - ; public static final Event DNSZONEHASHCHANGED_EVENT = new Event("DNSZonehashChanged", Arrays.>asList(new TypeReference(true) {}, new TypeReference() {}, new TypeReference() {})); - ; public static final Event INTERFACECHANGED_EVENT = new Event("InterfaceChanged", Arrays.>asList(new TypeReference(true) {}, new TypeReference(true) {}, new TypeReference
() {})); - ; public static final Event NAMECHANGED_EVENT = new Event("NameChanged", Arrays.>asList(new TypeReference(true) {}, new TypeReference() {})); - ; public static final Event PUBKEYCHANGED_EVENT = new Event("PubkeyChanged", Arrays.>asList(new TypeReference(true) {}, new TypeReference() {}, new TypeReference() {})); - ; public static final Event TEXTCHANGED_EVENT = new Event("TextChanged", Arrays.>asList(new TypeReference(true) {}, new TypeReference(true) {}, new TypeReference() {})); - ; @Deprecated protected PublicResolver(String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) { @@ -166,7 +155,7 @@ protected PublicResolver(String contractAddress, Web3j web3j, TransactionManager public List getABIChangedEvents(TransactionReceipt transactionReceipt) { List valueList = extractEventParametersWithLog(ABICHANGED_EVENT, transactionReceipt); - ArrayList responses = new ArrayList(valueList.size()); + ArrayList responses = new ArrayList<>(valueList.size()); for (Contract.EventValuesWithLog eventValues : valueList) { ABIChangedEventResponse typedResponse = new ABIChangedEventResponse(); typedResponse.log = eventValues.getLog(); @@ -178,17 +167,14 @@ public List getABIChangedEvents(TransactionReceipt tran } public Flowable aBIChangedEventFlowable(EthFilter filter) { - return web3j.ethLogFlowable(filter).map(new Function() { - @Override - public ABIChangedEventResponse apply(Log log) { - Contract.EventValuesWithLog eventValues = extractEventParametersWithLog(ABICHANGED_EVENT, log); - ABIChangedEventResponse typedResponse = new ABIChangedEventResponse(); - typedResponse.log = log; - typedResponse.node = (byte[]) eventValues.getIndexedValues().get(0).getValue(); - typedResponse.contentType = (BigInteger) eventValues.getIndexedValues().get(1).getValue(); - return typedResponse; - } - }); + return web3j.ethLogFlowable(filter).map(log -> { + EventValuesWithLog eventValues = extractEventParametersWithLog(ABICHANGED_EVENT, log); + ABIChangedEventResponse typedResponse = new ABIChangedEventResponse(); + typedResponse.log = log; + typedResponse.node = (byte[]) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.contentType = (BigInteger) eventValues.getIndexedValues().get(1).getValue(); + return typedResponse; + }); } public Flowable aBIChangedEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { @@ -199,7 +185,7 @@ public Flowable aBIChangedEventFlowable(DefaultBlockPar public List getAddrChangedEvents(TransactionReceipt transactionReceipt) { List valueList = extractEventParametersWithLog(ADDRCHANGED_EVENT, transactionReceipt); - ArrayList responses = new ArrayList(valueList.size()); + ArrayList responses = new ArrayList<>(valueList.size()); for (Contract.EventValuesWithLog eventValues : valueList) { AddrChangedEventResponse typedResponse = new AddrChangedEventResponse(); typedResponse.log = eventValues.getLog(); @@ -211,17 +197,14 @@ public List getAddrChangedEvents(TransactionReceipt tr } public Flowable addrChangedEventFlowable(EthFilter filter) { - return web3j.ethLogFlowable(filter).map(new Function() { - @Override - public AddrChangedEventResponse apply(Log log) { - Contract.EventValuesWithLog eventValues = extractEventParametersWithLog(ADDRCHANGED_EVENT, log); - AddrChangedEventResponse typedResponse = new AddrChangedEventResponse(); - typedResponse.log = log; - typedResponse.node = (byte[]) eventValues.getIndexedValues().get(0).getValue(); - typedResponse.a = (String) eventValues.getNonIndexedValues().get(0).getValue(); - return typedResponse; - } - }); + return web3j.ethLogFlowable(filter).map(log -> { + EventValuesWithLog eventValues = extractEventParametersWithLog(ADDRCHANGED_EVENT, log); + AddrChangedEventResponse typedResponse = new AddrChangedEventResponse(); + typedResponse.log = log; + typedResponse.node = (byte[]) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.a = (String) eventValues.getNonIndexedValues().get(0).getValue(); + return typedResponse; + }); } public Flowable addrChangedEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { @@ -232,7 +215,7 @@ public Flowable addrChangedEventFlowable(DefaultBlockP public List getAddressChangedEvents(TransactionReceipt transactionReceipt) { List valueList = extractEventParametersWithLog(ADDRESSCHANGED_EVENT, transactionReceipt); - ArrayList responses = new ArrayList(valueList.size()); + ArrayList responses = new ArrayList<>(valueList.size()); for (Contract.EventValuesWithLog eventValues : valueList) { AddressChangedEventResponse typedResponse = new AddressChangedEventResponse(); typedResponse.log = eventValues.getLog(); @@ -245,18 +228,15 @@ public List getAddressChangedEvents(TransactionRece } public Flowable addressChangedEventFlowable(EthFilter filter) { - return web3j.ethLogFlowable(filter).map(new Function() { - @Override - public AddressChangedEventResponse apply(Log log) { - Contract.EventValuesWithLog eventValues = extractEventParametersWithLog(ADDRESSCHANGED_EVENT, log); - AddressChangedEventResponse typedResponse = new AddressChangedEventResponse(); - typedResponse.log = log; - typedResponse.node = (byte[]) eventValues.getIndexedValues().get(0).getValue(); - typedResponse.coinType = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); - typedResponse.newAddress = (byte[]) eventValues.getNonIndexedValues().get(1).getValue(); - return typedResponse; - } - }); + return web3j.ethLogFlowable(filter).map(log -> { + EventValuesWithLog eventValues = extractEventParametersWithLog(ADDRESSCHANGED_EVENT, log); + AddressChangedEventResponse typedResponse = new AddressChangedEventResponse(); + typedResponse.log = log; + typedResponse.node = (byte[]) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.coinType = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue(); + typedResponse.newAddress = (byte[]) eventValues.getNonIndexedValues().get(1).getValue(); + return typedResponse; + }); } public Flowable addressChangedEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { @@ -267,7 +247,7 @@ public Flowable addressChangedEventFlowable(Default public List getApprovalForAllEvents(TransactionReceipt transactionReceipt) { List valueList = extractEventParametersWithLog(APPROVALFORALL_EVENT, transactionReceipt); - ArrayList responses = new ArrayList(valueList.size()); + ArrayList responses = new ArrayList<>(valueList.size()); for (Contract.EventValuesWithLog eventValues : valueList) { ApprovalForAllEventResponse typedResponse = new ApprovalForAllEventResponse(); typedResponse.log = eventValues.getLog(); @@ -280,18 +260,15 @@ public List getApprovalForAllEvents(TransactionRece } public Flowable approvalForAllEventFlowable(EthFilter filter) { - return web3j.ethLogFlowable(filter).map(new Function() { - @Override - public ApprovalForAllEventResponse apply(Log log) { - Contract.EventValuesWithLog eventValues = extractEventParametersWithLog(APPROVALFORALL_EVENT, log); - ApprovalForAllEventResponse typedResponse = new ApprovalForAllEventResponse(); - typedResponse.log = log; - typedResponse.owner = (String) eventValues.getIndexedValues().get(0).getValue(); - typedResponse.operator = (String) eventValues.getIndexedValues().get(1).getValue(); - typedResponse.approved = (Boolean) eventValues.getNonIndexedValues().get(0).getValue(); - return typedResponse; - } - }); + return web3j.ethLogFlowable(filter).map(log -> { + EventValuesWithLog eventValues = extractEventParametersWithLog(APPROVALFORALL_EVENT, log); + ApprovalForAllEventResponse typedResponse = new ApprovalForAllEventResponse(); + typedResponse.log = log; + typedResponse.owner = (String) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.operator = (String) eventValues.getIndexedValues().get(1).getValue(); + typedResponse.approved = (Boolean) eventValues.getNonIndexedValues().get(0).getValue(); + return typedResponse; + }); } public Flowable approvalForAllEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { @@ -302,7 +279,7 @@ public Flowable approvalForAllEventFlowable(Default public List getContenthashChangedEvents(TransactionReceipt transactionReceipt) { List valueList = extractEventParametersWithLog(CONTENTHASHCHANGED_EVENT, transactionReceipt); - ArrayList responses = new ArrayList(valueList.size()); + ArrayList responses = new ArrayList<>(valueList.size()); for (Contract.EventValuesWithLog eventValues : valueList) { ContenthashChangedEventResponse typedResponse = new ContenthashChangedEventResponse(); typedResponse.log = eventValues.getLog(); @@ -314,17 +291,14 @@ public List getContenthashChangedEvents(Transac } public Flowable contenthashChangedEventFlowable(EthFilter filter) { - return web3j.ethLogFlowable(filter).map(new Function() { - @Override - public ContenthashChangedEventResponse apply(Log log) { - Contract.EventValuesWithLog eventValues = extractEventParametersWithLog(CONTENTHASHCHANGED_EVENT, log); - ContenthashChangedEventResponse typedResponse = new ContenthashChangedEventResponse(); - typedResponse.log = log; - typedResponse.node = (byte[]) eventValues.getIndexedValues().get(0).getValue(); - typedResponse.hash = (byte[]) eventValues.getNonIndexedValues().get(0).getValue(); - return typedResponse; - } - }); + return web3j.ethLogFlowable(filter).map(log -> { + EventValuesWithLog eventValues = extractEventParametersWithLog(CONTENTHASHCHANGED_EVENT, log); + ContenthashChangedEventResponse typedResponse = new ContenthashChangedEventResponse(); + typedResponse.log = log; + typedResponse.node = (byte[]) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.hash = (byte[]) eventValues.getNonIndexedValues().get(0).getValue(); + return typedResponse; + }); } public Flowable contenthashChangedEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { @@ -335,7 +309,7 @@ public Flowable contenthashChangedEventFlowable public List getDNSRecordChangedEvents(TransactionReceipt transactionReceipt) { List valueList = extractEventParametersWithLog(DNSRECORDCHANGED_EVENT, transactionReceipt); - ArrayList responses = new ArrayList(valueList.size()); + ArrayList responses = new ArrayList<>(valueList.size()); for (Contract.EventValuesWithLog eventValues : valueList) { DNSRecordChangedEventResponse typedResponse = new DNSRecordChangedEventResponse(); typedResponse.log = eventValues.getLog(); @@ -349,19 +323,16 @@ public List getDNSRecordChangedEvents(Transaction } public Flowable dNSRecordChangedEventFlowable(EthFilter filter) { - return web3j.ethLogFlowable(filter).map(new Function() { - @Override - public DNSRecordChangedEventResponse apply(Log log) { - Contract.EventValuesWithLog eventValues = extractEventParametersWithLog(DNSRECORDCHANGED_EVENT, log); - DNSRecordChangedEventResponse typedResponse = new DNSRecordChangedEventResponse(); - typedResponse.log = log; - typedResponse.node = (byte[]) eventValues.getIndexedValues().get(0).getValue(); - typedResponse.name = (byte[]) eventValues.getNonIndexedValues().get(0).getValue(); - typedResponse.resource = (BigInteger) eventValues.getNonIndexedValues().get(1).getValue(); - typedResponse.record = (byte[]) eventValues.getNonIndexedValues().get(2).getValue(); - return typedResponse; - } - }); + return web3j.ethLogFlowable(filter).map(log -> { + EventValuesWithLog eventValues = extractEventParametersWithLog(DNSRECORDCHANGED_EVENT, log); + DNSRecordChangedEventResponse typedResponse = new DNSRecordChangedEventResponse(); + typedResponse.log = log; + typedResponse.node = (byte[]) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.name = (byte[]) eventValues.getNonIndexedValues().get(0).getValue(); + typedResponse.resource = (BigInteger) eventValues.getNonIndexedValues().get(1).getValue(); + typedResponse.record = (byte[]) eventValues.getNonIndexedValues().get(2).getValue(); + return typedResponse; + }); } public Flowable dNSRecordChangedEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { @@ -372,7 +343,7 @@ public Flowable dNSRecordChangedEventFlowable(Def public List getDNSRecordDeletedEvents(TransactionReceipt transactionReceipt) { List valueList = extractEventParametersWithLog(DNSRECORDDELETED_EVENT, transactionReceipt); - ArrayList responses = new ArrayList(valueList.size()); + ArrayList responses = new ArrayList<>(valueList.size()); for (Contract.EventValuesWithLog eventValues : valueList) { DNSRecordDeletedEventResponse typedResponse = new DNSRecordDeletedEventResponse(); typedResponse.log = eventValues.getLog(); @@ -385,18 +356,15 @@ public List getDNSRecordDeletedEvents(Transaction } public Flowable dNSRecordDeletedEventFlowable(EthFilter filter) { - return web3j.ethLogFlowable(filter).map(new Function() { - @Override - public DNSRecordDeletedEventResponse apply(Log log) { - Contract.EventValuesWithLog eventValues = extractEventParametersWithLog(DNSRECORDDELETED_EVENT, log); - DNSRecordDeletedEventResponse typedResponse = new DNSRecordDeletedEventResponse(); - typedResponse.log = log; - typedResponse.node = (byte[]) eventValues.getIndexedValues().get(0).getValue(); - typedResponse.name = (byte[]) eventValues.getNonIndexedValues().get(0).getValue(); - typedResponse.resource = (BigInteger) eventValues.getNonIndexedValues().get(1).getValue(); - return typedResponse; - } - }); + return web3j.ethLogFlowable(filter).map(log -> { + EventValuesWithLog eventValues = extractEventParametersWithLog(DNSRECORDDELETED_EVENT, log); + DNSRecordDeletedEventResponse typedResponse = new DNSRecordDeletedEventResponse(); + typedResponse.log = log; + typedResponse.node = (byte[]) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.name = (byte[]) eventValues.getNonIndexedValues().get(0).getValue(); + typedResponse.resource = (BigInteger) eventValues.getNonIndexedValues().get(1).getValue(); + return typedResponse; + }); } public Flowable dNSRecordDeletedEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { @@ -407,7 +375,7 @@ public Flowable dNSRecordDeletedEventFlowable(Def public List getDNSZoneClearedEvents(TransactionReceipt transactionReceipt) { List valueList = extractEventParametersWithLog(DNSZONECLEARED_EVENT, transactionReceipt); - ArrayList responses = new ArrayList(valueList.size()); + ArrayList responses = new ArrayList<>(valueList.size()); for (Contract.EventValuesWithLog eventValues : valueList) { DNSZoneClearedEventResponse typedResponse = new DNSZoneClearedEventResponse(); typedResponse.log = eventValues.getLog(); @@ -418,16 +386,13 @@ public List getDNSZoneClearedEvents(TransactionRece } public Flowable dNSZoneClearedEventFlowable(EthFilter filter) { - return web3j.ethLogFlowable(filter).map(new Function() { - @Override - public DNSZoneClearedEventResponse apply(Log log) { - Contract.EventValuesWithLog eventValues = extractEventParametersWithLog(DNSZONECLEARED_EVENT, log); - DNSZoneClearedEventResponse typedResponse = new DNSZoneClearedEventResponse(); - typedResponse.log = log; - typedResponse.node = (byte[]) eventValues.getIndexedValues().get(0).getValue(); - return typedResponse; - } - }); + return web3j.ethLogFlowable(filter).map(log -> { + EventValuesWithLog eventValues = extractEventParametersWithLog(DNSZONECLEARED_EVENT, log); + DNSZoneClearedEventResponse typedResponse = new DNSZoneClearedEventResponse(); + typedResponse.log = log; + typedResponse.node = (byte[]) eventValues.getIndexedValues().get(0).getValue(); + return typedResponse; + }); } public Flowable dNSZoneClearedEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { @@ -438,7 +403,7 @@ public Flowable dNSZoneClearedEventFlowable(Default public List getDNSZonehashChangedEvents(TransactionReceipt transactionReceipt) { List valueList = extractEventParametersWithLog(DNSZONEHASHCHANGED_EVENT, transactionReceipt); - ArrayList responses = new ArrayList(valueList.size()); + ArrayList responses = new ArrayList<>(valueList.size()); for (Contract.EventValuesWithLog eventValues : valueList) { DNSZonehashChangedEventResponse typedResponse = new DNSZonehashChangedEventResponse(); typedResponse.log = eventValues.getLog(); @@ -451,18 +416,15 @@ public List getDNSZonehashChangedEvents(Transac } public Flowable dNSZonehashChangedEventFlowable(EthFilter filter) { - return web3j.ethLogFlowable(filter).map(new Function() { - @Override - public DNSZonehashChangedEventResponse apply(Log log) { - Contract.EventValuesWithLog eventValues = extractEventParametersWithLog(DNSZONEHASHCHANGED_EVENT, log); - DNSZonehashChangedEventResponse typedResponse = new DNSZonehashChangedEventResponse(); - typedResponse.log = log; - typedResponse.node = (byte[]) eventValues.getIndexedValues().get(0).getValue(); - typedResponse.lastzonehash = (byte[]) eventValues.getNonIndexedValues().get(0).getValue(); - typedResponse.zonehash = (byte[]) eventValues.getNonIndexedValues().get(1).getValue(); - return typedResponse; - } - }); + return web3j.ethLogFlowable(filter).map(log -> { + EventValuesWithLog eventValues = extractEventParametersWithLog(DNSZONEHASHCHANGED_EVENT, log); + DNSZonehashChangedEventResponse typedResponse = new DNSZonehashChangedEventResponse(); + typedResponse.log = log; + typedResponse.node = (byte[]) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.lastzonehash = (byte[]) eventValues.getNonIndexedValues().get(0).getValue(); + typedResponse.zonehash = (byte[]) eventValues.getNonIndexedValues().get(1).getValue(); + return typedResponse; + }); } public Flowable dNSZonehashChangedEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { @@ -473,7 +435,7 @@ public Flowable dNSZonehashChangedEventFlowable public List getInterfaceChangedEvents(TransactionReceipt transactionReceipt) { List valueList = extractEventParametersWithLog(INTERFACECHANGED_EVENT, transactionReceipt); - ArrayList responses = new ArrayList(valueList.size()); + ArrayList responses = new ArrayList<>(valueList.size()); for (Contract.EventValuesWithLog eventValues : valueList) { InterfaceChangedEventResponse typedResponse = new InterfaceChangedEventResponse(); typedResponse.log = eventValues.getLog(); @@ -486,18 +448,15 @@ public List getInterfaceChangedEvents(Transaction } public Flowable interfaceChangedEventFlowable(EthFilter filter) { - return web3j.ethLogFlowable(filter).map(new Function() { - @Override - public InterfaceChangedEventResponse apply(Log log) { - Contract.EventValuesWithLog eventValues = extractEventParametersWithLog(INTERFACECHANGED_EVENT, log); - InterfaceChangedEventResponse typedResponse = new InterfaceChangedEventResponse(); - typedResponse.log = log; - typedResponse.node = (byte[]) eventValues.getIndexedValues().get(0).getValue(); - typedResponse.interfaceID = (byte[]) eventValues.getIndexedValues().get(1).getValue(); - typedResponse.implementer = (String) eventValues.getNonIndexedValues().get(0).getValue(); - return typedResponse; - } - }); + return web3j.ethLogFlowable(filter).map(log -> { + EventValuesWithLog eventValues = extractEventParametersWithLog(INTERFACECHANGED_EVENT, log); + InterfaceChangedEventResponse typedResponse = new InterfaceChangedEventResponse(); + typedResponse.log = log; + typedResponse.node = (byte[]) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.interfaceID = (byte[]) eventValues.getIndexedValues().get(1).getValue(); + typedResponse.implementer = (String) eventValues.getNonIndexedValues().get(0).getValue(); + return typedResponse; + }); } public Flowable interfaceChangedEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { @@ -508,7 +467,7 @@ public Flowable interfaceChangedEventFlowable(Def public List getNameChangedEvents(TransactionReceipt transactionReceipt) { List valueList = extractEventParametersWithLog(NAMECHANGED_EVENT, transactionReceipt); - ArrayList responses = new ArrayList(valueList.size()); + ArrayList responses = new ArrayList<>(valueList.size()); for (Contract.EventValuesWithLog eventValues : valueList) { NameChangedEventResponse typedResponse = new NameChangedEventResponse(); typedResponse.log = eventValues.getLog(); @@ -520,17 +479,14 @@ public List getNameChangedEvents(TransactionReceipt tr } public Flowable nameChangedEventFlowable(EthFilter filter) { - return web3j.ethLogFlowable(filter).map(new Function() { - @Override - public NameChangedEventResponse apply(Log log) { - Contract.EventValuesWithLog eventValues = extractEventParametersWithLog(NAMECHANGED_EVENT, log); - NameChangedEventResponse typedResponse = new NameChangedEventResponse(); - typedResponse.log = log; - typedResponse.node = (byte[]) eventValues.getIndexedValues().get(0).getValue(); - typedResponse.name = (String) eventValues.getNonIndexedValues().get(0).getValue(); - return typedResponse; - } - }); + return web3j.ethLogFlowable(filter).map(log -> { + EventValuesWithLog eventValues = extractEventParametersWithLog(NAMECHANGED_EVENT, log); + NameChangedEventResponse typedResponse = new NameChangedEventResponse(); + typedResponse.log = log; + typedResponse.node = (byte[]) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.name = (String) eventValues.getNonIndexedValues().get(0).getValue(); + return typedResponse; + }); } public Flowable nameChangedEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { @@ -541,7 +497,7 @@ public Flowable nameChangedEventFlowable(DefaultBlockP public List getPubkeyChangedEvents(TransactionReceipt transactionReceipt) { List valueList = extractEventParametersWithLog(PUBKEYCHANGED_EVENT, transactionReceipt); - ArrayList responses = new ArrayList(valueList.size()); + ArrayList responses = new ArrayList<>(valueList.size()); for (Contract.EventValuesWithLog eventValues : valueList) { PubkeyChangedEventResponse typedResponse = new PubkeyChangedEventResponse(); typedResponse.log = eventValues.getLog(); @@ -554,18 +510,15 @@ public List getPubkeyChangedEvents(TransactionReceip } public Flowable pubkeyChangedEventFlowable(EthFilter filter) { - return web3j.ethLogFlowable(filter).map(new Function() { - @Override - public PubkeyChangedEventResponse apply(Log log) { - Contract.EventValuesWithLog eventValues = extractEventParametersWithLog(PUBKEYCHANGED_EVENT, log); - PubkeyChangedEventResponse typedResponse = new PubkeyChangedEventResponse(); - typedResponse.log = log; - typedResponse.node = (byte[]) eventValues.getIndexedValues().get(0).getValue(); - typedResponse.x = (byte[]) eventValues.getNonIndexedValues().get(0).getValue(); - typedResponse.y = (byte[]) eventValues.getNonIndexedValues().get(1).getValue(); - return typedResponse; - } - }); + return web3j.ethLogFlowable(filter).map(log -> { + EventValuesWithLog eventValues = extractEventParametersWithLog(PUBKEYCHANGED_EVENT, log); + PubkeyChangedEventResponse typedResponse = new PubkeyChangedEventResponse(); + typedResponse.log = log; + typedResponse.node = (byte[]) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.x = (byte[]) eventValues.getNonIndexedValues().get(0).getValue(); + typedResponse.y = (byte[]) eventValues.getNonIndexedValues().get(1).getValue(); + return typedResponse; + }); } public Flowable pubkeyChangedEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { @@ -576,7 +529,7 @@ public Flowable pubkeyChangedEventFlowable(DefaultBl public List getTextChangedEvents(TransactionReceipt transactionReceipt) { List valueList = extractEventParametersWithLog(TEXTCHANGED_EVENT, transactionReceipt); - ArrayList responses = new ArrayList(valueList.size()); + ArrayList responses = new ArrayList<>(valueList.size()); for (Contract.EventValuesWithLog eventValues : valueList) { TextChangedEventResponse typedResponse = new TextChangedEventResponse(); typedResponse.log = eventValues.getLog(); @@ -589,18 +542,15 @@ public List getTextChangedEvents(TransactionReceipt tr } public Flowable textChangedEventFlowable(EthFilter filter) { - return web3j.ethLogFlowable(filter).map(new Function() { - @Override - public TextChangedEventResponse apply(Log log) { - Contract.EventValuesWithLog eventValues = extractEventParametersWithLog(TEXTCHANGED_EVENT, log); - TextChangedEventResponse typedResponse = new TextChangedEventResponse(); - typedResponse.log = log; - typedResponse.node = (byte[]) eventValues.getIndexedValues().get(0).getValue(); - typedResponse.indexedKey = (byte[]) eventValues.getIndexedValues().get(1).getValue(); - typedResponse.key = (String) eventValues.getNonIndexedValues().get(0).getValue(); - return typedResponse; - } - }); + return web3j.ethLogFlowable(filter).map(log -> { + EventValuesWithLog eventValues = extractEventParametersWithLog(TEXTCHANGED_EVENT, log); + TextChangedEventResponse typedResponse = new TextChangedEventResponse(); + typedResponse.log = log; + typedResponse.node = (byte[]) eventValues.getIndexedValues().get(0).getValue(); + typedResponse.indexedKey = (byte[]) eventValues.getIndexedValues().get(1).getValue(); + typedResponse.key = (String) eventValues.getNonIndexedValues().get(0).getValue(); + return typedResponse; + }); } public Flowable textChangedEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { diff --git a/core/src/main/java/org/web3j/protocol/admin/methods/response/TxPoolContent.java b/core/src/main/java/org/web3j/protocol/admin/methods/response/TxPoolContent.java index da5f43f00..6a27b41c7 100644 --- a/core/src/main/java/org/web3j/protocol/admin/methods/response/TxPoolContent.java +++ b/core/src/main/java/org/web3j/protocol/admin/methods/response/TxPoolContent.java @@ -52,14 +52,14 @@ public List getPendingTransactions() { return pending.values().stream() .map(Map::values) .flatMap(Collection::stream) - .collect(Collectors.toList()); + .toList(); } public List getQueuedTransactions() { return queued.values().stream() .map(Map::values) .flatMap(Collection::stream) - .collect(Collectors.toList()); + .toList(); } private static Map immutableCopy(Map map, Function valueMapper) { diff --git a/core/src/main/java/org/web3j/protocol/core/methods/response/AbiDefinition.java b/core/src/main/java/org/web3j/protocol/core/methods/response/AbiDefinition.java index aeda83955..9211971cf 100644 --- a/core/src/main/java/org/web3j/protocol/core/methods/response/AbiDefinition.java +++ b/core/src/main/java/org/web3j/protocol/core/methods/response/AbiDefinition.java @@ -200,7 +200,7 @@ public int hashCode() { } public static class NamedType { - private static String DEFAULT_INTERNAL_TYPE = ""; + private static final String DEFAULT_INTERNAL_TYPE = ""; private String name; private String type; @@ -348,6 +348,6 @@ public int hashCode() { } private static List clone(final List from) { - return from.stream().map(NamedType::new).collect(Collectors.toList()); + return from.stream().map(NamedType::new).toList(); } } diff --git a/core/src/main/java/org/web3j/protocol/core/methods/response/EthCall.java b/core/src/main/java/org/web3j/protocol/core/methods/response/EthCall.java index 2f6ddbb47..503f861fa 100644 --- a/core/src/main/java/org/web3j/protocol/core/methods/response/EthCall.java +++ b/core/src/main/java/org/web3j/protocol/core/methods/response/EthCall.java @@ -27,7 +27,7 @@ public class EthCall extends Response { // Numeric.toHexString(Hash.sha3("Error(string)".getBytes())).substring(0, 10) - private static final String errorMethodId = "0x08c379a0"; + private static final String ERROR_METHOD_ID = "0x08c379a0"; @SuppressWarnings("unchecked") private static final List> revertReasonType = @@ -52,12 +52,12 @@ public boolean reverts() { } private boolean isErrorInResult() { - return getValue() != null && getValue().startsWith(errorMethodId); + return getValue() != null && getValue().startsWith(ERROR_METHOD_ID); } public String getRevertReason() { if (isErrorInResult()) { - String hexRevertReason = getValue().substring(errorMethodId.length()); + String hexRevertReason = getValue().substring(ERROR_METHOD_ID.length()); List decoded = FunctionReturnDecoder.decode(hexRevertReason, revertReasonType); Utf8String decodedRevertReason = (Utf8String) decoded.get(0); return decodedRevertReason.getValue(); diff --git a/core/src/main/java/org/web3j/protocol/core/methods/response/EthFeeHistory.java b/core/src/main/java/org/web3j/protocol/core/methods/response/EthFeeHistory.java index 7e6226e27..0b7bbc687 100644 --- a/core/src/main/java/org/web3j/protocol/core/methods/response/EthFeeHistory.java +++ b/core/src/main/java/org/web3j/protocol/core/methods/response/EthFeeHistory.java @@ -78,8 +78,8 @@ public List> getReward() { rewardPercentile -> rewardPercentile.stream() .map(Numeric::decodeQuantity) - .collect(Collectors.toList())) - .collect(Collectors.toList()); + .toList()) + .toList(); } public void setReward(List> reward) { @@ -91,7 +91,7 @@ public List> getRewardRaw() { } public List getBaseFeePerGas() { - return baseFeePerGas.stream().map(Numeric::decodeQuantity).collect(Collectors.toList()); + return baseFeePerGas.stream().map(Numeric::decodeQuantity).toList(); } public void setBaseFeePerGas(List baseFeePerGas) { diff --git a/core/src/main/java/org/web3j/protocol/deserializer/KeepAsJsonDeserialzier.java b/core/src/main/java/org/web3j/protocol/deserializer/KeepAsJsonDeserialzier.java index e1e657f1f..a83fcb23d 100644 --- a/core/src/main/java/org/web3j/protocol/deserializer/KeepAsJsonDeserialzier.java +++ b/core/src/main/java/org/web3j/protocol/deserializer/KeepAsJsonDeserialzier.java @@ -24,7 +24,7 @@ public class KeepAsJsonDeserialzier extends JsonDeserializer { @Override public String deserialize(JsonParser jp, DeserializationContext ctxt) - throws IOException, JsonProcessingException { + throws IOException { TreeNode tree = jp.getCodec().readTree(jp); return tree.toString(); diff --git a/core/src/main/java/org/web3j/protocol/ipc/IpcService.java b/core/src/main/java/org/web3j/protocol/ipc/IpcService.java index 2fde5effb..3614320a1 100644 --- a/core/src/main/java/org/web3j/protocol/ipc/IpcService.java +++ b/core/src/main/java/org/web3j/protocol/ipc/IpcService.java @@ -15,6 +15,7 @@ import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; +import java.nio.charset.StandardCharsets; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -42,16 +43,16 @@ protected IOFacade getIO() { protected InputStream performIO(String payload) throws IOException { IOFacade io = getIO(); io.write(payload); - log.debug(">> " + payload); + log.debug(">> {}", payload); String result = io.read(); - log.debug("<< " + result); + log.debug("<< {}", result); io.close(); // It's not ideal converting back into an inputStream, but we want // to be consistent with the HTTPService API. // UTF-8 (the default encoding for JSON) is explicitly used here. - return new ByteArrayInputStream(result.getBytes("UTF-8")); + return new ByteArrayInputStream(result.getBytes(StandardCharsets.UTF_8)); } @Override diff --git a/core/src/main/java/org/web3j/tx/ChainId.java b/core/src/main/java/org/web3j/tx/ChainId.java index fd5c0846e..bc1eb9baa 100644 --- a/core/src/main/java/org/web3j/tx/ChainId.java +++ b/core/src/main/java/org/web3j/tx/ChainId.java @@ -28,4 +28,6 @@ public class ChainId { public static final byte KOVAN = 42; public static final byte ETHEREUM_CLASSIC_MAINNET = 61; public static final byte ETHEREUM_CLASSIC_TESTNET = 62; + + private ChainId() {} } diff --git a/core/src/main/java/org/web3j/tx/ChainIdLong.java b/core/src/main/java/org/web3j/tx/ChainIdLong.java index 81a8961d7..0adc31c54 100644 --- a/core/src/main/java/org/web3j/tx/ChainIdLong.java +++ b/core/src/main/java/org/web3j/tx/ChainIdLong.java @@ -28,4 +28,6 @@ public class ChainIdLong { public static final long ETHEREUM_CLASSIC_TESTNET = 62; public static final long LINEA = 59144; public static final long LINEA_SEPOLIA = 59141; + + private ChainIdLong() {} } diff --git a/core/src/main/java/org/web3j/tx/Contract.java b/core/src/main/java/org/web3j/tx/Contract.java index 1eb8649a2..044de3045 100644 --- a/core/src/main/java/org/web3j/tx/Contract.java +++ b/core/src/main/java/org/web3j/tx/Contract.java @@ -791,7 +791,7 @@ public static RemoteCall deployRemoteCall( public static EventValues staticExtractEventParameters(Event event, Log log) { final List topics = log.getTopics(); String encodedEventSignature = EventEncoder.encode(event); - if (topics == null || topics.size() == 0 || !topics.get(0).equals(encodedEventSignature)) { + if (topics == null || topics.isEmpty() || !topics.get(0).equals(encodedEventSignature)) { return null; } @@ -839,7 +839,7 @@ protected List extractEventParametersWithLog( return transactionReceipt.getLogs().stream() .map(log -> extractEventParametersWithLog(event, log)) .filter(Objects::nonNull) - .collect(Collectors.toList()); + .toList(); } protected static List staticExtractEventParametersWithLog( @@ -847,7 +847,7 @@ protected static List staticExtractEventParametersWithLog( return transactionReceipt.getLogs().stream() .map(log -> staticExtractEventParametersWithLog(event, log)) .filter(Objects::nonNull) - .collect(Collectors.toList()); + .toList(); } /** diff --git a/core/src/main/java/org/web3j/tx/exceptions/TxHashMismatchException.java b/core/src/main/java/org/web3j/tx/exceptions/TxHashMismatchException.java index 6bae6c142..83dcfa3bf 100644 --- a/core/src/main/java/org/web3j/tx/exceptions/TxHashMismatchException.java +++ b/core/src/main/java/org/web3j/tx/exceptions/TxHashMismatchException.java @@ -15,8 +15,8 @@ import java.io.IOException; public class TxHashMismatchException extends IOException { - private String txHashLocal; - private String txHashRemote; + private final String txHashLocal; + private final String txHashRemote; public TxHashMismatchException(String txHashLocal, String txHashRemote) { this.txHashLocal = txHashLocal; diff --git a/core/src/main/java/org/web3j/tx/response/EmptyTransactionReceipt.java b/core/src/main/java/org/web3j/tx/response/EmptyTransactionReceipt.java index cc5d707b7..3f4a24088 100644 --- a/core/src/main/java/org/web3j/tx/response/EmptyTransactionReceipt.java +++ b/core/src/main/java/org/web3j/tx/response/EmptyTransactionReceipt.java @@ -28,17 +28,7 @@ public EmptyTransactionReceipt(String transactionHash) { super(); this.setTransactionHash(transactionHash); } - - @Override - public String getTransactionHash() { - return super.getTransactionHash(); - } - - @Override - public void setTransactionHash(String transactionHash) { - super.setTransactionHash(transactionHash); - } - + private UnsupportedOperationException unsupportedOperation() { return new UnsupportedOperationException( "Empty transaction receipt, only transaction hash is available"); diff --git a/core/src/main/java/org/web3j/utils/Async.java b/core/src/main/java/org/web3j/utils/Async.java index 1b34e55af..87a61fb87 100644 --- a/core/src/main/java/org/web3j/utils/Async.java +++ b/core/src/main/java/org/web3j/utils/Async.java @@ -22,6 +22,8 @@ /** Async task facilitation. */ public class Async { + private Async() {} + private static final ExecutorService executor = Executors.newCachedThreadPool(); static { diff --git a/core/src/main/main/java/org/web3j/ens/contracts/generated/ENS.java b/core/src/main/main/java/org/web3j/ens/contracts/generated/ENS.java index edc060c1b..f3cdd514c 100644 --- a/core/src/main/main/java/org/web3j/ens/contracts/generated/ENS.java +++ b/core/src/main/main/java/org/web3j/ens/contracts/generated/ENS.java @@ -66,23 +66,18 @@ public class ENS extends Contract { public static final Event APPROVALFORALL_EVENT = new Event("ApprovalForAll", Arrays.>asList(new TypeReference
(true) {}, new TypeReference
(true) {}, new TypeReference() {})); - ; public static final Event NEWOWNER_EVENT = new Event("NewOwner", Arrays.>asList(new TypeReference(true) {}, new TypeReference(true) {}, new TypeReference
() {})); - ; public static final Event NEWRESOLVER_EVENT = new Event("NewResolver", Arrays.>asList(new TypeReference(true) {}, new TypeReference
() {})); - ; public static final Event NEWTTL_EVENT = new Event("NewTTL", Arrays.>asList(new TypeReference(true) {}, new TypeReference() {})); - ; public static final Event TRANSFER_EVENT = new Event("Transfer", Arrays.>asList(new TypeReference(true) {}, new TypeReference
() {})); - ; @Deprecated protected ENS(String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) { diff --git a/core/src/test/java/org/web3j/crypto/Bip44WalletUtilsTest.java b/core/src/test/java/org/web3j/crypto/Bip44WalletUtilsTest.java index e8b2506fd..65489cfc5 100644 --- a/core/src/test/java/org/web3j/crypto/Bip44WalletUtilsTest.java +++ b/core/src/test/java/org/web3j/crypto/Bip44WalletUtilsTest.java @@ -25,17 +25,17 @@ import static org.web3j.crypto.SampleKeys.PASSWORD; import static org.web3j.crypto.WalletUtilsTest.createTempDir; -public class Bip44WalletUtilsTest { +class Bip44WalletUtilsTest { private File tempDir; @BeforeEach - public void setUp() throws Exception { + void setUp() throws Exception { tempDir = createTempDir(); } @AfterEach - public void tearDown() throws Exception { + void tearDown() { for (File file : tempDir.listFiles()) { file.delete(); } @@ -43,7 +43,7 @@ public void tearDown() throws Exception { } @Test - public void generateBip44KeyPair() { + void generateBip44KeyPair() { String mnemonic = "spider elbow fossil truck deal circle divert sleep safe report laundry above"; byte[] seed = MnemonicUtils.generateSeed(mnemonic, null); @@ -75,7 +75,7 @@ public void generateBip44KeyPair() { } @Test - public void generateBip44KeyPairTestNet() { + void generateBip44KeyPairTestNet() { String mnemonic = "spider elbow fossil truck deal circle divert sleep safe report laundry above"; byte[] seed = MnemonicUtils.generateSeed(mnemonic, null); @@ -100,7 +100,7 @@ public void generateBip44KeyPairTestNet() { } @Test - public void testGenerateBip44Wallets() throws Exception { + void testGenerateBip44Wallets() throws Exception { Bip39Wallet wallet = Bip44WalletUtils.generateBip44Wallet(PASSWORD, tempDir); byte[] seed = MnemonicUtils.generateSeed(wallet.getMnemonic(), PASSWORD); Bip32ECKeyPair masterKeypair = Bip32ECKeyPair.generateKeyPair(seed); diff --git a/core/src/test/java/org/web3j/crypto/WalletFileTest.java b/core/src/test/java/org/web3j/crypto/WalletFileTest.java index a88bc9054..51b996d6a 100644 --- a/core/src/test/java/org/web3j/crypto/WalletFileTest.java +++ b/core/src/test/java/org/web3j/crypto/WalletFileTest.java @@ -19,10 +19,10 @@ import static org.junit.jupiter.api.Assertions.assertEquals; -public class WalletFileTest { +class WalletFileTest { @Test - public void equalsAndHashCodeTest() throws IOException { + void equalsAndHashCodeTest() throws IOException { final String AES_128_CTR = "{\n" diff --git a/core/src/test/java/org/web3j/crypto/WalletTest.java b/core/src/test/java/org/web3j/crypto/WalletTest.java index 3633f2bcf..584f1404a 100644 --- a/core/src/test/java/org/web3j/crypto/WalletTest.java +++ b/core/src/test/java/org/web3j/crypto/WalletTest.java @@ -22,15 +22,15 @@ import static org.junit.jupiter.api.Assertions.assertArrayEquals; import static org.junit.jupiter.api.Assertions.assertEquals; -public class WalletTest { +class WalletTest { @Test - public void testCreateStandard() throws Exception { + void testCreateStandard() throws Exception { testCreate(Wallet.createStandard(SampleKeys.PASSWORD, SampleKeys.KEY_PAIR)); } @Test - public void testCreateLight() throws Exception { + void testCreateLight() throws Exception { testCreate(Wallet.createLight(SampleKeys.PASSWORD, SampleKeys.KEY_PAIR)); } @@ -39,12 +39,12 @@ private void testCreate(WalletFile walletFile) throws Exception { } @Test - public void testEncryptDecryptStandard() throws Exception { + void testEncryptDecryptStandard() throws Exception { testEncryptDecrypt(Wallet.createStandard(SampleKeys.PASSWORD, SampleKeys.KEY_PAIR)); } @Test - public void testEncryptDecryptLight() throws Exception { + void testEncryptDecryptLight() throws Exception { testEncryptDecrypt(Wallet.createLight(SampleKeys.PASSWORD, SampleKeys.KEY_PAIR)); } @@ -53,21 +53,21 @@ private void testEncryptDecrypt(WalletFile walletFile) throws Exception { } @Test - public void testDecryptAes128Ctr() throws Exception { + void testDecryptAes128Ctr() throws Exception { WalletFile walletFile = load(AES_128_CTR); ECKeyPair ecKeyPair = Wallet.decrypt(PASSWORD, walletFile); assertEquals(Numeric.toHexStringNoPrefix(ecKeyPair.getPrivateKey()), (SECRET)); } @Test - public void testDecryptScrypt() throws Exception { + void testDecryptScrypt() throws Exception { WalletFile walletFile = load(SCRYPT); ECKeyPair ecKeyPair = Wallet.decrypt(PASSWORD, walletFile); assertEquals(Numeric.toHexStringNoPrefix(ecKeyPair.getPrivateKey()), (SECRET)); } @Test - public void testGenerateRandomBytes() { + void testGenerateRandomBytes() { assertArrayEquals(Wallet.generateRandomBytes(0), (new byte[] {})); assertEquals(Wallet.generateRandomBytes(10).length, (10)); } diff --git a/core/src/test/java/org/web3j/crypto/WalletUtilsTest.java b/core/src/test/java/org/web3j/crypto/WalletUtilsTest.java index 09bd0f771..0026521d9 100644 --- a/core/src/test/java/org/web3j/crypto/WalletUtilsTest.java +++ b/core/src/test/java/org/web3j/crypto/WalletUtilsTest.java @@ -33,7 +33,7 @@ import static org.web3j.crypto.WalletUtils.isValidAddress; import static org.web3j.crypto.WalletUtils.isValidPrivateKey; -public class WalletUtilsTest { +class WalletUtilsTest { private File tempDir; @@ -43,12 +43,12 @@ private String convertStreamToString(java.io.InputStream is) { } @BeforeEach - public void setUp() throws Exception { + void setUp() throws Exception { tempDir = createTempDir(); } @AfterEach - public void tearDown() throws Exception { + void tearDown() throws Exception { for (File file : tempDir.listFiles()) { file.delete(); } @@ -56,7 +56,7 @@ public void tearDown() throws Exception { } @Test - public void testGenerateBip39Wallets() throws Exception { + void testGenerateBip39Wallets() throws Exception { Bip39Wallet wallet = WalletUtils.generateBip39Wallet(PASSWORD, tempDir); byte[] seed = MnemonicUtils.generateSeed(wallet.getMnemonic(), PASSWORD); Credentials credentials = Credentials.create(ECKeyPair.create(sha256(seed))); @@ -65,7 +65,7 @@ public void testGenerateBip39Wallets() throws Exception { } @Test - public void testGenerateBip39WalletFromMnemonic() throws Exception { + void testGenerateBip39WalletFromMnemonic() throws Exception { Bip39Wallet wallet = WalletUtils.generateBip39WalletFromMnemonic(PASSWORD, MNEMONIC, tempDir); byte[] seed = MnemonicUtils.generateSeed(wallet.getMnemonic(), PASSWORD); @@ -75,19 +75,19 @@ public void testGenerateBip39WalletFromMnemonic() throws Exception { } @Test - public void testGenerateFullNewWalletFile() throws Exception { + void testGenerateFullNewWalletFile() throws Exception { String fileName = WalletUtils.generateFullNewWalletFile(PASSWORD, tempDir); testGeneratedNewWalletFile(fileName); } @Test - public void testGenerateNewWalletFile() throws Exception { + void testGenerateNewWalletFile() throws Exception { String fileName = WalletUtils.generateNewWalletFile(PASSWORD, tempDir); testGeneratedNewWalletFile(fileName); } @Test - public void testGenerateLightNewWalletFile() throws Exception { + void testGenerateLightNewWalletFile() throws Exception { String fileName = WalletUtils.generateLightNewWalletFile(PASSWORD, tempDir); testGeneratedNewWalletFile(fileName); } @@ -97,13 +97,13 @@ private void testGeneratedNewWalletFile(String fileName) throws Exception { } @Test - public void testGenerateFullWalletFile() throws Exception { + void testGenerateFullWalletFile() throws Exception { String fileName = WalletUtils.generateWalletFile(PASSWORD, KEY_PAIR, tempDir, true); testGenerateWalletFile(fileName); } @Test - public void testGenerateLightWalletFile() throws Exception { + void testGenerateLightWalletFile() throws Exception { String fileName = WalletUtils.generateWalletFile(PASSWORD, KEY_PAIR, tempDir, false); testGenerateWalletFile(fileName); } @@ -116,7 +116,7 @@ private void testGenerateWalletFile(String fileName) throws Exception { } @Test - public void testLoadCredentialsFromFile() throws Exception { + void testLoadCredentialsFromFile() throws Exception { Credentials credentials = WalletUtils.loadCredentials( PASSWORD, @@ -132,7 +132,7 @@ public void testLoadCredentialsFromFile() throws Exception { } @Test - public void testLoadCredentialsFromString() throws Exception { + void testLoadCredentialsFromString() throws Exception { Credentials credentials = WalletUtils.loadCredentials( PASSWORD, @@ -148,7 +148,7 @@ public void testLoadCredentialsFromString() throws Exception { @Disabled // enable if users need to work with MyEtherWallet @Test - public void testLoadCredentialsMyEtherWallet() throws Exception { + void testLoadCredentialsMyEtherWallet() throws Exception { Credentials credentials = WalletUtils.loadCredentials( PASSWORD, @@ -167,7 +167,7 @@ public void testLoadCredentialsMyEtherWallet() throws Exception { } @Test - public void testLoadJsonCredentials() throws Exception { + void testLoadJsonCredentials() throws Exception { Credentials credentials = WalletUtils.loadJsonCredentials( PASSWORD, @@ -181,7 +181,7 @@ public void testLoadJsonCredentials() throws Exception { } @Test - public void testGetDefaultKeyDirectory() { + void testGetDefaultKeyDirectory() { assertTrue( WalletUtils.getDefaultKeyDirectory("Mac OS X") .endsWith( @@ -196,7 +196,7 @@ public void testGetDefaultKeyDirectory() { } @Test - public void testGetTestnetKeyDirectory() { + void testGetTestnetKeyDirectory() { assertTrue( WalletUtils.getMainnetKeyDirectory() .endsWith(String.format("%skeystore", File.separator))); @@ -218,7 +218,7 @@ static File createTempDir() throws Exception { } @Test - public void testIsValidPrivateKey() { + void testIsValidPrivateKey() { assertTrue(isValidPrivateKey(SampleKeys.PRIVATE_KEY_STRING)); assertTrue(isValidPrivateKey(Numeric.prependHexPrefix(SampleKeys.PRIVATE_KEY_STRING))); @@ -228,7 +228,7 @@ public void testIsValidPrivateKey() { } @Test - public void testIsValidAddress() { + void testIsValidAddress() { assertTrue(isValidAddress(SampleKeys.ADDRESS)); assertTrue(isValidAddress(SampleKeys.ADDRESS_NO_PREFIX)); diff --git a/core/src/test/java/org/web3j/ens/ContractsTest.java b/core/src/test/java/org/web3j/ens/ContractsTest.java index 2f2cb7e5b..ef1c40cae 100644 --- a/core/src/test/java/org/web3j/ens/ContractsTest.java +++ b/core/src/test/java/org/web3j/ens/ContractsTest.java @@ -28,10 +28,10 @@ import static org.web3j.ens.Contracts.resolveRegistryContract; @SuppressWarnings("deprecation") -public class ContractsTest { +class ContractsTest { @Test - public void testResolveRegistryContract() { + void testResolveRegistryContract() { assertEquals(resolveRegistryContract(ChainIdLong.MAINNET + ""), (MAINNET)); assertEquals(resolveRegistryContract(ChainIdLong.ROPSTEN + ""), (ROPSTEN)); assertEquals(resolveRegistryContract(ChainIdLong.RINKEBY + ""), (RINKEBY)); @@ -42,7 +42,7 @@ public void testResolveRegistryContract() { } @Test - public void testResolveRegistryContractInvalid() { + void testResolveRegistryContractInvalid() { assertThrows( EnsResolutionException.class, () -> resolveRegistryContract(ChainIdLong.NONE + "")); } diff --git a/core/src/test/java/org/web3j/ens/EnsResolverTest.java b/core/src/test/java/org/web3j/ens/EnsResolverTest.java index 3c8516353..8fbe4aed1 100644 --- a/core/src/test/java/org/web3j/ens/EnsResolverTest.java +++ b/core/src/test/java/org/web3j/ens/EnsResolverTest.java @@ -58,7 +58,7 @@ import static org.web3j.ens.EnsResolver.isValidEnsName; import static org.web3j.protocol.http.HttpService.JSON_MEDIA_TYPE; -public class EnsResolverTest { +class EnsResolverTest { private Web3j web3j; private Web3jService web3jService; @@ -68,9 +68,9 @@ public class EnsResolverTest { private static List urls = new ArrayList<>(); - private String sender = "0x226159d592E2b063810a10Ebf6dcbADA94Ed68b8"; + private String sender; - private String data = "0x00112233"; + private String data; public static String LOOKUP_HEX = "0x556f1830000000000000000000000000c1735677a60884abbcf72295e88d47764beda28200000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000160f4d4d2f800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000028000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000004768747470733a2f2f6f6666636861696e2d7265736f6c7665722d6578616d706c652e75632e722e61707073706f742e636f6d2f7b73656e6465727d2f7b646174617d2e6a736f6e0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e49061b92300000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000001701310f6f6666636861696e6578616d706c65036574680000000000000000000000000000000000000000000000000000000000000000000000000000000000243b3b57de1c9fb8c1fe76f464ccec6d2c003169598fdfcbcb6bbddf6af9c097a39fa0048c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e49061b92300000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000001701310f6f6666636861696e6578616d706c65036574680000000000000000000000000000000000000000000000000000000000000000000000000000000000243b3b57de1c9fb8c1fe76f464ccec6d2c003169598fdfcbcb6bbddf6af9c097a39fa0048c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; @@ -89,10 +89,12 @@ public void setUp() { web3jService = mock(Web3jService.class); web3j = Web3j.build(web3jService); ensResolver = new EnsResolver(web3j); + data = "0x00112233"; + sender = "0x226159d592E2b063810a10Ebf6dcbADA94Ed68b8"; } @Test - public void testResolve() throws Exception { + void testResolve() throws Exception { configureSyncing(false); configureLatestBlock(System.currentTimeMillis() / 1000); // block timestamp is in seconds @@ -121,7 +123,7 @@ public void testResolve() throws Exception { } @Test - public void testResolveEnsNameEmptyOrDot() throws Exception { + void testResolveEnsNameEmptyOrDot() { assertNull(ensResolver.resolve(" ")); assertNull(ensResolver.resolve("")); assertNull(ensResolver.resolve(".")); @@ -129,7 +131,7 @@ public void testResolveEnsNameEmptyOrDot() throws Exception { } @Test - public void testReverseResolve() throws Exception { + void testReverseResolve() throws Exception { configureSyncing(false); configureLatestBlock(System.currentTimeMillis() / 1000); // block timestamp is in seconds @@ -160,14 +162,14 @@ public void testReverseResolve() throws Exception { } @Test - public void testIsSyncedSyncing() throws Exception { + void testIsSyncedSyncing() throws Exception { configureSyncing(true); assertFalse(ensResolver.isSynced()); } @Test - public void testIsSyncedFullySynced() throws Exception { + void testIsSyncedFullySynced() throws Exception { configureSyncing(false); configureLatestBlock(System.currentTimeMillis() / 1000); // block timestamp is in seconds @@ -175,7 +177,7 @@ public void testIsSyncedFullySynced() throws Exception { } @Test - public void testIsSyncedBelowThreshold() throws Exception { + void testIsSyncedBelowThreshold() throws Exception { configureSyncing(false); configureLatestBlock((System.currentTimeMillis() / 1000) - DEFAULT_SYNC_THRESHOLD); @@ -201,7 +203,7 @@ private void configureLatestBlock(long timestamp) throws IOException { } @Test - public void testIsEnsName() { + void testIsEnsName() { assertTrue(isValidEnsName("eth")); assertTrue(isValidEnsName("web3.eth")); assertTrue(isValidEnsName("0x19e03255f667bdfd50a32722df860b1eeaf4d635.eth")); @@ -232,8 +234,8 @@ void buildRequestWhenGetSuccessTest() throws IOException { @Test void buildRequestWhenPostSuccessTest() throws IOException { String url = "https://example.com/gateway/{sender}.json"; - String sender = "0x226159d592E2b063810a10Ebf6dcbADA94Ed68b8"; - String data = "0xd5fa2b00"; + sender = "0x226159d592E2b063810a10Ebf6dcbADA94Ed68b8"; + data = "0xd5fa2b00"; okhttp3.Request request = ensResolver.buildRequest(url, sender, data); @@ -247,26 +249,26 @@ void buildRequestWhenPostSuccessTest() throws IOException { } @Test - void buildRequestWhenWithoutDataTest() throws IOException { + void buildRequestWhenWithoutDataTest() { String url = "https://example.com/gateway/{sender}.json"; - String sender = "0x226159d592E2b063810a10Ebf6dcbADA94Ed68b8"; + sender = "0x226159d592E2b063810a10Ebf6dcbADA94Ed68b8"; assertThrows( EnsResolutionException.class, () -> ensResolver.buildRequest(url, sender, null)); } @Test - void buildRequestWhenWithoutSenderTest() throws IOException { + void buildRequestWhenWithoutSenderTest() { String url = "https://example.com/gateway/{sender}.json"; - String data = "0xd5fa2b00"; + data = "0xd5fa2b00"; assertThrows(EnsResolutionException.class, () -> ensResolver.buildRequest(url, null, data)); } @Test - void buildRequestWhenNotValidSenderTest() throws IOException { + void buildRequestWhenNotValidSenderTest() { String url = "https://example.com/gateway/{sender}.json"; - String data = "0xd5fa2b00"; + data = "0xd5fa2b00"; assertThrows( EnsResolutionException.class, @@ -274,10 +276,10 @@ void buildRequestWhenNotValidSenderTest() throws IOException { } @Test - void buildRequestWhenNotValidUrl() throws IOException { + void buildRequestWhenNotValidUrl() { String url = "https://example.com/gateway/{data}.json"; - String sender = "0x226159d592E2b063810a10Ebf6dcbADA94Ed68b8"; - String data = "0xd5fa2b00"; + sender = "0x226159d592E2b063810a10Ebf6dcbADA94Ed68b8"; + data = "0xd5fa2b00"; assertThrows( EnsResolutionException.class, () -> ensResolver.buildRequest(url, sender, data)); diff --git a/core/src/test/java/org/web3j/ens/NameHashTest.java b/core/src/test/java/org/web3j/ens/NameHashTest.java index 2818ed3b0..186577113 100644 --- a/core/src/test/java/org/web3j/ens/NameHashTest.java +++ b/core/src/test/java/org/web3j/ens/NameHashTest.java @@ -21,10 +21,10 @@ import static org.web3j.ens.NameHash.nameHash; import static org.web3j.ens.NameHash.normalise; -public class NameHashTest { +class NameHashTest { @Test - public void testNameHash() { + void testNameHash() { assertEquals( nameHash(""), ("0x0000000000000000000000000000000000000000000000000000000000000000")); @@ -43,7 +43,7 @@ public void testNameHash() { } @Test - public void testNormalise() { + void testNormalise() { assertEquals(normalise("foo"), ("foo")); assertEquals(normalise("foo.bar.baz.eth"), ("foo.bar.baz.eth")); assertEquals(normalise("fOo.eth"), ("foo.eth")); @@ -56,7 +56,7 @@ public void testNormalise() { } @Test - public void testNormaliseInvalid() { + void testNormaliseInvalid() { testInvalidName("foo..bar"); testInvalidName("ba\\u007Fr.eth"); testInvalidName("foo_bar.eth"); diff --git a/core/src/test/java/org/web3j/protocol/BatchTester.java b/core/src/test/java/org/web3j/protocol/BatchTester.java index 9a0a42ef2..c3402d415 100644 --- a/core/src/test/java/org/web3j/protocol/BatchTester.java +++ b/core/src/test/java/org/web3j/protocol/BatchTester.java @@ -103,16 +103,13 @@ public okhttp3.Response intercept(Chain chain) throws IOException { jsonResponse = responseBody.append(']').toString(); } - okhttp3.Response response = - new okhttp3.Response.Builder() + return new okhttp3.Response.Builder() .request(chain.request()) .protocol(Protocol.HTTP_2) .code(200) .body(ResponseBody.create(jsonResponse, JSON_MEDIA_TYPE)) .message("") .build(); - - return response; } public void setJsonResponse(String jsonResponse) { diff --git a/core/src/test/java/org/web3j/protocol/RequestTester.java b/core/src/test/java/org/web3j/protocol/RequestTester.java index 1c943387d..c62e9b1ef 100644 --- a/core/src/test/java/org/web3j/protocol/RequestTester.java +++ b/core/src/test/java/org/web3j/protocol/RequestTester.java @@ -70,8 +70,7 @@ public okhttp3.Response intercept(Chain chain) throws IOException { Request request = chain.request(); this.requestBody = request.body(); - okhttp3.Response response = - new okhttp3.Response.Builder() + return new okhttp3.Response.Builder() .request(chain.request()) .protocol(Protocol.HTTP_2) .code(200) @@ -82,8 +81,6 @@ public okhttp3.Response intercept(Chain chain) throws IOException { JSON_MEDIA_TYPE)) .message("") .build(); - - return response; } public RequestBody getRequestBody() { diff --git a/core/src/test/java/org/web3j/protocol/ResponseTester.java b/core/src/test/java/org/web3j/protocol/ResponseTester.java index a9b234d51..bde0546e1 100644 --- a/core/src/test/java/org/web3j/protocol/ResponseTester.java +++ b/core/src/test/java/org/web3j/protocol/ResponseTester.java @@ -74,16 +74,13 @@ public okhttp3.Response intercept(Chain chain) throws IOException { throw new UnsupportedOperationException("Response has not been configured"); } - okhttp3.Response response = - new okhttp3.Response.Builder() + return new okhttp3.Response.Builder() .body(ResponseBody.create(jsonResponse, JSON_MEDIA_TYPE)) .request(chain.request()) .protocol(Protocol.HTTP_2) .code(200) .message("") .build(); - - return response; } } } diff --git a/core/src/test/java/org/web3j/protocol/admin/RequestTest.java b/core/src/test/java/org/web3j/protocol/admin/RequestTest.java index 1f66049b5..3b16287b5 100644 --- a/core/src/test/java/org/web3j/protocol/admin/RequestTest.java +++ b/core/src/test/java/org/web3j/protocol/admin/RequestTest.java @@ -20,7 +20,7 @@ import org.web3j.protocol.core.methods.request.Transaction; import org.web3j.protocol.http.HttpService; -public class RequestTest extends RequestTester { +class RequestTest extends RequestTester { private Admin web3j; @@ -30,7 +30,7 @@ protected void initWeb3Client(HttpService httpService) { } @Test - public void testPersonalListAccounts() throws Exception { + void testPersonalListAccounts() throws Exception { web3j.personalListAccounts().send(); verifyResult( @@ -39,7 +39,7 @@ public void testPersonalListAccounts() throws Exception { } @Test - public void testPersonalNewAccount() throws Exception { + void testPersonalNewAccount() throws Exception { web3j.personalNewAccount("password").send(); verifyResult( @@ -48,7 +48,7 @@ public void testPersonalNewAccount() throws Exception { } @Test - public void testPersonalSendTransaction() throws Exception { + void testPersonalSendTransaction() throws Exception { web3j.personalSendTransaction( new Transaction( "FROM", @@ -68,7 +68,7 @@ public void testPersonalSendTransaction() throws Exception { } @Test - public void testPersonalUnlockAccount() throws Exception { + void testPersonalUnlockAccount() throws Exception { web3j.personalUnlockAccount( "0xfc390d8a8ddb591b010fda52f4db4945742c3809", "hunter2", BigInteger.ONE) .send(); @@ -80,7 +80,7 @@ public void testPersonalUnlockAccount() throws Exception { } @Test - public void testPersonalUnlockAccountNoDuration() throws Exception { + void testPersonalUnlockAccountNoDuration() throws Exception { web3j.personalUnlockAccount("0xfc390d8a8ddb591b010fda52f4db4945742c3809", "hunter2").send(); verifyResult( @@ -90,7 +90,7 @@ public void testPersonalUnlockAccountNoDuration() throws Exception { } @Test - public void testTxPoolContent() throws Exception { + void testTxPoolContent() throws Exception { web3j.txPoolContent().send(); verifyResult( diff --git a/core/src/test/java/org/web3j/protocol/admin/ResponseTest.java b/core/src/test/java/org/web3j/protocol/admin/ResponseTest.java index 8db22d50c..36d9b684c 100644 --- a/core/src/test/java/org/web3j/protocol/admin/ResponseTest.java +++ b/core/src/test/java/org/web3j/protocol/admin/ResponseTest.java @@ -28,10 +28,10 @@ import static org.junit.jupiter.api.Assertions.assertTrue; /** Parity/Geth Shared Protocol Response tests. */ -public class ResponseTest extends ResponseTester { +class ResponseTest extends ResponseTester { @Test - public void testBooleanResponse() { + void testBooleanResponse() { buildResponse( "{\n" + " \"jsonrpc\":\"2.0\",\n" @@ -44,7 +44,7 @@ public void testBooleanResponse() { } @Test - public void testNewAccountIdentifier() { + void testNewAccountIdentifier() { buildResponse( "{\n" + " \"jsonrpc\": \"2.0\",\n" @@ -59,7 +59,7 @@ public void testNewAccountIdentifier() { } @Test - public void testPersonalListAccounts() { + void testPersonalListAccounts() { buildResponse( "{\n" + " \"jsonrpc\": \"2.0\",\n" @@ -79,7 +79,7 @@ public void testPersonalListAccounts() { } @Test - public void testPersonalSign() { + void testPersonalSign() { buildResponse( "{\n" @@ -96,7 +96,7 @@ public void testPersonalSign() { } @Test - public void testPersonalUnlockAccount() { + void testPersonalUnlockAccount() { buildResponse( "{\n" + " \"jsonrpc\":\"2.0\",\n" @@ -110,7 +110,7 @@ public void testPersonalUnlockAccount() { } @Test - public void testTxPoolContent() { + void testTxPoolContent() { buildResponse( "{\n" + " \"jsonrpc\": \"2.0\",\n" diff --git a/core/src/test/java/org/web3j/protocol/core/BatchTest.java b/core/src/test/java/org/web3j/protocol/core/BatchTest.java index 2f829df32..a82be5906 100644 --- a/core/src/test/java/org/web3j/protocol/core/BatchTest.java +++ b/core/src/test/java/org/web3j/protocol/core/BatchTest.java @@ -24,7 +24,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; -public class BatchTest extends BatchTester { +class BatchTest extends BatchTester { private Web3j web3j; @@ -34,7 +34,7 @@ protected void initWeb3Client(HttpService httpService) { } @Test - public void testBatchRequest() throws Exception { + void testBatchRequest() throws Exception { web3j.newBatch() .add(web3j.web3ClientVersion()) .add(web3j.web3Sha3("0x68656c6c6f20776f726c64")) @@ -51,7 +51,7 @@ public void testBatchRequest() throws Exception { } @Test - public void testBatchResponse() throws Exception { + void testBatchResponse() throws Exception { buildResponse( "[" + "{\n" @@ -81,16 +81,16 @@ public void testBatchResponse() throws Exception { assertTrue(response.getResponses().get(0) instanceof Web3ClientVersion); Web3ClientVersion web3ClientVersion = (Web3ClientVersion) response.getResponses().get(0); - assertEquals(web3ClientVersion.getWeb3ClientVersion(), "Mist/v0.9.3/darwin/go1.4.1"); + assertEquals("Mist/v0.9.3/darwin/go1.4.1", web3ClientVersion.getWeb3ClientVersion()); assertTrue(response.getResponses().get(1) instanceof Web3Sha3); Web3Sha3 web3Sha3 = (Web3Sha3) response.getResponses().get(1); assertEquals( - web3Sha3.getResult(), - "0x47173285a8d7341e5e972fc677286384f802f8ef42a5ec5f03bbfa254cb01fad"); + "0x47173285a8d7341e5e972fc677286384f802f8ef42a5ec5f03bbfa254cb01fad", + web3Sha3.getResult()); assertTrue(response.getResponses().get(2) instanceof NetVersion); NetVersion netVersion = (NetVersion) response.getResponses().get(2); - assertEquals(netVersion.getNetVersion(), "59"); + assertEquals("59", netVersion.getNetVersion()); } } diff --git a/core/src/test/java/org/web3j/protocol/core/EqualsVerifierResponseTest.java b/core/src/test/java/org/web3j/protocol/core/EqualsVerifierResponseTest.java index b1c604eea..bbc06cef4 100644 --- a/core/src/test/java/org/web3j/protocol/core/EqualsVerifierResponseTest.java +++ b/core/src/test/java/org/web3j/protocol/core/EqualsVerifierResponseTest.java @@ -26,10 +26,10 @@ import org.web3j.protocol.core.methods.response.Transaction; import org.web3j.protocol.core.methods.response.TransactionReceipt; -public class EqualsVerifierResponseTest { +class EqualsVerifierResponseTest { @Test - public void testBlock() { + void testBlock() { EqualsVerifier.forClass(EthBlock.Block.class) .suppress(Warning.NONFINAL_FIELDS) .suppress(Warning.STRICT_INHERITANCE) @@ -37,7 +37,7 @@ public void testBlock() { } @Test - public void testTransaction() { + void testTransaction() { EqualsVerifier.forClass(Transaction.class) .suppress(Warning.NONFINAL_FIELDS) .suppress(Warning.STRICT_INHERITANCE) @@ -45,7 +45,7 @@ public void testTransaction() { } @Test - public void testTransactionReceipt() { + void testTransactionReceipt() { EqualsVerifier.forClass(TransactionReceipt.class) .suppress(Warning.NONFINAL_FIELDS) .suppress(Warning.STRICT_INHERITANCE) @@ -53,7 +53,7 @@ public void testTransactionReceipt() { } @Test - public void testLog() { + void testLog() { EqualsVerifier.forClass(Log.class) .suppress(Warning.NONFINAL_FIELDS) .suppress(Warning.STRICT_INHERITANCE) @@ -61,7 +61,7 @@ public void testLog() { } @Test - public void testSshMessage() { + void testSshMessage() { EqualsVerifier.forClass(ShhMessages.SshMessage.class) .suppress(Warning.NONFINAL_FIELDS) .suppress(Warning.STRICT_INHERITANCE) @@ -69,7 +69,7 @@ public void testSshMessage() { } @Test - public void testSolidityInfo() { + void testSolidityInfo() { EqualsVerifier.forClass(EthCompileSolidity.SolidityInfo.class) .withPrefabValues( AbiDefinition.NamedType.class, @@ -81,7 +81,7 @@ public void testSolidityInfo() { } @Test - public void testSyncing() { + void testSyncing() { EqualsVerifier.forClass(EthSyncing.Syncing.class) .suppress(Warning.NONFINAL_FIELDS) .suppress(Warning.STRICT_INHERITANCE) @@ -89,7 +89,7 @@ public void testSyncing() { } @Test - public void testAbiDefinition() { + void testAbiDefinition() { EqualsVerifier.forClass(AbiDefinition.class) .withPrefabValues( AbiDefinition.NamedType.class, @@ -101,7 +101,7 @@ public void testAbiDefinition() { } @Test - public void testAbiDefinitionNamedType() { + void testAbiDefinitionNamedType() { EqualsVerifier.forClass(AbiDefinition.NamedType.class) .withPrefabValues( AbiDefinition.NamedType.class, @@ -113,7 +113,7 @@ public void testAbiDefinitionNamedType() { } @Test - public void testHash() { + void testHash() { EqualsVerifier.forClass(EthLog.Hash.class) .suppress(Warning.NONFINAL_FIELDS) .suppress(Warning.STRICT_INHERITANCE) @@ -121,7 +121,7 @@ public void testHash() { } @Test - public void testCode() { + void testCode() { EqualsVerifier.forClass(EthCompileSolidity.Code.class) .withPrefabValues( AbiDefinition.NamedType.class, @@ -133,7 +133,7 @@ public void testCode() { } @Test - public void testTransactionHash() { + void testTransactionHash() { EqualsVerifier.forClass(EthBlock.TransactionHash.class) .suppress(Warning.NONFINAL_FIELDS) .suppress(Warning.STRICT_INHERITANCE) @@ -141,7 +141,7 @@ public void testTransactionHash() { } @Test - public void testCompiledSolidityCode() { + void testCompiledSolidityCode() { EqualsVerifier.forClass(EthCompileSolidity.Code.class) .withPrefabValues( AbiDefinition.NamedType.class, @@ -153,7 +153,7 @@ public void testCompiledSolidityCode() { } @Test - public void testDocumentation() { + void testDocumentation() { EqualsVerifier.forClass(EthCompileSolidity.Documentation.class) .suppress(Warning.NONFINAL_FIELDS) .suppress(Warning.STRICT_INHERITANCE) @@ -161,7 +161,7 @@ public void testDocumentation() { } @Test - public void testError() { + void testError() { EqualsVerifier.forClass(Response.Error.class) .suppress(Warning.NONFINAL_FIELDS) .suppress(Warning.STRICT_INHERITANCE) diff --git a/core/src/test/java/org/web3j/protocol/core/JsonRpc2_0Web3jTest.java b/core/src/test/java/org/web3j/protocol/core/JsonRpc2_0Web3jTest.java index 71a9915ae..1117f15d0 100644 --- a/core/src/test/java/org/web3j/protocol/core/JsonRpc2_0Web3jTest.java +++ b/core/src/test/java/org/web3j/protocol/core/JsonRpc2_0Web3jTest.java @@ -25,7 +25,7 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; -public class JsonRpc2_0Web3jTest { +class JsonRpc2_0Web3jTest { private ScheduledExecutorService scheduledExecutorService = mock(ScheduledExecutorService.class); @@ -34,14 +34,14 @@ public class JsonRpc2_0Web3jTest { private Web3j web3j = Web3j.build(service, 10, scheduledExecutorService); @Test - public void testStopExecutorOnShutdown() throws Exception { + void testStopExecutorOnShutdown() throws Exception { web3j.shutdown(); verifyServicesClosed(); } @Test - public void testExceptionOnServiceClosure() throws Exception { + void testExceptionOnServiceClosure() { assertThrows( RuntimeException.class, @@ -53,7 +53,7 @@ public void testExceptionOnServiceClosure() throws Exception { } @Test - public void shouldShutdownOnAutoClose() throws Exception { + void shouldShutdownOnAutoClose() throws Exception { try (Web3j web3j = Web3j.build(service, 10, scheduledExecutorService)) {} verifyServicesClosed(); } diff --git a/core/src/test/java/org/web3j/protocol/core/RawResponseTest.java b/core/src/test/java/org/web3j/protocol/core/RawResponseTest.java index ef3d8cd02..0b683a342 100644 --- a/core/src/test/java/org/web3j/protocol/core/RawResponseTest.java +++ b/core/src/test/java/org/web3j/protocol/core/RawResponseTest.java @@ -21,7 +21,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; /** Raw Response tests. */ -public class RawResponseTest extends ResponseTester { +class RawResponseTest extends ResponseTester { private static final String RAW_RESPONSE = "{\n" @@ -34,14 +34,14 @@ public class RawResponseTest extends ResponseTester { "{\"jsonrpc\":\"2.0\",\"id\":1,\"result\":{\"difficulty\":\"0x1aea99\",\"extraData\":\"0xd5830104028650617269747986312e31322e31826c69\",\"gasLimit\":\"0x47b760\",\"gasUsed\":\"0x21c687\",\"hash\":\"0xee5b9e9030d308c77a2d4f975b7090a026ac2cdfe9669e2452cedb4c82e8285e\",\"logsBloom\":\"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\",\"miner\":\"0x004355941066a10e81641d660e0b7082176dfdc0\",\"mixHash\":\"0x0f15a659a35b19fc053b2d3202274ea010ff4125899e18f3197544ec7f53feda\",\"nonce\":\"0x12969144f99ecad6\",\"number\":\"0xc9e\",\"parentHash\":\"0xb4c2c0218039582ce398f2e6e6b325baa62348ee486abb259ea71a9b7afdd125\",\"receiptsRoot\":\"0xb52507949b00d49ae98e6918f80813df0ce6cc62e87bff83387dce37bee0ed7f\",\"sha3Uncles\":\"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347\",\"size\":\"0x21fe\",\"stateRoot\":\"0x3e3e38f228413700e8c88f87edc51bf696e10652909cd32f6ac87f425c885948\",\"timestamp\":\"0x5832272b\",\"totalDifficulty\":\"0xdf702046\",\"transactions\":[{\"blockHash\":\"0xee5b9e9030d308c77a2d4f975b7090a026ac2cdfe9669e2452cedb4c82e8285e\",\"blockNumber\":\"0xc9e\",\"from\":\"0x0718197b9ac69127381ed0c4b5d0f724f857c4d1\",\"gas\":\"0x3d0900\",\"gasPrice\":\"0x0\",\"hash\":\"0x0a00ca4ab70707c097381f5f83c08eac50c4c8a8f9bf025d407b0d71703c5971\",\"input\":\"0x6060604052600180546c0100000000000000000000000033810204600160a060020a03199182168117909255600280549091169091179055611f4c806100456000396000f3606060405236156100a35760e060020a600035046304029f2381146100a85780631f9ea25d1461012057806349593f5314610148578063569aa0d81461025257806359a4669f14610384578063656104f51461047357806370de8c6e1461049b57806371bde8521461057b5780638d909ad9146106455780638f30435d14610730578063916dbc1714610787578063c91540f6146108c0578063fedc2a2814610b95575b610002565b3461000257610c6e6004808035906020019082018035906020019191908080601f01602080910402602001604051908101604052809392919081815260200183838082843750949650509335935050604435915050606435600154600090819033600160a060020a03908116911614610f7b57610002565b3461000257610c6e600435600254600160a060020a0390811633919091161461102a57610002565b3461000257610c6e6004808035906020019082018035906020019191908080601f0160208091040260200160405190810160405280939291908181526020018383808284375094965050933593505060443591505060643560843560006000600060006000600060006000508b604051808280519060200190808383829060006004602084601f0104600302600f01f1509050019150509081526020016040518091039020600050955085600001600050600033600160a060020a0316815260200190815260200160002060005094508967ffffffffffffffff168560000160059054906101000a900467ffffffffffffffff1667ffffffffffffffff161415156111ff576111f2565b3461000257610c706004808035906020019082018035906020019191908080601f01602080910402602001604051908101604052809392919081815260200183838082843750949650509335935050604435915050600060006000600060006000600060006000508a604051808280519060200190808383829060006004602084601f0104600302600f01f15090500191505090815260200160405180910390206000506001016000508960ff1660028110156100025760060201600050600160a060020a0389166000908152600491909101602052604090208054600182015463ffffffff8083169a5067ffffffffffffffff606060020a840481169a50640100000000840482169950919750604060020a830416955060a060020a90910416925090505093975093979195509350565b610c6e6004808035906020019082018035906020019191908080601f016020809104026020016040519081016040528093929190818152602001838380828437509496505050505050506000600060005082604051808280519060200190808383829060006004602084601f0104600302600f01f15090500191505090815260200160405180910390206000509050348160010160005082600d0160009054906101000a900460ff1660ff16600281101561000257600602016000506002018054608060020a6001608060020a0382169093018302929092046001608060020a03199092169190911790555050565b3461000257610c6e600435600154600160a060020a039081163391909116146113c857610002565b610c6e6004808035906020019082018035906020019191908080601f0160208091040260200160405190810160405280939291908181526020018383808284375094965050933593505060443591505060643560006000600060005086604051808280519060200190808383829060006004602084601f0104600302600f01f15090500191505090815260200160405180910390206000509150816001016000508460ff16600281101561000257600602016000506001810154909150346affffffffffffffffffffff608060020a90920491909116146113e757610002565b610c6e6004808035906020019082018035906020019191908080601f01602080910402602001604051908101604052809392919081815260200183838082843750506040805161012435808a013560208181028481018201909552818452989a8a359a6044359a6064359a50608435995060a435985060c435975060e4359661010435969395610144959301929182919085019084908082843750949650505050505050600154600090819081908190819033600160a060020a0390811691161461160f57610002565b3461000257610cba6004808035906020019082018035906020019191908080601f0160208091040260200160405190810160405280939291908181526020018383808284375094965050933593505050506000600060006000600060006000600060006000600060006000508d604051808280519060200190808383829060006004602084601f0104600302600f01f1509050019150509081526020016040518091039020600050915081600d0160009054906101000a900460ff1698508850816001016000508960ff1660028110156100025743600019019b50600602019050611b2d8a8d611519565b3461000257610d2c6004808035906020019082018035906020019191908080601f01602080910402602001604051908101604052809392919081815260200183838082843750949650509335935061099092505050565b3461000257610e0c6004808035906020019082018035906020019191908080601f016020809104026020016040519081016040528093929190818152602001838380828437509496505093359350505050602060405190810160405280600081526020015060006000600060005085604051808280519060200190808383829060006004602084601f0104600302600f01f15090500191505090815260200160405180910390206000506001016000508460ff1660028110156100025760060201600050600581018054604080516020808402820181019092528281529394508301828280156108a057602002820191906000526020600020905b8154600160a060020a03168152600190910190602001808311610882575b505093549298604060020a90930463ffffffff1697509195505050505050565b3461000257610d2c6004808035906020019082018035906020019191908080601f01602080910402602001604051908101604052809392919081815260200183838082843750949650505050505050600060006000600060006000602060405190810160405280600081526020015060006000600060006000611c0d8d60006000508f604051808280519060200190808383829060006004602084601f0104600302600f01f1509050019150509081526020016040518091039020600050600d0160009054906101000a900460ff165b600060006000600060006000602060405190810160405280600081526020015060006000600060006000600060006000508f604051808280519060200190808383829060006004602084601f0104600302600f01f15090500191505090815260200160405180910390206000506001016000508e60ff166002811015610002576006020160005090508060020160009054906101000a90046001608060020a03169c508c508060010160109054906101000a90046affffffffffffffffffffff169b508b5080600001600c9054906101000a900463ffffffff169a508a508060000160009054906101000a900460ff16995089508060010160009054906101000a900467ffffffffffffffff16985088508060000160089054906101000a900463ffffffff169750875080600301600050805480602002602001604051908101604052809291908181526020018280548015610b3157602002820191906000526020600020906000905b82829054906101000a900463ffffffff1681526020019060040190602082600301049283019260010382029150808411610afa5790505b505084546001860154949b5060ff6101008204169a5061ffff62010000820416995067ffffffffffffffff604060020a9095049490941697505063ffffffff6401000000009093049290921694508f93505050509295989b509295989b509295989b565b3461000257610c6e6004808035906020019082018035906020019191908080601f016020809104026020016040519081016040528093929190818152602001838380828437505060408051604435808a013560208181028481018201909552818452989a8a359a90996064995093975091909101945092508291908501908490808284375094965050505050505060006000600060006000600060006000600060006000600160009054906101000a9004600160a060020a0316600160a060020a031633600160a060020a0316141515611c3457610002565b005b6040805163ffffffff978816815267ffffffffffffffff9687166020820152948716858201526060850193909352941660808301529290911660a082015290519081900360c00190f35b6040805167ffffffffffffffff9a8b168152988a1660208a015260ff9097168888015263ffffffff958616606089015293881660808801526affffffffffffffffffffff90921660a087015290921660c085015290841660e08401529092166101008201529051908190036101200190f35b604051808d6001608060020a031681526020018c6affffffffffffffffffffff1681526020018b63ffffffff1681526020018a60ff1681526020018967ffffffffffffffff1681526020018863ffffffff168152602001806020018760ff1681526020018661ffff1681526020018567ffffffffffffffff1681526020018463ffffffff1681526020018360ff1681526020018281038252888181518152602001915080519060200190602002808383829060006004602084601f0104600302600f01f1509050019d505050505050505050505050505060405180910390f35b60405180806020018363ffffffff1681526020018281038252848181518152602001915080519060200190602002808383829060006004602084601f0104600302600f01f150905001935050505060405180910390f35b805473ffffffff00000000000000000000000000000000198116608060020a60e060020a606060020a9384900463ffffffff908116820282900492909202929092177bffffffffffffffff0000000000000000000000000000000000000000191660a060020a60c060020a888416430181020402176fffffffff000000000000000000000000191688830292909204929092021782556040518751918716918891908190602080850191908190849082908590600090600490601f850104600302600f01f15090500191505060405180910390207fa2f4a4124ab7224b7753e37c4d34f853613a576f8e812e4f6186a6f1e80d014786604051808260001916815260200191505060405180910390a35b505050505050565b600060005086604051808280519060200190808383829060006004602084601f0104600302600f01f150905001915050908152602001604051809103902060005091508160010160005082600d0160009054906101000a900460ff1660ff16600281101561000257600602018054909150606060020a900463ffffffff9081169086161161100857610002565b600181015442604060020a90910467ffffffffffffffff1611610e6357610f73565b60028054606060020a80840204600160a060020a031990911617905550565b33828263ffffffff1681548110156100025760009182526020909120018054600160a060020a031916606060020a928302929092049190911790555b83546bffffffff00000000000000001916604060020a60e060020a60018401810204021784555b6040805160c0810182528a815260208082018b81528854610100810463ffffffff168486019081526501000000000090910467ffffffffffffffff1660608501908152436080860190815260a086018e815233600160a060020a0316600090815260048d019096529690942094518554935192519151945163ffffffff1990941660e060020a9182028290041767ffffffff00000000191664010000000093820282900493909302929092176bffffffff00000000000000001916604060020a91830292909204021773ffffffffffffffff0000000000000000000000001916606060020a60c060020a93840284900402177bffffffffffffffff0000000000000000000000000000000000000000191660a060020a91830292909204021781559051600190910155845474ffffffffffffffff00000000000000000000000000191685555b5050505050505050505050565b8454606860020a900467ffffffffffffffff16151561121d576111f2565b8454600187019060ff16600281101561000257600602018054865491955062010000900461ffff16890163ffffffff16606860020a90910467ffffffffffffffff164203111561126c576111f2565b8354600185015464010000000090910463ffffffff16604060020a90910467ffffffffffffffff908116919091011642106112a6576111f2565b600160a060020a033316600090815260048501602052604090206001850154815491945067ffffffffffffffff90811660a060020a90920416101561130057835463ffffffff604060020a909104811610611317576111f2565b825463ffffffff908116908a1611611317576111f2565b6001840154835460058601935067ffffffffffffffff91821660a060020a90910490911610156110ac575082548154604060020a90910463ffffffff1690811061104957818054806001018281815481835581811511611398576000838152602090206113989181019083015b808211156113c45760008155600101611384565b5050506000928352506020909120018054600160a060020a031916606060020a33810204179055611085565b5090565b60018054606060020a80840204600160a060020a031990911617905550565b600181015442604060020a90910467ffffffffffffffff161115806114165750600d82015460ff858116911614155b806114695750805463ffffffff848116606060020a90920416148015906114695750805463ffffffff848116608060020a909204161415806114695750805460a060020a900467ffffffffffffffff1643115b806114945750805460ff1643108015906114945750805467ffffffffffffffff861660ff9091164303115b156114d35734158015906114c95750604051600160a060020a033316903480156108fc02916000818181858888f19350505050155b1561155157610002565b600281018054608060020a6001608060020a03821634018102046001608060020a0319909116179055604080516080810182528581526020810185905290810161155687335b6040805167ffffffffffffffff8416408152606060020a600160a060020a038416026020820152905190819003603401902092915050565b610f73565b81524260209182015233600160a060020a0316600090815293815260409384902082518154928401519584015160609094015160ff1990931660f860020a918202919091041764ffffffff00191661010060e060020a9687029690960495909502949094176cffffffffffffffff000000000019166501000000000060c060020a938402849004021774ffffffffffffffff000000000000000000000000001916606860020a9183029290920402179091555050505050565b60006000508f604051808280519060200190808383829060006004602084601f0104600302600f01f150905001915050908152602001604051809103902060005094508460010160005085600d0160009054906101000a900460ff1660010360ff1660028110156100025760060201600050600d860154909450600186019060ff166002811015610002576006020160005060018101549093504267ffffffffffffffff604060020a90920491909116106116c957610002565b83546000604060020a90910463ffffffff1611156116e657610002565b60048b60ff1610156116f757610002565b60018c60ff16101561170857610002565b85511580611717575060408651115b1561172157610002565b5060009050805b85518160ff16101561179c57858160ff168151811015610002579060200190602002015163ffffffff1660001480611792575063ffffffff82161580159061179257508163ffffffff16868260ff168151811015610002579060200190602002015163ffffffff16115b156119e557610002565b825463ffffffff8f8116606060020a909204161461182a578d63ffffffff168f604051808280519060200190808383829060006004602084601f0104600302600f01f15090500191505060405180910390207fa2f4a4124ab7224b7753e37c4d34f853613a576f8e812e4f6186a6f1e80d014789604051808260001916815260200191505060405180910390a35b84600d0160009054906101000a900460ff1660010385600d0160006101000a81548160ff021916908360f860020a908102040217905550438460010160006101000a81548167ffffffffffffffff021916908360c060020a90810204021790555060008460000160106101000a81548163ffffffff021916908360e060020a90810204021790555060008460000160146101000a81548167ffffffffffffffff021916908360c060020a9081020402179055508d84600001600c6101000a81548163ffffffff021916908360e060020a9081020402179055508c8460010160106101000a8154816affffffffffffffffffffff021916908375010000000000000000000000000000000000000000009081020402179055508b8460000160006101000a81548160ff021916908360f860020a9081020402179055508584600301600050908051906020019082805482825590600052602060002090600701600890048101928215611a095791602002820160005b83821115611a2c57835183826101000a81548163ffffffff021916908360e060020a908102040217905550926020019260040160208160030104928301926001030261199e565b858160ff16815181101561000257602090810290910101519150600101611728565b505b50611a5c9291505b808211156113c457805463ffffffff19168155600101611a11565b8015611a075782816101000a81549063ffffffff0219169055600401602081600301049283019260010302611a2c565b50508354600285018054608060020a6001608060020a03821634018102046001608060020a031990911617905560018501805460c060020a42909c018c029b909b04604060020a026fffffffffffffffff000000000000000019909b169a909a1790995550505060e060020a948502949094046401000000000267ffffffff000000001960f060020a97880297909704620100000263ffff00001960f860020a998a02999099046101000261ff00199097169690961797909716949094179490941694909417905550505050505050565b81546001830154600160a060020a038f166000908152600485016020526040902054929d50606060020a90910463ffffffff169950604060020a810467ffffffffffffffff9081169950608060020a82046affffffffffffffffffffff169850908116955060a060020a90910416849010611bca57600160a060020a038c16600090815260048201602052604090205463ffffffff169450611bcf565b600094505b600160a060020a038c1660009081526020839052604090205467ffffffffffffffff6501000000000090910416925050509295985092959850929598565b9b509b509b509b509b509b509b509b509b509b509b509b5091939597999b5091939597999b565b60006000508e604051808280519060200190808383829060006004602084601f0104600302600f01f15090500191505090815260200160405180910390206000506001016000508d60ff166002811015610002576006020180546001820154919c50640100000000900463ffffffff16604060020a90910467ffffffffffffffff1642031215611cc357610002565b60028b015460006001608060020a039091161115611e61578a5460028c015461010090910460ff16906001608060020a03168115610002576002808e01549054604051939092049c506001608060020a039081168d90039b50600160a060020a0390911691908c1680156108fc02916000818181858888f193505050501515611d4b57978901975b60038b0180548d518b9a50919850965060ff9081169087161115611d6e578b5195505b60009450600093505b8560ff168460ff161015611e8457868460ff168154811015610002579060005260206000209060089182820401919006600402905463ffffffff6101009290920a9004169490940193600190930192611d77565b60006000508e604051808280519060200190808383829060006004602084601f0104600302600f01f15090500191505090815260200160405180910390206000506001016000508d60010360ff166002811015610002576006020160005060028082018054608060020a6001608060020a0382168d018102046001608060020a031991821617909155908d018054909116905590505b8a546bffffffff000000000000000019168b555050505050505050505050505050565b600092505b8560ff168360ff161015611dcb578467ffffffffffffffff16878460ff1681548110156100025790600052602060002090600891828204019190066004029054906101000a900463ffffffff1663ffffffff168a026001608060020a03168115610002570491508b8360ff1681518110156100025760209081029091010151604051600160a060020a03909116906001608060020a03841680156108fc02916000818181858888f1935050505015611f415796819003965b600190920191611e8956\",\"nonce\":\"0x0\",\"to\":null,\"transactionIndex\":\"0x0\",\"value\":\"0x0\",\"v\":\"0x2a\",\"r\":\"0x5bf15422eec1ff6c602b1e1f4513aa577d737c105484744ed7722609357ae81d\",\"s\":\"0xcb1249d0abaeb172954896c495dab2f21099fb54a3b1a82adaacc1840bb24b7\"}],\"transactionsRoot\":\"0x42091b3f1a6dc05c829585b7957aec41b4228e993b6a9223ab3f4ba7277fbb5d\",\"uncles\":[]}}"; @Test - public void testRawResponseEnabled() { + void testRawResponseEnabled() { configureWeb3Service(true); final Web3ClientVersion web3ClientVersion = deserialiseWeb3ClientVersionResponse(); assertEquals(web3ClientVersion.getRawResponse(), (RAW_RESPONSE)); } @Test - public void testLargeRawResponseEnabled() { + void testLargeRawResponseEnabled() { configureWeb3Service(true); buildResponse(LARGE_RAW_RESPONSE); @@ -52,7 +52,7 @@ public void testLargeRawResponseEnabled() { } @Test - public void testRawResponseDisabled() { + void testRawResponseDisabled() { configureWeb3Service(false); final Web3ClientVersion web3ClientVersion = deserialiseWeb3ClientVersionResponse(); assertEquals(web3ClientVersion.getRawResponse(), null); diff --git a/core/src/test/java/org/web3j/protocol/core/RequestTest.java b/core/src/test/java/org/web3j/protocol/core/RequestTest.java index 79af37adc..7b7f042bf 100644 --- a/core/src/test/java/org/web3j/protocol/core/RequestTest.java +++ b/core/src/test/java/org/web3j/protocol/core/RequestTest.java @@ -34,7 +34,7 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -public class RequestTest extends RequestTester { +class RequestTest extends RequestTester { private Web3j web3j; @@ -44,7 +44,7 @@ protected void initWeb3Client(HttpService httpService) { } @Test - public void testWeb3ClientVersion() throws Exception { + void testWeb3ClientVersion() throws Exception { web3j.web3ClientVersion().send(); verifyResult( @@ -52,7 +52,7 @@ public void testWeb3ClientVersion() throws Exception { } @Test - public void testWeb3Sha3() throws Exception { + void testWeb3Sha3() throws Exception { web3j.web3Sha3("0x68656c6c6f20776f726c64").send(); verifyResult( @@ -61,35 +61,35 @@ public void testWeb3Sha3() throws Exception { } @Test - public void testNetVersion() throws Exception { + void testNetVersion() throws Exception { web3j.netVersion().send(); verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"net_version\",\"params\":[],\"id\":1}"); } @Test - public void testNetListening() throws Exception { + void testNetListening() throws Exception { web3j.netListening().send(); verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"net_listening\",\"params\":[],\"id\":1}"); } @Test - public void testNetPeerCount() throws Exception { + void testNetPeerCount() throws Exception { web3j.netPeerCount().send(); verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"net_peerCount\",\"params\":[],\"id\":1}"); } @Test - public void testAdminNodeInfo() throws Exception { + void testAdminNodeInfo() throws Exception { web3j.adminNodeInfo().send(); verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"admin_nodeInfo\",\"params\":[],\"id\":1}"); } @Test - public void testAdminAddPeer() throws Exception { + void testAdminAddPeer() throws Exception { web3j.adminAddPeer("url").send(); verifyResult( @@ -97,14 +97,14 @@ public void testAdminAddPeer() throws Exception { } @Test - public void testAdminDataDir() throws Exception { + void testAdminDataDir() throws Exception { web3j.adminDataDir().send(); verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"admin_datadir\",\"params\":[],\"id\":1}"); } @Test - public void testAdminRemovePeer() throws Exception { + void testAdminRemovePeer() throws Exception { web3j.adminRemovePeer("url").send(); verifyResult( @@ -112,7 +112,7 @@ public void testAdminRemovePeer() throws Exception { } @Test - public void testEthProtocolVersion() throws Exception { + void testEthProtocolVersion() throws Exception { web3j.ethProtocolVersion().send(); verifyResult( @@ -120,42 +120,42 @@ public void testEthProtocolVersion() throws Exception { } @Test - public void testEthSyncing() throws Exception { + void testEthSyncing() throws Exception { web3j.ethSyncing().send(); verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"eth_syncing\",\"params\":[],\"id\":1}"); } @Test - public void testEthCoinbase() throws Exception { + void testEthCoinbase() throws Exception { web3j.ethCoinbase().send(); verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"eth_coinbase\",\"params\":[],\"id\":1}"); } @Test - public void testEthMining() throws Exception { + void testEthMining() throws Exception { web3j.ethMining().send(); verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"eth_mining\",\"params\":[],\"id\":1}"); } @Test - public void testEthHashrate() throws Exception { + void testEthHashrate() throws Exception { web3j.ethHashrate().send(); verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"eth_hashrate\",\"params\":[],\"id\":1}"); } @Test - public void testEthGasPrice() throws Exception { + void testEthGasPrice() throws Exception { web3j.ethGasPrice().send(); verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"eth_gasPrice\",\"params\":[],\"id\":1}"); } @Test - public void testEthMaxPriorityFeePerGas() throws Exception { + void testEthMaxPriorityFeePerGas() throws Exception { web3j.ethMaxPriorityFeePerGas().send(); verifyResult( @@ -163,14 +163,14 @@ public void testEthMaxPriorityFeePerGas() throws Exception { } @Test - public void testEthBaseFee() throws Exception { + void testEthBaseFee() throws Exception { web3j.ethBaseFee().send(); verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"eth_baseFee\",\"params\":[],\"id\":1}"); } @Test - public void testEthFeeHistory() throws Exception { + void testEthFeeHistory() throws Exception { web3j.ethFeeHistory(1, DefaultBlockParameterName.LATEST, null).send(); verifyResult( @@ -178,21 +178,21 @@ public void testEthFeeHistory() throws Exception { } @Test - public void testEthAccounts() throws Exception { + void testEthAccounts() throws Exception { web3j.ethAccounts().send(); verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"eth_accounts\",\"params\":[],\"id\":1}"); } @Test - public void testEthBlockNumber() throws Exception { + void testEthBlockNumber() throws Exception { web3j.ethBlockNumber().send(); verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"eth_blockNumber\",\"params\":[],\"id\":1}"); } @Test - public void testEthGetBalance() throws Exception { + void testEthGetBalance() throws Exception { web3j.ethGetBalance( "0x407d73d8a49eeb85d32cf465507dd71d507100c1", DefaultBlockParameterName.LATEST) @@ -205,7 +205,7 @@ public void testEthGetBalance() throws Exception { } @Test - public void testEthGetStorageAt() throws Exception { + void testEthGetStorageAt() throws Exception { web3j.ethGetStorageAt( "0x295a70b2de5e3953354a6a8344e616ed314d7251", BigInteger.ZERO, @@ -219,7 +219,7 @@ public void testEthGetStorageAt() throws Exception { } @Test - public void testEthGetTransactionCount() throws Exception { + void testEthGetTransactionCount() throws Exception { web3j.ethGetTransactionCount( "0x407d73d8a49eeb85d32cf465507dd71d507100c1", DefaultBlockParameterName.LATEST) @@ -232,7 +232,7 @@ public void testEthGetTransactionCount() throws Exception { } @Test - public void testEthGetBlockTransactionCountByHash() throws Exception { + void testEthGetBlockTransactionCountByHash() throws Exception { web3j.ethGetBlockTransactionCountByHash( "0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238") .send(); @@ -242,7 +242,7 @@ public void testEthGetBlockTransactionCountByHash() throws Exception { } @Test - public void testEthGetBlockTransactionCountByNumber() throws Exception { + void testEthGetBlockTransactionCountByNumber() throws Exception { web3j.ethGetBlockTransactionCountByNumber( DefaultBlockParameter.valueOf(Numeric.toBigInt("0xe8"))) .send(); @@ -253,7 +253,7 @@ public void testEthGetBlockTransactionCountByNumber() throws Exception { } @Test - public void testEthGetUncleCountByBlockHash() throws Exception { + void testEthGetUncleCountByBlockHash() throws Exception { web3j.ethGetUncleCountByBlockHash( "0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238") .send(); @@ -263,7 +263,7 @@ public void testEthGetUncleCountByBlockHash() throws Exception { } @Test - public void testEthGetUncleCountByBlockNumber() throws Exception { + void testEthGetUncleCountByBlockNumber() throws Exception { web3j.ethGetUncleCountByBlockNumber(DefaultBlockParameter.valueOf(Numeric.toBigInt("0xe8"))) .send(); @@ -273,7 +273,7 @@ public void testEthGetUncleCountByBlockNumber() throws Exception { } @Test - public void testEthGetCode() throws Exception { + void testEthGetCode() throws Exception { web3j.ethGetCode( "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", DefaultBlockParameter.valueOf(Numeric.toBigInt("0x2"))) @@ -285,7 +285,7 @@ public void testEthGetCode() throws Exception { } @Test - public void testEthSign() throws Exception { + void testEthSign() throws Exception { web3j.ethSign( "0x8a3106a3e50576d4b6794a0e74d3bb5f8c9acaab", "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470") @@ -299,7 +299,7 @@ public void testEthSign() throws Exception { } @Test - public void testEthSendTransaction() throws Exception { + void testEthSendTransaction() throws Exception { web3j.ethSendTransaction( new Transaction( "0xb60e8dd61c5d32be8058bb8eb970870f07233155", @@ -317,7 +317,7 @@ public void testEthSendTransaction() throws Exception { } @Test - public void testEthSendRawTransaction() throws Exception { + void testEthSendRawTransaction() throws Exception { web3j.ethSendRawTransaction( "0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f" + "072445675058bb8eb970870f072445675") @@ -328,7 +328,7 @@ public void testEthSendRawTransaction() throws Exception { } @Test - public void testEthCall() throws Exception { + void testEthCall() throws Exception { web3j.ethCall( Transaction.createEthCallTransaction( "0xa70e8dd61c5d32be8058bb8eb970870f07233155", @@ -345,7 +345,7 @@ public void testEthCall() throws Exception { } @Test - public void testEthEstimateGas() throws Exception { + void testEthEstimateGas() throws Exception { web3j.ethEstimateGas( Transaction.createEthCallTransaction( "0xa70e8dd61c5d32be8058bb8eb970870f07233155", @@ -361,7 +361,7 @@ public void testEthEstimateGas() throws Exception { } @Test - public void testEthEstimateGasContractCreation() throws Exception { + void testEthEstimateGasContractCreation() throws Exception { web3j.ethEstimateGas( Transaction.createContractTransaction( "0x52b93c80364dc2dd4444c146d73b9836bbbb2b3f", @@ -377,7 +377,7 @@ public void testEthEstimateGasContractCreation() throws Exception { } @Test - public void testEthGetBlockByHash() throws Exception { + void testEthGetBlockByHash() throws Exception { web3j.ethGetBlockByHash( "0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331", true) .send(); @@ -389,7 +389,7 @@ public void testEthGetBlockByHash() throws Exception { } @Test - public void testEthGetBlockByNumber() throws Exception { + void testEthGetBlockByNumber() throws Exception { web3j.ethGetBlockByNumber(DefaultBlockParameter.valueOf(Numeric.toBigInt("0x1b4")), true) .send(); @@ -399,7 +399,7 @@ public void testEthGetBlockByNumber() throws Exception { } @Test - public void testEthGetTransactionByHash() throws Exception { + void testEthGetTransactionByHash() throws Exception { web3j.ethGetTransactionByHash( "0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238") .send(); @@ -411,7 +411,7 @@ public void testEthGetTransactionByHash() throws Exception { } @Test - public void testEthGetTransactionByBlockHashAndIndex() throws Exception { + void testEthGetTransactionByBlockHashAndIndex() throws Exception { web3j.ethGetTransactionByBlockHashAndIndex( "0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331", BigInteger.ZERO) @@ -422,7 +422,7 @@ public void testEthGetTransactionByBlockHashAndIndex() throws Exception { } @Test - public void testEthGetTransactionByBlockNumberAndIndex() throws Exception { + void testEthGetTransactionByBlockNumberAndIndex() throws Exception { web3j.ethGetTransactionByBlockNumberAndIndex( DefaultBlockParameter.valueOf(Numeric.toBigInt("0x29c")), BigInteger.ZERO) .send(); @@ -433,7 +433,7 @@ public void testEthGetTransactionByBlockNumberAndIndex() throws Exception { } @Test - public void testEthGetTransactionReceipt() throws Exception { + void testEthGetTransactionReceipt() throws Exception { web3j.ethGetTransactionReceipt( "0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238") .send(); @@ -445,7 +445,7 @@ public void testEthGetTransactionReceipt() throws Exception { } @Test - public void testEthGetBlockReceipts() throws Exception { + void testEthGetBlockReceipts() throws Exception { web3j.ethGetBlockReceipts(DefaultBlockParameter.valueOf(BigInteger.valueOf(15455945))) .send(); @@ -456,7 +456,7 @@ public void testEthGetBlockReceipts() throws Exception { } @Test - public void testEthGetUncleByBlockHashAndIndex() throws Exception { + void testEthGetUncleByBlockHashAndIndex() throws Exception { web3j.ethGetUncleByBlockHashAndIndex( "0xc6ef2fc5426d6ad6fd9e2a26abeab0aa2411b7ab17f30a99d3cb96aed1d1055b", BigInteger.ZERO) @@ -470,7 +470,7 @@ public void testEthGetUncleByBlockHashAndIndex() throws Exception { } @Test - public void testEthGetUncleByBlockNumberAndIndex() throws Exception { + void testEthGetUncleByBlockNumberAndIndex() throws Exception { web3j.ethGetUncleByBlockNumberAndIndex( DefaultBlockParameter.valueOf(Numeric.toBigInt("0x29c")), BigInteger.ZERO) .send(); @@ -481,7 +481,7 @@ public void testEthGetUncleByBlockNumberAndIndex() throws Exception { } @Test - public void testEthGetCompilers() throws Exception { + void testEthGetCompilers() throws Exception { web3j.ethGetCompilers().send(); verifyResult( @@ -490,7 +490,7 @@ public void testEthGetCompilers() throws Exception { } @Test - public void testEthCompileSolidity() throws Exception { + void testEthCompileSolidity() throws Exception { web3j.ethCompileSolidity( "contract test { function multiply(uint a) returns(uint d) { return a * 7; } }") .send(); @@ -502,7 +502,7 @@ public void testEthCompileSolidity() throws Exception { } @Test - public void testEthCompileLLL() throws Exception { + void testEthCompileLLL() throws Exception { web3j.ethCompileLLL("(returnlll (suicide (caller)))").send(); verifyResult( @@ -511,7 +511,7 @@ public void testEthCompileLLL() throws Exception { } @Test - public void testEthCompileSerpent() throws Exception { + void testEthCompileSerpent() throws Exception { web3j.ethCompileSerpent("/* some serpent */").send(); verifyResult( @@ -520,7 +520,7 @@ public void testEthCompileSerpent() throws Exception { } @Test - public void testEthNewFilter() throws Exception { + void testEthNewFilter() throws Exception { EthFilter ethFilter = new EthFilter().addSingleTopic("0x12341234"); web3j.ethNewFilter(ethFilter).send(); @@ -531,7 +531,7 @@ public void testEthNewFilter() throws Exception { } @Test - public void testEthNewBlockFilter() throws Exception { + void testEthNewBlockFilter() throws Exception { web3j.ethNewBlockFilter().send(); verifyResult( @@ -540,7 +540,7 @@ public void testEthNewBlockFilter() throws Exception { } @Test - public void testEthNewPendingTransactionFilter() throws Exception { + void testEthNewPendingTransactionFilter() throws Exception { web3j.ethNewPendingTransactionFilter().send(); verifyResult( @@ -549,7 +549,7 @@ public void testEthNewPendingTransactionFilter() throws Exception { } @Test - public void testEthUninstallFilter() throws Exception { + void testEthUninstallFilter() throws Exception { web3j.ethUninstallFilter(Numeric.toBigInt("0xb")).send(); verifyResult( @@ -558,7 +558,7 @@ public void testEthUninstallFilter() throws Exception { } @Test - public void testEthGetFilterChanges() throws Exception { + void testEthGetFilterChanges() throws Exception { web3j.ethGetFilterChanges(Numeric.toBigInt("0x16")).send(); verifyResult( @@ -567,7 +567,7 @@ public void testEthGetFilterChanges() throws Exception { } @Test - public void testEthGetFilterLogs() throws Exception { + void testEthGetFilterLogs() throws Exception { web3j.ethGetFilterLogs(Numeric.toBigInt("0x16")).send(); verifyResult( @@ -576,7 +576,7 @@ public void testEthGetFilterLogs() throws Exception { } @Test - public void testEthGetLogs() throws Exception { + void testEthGetLogs() throws Exception { web3j.ethGetLogs( new EthFilter() .addSingleTopic( @@ -591,7 +591,7 @@ public void testEthGetLogs() throws Exception { } @Test - public void testEthGetLogsWithNumericBlockRange() throws Exception { + void testEthGetLogsWithNumericBlockRange() throws Exception { web3j.ethGetLogs( new EthFilter( DefaultBlockParameter.valueOf(Numeric.toBigInt("0xe8")), @@ -606,7 +606,7 @@ public void testEthGetLogsWithNumericBlockRange() throws Exception { } @Test - public void testEthGetLogsWithBlockHash() throws Exception { + void testEthGetLogsWithBlockHash() throws Exception { web3j.ethGetLogs( new EthFilter( "0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331", @@ -621,7 +621,7 @@ public void testEthGetLogsWithBlockHash() throws Exception { } @Test - public void testEthGetProof() throws Exception { + void testEthGetProof() throws Exception { web3j.ethGetProof( "0x7F0d15C7FAae65896648C8273B6d7E43f58Fa842", Arrays.asList( @@ -637,14 +637,14 @@ public void testEthGetProof() throws Exception { } @Test - public void testEthGetWork() throws Exception { + void testEthGetWork() throws Exception { web3j.ethGetWork().send(); verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"eth_getWork\",\"params\":[],\"id\":1}"); } @Test - public void testEthSubmitWork() throws Exception { + void testEthSubmitWork() throws Exception { web3j.ethSubmitWork( "0x0000000000000001", "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef", @@ -660,7 +660,7 @@ public void testEthSubmitWork() throws Exception { } @Test - public void testEthSubmitHashRate() throws Exception { + void testEthSubmitHashRate() throws Exception { web3j.ethSubmitHashrate( "0x0000000000000000000000000000000000000000000000000000000000500000", "0x59daa26581d0acd1fce254fb7e85952f4c09d0915afd33d3886cd914bc7d283c") @@ -675,7 +675,7 @@ public void testEthSubmitHashRate() throws Exception { } @Test - public void testDbPutString() throws Exception { + void testDbPutString() throws Exception { web3j.dbPutString("testDB", "myKey", "myString").send(); verifyResult( @@ -684,7 +684,7 @@ public void testDbPutString() throws Exception { } @Test - public void testDbGetString() throws Exception { + void testDbGetString() throws Exception { web3j.dbGetString("testDB", "myKey").send(); verifyResult( @@ -693,7 +693,7 @@ public void testDbGetString() throws Exception { } @Test - public void testDbPutHex() throws Exception { + void testDbPutHex() throws Exception { web3j.dbPutHex("testDB", "myKey", "0x68656c6c6f20776f726c64").send(); verifyResult( @@ -702,7 +702,7 @@ public void testDbPutHex() throws Exception { } @Test - public void testDbGetHex() throws Exception { + void testDbGetHex() throws Exception { web3j.dbGetHex("testDB", "myKey").send(); verifyResult( @@ -711,7 +711,7 @@ public void testDbGetHex() throws Exception { } @Test - public void testShhVersion() throws Exception { + void testShhVersion() throws Exception { web3j.shhVersion().send(); verifyResult( @@ -719,7 +719,7 @@ public void testShhVersion() throws Exception { } @Test - public void testShhPost() throws Exception { + void testShhPost() throws Exception { web3j.shhPost( new ShhPost( @@ -738,14 +738,14 @@ public void testShhPost() throws Exception { } @Test - public void testShhNewIdentity() throws Exception { + void testShhNewIdentity() throws Exception { web3j.shhNewIdentity().send(); verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"shh_newIdentity\",\"params\":[],\"id\":1}"); } @Test - public void testShhHasIdentity() throws Exception { + void testShhHasIdentity() throws Exception { web3j.shhHasIdentity( "0x04f96a5e25610293e42a73908e93ccc8c4d4dc0edcfa9fa872f50cb214e08ebf61a03e245533f97284d442460f2998cd41858798ddfd4d661997d3940272b717b1") @@ -756,14 +756,14 @@ public void testShhHasIdentity() throws Exception { } @Test - public void testShhNewGroup() throws Exception { + void testShhNewGroup() throws Exception { web3j.shhNewGroup().send(); verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"shh_newGroup\",\"params\":[],\"id\":1}"); } @Test - public void testShhAddToGroup() throws Exception { + void testShhAddToGroup() throws Exception { web3j.shhAddToGroup( "0x04f96a5e25610293e42a73908e93ccc8c4d4dc0edcfa9fa872f50cb214e08ebf61a03e245533f97284d442460f2998cd41858798ddfd4d661997d3940272b717b1") @@ -774,7 +774,7 @@ public void testShhAddToGroup() throws Exception { } @Test - public void testShhNewFilter() throws Exception { + void testShhNewFilter() throws Exception { web3j.shhNewFilter( new ShhFilter( @@ -787,7 +787,7 @@ public void testShhNewFilter() throws Exception { } @Test - public void testShhUninstallFilter() throws Exception { + void testShhUninstallFilter() throws Exception { web3j.shhUninstallFilter(Numeric.toBigInt("0x7")).send(); verifyResult( @@ -796,7 +796,7 @@ public void testShhUninstallFilter() throws Exception { } @Test - public void testShhGetFilterChanges() throws Exception { + void testShhGetFilterChanges() throws Exception { web3j.shhGetFilterChanges(Numeric.toBigInt("0x7")).send(); verifyResult( @@ -805,7 +805,7 @@ public void testShhGetFilterChanges() throws Exception { } @Test - public void testShhGetMessages() throws Exception { + void testShhGetMessages() throws Exception { web3j.shhGetMessages(Numeric.toBigInt("0x7")).send(); verifyResult( @@ -814,14 +814,14 @@ public void testShhGetMessages() throws Exception { } @Test - public void testTxPoolStatus() throws Exception { + void testTxPoolStatus() throws Exception { web3j.txPoolStatus().send(); verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"txpool_status\",\"params\":[],\"id\":1}"); } @Test - public void testEthGetBaseFeePerBlobGas() throws Exception { + void testEthGetBaseFeePerBlobGas() throws Exception { // mock Web3jService Web3jService web3jService = mock(Web3jService.class); EthBlock ethBlock = mock(EthBlock.class); diff --git a/core/src/test/java/org/web3j/protocol/core/ResponseTest.java b/core/src/test/java/org/web3j/protocol/core/ResponseTest.java index a5fb24a50..377647f09 100644 --- a/core/src/test/java/org/web3j/protocol/core/ResponseTest.java +++ b/core/src/test/java/org/web3j/protocol/core/ResponseTest.java @@ -95,10 +95,10 @@ import static org.junit.jupiter.api.Assertions.assertTrue; /** Core Protocol Response tests. */ -public class ResponseTest extends ResponseTester { +class ResponseTest extends ResponseTester { @Test - public void testErrorResponse() { + void testErrorResponse() { buildResponse( "{" + " \"jsonrpc\":\"2.0\"," @@ -118,7 +118,7 @@ public void testErrorResponse() { } @Test - public void testErrorResponseComplexData() { + void testErrorResponseComplexData() { buildResponse( "{" + " \"jsonrpc\":\"2.0\"," @@ -136,7 +136,7 @@ public void testErrorResponseComplexData() { } @Test - public void testWeb3ClientVersion() { + void testWeb3ClientVersion() { buildResponse( "{\n" + " \"id\":67,\n" @@ -149,7 +149,7 @@ public void testWeb3ClientVersion() { } @Test - public void testWeb3Sha3() throws IOException { + void testWeb3Sha3() throws IOException { buildResponse( "{\n" + " \"id\":64,\n" @@ -165,7 +165,7 @@ public void testWeb3Sha3() throws IOException { } @Test - public void testNetVersion() throws IOException { + void testNetVersion() throws IOException { buildResponse( "{\n" + " \"id\":67,\n" @@ -178,7 +178,7 @@ public void testNetVersion() throws IOException { } @Test - public void testNetListening() throws IOException { + void testNetListening() throws IOException { buildResponse( "{\n" + " \"id\":67,\n" @@ -191,7 +191,7 @@ public void testNetListening() throws IOException { } @Test - public void testNetPeerCount() throws IOException { + void testNetPeerCount() throws IOException { buildResponse( "{\n" + " \"id\":74,\n" @@ -204,7 +204,7 @@ public void testNetPeerCount() throws IOException { } @Test - public void testAdminNodeInfo() throws Exception { + void testAdminNodeInfo() throws Exception { buildResponse( "{\n" + " \"jsonrpc\": \"2.0\",\n" @@ -256,7 +256,7 @@ public void testAdminNodeInfo() throws Exception { } @Test - public void testEthProtocolVersion() throws IOException { + void testEthProtocolVersion() throws IOException { buildResponse( "{\n" + " \"id\":67,\n" @@ -269,7 +269,7 @@ public void testEthProtocolVersion() throws IOException { } @Test - public void testEthSyncingInProgress() { + void testEthSyncingInProgress() { buildResponse( "{\n" + " \"id\":1,\n" @@ -294,7 +294,7 @@ public void testEthSyncingInProgress() { } @Test - public void testEthSyncing() { + void testEthSyncing() { buildResponse( "{\n" + " \"id\":1,\n" @@ -307,7 +307,7 @@ public void testEthSyncing() { } @Test - public void testEthMining() { + void testEthMining() { buildResponse( "{\n" + " \"id\":71,\n" @@ -320,7 +320,7 @@ public void testEthMining() { } @Test - public void testEthHashrate() { + void testEthHashrate() { buildResponse( "{\n" + " \"id\":71,\n" @@ -333,7 +333,7 @@ public void testEthHashrate() { } @Test - public void testEthGasPrice() { + void testEthGasPrice() { buildResponse( "{\n" + " \"id\":73,\n" @@ -346,7 +346,7 @@ public void testEthGasPrice() { } @Test - public void testEthAccounts() { + void testEthAccounts() { buildResponse( "{\n" + " \"id\":1,\n" @@ -361,7 +361,7 @@ public void testEthAccounts() { } @Test - public void testEthBlockNumber() { + void testEthBlockNumber() { buildResponse( "{\n" + " \"id\":83,\n" @@ -374,7 +374,7 @@ public void testEthBlockNumber() { } @Test - public void testEthGetBalance() { + void testEthGetBalance() { buildResponse( "{\n" + " \"id\":1,\n" @@ -387,7 +387,7 @@ public void testEthGetBalance() { } @Test - public void testEthStorageAt() { + void testEthStorageAt() { buildResponse( "{\n" + " \"jsonrpc\":\"2.0\"," @@ -403,7 +403,7 @@ public void testEthStorageAt() { } @Test - public void testEthGetTransactionCount() { + void testEthGetTransactionCount() { buildResponse( "{\n" + " \"id\":1,\n" @@ -417,7 +417,7 @@ public void testEthGetTransactionCount() { } @Test - public void testEthGetBlockTransactionCountByHash() { + void testEthGetBlockTransactionCountByHash() { buildResponse( "{\n" + " \"id\":1,\n" @@ -432,7 +432,7 @@ public void testEthGetBlockTransactionCountByHash() { } @Test - public void testEthGetBlockTransactionCountByNumber() { + void testEthGetBlockTransactionCountByNumber() { buildResponse( "{\n" + " \"id\":1,\n" @@ -448,7 +448,7 @@ public void testEthGetBlockTransactionCountByNumber() { } @Test - public void testEthGetUncleCountByBlockHash() { + void testEthGetUncleCountByBlockHash() { buildResponse( "{\n" + " \"id\":1,\n" @@ -462,7 +462,7 @@ public void testEthGetUncleCountByBlockHash() { } @Test - public void testEthGetUncleCountByBlockNumber() { + void testEthGetUncleCountByBlockNumber() { buildResponse( "{\n" + " \"id\":1,\n" @@ -476,7 +476,7 @@ public void testEthGetUncleCountByBlockNumber() { } @Test - public void testGetCode() { + void testGetCode() { buildResponse( "{\n" + " \"id\":1,\n" @@ -493,7 +493,7 @@ public void testGetCode() { } @Test - public void testEthSign() { + void testEthSign() { buildResponse( "{\n" + " \"id\":1,\n" @@ -511,7 +511,7 @@ public void testEthSign() { } @Test - public void testEthSendTransaction() { + void testEthSendTransaction() { buildResponse( "{\n" + " \"id\":1,\n" @@ -527,7 +527,7 @@ public void testEthSendTransaction() { } @Test - public void testEthSendRawTransaction() { + void testEthSendRawTransaction() { buildResponse( "{\n" + " \"id\":1,\n" @@ -544,7 +544,7 @@ public void testEthSendRawTransaction() { } @Test - public void testEthCall() { + void testEthCall() { buildResponse( "{\n" + " \"id\":1,\n" @@ -559,7 +559,7 @@ public void testEthCall() { } @Test - public void testEthCallReverted() { + void testEthCallReverted() { buildResponse( "{\n" + " \"id\":1,\n" @@ -590,7 +590,7 @@ public void testEthCallReverted() { } @Test - public void testEthEstimateGas() { + void testEthEstimateGas() { buildResponse( "{\n" + " \"id\":1,\n" @@ -603,7 +603,7 @@ public void testEthEstimateGas() { } @Test - public void testEthBaseFee() { + void testEthBaseFee() { buildResponse( "{\n" + " \"id\":1,\n" @@ -616,7 +616,7 @@ public void testEthBaseFee() { } @Test - public void testEthBlockTransactionHashes() { + void testEthBlockTransactionHashes() { buildResponse( "{\n" @@ -719,7 +719,7 @@ public void testEthBlockTransactionHashes() { } @Test - public void testEthBlockFullTransactionsWithoutBlob() { + void testEthBlockFullTransactionsWithoutBlob() { buildResponse( "{\n" @@ -864,7 +864,7 @@ public void testEthBlockFullTransactionsWithoutBlob() { } @Test - public void testEthBlockFullTransactionsWithBlob() { + void testEthBlockFullTransactionsWithBlob() { buildResponse( "{\n" @@ -1025,7 +1025,7 @@ public void testEthBlockFullTransactionsWithBlob() { } @Test - public void testEthBlockNull() { + void testEthBlockNull() { buildResponse("{\n" + " \"result\": null\n" + "}"); EthBlock ethBlock = deserialiseResponse(EthBlock.class); @@ -1034,7 +1034,7 @@ public void testEthBlockNull() { // @Test - public void testEthTransaction() { + void testEthTransaction() { buildResponse( "{\n" @@ -1104,7 +1104,7 @@ public void testEthTransaction() { } @Test - public void testEthTransactionResponseWithYParity() { + void testEthTransactionResponseWithYParity() { buildResponse( "{\n" + " \"id\":1,\n" @@ -1177,21 +1177,21 @@ public void testEthTransactionResponseWithYParity() { } @Test - public void testTransactionChainId() { + void testTransactionChainId() { Transaction transaction = new Transaction(); transaction.setV(0x25); assertEquals(transaction.getChainId(), (1L)); } @Test - public void testTransactionLongChainId() { + void testTransactionLongChainId() { Transaction transaction = new Transaction(); transaction.setV(0x4A817C823L); assertEquals(transaction.getChainId(), (10000000000L)); } @Test - public void testEthTransactionNull() { + void testEthTransactionNull() { buildResponse("{\n" + " \"result\": null\n" + "}"); EthTransaction ethTransaction = deserialiseResponse(EthTransaction.class); @@ -1199,7 +1199,7 @@ public void testEthTransactionNull() { } @Test - public void testeEthGetTransactionReceiptBeforeByzantium() { + void testeEthGetTransactionReceiptBeforeByzantium() { buildResponse( "{\n" @@ -1271,7 +1271,7 @@ public void testeEthGetTransactionReceiptBeforeByzantium() { } @Test - public void testEthGetBlockReceipts() { + void testEthGetBlockReceipts() { buildResponse( "{\n" + " \"jsonrpc\": \"2.0\",\n" @@ -1379,7 +1379,7 @@ public void testEthGetBlockReceipts() { } @Test - public void testeEthGetTransactionReceiptAfterByzantium() { + void testeEthGetTransactionReceiptAfterByzantium() { buildResponse( "{\n" @@ -1451,7 +1451,7 @@ public void testeEthGetTransactionReceiptAfterByzantium() { } @Test - public void testeEthGetTransactionReceiptAfterEIP4844() { + void testeEthGetTransactionReceiptAfterEIP4844() { buildResponse( "{\n" @@ -1527,7 +1527,7 @@ public void testeEthGetTransactionReceiptAfterEIP4844() { } @Test - public void testTransactionReceiptIsStatusOK() { + void testTransactionReceiptIsStatusOK() { TransactionReceipt transactionReceipt = new TransactionReceipt(); transactionReceipt.setStatus("0x1"); assertEquals(transactionReceipt.isStatusOK(), (true)); @@ -1541,7 +1541,7 @@ public void testTransactionReceiptIsStatusOK() { } @Test - public void testEthGetCompilers() { + void testEthGetCompilers() { buildResponse( "{\n" + " \"id\":1,\n" @@ -1554,7 +1554,7 @@ public void testEthGetCompilers() { } @Test - public void testEthCompileSolidity() { + void testEthCompileSolidity() { buildResponse( "{\n" @@ -1634,7 +1634,7 @@ public void testEthCompileSolidity() { } @Test - public void testEthCompileLLL() { + void testEthCompileLLL() { buildResponse( "{\n" + " \"id\":1,\n" @@ -1652,7 +1652,7 @@ public void testEthCompileLLL() { } @Test - public void testEthCompileSerpent() { + void testEthCompileSerpent() { buildResponse( "{\n" + " \"id\":1,\n" @@ -1670,7 +1670,7 @@ public void testEthCompileSerpent() { } @Test - public void testEthFilter() { + void testEthFilter() { buildResponse( "{\n" + " \"id\":1,\n" @@ -1683,7 +1683,7 @@ public void testEthFilter() { } @Test - public void testEthUninstallFilter() { + void testEthUninstallFilter() { buildResponse( "{\n" + " \"id\":1,\n" @@ -1696,7 +1696,7 @@ public void testEthUninstallFilter() { } @Test - public void testEthLog() { + void testEthLog() { buildResponse( "{\n" @@ -1736,7 +1736,7 @@ public void testEthLog() { } @Test - public void testEthGetProof() { + void testEthGetProof() { buildResponse( "{\n" + " \"jsonrpc\": \"2.0\",\n" @@ -1792,7 +1792,7 @@ public void testEthGetProof() { } @Test - public void testEthGetWork() { + void testEthGetWork() { buildResponse( "{\n" @@ -1818,7 +1818,7 @@ public void testEthGetWork() { } @Test - public void testEthSubmitWork() { + void testEthSubmitWork() { buildResponse( "{\n" + " \"id\":1,\n" @@ -1831,7 +1831,7 @@ public void testEthSubmitWork() { } @Test - public void testEthSubmitHashrate() { + void testEthSubmitHashrate() { buildResponse( "{\n" + " \"id\":1,\n" @@ -1844,7 +1844,7 @@ public void testEthSubmitHashrate() { } @Test - public void testDbPutString() { + void testDbPutString() { buildResponse( "{\n" + " \"id\":1,\n" @@ -1857,7 +1857,7 @@ public void testDbPutString() { } @Test - public void testDbGetString() { + void testDbGetString() { buildResponse( "{\n" + " \"id\":1,\n" @@ -1870,7 +1870,7 @@ public void testDbGetString() { } @Test - public void testDbPutHex() { + void testDbPutHex() { buildResponse( "{\n" + " \"id\":1,\n" @@ -1883,7 +1883,7 @@ public void testDbPutHex() { } @Test - public void testDbGetHex() { + void testDbGetHex() { buildResponse( "{\n" + " \"id\":1,\n" @@ -1896,7 +1896,7 @@ public void testDbGetHex() { } @Test - public void testSshVersion() { + void testSshVersion() { buildResponse( "{\n" + " \"id\":67,\n" @@ -1909,7 +1909,7 @@ public void testSshVersion() { } @Test - public void testSshPost() { + void testSshPost() { buildResponse( "{\n" + " \"id\":1,\n" @@ -1922,7 +1922,7 @@ public void testSshPost() { } @Test - public void testSshNewIdentity() { + void testSshNewIdentity() { buildResponse( "{\n" + " \"id\":1,\n" @@ -1940,7 +1940,7 @@ public void testSshNewIdentity() { } @Test - public void testSshHasIdentity() { + void testSshHasIdentity() { buildResponse( "{\n" + " \"id\":1,\n" @@ -1953,7 +1953,7 @@ public void testSshHasIdentity() { } @Test - public void testSshNewGroup() { + void testSshNewGroup() { buildResponse( "{\n" + " \"id\":1,\n" @@ -1971,7 +1971,7 @@ public void testSshNewGroup() { } @Test - public void testSshAddToGroup() { + void testSshAddToGroup() { buildResponse( "{\n" + " \"id\":1,\n" @@ -1984,7 +1984,7 @@ public void testSshAddToGroup() { } @Test - public void testSshNewFilter() { + void testSshNewFilter() { buildResponse( "{\n" + " \"id\":1,\n" @@ -1997,7 +1997,7 @@ public void testSshNewFilter() { } @Test - public void testSshUninstallFilter() { + void testSshUninstallFilter() { buildResponse( "{\n" + " \"id\":1,\n" @@ -2010,7 +2010,7 @@ public void testSshUninstallFilter() { } @Test - public void testSshMessages() { + void testSshMessages() { buildResponse( "{\n" + " \"id\":1,\n" @@ -2047,7 +2047,7 @@ public void testSshMessages() { } @Test - public void testBooleanResponse() { + void testBooleanResponse() { buildResponse( "{\n" + " \"jsonrpc\":\"2.0\",\n" @@ -2060,7 +2060,7 @@ public void testBooleanResponse() { } @Test - public void testAdminDataDir() { + void testAdminDataDir() { buildResponse( "{\n" + " \"jsonrpc\":\"2.0\",\n" @@ -2073,7 +2073,7 @@ public void testAdminDataDir() { } @Test - public void testTxPoolStatus() { + void testTxPoolStatus() { buildResponse( "{\n" + " \"jsonrpc\":\"2.0\",\n" @@ -2083,7 +2083,7 @@ public void testTxPoolStatus() { + "}"); TxPoolStatus status = deserialiseResponse(TxPoolStatus.class); - assertEquals(status.getPending(), 10); - assertEquals(status.getQueued(), 7); + assertEquals(10, status.getPending()); + assertEquals(7, status.getQueued()); } } diff --git a/core/src/test/java/org/web3j/protocol/core/WebSocketEventTest.java b/core/src/test/java/org/web3j/protocol/core/WebSocketEventTest.java index b337a62c6..10bbe414c 100644 --- a/core/src/test/java/org/web3j/protocol/core/WebSocketEventTest.java +++ b/core/src/test/java/org/web3j/protocol/core/WebSocketEventTest.java @@ -35,7 +35,7 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -public class WebSocketEventTest { +class WebSocketEventTest { private WebSocketClient webSocketClient = mock(WebSocketClient.class); @@ -48,7 +48,7 @@ public class WebSocketEventTest { private WebSocketListener listener; @BeforeEach - public void before() throws Exception { + void before() throws Exception { when(webSocketClient.connectBlocking()).thenReturn(true); doAnswer( @@ -74,7 +74,7 @@ public void before() throws Exception { } @Test - public void testNewHeadsNotifications() { + void testNewHeadsNotifications() { web3j.newHeadsNotifications(); verify(webSocketClient) @@ -85,7 +85,7 @@ public void testNewHeadsNotifications() { } @Test - public void testLogsNotificationsWithoutArguments() { + void testLogsNotificationsWithoutArguments() { web3j.logsNotifications(new ArrayList<>(), new ArrayList<>()); verify(webSocketClient) @@ -96,7 +96,7 @@ public void testLogsNotificationsWithoutArguments() { } @Test - public void testLogsNotificationsWithArguments() { + void testLogsNotificationsWithArguments() { web3j.logsNotifications(Collections.singletonList("0x1"), Collections.singletonList("0x2")); verify(webSocketClient) diff --git a/core/src/test/java/org/web3j/protocol/core/filters/BlockFilterTest.java b/core/src/test/java/org/web3j/protocol/core/filters/BlockFilterTest.java index 1ebbd9a6a..d61298198 100644 --- a/core/src/test/java/org/web3j/protocol/core/filters/BlockFilterTest.java +++ b/core/src/test/java/org/web3j/protocol/core/filters/BlockFilterTest.java @@ -19,10 +19,10 @@ import org.web3j.protocol.core.methods.response.EthLog; @ExtendWith(MockitoExtension.class) -public class BlockFilterTest extends FilterTester { +class BlockFilterTest extends FilterTester { @Test - public void testBlockFilter() throws Exception { + void testBlockFilter() throws Exception { EthLog ethLog = objectMapper.readValue( diff --git a/core/src/test/java/org/web3j/protocol/core/filters/FilterTester.java b/core/src/test/java/org/web3j/protocol/core/filters/FilterTester.java index 37fe76d12..957da3177 100644 --- a/core/src/test/java/org/web3j/protocol/core/filters/FilterTester.java +++ b/core/src/test/java/org/web3j/protocol/core/filters/FilterTester.java @@ -118,6 +118,6 @@ List createExpected(EthLog ethLog) { fail("Results cannot be empty"); } - return ethLog.getLogs().stream().map(t -> t.get()).collect(Collectors.toList()); + return ethLog.getLogs().stream().map(EthLog.LogResult::get).toList(); } } diff --git a/core/src/test/java/org/web3j/protocol/core/filters/LogFilterTest.java b/core/src/test/java/org/web3j/protocol/core/filters/LogFilterTest.java index 85050b340..9576a1a55 100644 --- a/core/src/test/java/org/web3j/protocol/core/filters/LogFilterTest.java +++ b/core/src/test/java/org/web3j/protocol/core/filters/LogFilterTest.java @@ -17,10 +17,10 @@ import org.web3j.protocol.core.methods.request.EthFilter; import org.web3j.protocol.core.methods.response.EthLog; -public class LogFilterTest extends FilterTester { +class LogFilterTest extends FilterTester { @Test - public void testLogFilter() throws Exception { + void testLogFilter() throws Exception { EthLog ethLog = objectMapper.readValue( diff --git a/core/src/test/java/org/web3j/protocol/core/filters/PendingTransactionFilterTest.java b/core/src/test/java/org/web3j/protocol/core/filters/PendingTransactionFilterTest.java index 25af036be..15abdc009 100644 --- a/core/src/test/java/org/web3j/protocol/core/filters/PendingTransactionFilterTest.java +++ b/core/src/test/java/org/web3j/protocol/core/filters/PendingTransactionFilterTest.java @@ -19,10 +19,10 @@ import org.web3j.protocol.core.methods.response.EthLog; @ExtendWith(MockitoExtension.class) -public class PendingTransactionFilterTest extends FilterTester { +class PendingTransactionFilterTest extends FilterTester { @Test - public void testPendingTransactionFilter() throws Exception { + void testPendingTransactionFilter() throws Exception { EthLog ethLog = objectMapper.readValue( "{\"jsonrpc\":\"2.0\",\"id\":1,\"result\":[\"0x31c2342b1e0b8ffda1507fbffddf213c4b3c1e819ff6a84b943faabb0ebf2403\",\"0xccc0d2e07c1febcaca0c3341c4e1268204b06fefa4bb0c8c0d693d8e581c82da\"]}", diff --git a/core/src/test/java/org/web3j/protocol/core/methods/response/EthBlockTest.java b/core/src/test/java/org/web3j/protocol/core/methods/response/EthBlockTest.java index c6f03cc6b..06eec87d2 100644 --- a/core/src/test/java/org/web3j/protocol/core/methods/response/EthBlockTest.java +++ b/core/src/test/java/org/web3j/protocol/core/methods/response/EthBlockTest.java @@ -18,27 +18,27 @@ import static org.junit.jupiter.api.Assertions.assertEquals; -public class EthBlockTest { +class EthBlockTest { @Test - public void testEthBlockNullSize() { + void testEthBlockNullSize() { EthBlock.Block ethBlock = new EthBlock.Block( null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null); - assertEquals(ethBlock.getSize(), BigInteger.ZERO); + assertEquals(BigInteger.ZERO, ethBlock.getSize()); } @Test - public void testEthBlockNotNullSize() { + void testEthBlockNotNullSize() { EthBlock.Block ethBlock = new EthBlock.Block( null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, "0x3e8", null, null, null, null, null, null, null, null, null, null, null); - assertEquals(ethBlock.getSize(), BigInteger.valueOf(1000)); + assertEquals(BigInteger.valueOf(1000), ethBlock.getSize()); } } diff --git a/core/src/test/java/org/web3j/protocol/http/HttpServiceTest.java b/core/src/test/java/org/web3j/protocol/http/HttpServiceTest.java index 36f66352a..f71b53113 100644 --- a/core/src/test/java/org/web3j/protocol/http/HttpServiceTest.java +++ b/core/src/test/java/org/web3j/protocol/http/HttpServiceTest.java @@ -36,12 +36,12 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.fail; -public class HttpServiceTest { +class HttpServiceTest { private HttpService httpService = new HttpService(); @Test - public void testAddHeader() { + void testAddHeader() { String headerName = "customized_header0"; String headerValue = "customized_value0"; httpService.addHeader(headerName, headerValue); @@ -49,7 +49,7 @@ public void testAddHeader() { } @Test - public void testAddHeaders() { + void testAddHeaders() { String headerName1 = "customized_header1"; String headerValue1 = "customized_value1"; @@ -67,7 +67,7 @@ public void testAddHeaders() { } @Test - public void httpWebException() throws IOException { + void httpWebException() throws IOException { String content = "400 error"; Response response = new Response.Builder() @@ -108,7 +108,7 @@ public void httpWebException() throws IOException { } @Test - public void subscriptionNotSupported() { + void subscriptionNotSupported() { Request subscribeRequest = new Request<>( "eth_subscribe", diff --git a/core/src/test/java/org/web3j/protocol/ipc/IpcServiceTest.java b/core/src/test/java/org/web3j/protocol/ipc/IpcServiceTest.java index c4ca45f00..75d4957e5 100644 --- a/core/src/test/java/org/web3j/protocol/ipc/IpcServiceTest.java +++ b/core/src/test/java/org/web3j/protocol/ipc/IpcServiceTest.java @@ -24,7 +24,7 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -public class IpcServiceTest { +class IpcServiceTest { private IpcService ipcService; private IOFacade ioFacade; @@ -42,7 +42,7 @@ protected IOFacade getIO() { } @Test - public void testSend() throws IOException { + void testSend() throws IOException { when(ioFacade.read()) .thenReturn( "{\"jsonrpc\":\"2.0\",\"id\":1," diff --git a/core/src/test/java/org/web3j/protocol/ipc/UnixDomainSocketTest.java b/core/src/test/java/org/web3j/protocol/ipc/UnixDomainSocketTest.java index 2bf0e78d1..3b3b7997d 100644 --- a/core/src/test/java/org/web3j/protocol/ipc/UnixDomainSocketTest.java +++ b/core/src/test/java/org/web3j/protocol/ipc/UnixDomainSocketTest.java @@ -29,7 +29,7 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; -public class UnixDomainSocketTest { +class UnixDomainSocketTest { private static final String RESPONSE = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor " @@ -41,13 +41,13 @@ public class UnixDomainSocketTest { private UnixDomainSocket unixDomainSocket; @BeforeEach - public void setUp() { + void setUp() { writer = mock(PrintWriter.class); reader = mock(InputStreamReader.class); } @Test - public void testIpcService() throws IOException { + void testIpcService() throws IOException { unixDomainSocket = new UnixDomainSocket(reader, writer, RESPONSE.length()); doAnswer( @@ -63,7 +63,7 @@ public void testIpcService() throws IOException { } @Test - public void testReadExceedsBuffer() throws IOException { + void testReadExceedsBuffer() throws IOException { int bufferSize = RESPONSE.length() / 3; unixDomainSocket = new UnixDomainSocket(reader, writer, RESPONSE.length() / 3); @@ -110,7 +110,7 @@ private void runTest() throws IOException { } @Test - public void testSlowResponse() throws Exception { + void testSlowResponse() throws Exception { String response = "{\"jsonrpc\":\"2.0\",\"id\":1," + "\"result\":\"Geth/v1.5.4-stable-b70acf3c/darwin/go1.7.3\"}\n"; diff --git a/core/src/test/java/org/web3j/protocol/rx/JsonRpc2_0RxTest.java b/core/src/test/java/org/web3j/protocol/rx/JsonRpc2_0RxTest.java index 504079039..27d617f45 100644 --- a/core/src/test/java/org/web3j/protocol/rx/JsonRpc2_0RxTest.java +++ b/core/src/test/java/org/web3j/protocol/rx/JsonRpc2_0RxTest.java @@ -53,7 +53,7 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -public class JsonRpc2_0RxTest { +class JsonRpc2_0RxTest { private final ObjectMapper objectMapper = ObjectMapperFactory.getObjectMapper(); @@ -68,7 +68,7 @@ public void setUp() { } @Test - public void testReplayBlocksFlowable() throws Exception { + void testReplayBlocksFlowable() throws Exception { List ethBlocks = Arrays.asList(createBlock(0), createBlock(1), createBlock(2)); @@ -107,7 +107,7 @@ public void testReplayBlocksFlowable() throws Exception { } @Test - public void testReplayBlocksDescendingFlowable() throws Exception { + void testReplayBlocksDescendingFlowable() throws Exception { List ethBlocks = Arrays.asList(createBlock(2), createBlock(1), createBlock(0)); @@ -147,7 +147,7 @@ public void testReplayBlocksDescendingFlowable() throws Exception { } @Test - public void testReplayPastBlocksFlowable() throws Exception { + void testReplayPastBlocksFlowable() throws Exception { List expected = Arrays.asList( createBlock(0), @@ -302,7 +302,7 @@ public void testReplayPastAndFutureBlocksFlowable() throws Exception { } @Test - public void testReplayTransactionsFlowable() throws Exception { + void testReplayTransactionsFlowable() throws Exception { List ethBlocks = Arrays.asList( diff --git a/core/src/test/java/org/web3j/protocol/websocket/WebSocketClientTest.java b/core/src/test/java/org/web3j/protocol/websocket/WebSocketClientTest.java index a9b2940a7..94cebe0b5 100644 --- a/core/src/test/java/org/web3j/protocol/websocket/WebSocketClientTest.java +++ b/core/src/test/java/org/web3j/protocol/websocket/WebSocketClientTest.java @@ -22,27 +22,27 @@ import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; -public class WebSocketClientTest { +class WebSocketClientTest { private WebSocketListener listener = mock(WebSocketListener.class); private WebSocketClient client; @BeforeEach - public void before() throws Exception { + void before() throws Exception { client = new WebSocketClient(new URI("ws://localhost/")); client.setListener(listener); } @Test - public void testNotifyListenerOnMessage() throws Exception { + void testNotifyListenerOnMessage() throws Exception { client.onMessage("message"); verify(listener).onMessage("message"); } @Test - public void testNotifyListenerOnError() throws Exception { + void testNotifyListenerOnError() { IOException e = new IOException("123"); client.onError(e); @@ -50,7 +50,7 @@ public void testNotifyListenerOnError() throws Exception { } @Test - public void testErrorBeforeListenerSet() throws Exception { + void testErrorBeforeListenerSet() { final IOException e = new IOException("123"); client.setListener(null); client.onError(e); @@ -59,7 +59,7 @@ public void testErrorBeforeListenerSet() throws Exception { } @Test - public void testNotifyListenerOnClose() throws Exception { + void testNotifyListenerOnClose() { client.onClose(1, "reason", true); verify(listener).onClose(); diff --git a/core/src/test/java/org/web3j/protocol/websocket/WebSocketServiceTest.java b/core/src/test/java/org/web3j/protocol/websocket/WebSocketServiceTest.java index 3f23c79a0..df5c0bf9e 100644 --- a/core/src/test/java/org/web3j/protocol/websocket/WebSocketServiceTest.java +++ b/core/src/test/java/org/web3j/protocol/websocket/WebSocketServiceTest.java @@ -54,7 +54,7 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -public class WebSocketServiceTest { +class WebSocketServiceTest { private static final int REQUEST_ID = 1; @@ -74,27 +74,27 @@ public class WebSocketServiceTest { private Request subscribeRequest; @BeforeEach - public void before() throws InterruptedException { + void before() throws InterruptedException { when(webSocketClient.connectBlocking()).thenReturn(true); when(webSocketClient.reconnectBlocking()).thenReturn(true); request.setId(1); } @Test - public void testThrowExceptionIfServerUrlIsInvalid() { + void testThrowExceptionIfServerUrlIsInvalid() { assertThrows(RuntimeException.class, () -> new WebSocketService("invalid\\url", true)); } @Test - public void testConnectViaWebSocketClient() throws Exception { + void testConnectViaWebSocketClient() throws Exception { service.connect(); verify(webSocketClient).connectBlocking(); } @Test - public void testReConnectAfterConnected() throws Exception { + void testReConnectAfterConnected() throws Exception { service.connect(); service.close(); service.connect(); @@ -104,7 +104,7 @@ public void testReConnectAfterConnected() throws Exception { } @Test - public void testInterruptCurrentThreadIfConnectionIsInterrupted() throws Exception { + void testInterruptCurrentThreadIfConnectionIsInterrupted() throws Exception { when(webSocketClient.connectBlocking()).thenThrow(new InterruptedException()); service.connect(); @@ -112,7 +112,7 @@ public void testInterruptCurrentThreadIfConnectionIsInterrupted() throws Excepti } @Test - public void testThrowExceptionIfConnectionFailed() throws Exception { + void testThrowExceptionIfConnectionFailed() throws Exception { when(webSocketClient.connectBlocking()).thenReturn(false); assertThrows( ConnectException.class, @@ -122,7 +122,7 @@ public void testThrowExceptionIfConnectionFailed() throws Exception { } @Test - public void testReconnectIfFirstConnectionFailed() throws Exception { + void testReconnectIfFirstConnectionFailed() throws Exception { when(webSocketClient.connectBlocking()).thenReturn(false); assertThrows( ConnectException.class, @@ -137,7 +137,7 @@ public void testReconnectIfFirstConnectionFailed() throws Exception { } @Test - public void testAddedWebSocketListener() throws Exception { + void testAddedWebSocketListener() throws Exception { doAnswer( invocation -> { listener = invocation.getArgument(0, WebSocketListener.class); @@ -168,19 +168,19 @@ public void testAddedWebSocketListener() throws Exception { } @Test - public void testNotWaitingForReplyWithUnknownId() { + void testNotWaitingForReplyWithUnknownId() { assertFalse(service.isWaitingForReply(123)); } @Test - public void testWaitingForReplyToSentRequest() throws Exception { + void testWaitingForReplyToSentRequest() throws Exception { service.sendAsync(request, Web3ClientVersion.class); assertTrue(service.isWaitingForReply(request.getId())); } @Test - public void testNoLongerWaitingForResponseAfterReply() throws Exception { + void testNoLongerWaitingForResponseAfterReply() throws Exception { service.sendAsync(request, Web3ClientVersion.class); sendGethVersionReply(); @@ -188,7 +188,7 @@ public void testNoLongerWaitingForResponseAfterReply() throws Exception { } @Test - public void testSendWebSocketRequest() throws Exception { + void testSendWebSocketRequest() throws Exception { service.sendAsync(request, Web3ClientVersion.class); verify(webSocketClient) @@ -197,7 +197,7 @@ public void testSendWebSocketRequest() throws Exception { } @Test - public void testBatchRequestReply() throws Exception { + void testBatchRequestReply() throws Exception { BatchRequest request = new BatchRequest(service); request.add( new Request<>( @@ -239,25 +239,25 @@ public void testBatchRequestReply() throws Exception { } @Test - public void testIgnoreInvalidReplies() { + void testIgnoreInvalidReplies() { service.sendAsync(request, Web3ClientVersion.class); assertThrows(IOException.class, () -> service.onWebSocketMessage("{")); } @Test - public void testThrowExceptionIfIdHasInvalidType() { + void testThrowExceptionIfIdHasInvalidType() { service.sendAsync(request, Web3ClientVersion.class); assertThrows(IOException.class, () -> service.onWebSocketMessage("{\"id\":true}")); } @Test - public void testThrowExceptionIfIdIsMissing() { + void testThrowExceptionIfIdIsMissing() { service.sendAsync(request, Web3ClientVersion.class); assertThrows(IOException.class, () -> service.onWebSocketMessage("{}")); } @Test - public void testThrowExceptionIfUnexpectedIdIsReceived() { + void testThrowExceptionIfUnexpectedIdIsReceived() { service.sendAsync(request, Web3ClientVersion.class); assertThrows( IOException.class, @@ -267,7 +267,7 @@ public void testThrowExceptionIfUnexpectedIdIsReceived() { } @Test - public void testReceiveReply() throws Exception { + void testReceiveReply() throws Exception { CompletableFuture reply = service.sendAsync(request, Web3ClientVersion.class); sendGethVersionReply(); @@ -277,7 +277,7 @@ public void testReceiveReply() throws Exception { } @Test - public void testReceiveError() throws Exception { + void testReceiveError() throws Exception { CompletableFuture reply = service.sendAsync(request, Web3ClientVersion.class); sendErrorReply(); @@ -289,7 +289,7 @@ public void testReceiveError() throws Exception { } @Test - public void testCloseRequestWhenConnectionIsClosed() { + void testCloseRequestWhenConnectionIsClosed() { CompletableFuture reply = service.sendAsync(request, Web3ClientVersion.class); service.onWebSocketClose(); @@ -299,7 +299,7 @@ public void testCloseRequestWhenConnectionIsClosed() { } @Test - public void testCancelRequestAfterTimeout() { + void testCancelRequestAfterTimeout() { when(executorService.schedule( any(Runnable.class), eq(WebSocketService.REQUEST_TIMEOUT), @@ -319,7 +319,7 @@ public void testCancelRequestAfterTimeout() { } @Test - public void testSyncRequest() throws Exception { + void testSyncRequest() throws Exception { CountDownLatch requestSent = new CountDownLatch(1); // Wait for a request to be sent @@ -348,7 +348,7 @@ public void testSyncRequest() throws Exception { } @Test - public void testCloseWebSocketOnClose() throws Exception { + void testCloseWebSocketOnClose() throws Exception { service.close(); verify(webSocketClient).close(); @@ -356,7 +356,7 @@ public void testCloseWebSocketOnClose() throws Exception { } @Test - public void testSendSubscriptionReply() throws Exception { + void testSendSubscriptionReply() throws Exception { runAsync(() -> subscribeToEvents()); sendSubscriptionConfirmation(); @@ -364,7 +364,7 @@ public void testSendSubscriptionReply() throws Exception { } @Test - public void testPropagateSubscriptionEvent() throws Exception { + void testPropagateSubscriptionEvent() throws Exception { CountDownLatch eventReceived = new CountDownLatch(1); CountDownLatch disposed = new CountDownLatch(1); AtomicReference actualNotificationRef = new AtomicReference<>(); @@ -400,7 +400,7 @@ public void testPropagateSubscriptionEvent() throws Exception { } @Test - public void testSendUnsubscribeRequest() throws Exception { + void testSendUnsubscribeRequest() throws Exception { CountDownLatch unsubscribed = new CountDownLatch(1); runAsync( @@ -417,7 +417,7 @@ public void testSendUnsubscribeRequest() throws Exception { } @Test - public void testStopWaitingForSubscriptionReplyAfterTimeout() throws Exception { + void testStopWaitingForSubscriptionReplyAfterTimeout() throws Exception { CountDownLatch errorReceived = new CountDownLatch(1); AtomicReference actualThrowable = new AtomicReference<>(); @@ -452,7 +452,7 @@ public void onNext( } @Test - public void testOnErrorCalledIfConnectionClosed() throws Exception { + void testOnErrorCalledIfConnectionClosed() throws Exception { CountDownLatch errorReceived = new CountDownLatch(1); AtomicReference actualThrowable = new AtomicReference<>(); @@ -488,7 +488,7 @@ public void onNext( } @Test - public void testIfCloseObserverIfSubscriptionRequestFailed() throws Exception { + void testIfCloseObserverIfSubscriptionRequestFailed() throws Exception { CountDownLatch errorReceived = new CountDownLatch(1); AtomicReference actualThrowable = new AtomicReference<>(); diff --git a/core/src/test/java/org/web3j/tx/ContractTest.java b/core/src/test/java/org/web3j/tx/ContractTest.java index e234927a8..d4618be3c 100644 --- a/core/src/test/java/org/web3j/tx/ContractTest.java +++ b/core/src/test/java/org/web3j/tx/ContractTest.java @@ -74,7 +74,7 @@ import static org.mockito.Mockito.when; @SuppressWarnings("deprecation") -public class ContractTest extends ManagedTransactionTester { +class ContractTest extends ManagedTransactionTester { private static final String TEST_CONTRACT_BINARY = "12345"; @@ -98,6 +98,7 @@ public class ContractTest extends ManagedTransactionTester { private TestContract contract; + @Override @BeforeEach public void setUp() throws Exception { super.setUp(); @@ -111,17 +112,17 @@ public void setUp() throws Exception { } @Test - public void testGetContractAddress() { + void testGetContractAddress() { assertEquals(ADDRESS, contract.getContractAddress()); } @Test - public void testGetContractTransactionReceipt() { + void testGetContractTransactionReceipt() { assertFalse(contract.getTransactionReceipt().isPresent()); } @Test - public void testDeploy() throws Exception { + void testDeploy() throws Exception { TransactionReceipt transactionReceipt = createTransactionReceipt(); Contract deployedContract = deployContract(transactionReceipt); @@ -131,14 +132,14 @@ public void testDeploy() throws Exception { } @Test - public void testContractDeployFails() throws IOException { + void testContractDeployFails() throws IOException { TransactionReceipt transactionReceipt = createFailedTransactionReceipt(); prepareCall(null); assertThrows(TransactionException.class, () -> deployContract(transactionReceipt)); } @Test - public void testContractDeployWithNullStatusSucceeds() throws Exception { + void testContractDeployWithNullStatusSucceeds() throws Exception { TransactionReceipt transactionReceipt = createTransactionReceiptWithStatus(null); Contract deployedContract = deployContract(transactionReceipt); @@ -148,7 +149,7 @@ public void testContractDeployWithNullStatusSucceeds() throws Exception { } @Test - public void testIsValid() throws Exception { + void testIsValid() throws Exception { prepareEthGetCode(TEST_CONTRACT_BINARY); Contract contract = deployContract(createTransactionReceipt()); @@ -156,7 +157,7 @@ public void testIsValid() throws Exception { } @Test - public void testIsValidSkipMetadataBzzr0() throws Exception { + void testIsValidSkipMetadataBzzr0() throws Exception { prepareEthGetCode( TEST_CONTRACT_BINARY + "a165627a7a72305820" @@ -167,7 +168,7 @@ public void testIsValidSkipMetadataBzzr0() throws Exception { } @Test - public void testIsValidSkipMetadataBzzr1() throws Exception { + void testIsValidSkipMetadataBzzr1() throws Exception { prepareEthGetCode( TEST_CONTRACT_BINARY + "a265627a7a72315820" @@ -178,7 +179,7 @@ public void testIsValidSkipMetadataBzzr1() throws Exception { } @Test - public void testIsValidSkipMetadataIpfs() throws Exception { + void testIsValidSkipMetadataIpfs() throws Exception { prepareEthGetCode( TEST_CONTRACT_BINARY + "a2646970667358221220" @@ -189,7 +190,7 @@ public void testIsValidSkipMetadataIpfs() throws Exception { } @Test - public void testIsValidSkipMetadataNone() throws Exception { + void testIsValidSkipMetadataNone() throws Exception { prepareEthGetCode( TEST_CONTRACT_BINARY + "a164736f6c634300080a000a" @@ -200,7 +201,7 @@ public void testIsValidSkipMetadataNone() throws Exception { } @Test - public void testIsValidDifferentCode() throws Exception { + void testIsValidDifferentCode() throws Exception { prepareEthGetCode(TEST_CONTRACT_BINARY + "0"); Contract contract = deployContract(createTransactionReceipt()); @@ -208,7 +209,7 @@ public void testIsValidDifferentCode() throws Exception { } @Test - public void testIsValidEmptyCode() throws Exception { + void testIsValidEmptyCode() throws Exception { prepareEthGetCode(""); Contract contract = deployContract(createTransactionReceipt()); @@ -216,7 +217,7 @@ public void testIsValidEmptyCode() throws Exception { } @Test - public void testIsValidNoBinThrows() { + void testIsValidNoBinThrows() { TransactionManager txManager = mock(TransactionManager.class); TestContract contract = new TestContract( @@ -229,7 +230,7 @@ public void testIsValidNoBinThrows() { } @Test - public void testDeployInvalidContractAddress() throws Throwable { + void testDeployInvalidContractAddress() throws Throwable { TransactionReceipt transactionReceipt = new TransactionReceipt(); transactionReceipt.setTransactionHash(TRANSACTION_HASH); @@ -253,7 +254,7 @@ public void testDeployInvalidContractAddress() throws Throwable { } @Test - public void testCallSingleValue() throws Exception { + void testCallSingleValue() throws Exception { // Example taken from FunctionReturnDecoderTest prepareCall( @@ -264,7 +265,7 @@ public void testCallSingleValue() throws Exception { } @Test - public void testCallSingleValueEmpty() throws Exception { + void testCallSingleValueEmpty() throws Exception { // Example taken from FunctionReturnDecoderTest prepareCall("0x"); @@ -273,7 +274,7 @@ public void testCallSingleValueEmpty() throws Exception { } @Test - public void testCallSingleValueReverted() throws Exception { + void testCallSingleValueReverted() throws Exception { prepareCall(OWNER_REVERT_MSG_HASH); ContractCallException thrown = assertThrows(ContractCallException.class, () -> contract.callSingleValue().send()); @@ -284,7 +285,7 @@ public void testCallSingleValueReverted() throws Exception { } @Test - public void testCallMultipleValue() throws Exception { + void testCallMultipleValue() throws Exception { prepareCall( "0x0000000000000000000000000000000000000000000000000000000000000037" + "0000000000000000000000000000000000000000000000000000000000000007"); @@ -296,7 +297,7 @@ public void testCallMultipleValue() throws Exception { } @Test - public void testCallMultipleValueEmpty() throws Exception { + void testCallMultipleValueEmpty() throws Exception { prepareCall("0x"); assertEquals(emptyList(), contract.callMultipleValue().send()); @@ -315,7 +316,7 @@ private void prepareCall(String result) throws IOException { } @Test - public void testTransaction() throws Exception { + void testTransaction() throws Exception { TransactionReceipt transactionReceipt = new TransactionReceipt(); transactionReceipt.setTransactionHash(TRANSACTION_HASH); transactionReceipt.setStatus(TXN_SUCCESS_STATUS); @@ -330,7 +331,7 @@ public void testTransaction() throws Exception { } @Test - public void testTransactionFailed() throws IOException { + void testTransactionFailed() throws IOException { TransactionReceipt transactionReceipt = createFailedTransactionReceipt(); prepareCall(null); @@ -346,7 +347,7 @@ public void testTransactionFailed() throws IOException { } @Test - public void testTransactionFailedWithRevertReason() throws Exception { + void testTransactionFailedWithRevertReason() throws Exception { TransactionReceipt transactionReceipt = createFailedTransactionReceipt(); prepareCall(OWNER_REVERT_MSG_HASH); @@ -371,7 +372,7 @@ public void testTransactionFailedWithRevertReason() throws Exception { } @Test - public void testProcessEvent() { + void testProcessEvent() { TransactionReceipt transactionReceipt = new TransactionReceipt(); Log log = new Log(); log.setTopics( @@ -394,7 +395,7 @@ public void testProcessEvent() { } @Test - public void testProcessEventForLogWithoutTopics() { + void testProcessEventForLogWithoutTopics() { TransactionReceipt transactionReceipt = new TransactionReceipt(); final Log log = new Log(); log.setTopics(Collections.emptyList()); @@ -407,7 +408,7 @@ public void testProcessEventForLogWithoutTopics() { } @Test - public void testTimeout() throws IOException { + void testTimeout() throws IOException { prepareTransaction(null); TransactionManager transactionManager = @@ -419,7 +420,7 @@ public void testTimeout() throws IOException { @Test @SuppressWarnings("unchecked") - public void testInvalidTransactionResponse() throws IOException { + void testInvalidTransactionResponse() throws IOException { prepareNonceRequest(); EthSendTransaction ethSendTransaction = new EthSendTransaction(); @@ -433,7 +434,7 @@ public void testInvalidTransactionResponse() throws IOException { } @Test - public void testJsonRpcError() throws IOException { + void testJsonRpcError() throws IOException { EthSendTransaction ethSendTransaction = new EthSendTransaction(); Response.Error error = new Response.Error(1, "Invalid Transaction"); error.setData("Additional data"); @@ -469,7 +470,7 @@ public void testJsonRpcError() throws IOException { } @Test - public void testSetGetAddresses() { + void testSetGetAddresses() { assertNull(contract.getDeployedAddress("1")); contract.setDeployedAddress("1", "0x000000000000add0e00000000000"); assertNotNull(contract.getDeployedAddress("1")); @@ -478,7 +479,7 @@ public void testSetGetAddresses() { } @Test - public void testSetGetGasPrice() { + void testSetGetGasPrice() { assertEquals(DefaultGasProvider.GAS_PRICE, contract.getGasPrice()); BigInteger newPrice = ManagedTransaction.GAS_PRICE.multiply(BigInteger.valueOf(2)); contract.setGasPrice(newPrice); @@ -486,7 +487,7 @@ public void testSetGetGasPrice() { } @Test - public void testStaticGasProvider() throws IOException, TransactionException { + void testStaticGasProvider() throws IOException, TransactionException { StaticGasProvider gasProvider = new StaticGasProvider(BigInteger.TEN, BigInteger.ONE); TransactionManager txManager = mock(TransactionManager.class); @@ -519,7 +520,7 @@ public void testStaticGasProvider() throws IOException, TransactionException { } @Test - public void testStaticEIP1559GasProvider() throws IOException, TransactionException { + void testStaticEIP1559GasProvider() throws IOException, TransactionException { StaticEIP1559GasProvider gasProvider = new StaticEIP1559GasProvider(1L, BigInteger.TEN, BigInteger.ZERO, BigInteger.ONE); TransactionManager txManager = mock(TransactionManager.class); @@ -556,7 +557,7 @@ public void testStaticEIP1559GasProvider() throws IOException, TransactionExcept @Test @SuppressWarnings("unchecked") - public void testInvalidTransactionReceipt() throws Throwable { + void testInvalidTransactionReceipt() throws Throwable { prepareNonceRequest(); prepareTransactionRequest(); @@ -572,7 +573,7 @@ public void testInvalidTransactionReceipt() throws Throwable { } @Test - public void testExtractEventParametersWithLogGivenATransactionReceipt() { + void testExtractEventParametersWithLogGivenATransactionReceipt() { final java.util.function.Function eventFactory = name -> new Event(name, emptyList()); @@ -614,7 +615,7 @@ public void testExtractEventParametersWithLogGivenATransactionReceipt() { } @Test - public void testEmptyTransactionReceipt() throws Exception { + void testEmptyTransactionReceipt() throws Exception { TransactionReceipt transactionReceipt = new EmptyTransactionReceipt(TRANSACTION_HASH); prepareTransaction(transactionReceipt); diff --git a/core/src/test/java/org/web3j/tx/FastRawTransactionManagerTest.java b/core/src/test/java/org/web3j/tx/FastRawTransactionManagerTest.java index 37f30a1f3..210e79d1a 100644 --- a/core/src/test/java/org/web3j/tx/FastRawTransactionManagerTest.java +++ b/core/src/test/java/org/web3j/tx/FastRawTransactionManagerTest.java @@ -24,7 +24,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.Mockito.mock; -public class FastRawTransactionManagerTest { +class FastRawTransactionManagerTest { private Web3j web3j; private FastRawTransactionManager fastRawTransactionManager; @@ -35,7 +35,7 @@ public void setUp() throws Exception { } @Test - void clearNonce() throws IOException { + void clearNonce() { fastRawTransactionManager.setNonce(BigInteger.valueOf(42)); fastRawTransactionManager.clearNonce(); diff --git a/core/src/test/java/org/web3j/tx/ManagedTransactionTester.java b/core/src/test/java/org/web3j/tx/ManagedTransactionTester.java index 13ececc76..19eafba0d 100644 --- a/core/src/test/java/org/web3j/tx/ManagedTransactionTester.java +++ b/core/src/test/java/org/web3j/tx/ManagedTransactionTester.java @@ -74,10 +74,7 @@ public RawTransaction createRawTx() { BigInteger gasLimit = BigInteger.TEN; String to = "0x0add5355"; BigInteger value = BigInteger.valueOf(Long.MAX_VALUE); - RawTransaction rawTransaction = - RawTransaction.createEtherTransaction(nonce, gasPrice, gasLimit, to, value); - - return rawTransaction; + return RawTransaction.createEtherTransaction(nonce, gasPrice, gasLimit, to, value); } @SuppressWarnings("unchecked") diff --git a/core/src/test/java/org/web3j/tx/RawTransactionManagerTest.java b/core/src/test/java/org/web3j/tx/RawTransactionManagerTest.java index a1fe89f9a..7465b0471 100644 --- a/core/src/test/java/org/web3j/tx/RawTransactionManagerTest.java +++ b/core/src/test/java/org/web3j/tx/RawTransactionManagerTest.java @@ -39,7 +39,7 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -public class RawTransactionManagerTest extends ManagedTransactionTester { +class RawTransactionManagerTest extends ManagedTransactionTester { // Get From org.web3j.crypto.TransactionDecoderTest.testDecodingSigned private static final String TX_SIGN_FORMAT_DER_HEX = @@ -48,7 +48,7 @@ public class RawTransactionManagerTest extends ManagedTransactionTester { "0xf85580010a840add5355887fffffffffffffff801ca046360b50498ddf5566551ce1ce69c46c565f1f478bb0ee680caf31fbc08ab727a01b2f1432de16d110407d544f519fc91b84c8e16d3b6ec899592d486a94974cd0"; @Test - public void testTxHashMismatch() throws IOException { + void testTxHashMismatch() throws IOException { TransactionReceipt transactionReceipt = prepareTransfer(); prepareTransaction(transactionReceipt); @@ -61,7 +61,7 @@ public void testTxHashMismatch() throws IOException { } @Test - public void testSignRawTxWithHSM() throws IOException { + void testSignRawTxWithHSM() throws IOException { TransactionReceipt transactionReceipt = prepareTransfer(); prepareTransaction(transactionReceipt); diff --git a/core/src/test/java/org/web3j/tx/ReadonlyTransactionManagerTest.java b/core/src/test/java/org/web3j/tx/ReadonlyTransactionManagerTest.java index 2a70b4d42..5a64d9580 100644 --- a/core/src/test/java/org/web3j/tx/ReadonlyTransactionManagerTest.java +++ b/core/src/test/java/org/web3j/tx/ReadonlyTransactionManagerTest.java @@ -30,7 +30,7 @@ import static org.mockito.Mockito.when; import static org.web3j.tx.TransactionManager.REVERT_ERR_STR; -public class ReadonlyTransactionManagerTest { +class ReadonlyTransactionManagerTest { private static final String OWNER_REVERT_MSG_STR = "Only the contract owner can perform this action"; @@ -41,7 +41,7 @@ public class ReadonlyTransactionManagerTest { EthCall response = mock(EthCall.class); @Test - public void sendCallTest() throws IOException { + void sendCallTest() throws IOException { when(response.getValue()).thenReturn("test"); when(service.send(any(), any())).thenReturn(response); ReadonlyTransactionManager readonlyTransactionManager = @@ -51,7 +51,7 @@ public void sendCallTest() throws IOException { } @Test - public void sendCallRevertedTest() throws IOException { + void sendCallRevertedTest() throws IOException { when(response.isReverted()).thenReturn(true); when(response.getRevertReason()).thenReturn(OWNER_REVERT_MSG_STR); when(service.send(any(), any())).thenReturn(response); @@ -68,7 +68,7 @@ public void sendCallRevertedTest() throws IOException { } @Test - public void testSendTransaction() { + void testSendTransaction() { ReadonlyTransactionManager readonlyTransactionManager = new ReadonlyTransactionManager(web3j, ""); assertThrows( diff --git a/core/src/test/java/org/web3j/tx/TransferTest.java b/core/src/test/java/org/web3j/tx/TransferTest.java index 622919a62..33446ad98 100644 --- a/core/src/test/java/org/web3j/tx/TransferTest.java +++ b/core/src/test/java/org/web3j/tx/TransferTest.java @@ -25,7 +25,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; -public class TransferTest extends ManagedTransactionTester { +class TransferTest extends ManagedTransactionTester { protected TransactionReceipt transactionReceipt; @@ -37,14 +37,14 @@ public void setUp() throws Exception { } @Test - public void testSendFunds() throws Exception { + void testSendFunds() throws Exception { assertEquals( sendFunds(SampleKeys.CREDENTIALS, ADDRESS, BigDecimal.TEN, Convert.Unit.ETHER), (transactionReceipt)); } @Test - public void testTransferInvalidValue() { + void testTransferInvalidValue() { assertThrows( UnsupportedOperationException.class, diff --git a/core/src/test/java/org/web3j/tx/response/PollingTransactionReceiptProcessorTest.java b/core/src/test/java/org/web3j/tx/response/PollingTransactionReceiptProcessorTest.java index 44154528a..e70c2efb6 100644 --- a/core/src/test/java/org/web3j/tx/response/PollingTransactionReceiptProcessorTest.java +++ b/core/src/test/java/org/web3j/tx/response/PollingTransactionReceiptProcessorTest.java @@ -31,7 +31,7 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -public class PollingTransactionReceiptProcessorTest { +class PollingTransactionReceiptProcessorTest { private static final String TRANSACTION_HASH = "0x00"; private Web3j web3j; private long sleepDuration; @@ -47,7 +47,7 @@ public void setUp() { } @Test - public void returnsTransactionReceiptWhenItIsAvailableInstantly() throws Exception { + void returnsTransactionReceiptWhenItIsAvailableInstantly() throws Exception { TransactionReceipt transactionReceipt = new TransactionReceipt(); doReturn(requestReturning(response(transactionReceipt))) .when(web3j) @@ -59,7 +59,7 @@ public void returnsTransactionReceiptWhenItIsAvailableInstantly() throws Excepti } @Test - public void throwsTransactionExceptionWhenReceiptIsNotAvailableInTime() throws Exception { + void throwsTransactionExceptionWhenReceiptIsNotAvailableInTime() throws Exception { doReturn(requestReturning(response(null))) .when(web3j) .ethGetTransactionReceipt(TRANSACTION_HASH); diff --git a/core/src/test/java/org/web3j/utils/AsyncTest.java b/core/src/test/java/org/web3j/utils/AsyncTest.java index 1d9ab88da..149634f96 100644 --- a/core/src/test/java/org/web3j/utils/AsyncTest.java +++ b/core/src/test/java/org/web3j/utils/AsyncTest.java @@ -19,15 +19,15 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; -public class AsyncTest { +class AsyncTest { @Test - public void testRun() throws Exception { + void testRun() throws Exception { assertEquals("", Async.run(() -> "").get()); } @Test - public void testRunException() { + void testRunException() { assertThrows( ExecutionException.class, diff --git a/core/src/test/java/org/web3j/utils/CollectionTest.java b/core/src/test/java/org/web3j/utils/CollectionTest.java index e25d21474..b2f199c90 100644 --- a/core/src/test/java/org/web3j/utils/CollectionTest.java +++ b/core/src/test/java/org/web3j/utils/CollectionTest.java @@ -24,24 +24,24 @@ import static org.web3j.utils.Collection.join; import static org.web3j.utils.Collection.tail; -public class CollectionTest { +class CollectionTest { @Test - public void testTail() { + void testTail() { assertArrayEquals(tail(EMPTY_STRING_ARRAY), (EMPTY_STRING_ARRAY)); assertArrayEquals(tail(create("a", "b", "c")), (create("b", "c"))); assertArrayEquals(tail(create("a")), (EMPTY_STRING_ARRAY)); } @Test - public void testCreate() { + void testCreate() { assertArrayEquals(create("a"), (new String[] {"a"})); assertArrayEquals(create(""), (new String[] {""})); assertArrayEquals(create("a", "b"), (new String[] {"a", "b"})); } @Test - public void testJoinWithFunction() { + void testJoinWithFunction() { final List specs1 = Arrays.asList(new FakeSpec("a"), new FakeSpec("b"), new FakeSpec("c")); assertEquals(join(specs1, ",", FakeSpec::getName), ("a,b,c")); diff --git a/core/src/test/java/org/web3j/utils/FlowablesTests.java b/core/src/test/java/org/web3j/utils/FlowablesTests.java index 300cfb883..cfa68ab89 100644 --- a/core/src/test/java/org/web3j/utils/FlowablesTests.java +++ b/core/src/test/java/org/web3j/utils/FlowablesTests.java @@ -27,10 +27,10 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.fail; -public class FlowablesTests { +class FlowablesTests { @Test - public void testRangeFlowable() throws InterruptedException { + void testRangeFlowable() throws InterruptedException { int count = 10; Flowable flowable = @@ -45,7 +45,7 @@ public void testRangeFlowable() throws InterruptedException { } @Test - public void testRangeDescendingFlowable() throws InterruptedException { + void testRangeDescendingFlowable() throws InterruptedException { int count = 10; Flowable flowable = @@ -86,7 +86,7 @@ private void runRangeTest(Flowable flowable, List expect } @Test - public void testRangeFlowableIllegalLowerBound() { + void testRangeFlowableIllegalLowerBound() { assertThrows( IllegalArgumentException.class, @@ -94,7 +94,7 @@ public void testRangeFlowableIllegalLowerBound() { } @Test - public void testRangeFlowableIllegalBounds() { + void testRangeFlowableIllegalBounds() { assertThrows( IllegalArgumentException.class, diff --git a/core/src/test/java/org/web3j/utils/VersionTest.java b/core/src/test/java/org/web3j/utils/VersionTest.java index c74fcb105..968abd1a6 100644 --- a/core/src/test/java/org/web3j/utils/VersionTest.java +++ b/core/src/test/java/org/web3j/utils/VersionTest.java @@ -21,15 +21,15 @@ import static org.web3j.utils.Version.getTimestamp; import static org.web3j.utils.Version.getVersion; -public class VersionTest { +class VersionTest { @Test - public void testGetVersion() throws IOException { + void testGetVersion() throws IOException { assertEquals(getVersion(), (DEFAULT)); } @Test - public void testGetTimestamp() throws IOException { + void testGetTimestamp() throws IOException { assertEquals(getTimestamp(), ("2017-01-31 01:21:09.843 UTC")); } }