mirror of
https://github.com/vacp2p/linea-besu.git
synced 2026-01-09 21:17:54 -05:00
Update errorprone (#401)
* Upgrade errorprone * Upgrade errorprone from 2.3.1 to 2.3.2 * Upgrade Jenkinsfile so that CI will use Java 11 * Suppress these new rules: * EqualsGetClass * ImmutableEnumChecker * UnnecessaryParentheses * Change code to conform to these new rules: * BadImport * BadInstanceof * InconsistentHashCode * LockNotBeforeTry * MathAbsoluteRandom * ModifiedButNotUsed * UndefinedEquals Signed-off-by: Adrian Sutton <adrian.sutton@consensys.net>
This commit is contained in:
4
Jenkinsfile
vendored
4
Jenkinsfile
vendored
@@ -24,7 +24,7 @@ try {
|
||||
node {
|
||||
checkout scm
|
||||
docker.image('docker:18.06.0-ce-dind').withRun('--privileged') { d ->
|
||||
docker.image('pegasyseng/pantheon-build:0.0.1').inside("--link ${d.id}:docker") {
|
||||
docker.image('pegasyseng/pantheon-build:0.0.3').inside("--link ${d.id}:docker") {
|
||||
try {
|
||||
stage('Compile') {
|
||||
sh './gradlew --no-daemon --parallel clean compileJava'
|
||||
@@ -71,7 +71,7 @@ try {
|
||||
node {
|
||||
checkout scm
|
||||
docker.image('docker:18.06.0-ce-dind').withRun('--privileged') { d ->
|
||||
docker.image('pegasyseng/pantheon-build:0.0.1').inside("--link ${d.id}:docker") {
|
||||
docker.image('pegasyseng/pantheon-build:0.0.3').inside("--link ${d.id}:docker") {
|
||||
try {
|
||||
stage('Docker quickstart Tests') {
|
||||
sh 'DOCKER_HOST=tcp://docker:2375 ./gradlew --no-daemon --parallel clean dockerQuickstartTest'
|
||||
|
||||
11
build.gradle
11
build.gradle
@@ -154,9 +154,18 @@ allprojects {
|
||||
|
||||
options.errorprone {
|
||||
excludedPaths '.*/(generated/*.*|.*ReferenceTest_.*)'
|
||||
|
||||
// Our equals need to be symmetric, this checker doesn't respect that.
|
||||
check('EqualsGetClass', CheckSeverity.OFF)
|
||||
// We like to use futures with no return values.
|
||||
check('FutureReturnValueIgnored', CheckSeverity.OFF)
|
||||
check('InsecureCryptoUsage', CheckSeverity.WARN)
|
||||
// We use the JSR-305 annotations instead of the Google annotations.
|
||||
check('ImmutableEnumChecker', CheckSeverity.OFF)
|
||||
// This is a style check instead of an error-prone pattern.
|
||||
check('UnnecessaryParentheses', CheckSeverity.OFF)
|
||||
|
||||
check('FieldCanBeFinal', CheckSeverity.WARN)
|
||||
check('InsecureCryptoUsage', CheckSeverity.WARN)
|
||||
check('WildcardImport', CheckSeverity.WARN)
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ package tech.pegasys.pantheon.consensus.ibft.ibftmessagedata;
|
||||
import tech.pegasys.pantheon.ethereum.rlp.RLPInput;
|
||||
import tech.pegasys.pantheon.ethereum.rlp.RLPOutput;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Objects;
|
||||
import java.util.StringJoiner;
|
||||
@@ -67,7 +68,7 @@ public class PreparedCertificate {
|
||||
}
|
||||
final PreparedCertificate that = (PreparedCertificate) o;
|
||||
return Objects.equals(proposalPayload, that.proposalPayload)
|
||||
&& Objects.equals(preparePayloads, that.preparePayloads);
|
||||
&& Objects.equals(new ArrayList<>(preparePayloads), new ArrayList<>(that.preparePayloads));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -15,6 +15,7 @@ package tech.pegasys.pantheon.consensus.ibft.ibftmessagedata;
|
||||
import tech.pegasys.pantheon.ethereum.rlp.RLPInput;
|
||||
import tech.pegasys.pantheon.ethereum.rlp.RLPOutput;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
@@ -73,7 +74,8 @@ public class RoundChangeCertificate {
|
||||
return false;
|
||||
}
|
||||
final RoundChangeCertificate that = (RoundChangeCertificate) o;
|
||||
return Objects.equals(roundChangePayloads, that.roundChangePayloads);
|
||||
return Objects.equals(
|
||||
new ArrayList<>(roundChangePayloads), new ArrayList<>(that.roundChangePayloads));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -23,7 +23,6 @@ import tech.pegasys.pantheon.consensus.ibft.TestHelpers;
|
||||
import tech.pegasys.pantheon.consensus.ibft.blockcreation.ProposerSelector;
|
||||
import tech.pegasys.pantheon.consensus.ibft.ibftmessagedata.MessageFactory;
|
||||
import tech.pegasys.pantheon.consensus.ibft.ibftmessagedata.NewRoundPayload;
|
||||
import tech.pegasys.pantheon.consensus.ibft.ibftmessagedata.NewRoundPayload.Builder;
|
||||
import tech.pegasys.pantheon.consensus.ibft.ibftmessagedata.PreparedCertificate;
|
||||
import tech.pegasys.pantheon.consensus.ibft.ibftmessagedata.ProposalPayload;
|
||||
import tech.pegasys.pantheon.consensus.ibft.ibftmessagedata.RoundChangeCertificate;
|
||||
@@ -65,7 +64,8 @@ public class NewRoundMessageValidatorTest {
|
||||
|
||||
private final SignedData<NewRoundPayload> validMsg =
|
||||
createValidNewRoundMessageSignedBy(proposerKey);
|
||||
private final NewRoundPayload.Builder msgBuilder = Builder.fromExisting(validMsg.getPayload());
|
||||
private final NewRoundPayload.Builder msgBuilder =
|
||||
NewRoundPayload.Builder.fromExisting(validMsg.getPayload());
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
|
||||
@@ -258,7 +258,9 @@ public abstract class AbstractFqp<T extends AbstractFqp> implements FieldElement
|
||||
return false;
|
||||
}
|
||||
|
||||
final AbstractFqp other = (AbstractFqp) obj;
|
||||
final AbstractFqp<?> other = (AbstractFqp<?>) obj;
|
||||
if (degree != other.degree) return false;
|
||||
if (!Arrays.equals(modulusCoefficients, other.modulusCoefficients)) return false;
|
||||
return Arrays.equals(coefficients, other.coefficients);
|
||||
}
|
||||
|
||||
|
||||
@@ -43,13 +43,11 @@ dependencies {
|
||||
}
|
||||
|
||||
test {
|
||||
if (!JavaVersion.current().isJava8()) {
|
||||
if (JavaVersion.current().isJava8()) {
|
||||
enabled = false
|
||||
logger.info("Disabling {} because errorprone tests always fail in Java {}",
|
||||
project.name, JavaVersion.current().majorVersion)
|
||||
}
|
||||
|
||||
jvmArgs "-Xbootclasspath/p:${configurations.epJavac.asPath}"
|
||||
|
||||
testLogging { showStandardStreams = true }
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ import org.junit.Test;
|
||||
public class EntriesFromIntegrationTest {
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("MathAbsoluteRandom")
|
||||
public void shouldCollectStateEntries() {
|
||||
final MutableWorldState worldState = createInMemoryWorldStateArchive().getMutable();
|
||||
final WorldUpdater updater = worldState.updater();
|
||||
|
||||
@@ -26,7 +26,6 @@ import tech.pegasys.pantheon.ethereum.ProtocolContext;
|
||||
import tech.pegasys.pantheon.ethereum.chain.MutableBlockchain;
|
||||
import tech.pegasys.pantheon.ethereum.core.BlockDataGenerator;
|
||||
import tech.pegasys.pantheon.ethereum.core.BlockHeader;
|
||||
import tech.pegasys.pantheon.ethereum.mainnet.BlockHeaderValidator.Builder;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@@ -235,7 +234,12 @@ public class BlockHeaderValidatorTest {
|
||||
final AttachedBlockHeaderValidationRule<Void> rule4 = createPassingAttachedRule();
|
||||
|
||||
final BlockHeaderValidator<Void> validator =
|
||||
new Builder<Void>().addRule(rule1).addRule(rule2).addRule(rule3).addRule(rule4).build();
|
||||
new BlockHeaderValidator.Builder<Void>()
|
||||
.addRule(rule1)
|
||||
.addRule(rule2)
|
||||
.addRule(rule3)
|
||||
.addRule(rule4)
|
||||
.build();
|
||||
|
||||
final BlockHeader header = generator.header();
|
||||
final BlockHeader parent = generator.header();
|
||||
|
||||
@@ -18,6 +18,7 @@ import java.util.Collections;
|
||||
|
||||
import com.google.common.base.MoreObjects;
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
public class JsonRpcConfiguration {
|
||||
private static final String DEFAULT_JSON_RPC_HOST = "127.0.0.1";
|
||||
@@ -120,9 +121,11 @@ public class JsonRpcConfiguration {
|
||||
return enabled == that.enabled
|
||||
&& port == that.port
|
||||
&& Objects.equal(host, that.host)
|
||||
&& Objects.equal(corsAllowedDomains, that.corsAllowedDomains)
|
||||
&& Objects.equal(hostsWhitelist, that.hostsWhitelist)
|
||||
&& Objects.equal(rpcApis, that.rpcApis);
|
||||
&& Objects.equal(
|
||||
Lists.newArrayList(corsAllowedDomains), Lists.newArrayList(that.corsAllowedDomains))
|
||||
&& Objects.equal(
|
||||
Lists.newArrayList(hostsWhitelist), Lists.newArrayList(that.hostsWhitelist))
|
||||
&& Objects.equal(Lists.newArrayList(rpcApis), Lists.newArrayList(that.rpcApis));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.util.Collection;
|
||||
|
||||
import com.google.common.base.MoreObjects;
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
public class WebSocketConfiguration {
|
||||
public static final String DEFAULT_WEBSOCKET_HOST = "127.0.0.1";
|
||||
@@ -106,7 +107,7 @@ public class WebSocketConfiguration {
|
||||
return enabled == that.enabled
|
||||
&& port == that.port
|
||||
&& Objects.equal(host, that.host)
|
||||
&& Objects.equal(rpcApis, that.rpcApis);
|
||||
&& Objects.equal(Lists.newArrayList(rpcApis), Lists.newArrayList(that.rpcApis));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -22,7 +22,6 @@ import com.google.common.collect.Lists;
|
||||
import io.vertx.core.Vertx;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Request.Builder;
|
||||
import okhttp3.Response;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
@@ -53,7 +52,10 @@ public class JsonRpcHttpServiceCorsTest {
|
||||
jsonRpcHttpService = createJsonRpcHttpServiceWithAllowedDomains("http://foo.io");
|
||||
|
||||
final Request request =
|
||||
new Builder().url(jsonRpcHttpService.url()).header("Origin", "http://bar.me").build();
|
||||
new Request.Builder()
|
||||
.url(jsonRpcHttpService.url())
|
||||
.header("Origin", "http://bar.me")
|
||||
.build();
|
||||
|
||||
try (final Response response = client.newCall(request).execute()) {
|
||||
assertThat(response.isSuccessful()).isFalse();
|
||||
@@ -65,7 +67,10 @@ public class JsonRpcHttpServiceCorsTest {
|
||||
jsonRpcHttpService = createJsonRpcHttpServiceWithAllowedDomains("http://foo.io");
|
||||
|
||||
final Request request =
|
||||
new Builder().url(jsonRpcHttpService.url()).header("Origin", "http://foo.io").build();
|
||||
new Request.Builder()
|
||||
.url(jsonRpcHttpService.url())
|
||||
.header("Origin", "http://foo.io")
|
||||
.build();
|
||||
|
||||
try (final Response response = client.newCall(request).execute()) {
|
||||
assertThat(response.isSuccessful()).isTrue();
|
||||
@@ -78,7 +83,10 @@ public class JsonRpcHttpServiceCorsTest {
|
||||
createJsonRpcHttpServiceWithAllowedDomains("http://foo.io", "http://bar.me");
|
||||
|
||||
final Request request =
|
||||
new Builder().url(jsonRpcHttpService.url()).header("Origin", "http://bar.me").build();
|
||||
new Request.Builder()
|
||||
.url(jsonRpcHttpService.url())
|
||||
.header("Origin", "http://bar.me")
|
||||
.build();
|
||||
|
||||
try (final Response response = client.newCall(request).execute()) {
|
||||
assertThat(response.isSuccessful()).isTrue();
|
||||
@@ -91,7 +99,10 @@ public class JsonRpcHttpServiceCorsTest {
|
||||
createJsonRpcHttpServiceWithAllowedDomains("http://foo.io", "http://bar.me");
|
||||
|
||||
final Request request =
|
||||
new Builder().url(jsonRpcHttpService.url()).header("Origin", "http://hel.lo").build();
|
||||
new Request.Builder()
|
||||
.url(jsonRpcHttpService.url())
|
||||
.header("Origin", "http://hel.lo")
|
||||
.build();
|
||||
|
||||
try (final Response response = client.newCall(request).execute()) {
|
||||
assertThat(response.isSuccessful()).isFalse();
|
||||
@@ -102,7 +113,7 @@ public class JsonRpcHttpServiceCorsTest {
|
||||
public void requestWithNoOriginShouldSucceedWhenNoCorsConfigSet() throws Exception {
|
||||
jsonRpcHttpService = createJsonRpcHttpServiceWithAllowedDomains();
|
||||
|
||||
final Request request = new Builder().url(jsonRpcHttpService.url()).build();
|
||||
final Request request = new Request.Builder().url(jsonRpcHttpService.url()).build();
|
||||
|
||||
try (final Response response = client.newCall(request).execute()) {
|
||||
assertThat(response.isSuccessful()).isTrue();
|
||||
@@ -113,7 +124,7 @@ public class JsonRpcHttpServiceCorsTest {
|
||||
public void requestWithNoOriginShouldSucceedWhenCorsIsSet() throws Exception {
|
||||
jsonRpcHttpService = createJsonRpcHttpServiceWithAllowedDomains("http://foo.io");
|
||||
|
||||
final Request request = new Builder().url(jsonRpcHttpService.url()).build();
|
||||
final Request request = new Request.Builder().url(jsonRpcHttpService.url()).build();
|
||||
|
||||
try (final Response response = client.newCall(request).execute()) {
|
||||
assertThat(response.isSuccessful()).isTrue();
|
||||
@@ -125,7 +136,10 @@ public class JsonRpcHttpServiceCorsTest {
|
||||
jsonRpcHttpService = createJsonRpcHttpServiceWithAllowedDomains("");
|
||||
|
||||
final Request request =
|
||||
new Builder().url(jsonRpcHttpService.url()).header("Origin", "http://bar.me").build();
|
||||
new Request.Builder()
|
||||
.url(jsonRpcHttpService.url())
|
||||
.header("Origin", "http://bar.me")
|
||||
.build();
|
||||
|
||||
try (final Response response = client.newCall(request).execute()) {
|
||||
assertThat(response.isSuccessful()).isFalse();
|
||||
@@ -137,7 +151,10 @@ public class JsonRpcHttpServiceCorsTest {
|
||||
jsonRpcHttpService = createJsonRpcHttpServiceWithAllowedDomains("*");
|
||||
|
||||
final Request request =
|
||||
new Builder().url(jsonRpcHttpService.url()).header("Origin", "http://bar.me").build();
|
||||
new Request.Builder()
|
||||
.url(jsonRpcHttpService.url())
|
||||
.header("Origin", "http://bar.me")
|
||||
.build();
|
||||
|
||||
try (final Response response = client.newCall(request).execute()) {
|
||||
assertThat(response.isSuccessful()).isTrue();
|
||||
@@ -149,7 +166,7 @@ public class JsonRpcHttpServiceCorsTest {
|
||||
jsonRpcHttpService = createJsonRpcHttpServiceWithAllowedDomains("http://foo.io");
|
||||
|
||||
final Request request =
|
||||
new Builder()
|
||||
new Request.Builder()
|
||||
.url(jsonRpcHttpService.url())
|
||||
.method("OPTIONS", null)
|
||||
.header("Access-Control-Request-Method", "OPTIONS")
|
||||
|
||||
@@ -33,7 +33,7 @@ import tech.pegasys.pantheon.ethereum.core.TransactionReceipt;
|
||||
import tech.pegasys.pantheon.ethereum.core.Wei;
|
||||
import tech.pegasys.pantheon.ethereum.core.WorldState;
|
||||
import tech.pegasys.pantheon.ethereum.db.WorldStateArchive;
|
||||
import tech.pegasys.pantheon.ethereum.jsonrpc.internal.filter.LogsQuery.Builder;
|
||||
import tech.pegasys.pantheon.ethereum.jsonrpc.internal.filter.LogsQuery;
|
||||
import tech.pegasys.pantheon.util.uint.UInt256;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -303,14 +303,10 @@ public class BlockchainQueriesTest {
|
||||
// create initial blockchain
|
||||
final BlockchainWithData data = setupBlockchain(3);
|
||||
final Block targetBlock = data.blockData.get(data.blockData.size() - 1).block;
|
||||
final List<Block> blocks =
|
||||
data.blockData.stream().map(b -> b.block).collect(Collectors.toList());
|
||||
final List<List<TransactionReceipt>> blockReceipts =
|
||||
blocks.stream().map(gen::receipts).collect(Collectors.toList());
|
||||
|
||||
// check that logs have removed = false
|
||||
List<LogWithMetadata> logs =
|
||||
data.blockchainQueries.matchingLogs(targetBlock.getHash(), new Builder().build());
|
||||
data.blockchainQueries.matchingLogs(targetBlock.getHash(), new LogsQuery.Builder().build());
|
||||
assertThat(logs).isNotEmpty();
|
||||
assertThat(logs).allMatch(l -> !l.isRemoved());
|
||||
|
||||
@@ -326,17 +322,12 @@ public class BlockchainQueriesTest {
|
||||
final Block fork = gen.block(options);
|
||||
final List<TransactionReceipt> forkReceipts = gen.receipts(fork);
|
||||
|
||||
final List<Block> reorgedChain = new ArrayList<>(blocks.subList(0, forkBlock));
|
||||
reorgedChain.add(fork);
|
||||
final List<List<TransactionReceipt>> reorgedReceipts =
|
||||
new ArrayList<>(blockReceipts.subList(0, forkBlock));
|
||||
reorgedReceipts.add(forkReceipts);
|
||||
|
||||
// Add fork
|
||||
data.blockchain.appendBlock(fork, forkReceipts);
|
||||
|
||||
// check that logs have removed = true
|
||||
logs = data.blockchainQueries.matchingLogs(targetBlock.getHash(), new Builder().build());
|
||||
logs =
|
||||
data.blockchainQueries.matchingLogs(targetBlock.getHash(), new LogsQuery.Builder().build());
|
||||
assertThat(logs).isNotEmpty();
|
||||
assertThat(logs).allMatch(LogWithMetadata::isRemoved);
|
||||
}
|
||||
@@ -542,10 +533,7 @@ public class BlockchainQueriesTest {
|
||||
final MutableBlockchain blockchain = createInMemoryBlockchain(blocks.get(0));
|
||||
blockData
|
||||
.subList(1, blockData.size())
|
||||
.forEach(
|
||||
b -> {
|
||||
blockchain.appendBlock(b.block, b.receipts);
|
||||
});
|
||||
.forEach(b -> blockchain.appendBlock(b.block, b.receipts));
|
||||
|
||||
return new BlockchainWithData(blockchain, blockData, worldStateArchive);
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@ package tech.pegasys.pantheon.ethereum.p2p.discovery.internal;
|
||||
|
||||
import static java.lang.System.arraycopy;
|
||||
import static java.util.Arrays.asList;
|
||||
import static java.util.Arrays.copyOf;
|
||||
import static java.util.Collections.unmodifiableList;
|
||||
|
||||
import tech.pegasys.pantheon.ethereum.p2p.discovery.DiscoveryPeer;
|
||||
@@ -135,7 +134,7 @@ public class Bucket {
|
||||
* @return immutable view of the peer array
|
||||
*/
|
||||
synchronized List<DiscoveryPeer> peers() {
|
||||
return unmodifiableList(asList(copyOf(kBucket, tailIndex + 1)));
|
||||
return unmodifiableList(asList(Arrays.copyOf(kBucket, tailIndex + 1)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -30,7 +30,6 @@ import java.util.Set;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableRangeMap;
|
||||
import com.google.common.collect.ImmutableRangeMap.Builder;
|
||||
import com.google.common.collect.Range;
|
||||
|
||||
public class CapabilityMultiplexer {
|
||||
@@ -120,7 +119,7 @@ public class CapabilityMultiplexer {
|
||||
caps.sort(CAPABILITY_COMPARATOR);
|
||||
caps.retainAll(b);
|
||||
|
||||
final Builder<Integer, Capability> builder = ImmutableRangeMap.builder();
|
||||
final ImmutableRangeMap.Builder<Integer, Capability> builder = ImmutableRangeMap.builder();
|
||||
// Reserve some messages for WireProtocol
|
||||
int offset = WIRE_PROTOCOL_MESSAGE_SPACE;
|
||||
String prevProtocol = null;
|
||||
|
||||
@@ -35,7 +35,8 @@ public class CompactEncodingTest {
|
||||
public void shouldRoundTripFromBytesToPathAndBack() {
|
||||
final Random random = new Random(282943948928429484L);
|
||||
for (int i = 0; i < 1000; i++) {
|
||||
final Bytes32 bytes = Hash.keccak256(UInt256.of(Math.abs(random.nextInt())).getBytes());
|
||||
final Bytes32 bytes =
|
||||
Hash.keccak256(UInt256.of(random.nextInt(Integer.MAX_VALUE)).getBytes());
|
||||
final BytesValue path = CompactEncoding.bytesToPath(bytes);
|
||||
assertThat(CompactEncoding.pathToBytes(path)).isEqualTo(bytes);
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ public class TrieIteratorTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
@SuppressWarnings({"unchecked", "MathAbsoluteRandom"})
|
||||
public void shouldIterateArbitraryStructureAccurately() {
|
||||
Node<String> root = NullNode.instance();
|
||||
final NavigableSet<Bytes32> expectedKeyHashes = new TreeSet<>();
|
||||
|
||||
@@ -20,10 +20,10 @@ dependencyManagement {
|
||||
dependency 'com.google.auto.service:auto-service:1.0-rc4'
|
||||
|
||||
dependency 'com.google.errorprone:javac:9+181-r4173-1'
|
||||
dependency 'com.google.errorprone:error_prone_check_api:2.3.1'
|
||||
dependency 'com.google.errorprone:error_prone_core:2.3.1'
|
||||
dependency 'com.google.errorprone:error_prone_annotation:2.3.1'
|
||||
dependency 'com.google.errorprone:error_prone_test_helpers:2.3.1'
|
||||
dependency 'com.google.errorprone:error_prone_check_api:2.3.2'
|
||||
dependency 'com.google.errorprone:error_prone_core:2.3.2'
|
||||
dependency 'com.google.errorprone:error_prone_annotation:2.3.2'
|
||||
dependency 'com.google.errorprone:error_prone_test_helpers:2.3.2'
|
||||
|
||||
dependency 'com.google.guava:guava:27.0.1-jre'
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ import java.util.Collection;
|
||||
import java.util.Objects;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.io.Resources;
|
||||
|
||||
public class EthNetworkConfig {
|
||||
@@ -72,7 +73,7 @@ public class EthNetworkConfig {
|
||||
final EthNetworkConfig that = (EthNetworkConfig) o;
|
||||
return networkId == that.networkId
|
||||
&& Objects.equals(genesisConfig, that.genesisConfig)
|
||||
&& Objects.equals(bootNodes, that.bootNodes);
|
||||
&& Objects.equals(Lists.newArrayList(bootNodes), Lists.newArrayList(that.bootNodes));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -30,7 +30,6 @@ import tech.pegasys.pantheon.ethereum.core.MiningParameters;
|
||||
import tech.pegasys.pantheon.ethereum.core.Wei;
|
||||
import tech.pegasys.pantheon.ethereum.eth.sync.SyncMode;
|
||||
import tech.pegasys.pantheon.ethereum.eth.sync.SynchronizerConfiguration;
|
||||
import tech.pegasys.pantheon.ethereum.eth.sync.SynchronizerConfiguration.Builder;
|
||||
import tech.pegasys.pantheon.ethereum.jsonrpc.JsonRpcConfiguration;
|
||||
import tech.pegasys.pantheon.ethereum.jsonrpc.RpcApi;
|
||||
import tech.pegasys.pantheon.ethereum.jsonrpc.RpcApis;
|
||||
@@ -125,7 +124,7 @@ public class PantheonCommand implements DefaultCommandValues, Runnable {
|
||||
private final BlockImporter blockImporter;
|
||||
|
||||
private final PantheonControllerBuilder controllerBuilder;
|
||||
private final Builder synchronizerConfigurationBuilder;
|
||||
private final SynchronizerConfiguration.Builder synchronizerConfigurationBuilder;
|
||||
private final RunnerBuilder runnerBuilder;
|
||||
|
||||
private final MetricsSystem metricsSystem = PrometheusMetricsSystem.init();
|
||||
@@ -413,7 +412,7 @@ public class PantheonCommand implements DefaultCommandValues, Runnable {
|
||||
final BlockImporter blockImporter,
|
||||
final RunnerBuilder runnerBuilder,
|
||||
final PantheonControllerBuilder controllerBuilder,
|
||||
final Builder synchronizerConfigurationBuilder) {
|
||||
final SynchronizerConfiguration.Builder synchronizerConfigurationBuilder) {
|
||||
this.blockImporter = blockImporter;
|
||||
this.runnerBuilder = runnerBuilder;
|
||||
this.controllerBuilder = controllerBuilder;
|
||||
|
||||
@@ -28,7 +28,6 @@ import static org.mockito.Mockito.when;
|
||||
import static tech.pegasys.pantheon.ethereum.p2p.config.DiscoveryConfiguration.MAINNET_BOOTSTRAP_NODES;
|
||||
|
||||
import tech.pegasys.pantheon.PantheonInfo;
|
||||
import tech.pegasys.pantheon.cli.EthNetworkConfig.Builder;
|
||||
import tech.pegasys.pantheon.consensus.clique.jsonrpc.CliqueRpcApis;
|
||||
import tech.pegasys.pantheon.consensus.ibft.jsonrpc.IbftRpcApis;
|
||||
import tech.pegasys.pantheon.ethereum.core.Address;
|
||||
@@ -298,7 +297,7 @@ public class PantheonCommandTest extends CommandTestAbstract {
|
||||
assertThat(uriListArgumentCaptor.getValue()).isEqualTo(nodes);
|
||||
|
||||
final EthNetworkConfig networkConfig =
|
||||
new Builder(EthNetworkConfig.mainnet())
|
||||
new EthNetworkConfig.Builder(EthNetworkConfig.mainnet())
|
||||
.setGenesisConfig(GENESIS_CONFIG_TESTDATA)
|
||||
.setBootNodes(nodes)
|
||||
.build();
|
||||
|
||||
@@ -42,6 +42,7 @@ import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.web3j.protocol.Web3j;
|
||||
import org.web3j.protocol.http.HttpService;
|
||||
@@ -212,6 +213,7 @@ public class DockerQuickstartTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void rpcNodeShouldReturnCorrectVersion() {
|
||||
final String expectedVersion = PantheonInfo.version();
|
||||
Awaitility.await()
|
||||
|
||||
@@ -33,8 +33,8 @@ public class InMemoryKeyValueStorage implements KeyValueStorage {
|
||||
@Override
|
||||
public Optional<BytesValue> get(final BytesValue key) {
|
||||
final Lock lock = rwLock.readLock();
|
||||
lock.lock();
|
||||
try {
|
||||
lock.lock();
|
||||
return Optional.ofNullable(hashValueStore.get(key));
|
||||
} finally {
|
||||
lock.unlock();
|
||||
@@ -44,8 +44,8 @@ public class InMemoryKeyValueStorage implements KeyValueStorage {
|
||||
@Override
|
||||
public void put(final BytesValue key, final BytesValue value) {
|
||||
final Lock lock = rwLock.writeLock();
|
||||
lock.lock();
|
||||
try {
|
||||
lock.lock();
|
||||
hashValueStore.put(key, value);
|
||||
} finally {
|
||||
lock.unlock();
|
||||
@@ -55,8 +55,8 @@ public class InMemoryKeyValueStorage implements KeyValueStorage {
|
||||
@Override
|
||||
public void remove(final BytesValue key) throws StorageException {
|
||||
final Lock lock = rwLock.writeLock();
|
||||
lock.lock();
|
||||
try {
|
||||
lock.lock();
|
||||
hashValueStore.remove(key);
|
||||
} finally {
|
||||
lock.unlock();
|
||||
@@ -71,8 +71,8 @@ public class InMemoryKeyValueStorage implements KeyValueStorage {
|
||||
@Override
|
||||
public Stream<Entry> entries() {
|
||||
final Lock lock = rwLock.readLock();
|
||||
lock.lock();
|
||||
try {
|
||||
lock.lock();
|
||||
// Ensure we have collected all entries before releasing the lock and returning
|
||||
return hashValueStore
|
||||
.entrySet()
|
||||
@@ -108,8 +108,8 @@ public class InMemoryKeyValueStorage implements KeyValueStorage {
|
||||
@Override
|
||||
protected void doCommit() {
|
||||
final Lock lock = rwLock.writeLock();
|
||||
lock.lock();
|
||||
try {
|
||||
lock.lock();
|
||||
hashValueStore.putAll(updatedValues);
|
||||
removedKeys.forEach(k -> hashValueStore.remove(k));
|
||||
updatedValues = null;
|
||||
|
||||
@@ -21,7 +21,6 @@ import tech.pegasys.pantheon.services.kvstore.KeyValueStorage.Transaction;
|
||||
import tech.pegasys.pantheon.util.bytes.BytesValue;
|
||||
import tech.pegasys.pantheon.util.bytes.BytesValues;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
@@ -128,9 +127,7 @@ public abstract class AbstractKeyValueStorageTest {
|
||||
assertTrue(actual.equals(a) || actual.equals(b));
|
||||
}
|
||||
|
||||
if (store instanceof Closeable) {
|
||||
((Closeable) store).close();
|
||||
}
|
||||
store.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -328,8 +325,6 @@ public abstract class AbstractKeyValueStorageTest {
|
||||
assertArrayEquals(expectedValues, finalValues);
|
||||
assertTrue(finalValues[0].equals(a) || finalValues[0].equals(b));
|
||||
|
||||
if (store instanceof Closeable) {
|
||||
((Closeable) store).close();
|
||||
}
|
||||
store.close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotEquals;
|
||||
import static tech.pegasys.pantheon.util.bytes.BytesValue.fromHexString;
|
||||
import static tech.pegasys.pantheon.util.bytes.BytesValue.fromHexStringLenient;
|
||||
import static tech.pegasys.pantheon.util.bytes.BytesValue.of;
|
||||
import static tech.pegasys.pantheon.util.bytes.BytesValue.wrap;
|
||||
import static tech.pegasys.pantheon.util.bytes.BytesValue.wrapBuffer;
|
||||
|
||||
@@ -158,55 +157,56 @@ public class BytesValueTest {
|
||||
|
||||
@Test
|
||||
public void bytes() {
|
||||
assertArrayEquals(new byte[] {}, of().extractArray());
|
||||
assertArrayEquals(new byte[] {1, 2}, of((byte) 1, (byte) 2).extractArray());
|
||||
assertArrayEquals(new byte[] {}, BytesValue.of().extractArray());
|
||||
assertArrayEquals(new byte[] {1, 2}, BytesValue.of((byte) 1, (byte) 2).extractArray());
|
||||
assertArrayEquals(
|
||||
new byte[] {1, 2, 3, 4, 5},
|
||||
of((byte) 1, (byte) 2, (byte) 3, (byte) 4, (byte) 5).extractArray());
|
||||
BytesValue.of((byte) 1, (byte) 2, (byte) 3, (byte) 4, (byte) 5).extractArray());
|
||||
|
||||
assertArrayEquals(new byte[] {-1, 2, -3}, of((byte) -1, (byte) 2, (byte) -3).extractArray());
|
||||
assertArrayEquals(
|
||||
new byte[] {-1, 2, -3}, BytesValue.of((byte) -1, (byte) 2, (byte) -3).extractArray());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void integers() {
|
||||
assertArrayEquals(new byte[] {1, 2}, of(1, 2).extractArray());
|
||||
assertArrayEquals(new byte[] {1, 2, 3, 4, 5}, of(1, 2, 3, 4, 5).extractArray());
|
||||
assertArrayEquals(new byte[] {-1, 127, -128}, of(0xff, 0x7f, 0x80).extractArray());
|
||||
assertArrayEquals(new byte[] {1, 2}, BytesValue.of(1, 2).extractArray());
|
||||
assertArrayEquals(new byte[] {1, 2, 3, 4, 5}, BytesValue.of(1, 2, 3, 4, 5).extractArray());
|
||||
assertArrayEquals(new byte[] {-1, 127, -128}, BytesValue.of(0xff, 0x7f, 0x80).extractArray());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void integerTooBig() {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("3th value 256 does not fit a byte");
|
||||
of(2, 3, 256);
|
||||
BytesValue.of(2, 3, 256);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void integerTooLow() {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("2th value -1 does not fit a byte");
|
||||
of(2, -1, 3);
|
||||
BytesValue.of(2, -1, 3);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void hexStringLenient() {
|
||||
assertEquals(of(), fromHexStringLenient(""));
|
||||
assertEquals(of(), fromHexStringLenient("0x"));
|
||||
assertEquals(BytesValue.of(), fromHexStringLenient(""));
|
||||
assertEquals(BytesValue.of(), fromHexStringLenient("0x"));
|
||||
|
||||
assertEquals(of(0), fromHexStringLenient("0"));
|
||||
assertEquals(of(0), fromHexStringLenient("0x0"));
|
||||
assertEquals(of(0), fromHexStringLenient("00"));
|
||||
assertEquals(of(0), fromHexStringLenient("0x00"));
|
||||
assertEquals(of(1), fromHexStringLenient("0x1"));
|
||||
assertEquals(of(1), fromHexStringLenient("0x01"));
|
||||
assertEquals(BytesValue.of(0), fromHexStringLenient("0"));
|
||||
assertEquals(BytesValue.of(0), fromHexStringLenient("0x0"));
|
||||
assertEquals(BytesValue.of(0), fromHexStringLenient("00"));
|
||||
assertEquals(BytesValue.of(0), fromHexStringLenient("0x00"));
|
||||
assertEquals(BytesValue.of(1), fromHexStringLenient("0x1"));
|
||||
assertEquals(BytesValue.of(1), fromHexStringLenient("0x01"));
|
||||
|
||||
assertEquals(of(0x01, 0xff, 0x2a), fromHexStringLenient("1FF2A"));
|
||||
assertEquals(of(0x01, 0xff, 0x2a), fromHexStringLenient("0x1FF2A"));
|
||||
assertEquals(of(0x01, 0xff, 0x2a), fromHexStringLenient("0x1ff2a"));
|
||||
assertEquals(of(0x01, 0xff, 0x2a), fromHexStringLenient("0x1fF2a"));
|
||||
assertEquals(of(0x01, 0xff, 0x2a), fromHexStringLenient("01FF2A"));
|
||||
assertEquals(of(0x01, 0xff, 0x2a), fromHexStringLenient("0x01FF2A"));
|
||||
assertEquals(of(0x01, 0xff, 0x2a), fromHexStringLenient("0x01ff2A"));
|
||||
assertEquals(BytesValue.of(0x01, 0xff, 0x2a), fromHexStringLenient("1FF2A"));
|
||||
assertEquals(BytesValue.of(0x01, 0xff, 0x2a), fromHexStringLenient("0x1FF2A"));
|
||||
assertEquals(BytesValue.of(0x01, 0xff, 0x2a), fromHexStringLenient("0x1ff2a"));
|
||||
assertEquals(BytesValue.of(0x01, 0xff, 0x2a), fromHexStringLenient("0x1fF2a"));
|
||||
assertEquals(BytesValue.of(0x01, 0xff, 0x2a), fromHexStringLenient("01FF2A"));
|
||||
assertEquals(BytesValue.of(0x01, 0xff, 0x2a), fromHexStringLenient("0x01FF2A"));
|
||||
assertEquals(BytesValue.of(0x01, 0xff, 0x2a), fromHexStringLenient("0x01ff2A"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -218,25 +218,25 @@ public class BytesValueTest {
|
||||
|
||||
@Test
|
||||
public void hexStringLenientLeftPadding() {
|
||||
assertEquals(of(), fromHexStringLenient("", 0));
|
||||
assertEquals(of(0), fromHexStringLenient("", 1));
|
||||
assertEquals(of(0, 0), fromHexStringLenient("", 2));
|
||||
assertEquals(of(0, 0), fromHexStringLenient("0x", 2));
|
||||
assertEquals(BytesValue.of(), fromHexStringLenient("", 0));
|
||||
assertEquals(BytesValue.of(0), fromHexStringLenient("", 1));
|
||||
assertEquals(BytesValue.of(0, 0), fromHexStringLenient("", 2));
|
||||
assertEquals(BytesValue.of(0, 0), fromHexStringLenient("0x", 2));
|
||||
|
||||
assertEquals(of(0, 0, 0), fromHexStringLenient("0", 3));
|
||||
assertEquals(of(0, 0, 0), fromHexStringLenient("0x0", 3));
|
||||
assertEquals(of(0, 0, 0), fromHexStringLenient("00", 3));
|
||||
assertEquals(of(0, 0, 0), fromHexStringLenient("0x00", 3));
|
||||
assertEquals(of(0, 0, 1), fromHexStringLenient("0x1", 3));
|
||||
assertEquals(of(0, 0, 1), fromHexStringLenient("0x01", 3));
|
||||
assertEquals(BytesValue.of(0, 0, 0), fromHexStringLenient("0", 3));
|
||||
assertEquals(BytesValue.of(0, 0, 0), fromHexStringLenient("0x0", 3));
|
||||
assertEquals(BytesValue.of(0, 0, 0), fromHexStringLenient("00", 3));
|
||||
assertEquals(BytesValue.of(0, 0, 0), fromHexStringLenient("0x00", 3));
|
||||
assertEquals(BytesValue.of(0, 0, 1), fromHexStringLenient("0x1", 3));
|
||||
assertEquals(BytesValue.of(0, 0, 1), fromHexStringLenient("0x01", 3));
|
||||
|
||||
assertEquals(of(0x01, 0xff, 0x2a), fromHexStringLenient("1FF2A", 3));
|
||||
assertEquals(of(0x00, 0x01, 0xff, 0x2a), fromHexStringLenient("0x1FF2A", 4));
|
||||
assertEquals(of(0x00, 0x00, 0x01, 0xff, 0x2a), fromHexStringLenient("0x1ff2a", 5));
|
||||
assertEquals(of(0x00, 0x01, 0xff, 0x2a), fromHexStringLenient("0x1fF2a", 4));
|
||||
assertEquals(of(0x00, 0x01, 0xff, 0x2a), fromHexStringLenient("01FF2A", 4));
|
||||
assertEquals(of(0x01, 0xff, 0x2a), fromHexStringLenient("0x01FF2A", 3));
|
||||
assertEquals(of(0x01, 0xff, 0x2a), fromHexStringLenient("0x01ff2A", 3));
|
||||
assertEquals(BytesValue.of(0x01, 0xff, 0x2a), fromHexStringLenient("1FF2A", 3));
|
||||
assertEquals(BytesValue.of(0x00, 0x01, 0xff, 0x2a), fromHexStringLenient("0x1FF2A", 4));
|
||||
assertEquals(BytesValue.of(0x00, 0x00, 0x01, 0xff, 0x2a), fromHexStringLenient("0x1ff2a", 5));
|
||||
assertEquals(BytesValue.of(0x00, 0x01, 0xff, 0x2a), fromHexStringLenient("0x1fF2a", 4));
|
||||
assertEquals(BytesValue.of(0x00, 0x01, 0xff, 0x2a), fromHexStringLenient("01FF2A", 4));
|
||||
assertEquals(BytesValue.of(0x01, 0xff, 0x2a), fromHexStringLenient("0x01FF2A", 3));
|
||||
assertEquals(BytesValue.of(0x01, 0xff, 0x2a), fromHexStringLenient("0x01ff2A", 3));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -255,16 +255,16 @@ public class BytesValueTest {
|
||||
|
||||
@Test
|
||||
public void hexString() {
|
||||
assertEquals(of(), fromHexString("0x"));
|
||||
assertEquals(BytesValue.of(), fromHexString("0x"));
|
||||
|
||||
assertEquals(of(0), fromHexString("00"));
|
||||
assertEquals(of(0), fromHexString("0x00"));
|
||||
assertEquals(of(1), fromHexString("0x01"));
|
||||
assertEquals(BytesValue.of(0), fromHexString("00"));
|
||||
assertEquals(BytesValue.of(0), fromHexString("0x00"));
|
||||
assertEquals(BytesValue.of(1), fromHexString("0x01"));
|
||||
|
||||
assertEquals(of(1, 0xff, 0x2a), fromHexString("01FF2A"));
|
||||
assertEquals(of(1, 0xff, 0x2a), fromHexString("0x01FF2A"));
|
||||
assertEquals(of(1, 0xff, 0x2a), fromHexString("0x01ff2a"));
|
||||
assertEquals(of(1, 0xff, 0x2a), fromHexString("0x01fF2a"));
|
||||
assertEquals(BytesValue.of(1, 0xff, 0x2a), fromHexString("01FF2A"));
|
||||
assertEquals(BytesValue.of(1, 0xff, 0x2a), fromHexString("0x01FF2A"));
|
||||
assertEquals(BytesValue.of(1, 0xff, 0x2a), fromHexString("0x01ff2a"));
|
||||
assertEquals(BytesValue.of(1, 0xff, 0x2a), fromHexString("0x01fF2a"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -283,18 +283,18 @@ public class BytesValueTest {
|
||||
|
||||
@Test
|
||||
public void hexStringLeftPadding() {
|
||||
assertEquals(of(), fromHexString("0x", 0));
|
||||
assertEquals(of(0, 0), fromHexString("0x", 2));
|
||||
assertEquals(of(0, 0, 0, 0), fromHexString("0x", 4));
|
||||
assertEquals(BytesValue.of(), fromHexString("0x", 0));
|
||||
assertEquals(BytesValue.of(0, 0), fromHexString("0x", 2));
|
||||
assertEquals(BytesValue.of(0, 0, 0, 0), fromHexString("0x", 4));
|
||||
|
||||
assertEquals(of(0, 0), fromHexString("00", 2));
|
||||
assertEquals(of(0, 0), fromHexString("0x00", 2));
|
||||
assertEquals(of(0, 0, 1), fromHexString("0x01", 3));
|
||||
assertEquals(BytesValue.of(0, 0), fromHexString("00", 2));
|
||||
assertEquals(BytesValue.of(0, 0), fromHexString("0x00", 2));
|
||||
assertEquals(BytesValue.of(0, 0, 1), fromHexString("0x01", 3));
|
||||
|
||||
assertEquals(of(0x00, 0x01, 0xff, 0x2a), fromHexString("01FF2A", 4));
|
||||
assertEquals(of(0x01, 0xff, 0x2a), fromHexString("0x01FF2A", 3));
|
||||
assertEquals(of(0x00, 0x00, 0x01, 0xff, 0x2a), fromHexString("0x01ff2a", 5));
|
||||
assertEquals(of(0x00, 0x00, 0x01, 0xff, 0x2a), fromHexString("0x01fF2a", 5));
|
||||
assertEquals(BytesValue.of(0x00, 0x01, 0xff, 0x2a), fromHexString("01FF2A", 4));
|
||||
assertEquals(BytesValue.of(0x01, 0xff, 0x2a), fromHexString("0x01FF2A", 3));
|
||||
assertEquals(BytesValue.of(0x00, 0x00, 0x01, 0xff, 0x2a), fromHexString("0x01ff2a", 5));
|
||||
assertEquals(BytesValue.of(0x00, 0x00, 0x01, 0xff, 0x2a), fromHexString("0x01fF2a", 5));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user