From 99b55f3353a4010e9fe6959869e0fc5b53c08f44 Mon Sep 17 00:00:00 2001 From: Adrian Tiberius Date: Mon, 1 Jun 2015 21:31:10 +0200 Subject: [PATCH] Unit tests fixes ( 1 failing left ). --- ethereumj-core/build.gradle | 13 +++---- .../datasource/redis/RedisConnectionImpl.java | 9 ----- .../di/components/EthereumComponent.java | 2 + .../org/ethereum/facade/CommonConfig.java | 26 ++----------- .../org/ethereum/facade/DefaultConfig.java | 12 ------ .../org/ethereum/facade/EthereumFactory.java | 8 +--- .../org/ethereum/facade/RemoteConfig.java | 14 ------- .../ethereum/jsontestsuite/TestRunner.java | 7 ++++ .../test/java/org/ethereum/TestContext.java | 17 ++++----- .../java/org/ethereum/core/ImportTest.java | 35 +++++++++-------- .../datasource/AbstractRedisTest.java | 38 ++++++++++--------- .../di/components/TestEthereumComponent.java | 6 ++- .../di/modules/TestEthereumModule.java | 11 ++++++ .../jsontestsuite/GitHubBlockTest.java | 11 ++++++ .../net/wire/AdaptiveMessageIdsTest.java | 6 ++- 15 files changed, 95 insertions(+), 120 deletions(-) diff --git a/ethereumj-core/build.gradle b/ethereumj-core/build.gradle index 7263a62b..409fead1 100644 --- a/ethereumj-core/build.gradle +++ b/ethereumj-core/build.gradle @@ -25,8 +25,6 @@ plugins { id 'com.jfrog.bintray' version '1.0' } -apply plugin: 'com.jfrog.artifactory-upload' - sourceCompatibility = 1.7 mainClassName = 'org.ethereum.Start' @@ -39,7 +37,6 @@ configurations { repositories { maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' } mavenCentral() - maven { url 'http://repo.spring.io/plugins-release-local' } flatDir { dirs "libs" @@ -56,9 +53,6 @@ antlr4 { preBuild.dependsOn antlr4 -configurations { - compile.extendsFrom antlr4 -} ext { slf4jVersion = '1.7.7' @@ -108,7 +102,7 @@ dependencies { compile 'com.yuvalshavit:antlr-denter:1.1' - compile 'org.slf4j:slf4j-android:1.7.12' + compile "org.slf4j:slf4j-log4j12:${slf4jVersion}" compile 'org.codehaus.jackson:jackson-mapper-asl:1.9.13' compile 'com.google.code.findbugs:jsr305:3.0.0' @@ -116,8 +110,11 @@ dependencies { compile 'org.apache.commons:commons-collections4:4.0' compile "commons-codec:commons-codec:1.10" compile 'org.hsqldb:hsqldb:1.8.0.10' // best performance - do not upgrade! + compile ("org.hibernate:hibernate-core:${hibernateVersion}") { + exclude group: 'commons-logging', module: 'commons-logging' + } + compile "org.hibernate:hibernate-entitymanager:${hibernateVersion}" - compile 'javax.persistence:persistence-api:1.0.2' compile('redis.clients:jedis:2.6.0') { exclude group: 'org.apache.commons', module: 'commons-pool2' diff --git a/ethereumj-core/src/main/java/org/ethereum/datasource/redis/RedisConnectionImpl.java b/ethereumj-core/src/main/java/org/ethereum/datasource/redis/RedisConnectionImpl.java index 41e0ac88..3ff42f84 100644 --- a/ethereumj-core/src/main/java/org/ethereum/datasource/redis/RedisConnectionImpl.java +++ b/ethereumj-core/src/main/java/org/ethereum/datasource/redis/RedisConnectionImpl.java @@ -5,8 +5,6 @@ import org.ethereum.core.Transaction; import org.ethereum.datasource.KeyValueDataSource; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -//import org.springframework.stereotype.Component; -//import org.springframework.util.StringUtils; import redis.clients.jedis.Jedis; import redis.clients.jedis.JedisPool; import redis.clients.jedis.JedisPoolConfig; @@ -18,9 +16,6 @@ import java.net.URI; import java.util.Map; import java.util.Set; -//import static org.springframework.util.StringUtils.isEmpty; - -//@Component public class RedisConnectionImpl implements RedisConnection { private static final Logger logger = LoggerFactory.getLogger("db"); @@ -54,20 +49,16 @@ public class RedisConnectionImpl implements RedisConnection { private static JedisPool createJedisPool(URI redisUri) { String userInfo = redisUri.getUserInfo(); if (hasText(userInfo)) { - /* return new JedisPool(new JedisPoolConfig(), redisUri.getHost(), redisUri.getPort(), Protocol.DEFAULT_TIMEOUT, userInfo.split(":", 2)[1]); - */ } -/* return new JedisPool(new JedisPoolConfig(), redisUri.getHost(), redisUri.getPort(), Protocol.DEFAULT_TIMEOUT); - */ return null; } diff --git a/ethereumj-core/src/main/java/org/ethereum/di/components/EthereumComponent.java b/ethereumj-core/src/main/java/org/ethereum/di/components/EthereumComponent.java index e20a423b..e239d5d5 100644 --- a/ethereumj-core/src/main/java/org/ethereum/di/components/EthereumComponent.java +++ b/ethereumj-core/src/main/java/org/ethereum/di/components/EthereumComponent.java @@ -7,6 +7,7 @@ import org.ethereum.listener.EthereumListener; import javax.inject.Singleton; import dagger.Component; +import org.ethereum.net.server.ChannelManager; @Singleton @Component(modules = EthereumModule.class) @@ -14,4 +15,5 @@ public interface EthereumComponent { Ethereum ethereum(); EthereumListener listener(); + ChannelManager channelManager(); } \ No newline at end of file diff --git a/ethereumj-core/src/main/java/org/ethereum/facade/CommonConfig.java b/ethereumj-core/src/main/java/org/ethereum/facade/CommonConfig.java index ca1ff808..7534cc3f 100644 --- a/ethereumj-core/src/main/java/org/ethereum/facade/CommonConfig.java +++ b/ethereumj-core/src/main/java/org/ethereum/facade/CommonConfig.java @@ -9,15 +9,6 @@ import org.ethereum.db.RepositoryImpl; import org.hibernate.SessionFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Scope; -import org.springframework.jdbc.datasource.DriverManagerDataSource; -import org.springframework.orm.hibernate4.HibernateTransactionManager; -import org.springframework.orm.hibernate4.LocalSessionFactoryBuilder; -import org.springframework.transaction.annotation.EnableTransactionManagement; import java.util.Collections; import java.util.HashSet; @@ -26,23 +17,16 @@ import java.util.Set; import static org.ethereum.config.SystemProperties.CONFIG; -@Configuration -@EnableTransactionManagement -@ComponentScan(basePackages = "org.ethereum") public class CommonConfig { private static final Logger logger = LoggerFactory.getLogger("general"); - @Autowired private RedisConnection redisConnection; - @Bean Repository repository() { return new RepositoryImpl(keyValueDataSource(), keyValueDataSource()); } - @Bean - @Scope("prototype") public KeyValueDataSource keyValueDataSource() { String dataSource = CONFIG.getKeyValueDataSource(); try { @@ -58,7 +42,6 @@ public class CommonConfig { } } - @Bean public Set pendingTransactions() { String storage = "Redis"; try { @@ -73,7 +56,7 @@ public class CommonConfig { } } - @Bean + /* public SessionFactory sessionFactory() { LocalSessionFactoryBuilder builder = new LocalSessionFactoryBuilder(dataSource()); @@ -82,6 +65,7 @@ public class CommonConfig { return builder.buildSessionFactory(); } + */ private Properties getHibernateProperties() { @@ -96,13 +80,11 @@ public class CommonConfig { "org.hibernate.dialect.HSQLDialect"); return prop; } - - @Bean + /* public HibernateTransactionManager txManager() { return new HibernateTransactionManager(sessionFactory()); } - @Bean(name = "dataSource") public DriverManagerDataSource dataSource() { logger.info("Connecting to the block store"); @@ -123,5 +105,5 @@ public class CommonConfig { return ds; } - + */ } diff --git a/ethereumj-core/src/main/java/org/ethereum/facade/DefaultConfig.java b/ethereumj-core/src/main/java/org/ethereum/facade/DefaultConfig.java index c82b76dd..c63f438b 100644 --- a/ethereumj-core/src/main/java/org/ethereum/facade/DefaultConfig.java +++ b/ethereumj-core/src/main/java/org/ethereum/facade/DefaultConfig.java @@ -3,26 +3,14 @@ package org.ethereum.facade; import org.ethereum.db.BlockStore; import org.ethereum.db.BlockStoreImpl; import org.hibernate.SessionFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Import; -import org.springframework.transaction.annotation.Propagation; -import org.springframework.transaction.annotation.Transactional; /** * * @author: Roman Mandeleil * Created on: 27/01/2015 01:05 */ -@Configuration -@Import(CommonConfig.class) public class DefaultConfig { - @Autowired CommonConfig commonConfig; - - @Bean - @Transactional(propagation = Propagation.SUPPORTS) public BlockStore blockStore(SessionFactory sessionFactory){ return new BlockStoreImpl(sessionFactory); } diff --git a/ethereumj-core/src/main/java/org/ethereum/facade/EthereumFactory.java b/ethereumj-core/src/main/java/org/ethereum/facade/EthereumFactory.java index a649c02a..e2f43830 100644 --- a/ethereumj-core/src/main/java/org/ethereum/facade/EthereumFactory.java +++ b/ethereumj-core/src/main/java/org/ethereum/facade/EthereumFactory.java @@ -6,19 +6,14 @@ import org.ethereum.net.shh.ShhHandler; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.context.ApplicationContext; -import org.springframework.context.annotation.AnnotationConfigApplicationContext; -import org.springframework.stereotype.Component; /** * @author Roman Mandeleil * @since 13.11.2014 */ -@Component public class EthereumFactory { private static final Logger logger = LoggerFactory.getLogger("general"); - public static ApplicationContext context = null; public static Ethereum createEthereum() { return createEthereum(DefaultConfig.class); @@ -29,8 +24,7 @@ public class EthereumFactory { logger.info("capability eth version: [{}]", EthHandler.VERSION); logger.info("capability shh version: [{}]", ShhHandler.VERSION); - context = new AnnotationConfigApplicationContext(clazz); - return context.getBean(Ethereum.class); + return null; } } diff --git a/ethereumj-core/src/main/java/org/ethereum/facade/RemoteConfig.java b/ethereumj-core/src/main/java/org/ethereum/facade/RemoteConfig.java index 31ff3611..07c4cf22 100644 --- a/ethereumj-core/src/main/java/org/ethereum/facade/RemoteConfig.java +++ b/ethereumj-core/src/main/java/org/ethereum/facade/RemoteConfig.java @@ -3,29 +3,15 @@ package org.ethereum.facade; import org.ethereum.db.BlockStore; import org.ethereum.db.InMemoryBlockStore; import org.hibernate.SessionFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Import; -import org.springframework.transaction.annotation.Propagation; -import org.springframework.transaction.annotation.Transactional; /** * * @author: Roman Mandeleil * Created on: 27/01/2015 01:05 */ -@Configuration -@Import(CommonConfig.class) public class RemoteConfig { - @Autowired CommonConfig commonConfig; - // todo: init total difficulty - // todo: init last 1000 blocks - - @Bean - @Transactional(propagation = Propagation.SUPPORTS) public BlockStore blockStore(SessionFactory sessionFactory){ return new InMemoryBlockStore(); } diff --git a/ethereumj-core/src/main/java/org/ethereum/jsontestsuite/TestRunner.java b/ethereumj-core/src/main/java/org/ethereum/jsontestsuite/TestRunner.java index d576c780..b0d5009e 100644 --- a/ethereumj-core/src/main/java/org/ethereum/jsontestsuite/TestRunner.java +++ b/ethereumj-core/src/main/java/org/ethereum/jsontestsuite/TestRunner.java @@ -6,6 +6,9 @@ import org.ethereum.core.BlockchainImpl; import org.ethereum.core.TransactionReceipt; import org.ethereum.core.Wallet; import org.ethereum.db.*; +import org.ethereum.di.components.DaggerEthereumComponent; +import org.ethereum.di.modules.EthereumModule; +import org.ethereum.facade.Ethereum; import org.ethereum.facade.Repository; import org.ethereum.jsontestsuite.builder.BlockBuilder; import org.ethereum.jsontestsuite.builder.RepositoryBuilder; @@ -47,6 +50,10 @@ public class TestRunner { @Inject public TestRunner() { + + channelManager = DaggerEthereumComponent.builder() + .ethereumModule(new EthereumModule()) + .build().channelManager(); } public List runTestSuite(TestSuite testSuite) { diff --git a/ethereumj-core/src/test/java/org/ethereum/TestContext.java b/ethereumj-core/src/test/java/org/ethereum/TestContext.java index eda1c0bb..195955a2 100644 --- a/ethereumj-core/src/test/java/org/ethereum/TestContext.java +++ b/ethereumj-core/src/test/java/org/ethereum/TestContext.java @@ -5,10 +5,6 @@ import org.ethereum.facade.Ethereum; import org.hibernate.SessionFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Bean; -import org.springframework.jdbc.datasource.DriverManagerDataSource; -import org.springframework.orm.hibernate4.LocalSessionFactoryBuilder; import java.sql.SQLException; import java.util.Properties; @@ -19,6 +15,7 @@ import java.util.Properties; */ public class TestContext { + /* private static final Logger logger = LoggerFactory.getLogger("test"); @@ -56,11 +53,11 @@ public class TestContext { } -/* - - - -*/ + +// +// +// + @Bean(name = "dataSource") @@ -88,5 +85,5 @@ public class TestContext { @Autowired Ethereum eth; - +*/ } diff --git a/ethereumj-core/src/test/java/org/ethereum/core/ImportTest.java b/ethereumj-core/src/test/java/org/ethereum/core/ImportTest.java index 09b13e04..2dc1d1cd 100644 --- a/ethereumj-core/src/test/java/org/ethereum/core/ImportTest.java +++ b/ethereumj-core/src/test/java/org/ethereum/core/ImportTest.java @@ -4,23 +4,18 @@ package org.ethereum.core; import org.ethereum.config.SystemProperties; import org.ethereum.db.BlockStore; import org.ethereum.db.InMemoryBlockStore; +import org.ethereum.di.modules.TestEthereumModule; +import org.ethereum.di.components.DaggerTestEthereumComponent; +import org.ethereum.facade.Ethereum; import org.ethereum.manager.WorldManager; import org.hibernate.SessionFactory; import org.junit.After; +import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.spongycastle.util.encoders.Hex; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.context.support.AnnotationConfigContextLoader; -import org.springframework.transaction.annotation.Propagation; -import org.springframework.transaction.annotation.Transactional; import org.ethereum.TestContext; import java.io.File; @@ -31,32 +26,40 @@ import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.util.List; +import javax.inject.Inject; + import static org.junit.Assert.assertEquals; -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(loader = AnnotationConfigContextLoader.class) public class ImportTest { private static final Logger logger = LoggerFactory.getLogger("test"); - @Configuration - @ComponentScan(basePackages = "org.ethereum") static class ContextConfiguration extends TestContext { static { SystemProperties.CONFIG.setDataBaseDir("test_db/" + ImportTest.class); SystemProperties.CONFIG.setDatabaseReset(true); } - @Bean - @Transactional(propagation = Propagation.SUPPORTS) public BlockStore blockStore(SessionFactory sessionFactory){ return new InMemoryBlockStore(); } } - @Autowired + @Inject WorldManager worldManager; + @Inject + public ImportTest() { + + } + + @Before + public void setup() { + worldManager = DaggerTestEthereumComponent.builder() + .testEthereumModule(new TestEthereumModule()) + .build().worldManager(); + } + @After public void close(){ worldManager.close(); diff --git a/ethereumj-core/src/test/java/org/ethereum/datasource/AbstractRedisTest.java b/ethereumj-core/src/test/java/org/ethereum/datasource/AbstractRedisTest.java index 8adc7ea4..f49f6e46 100644 --- a/ethereumj-core/src/test/java/org/ethereum/datasource/AbstractRedisTest.java +++ b/ethereumj-core/src/test/java/org/ethereum/datasource/AbstractRedisTest.java @@ -4,51 +4,53 @@ import org.ethereum.config.SystemProperties; import org.ethereum.datasource.redis.RedisConnection; import org.ethereum.db.BlockStore; import org.ethereum.db.InMemoryBlockStore; +import org.ethereum.di.components.TestEthereumComponent; +import org.ethereum.di.components.DaggerTestEthereumComponent; +import org.ethereum.di.modules.TestEthereumModule; import org.ethereum.manager.WorldManager; import org.hibernate.SessionFactory; import org.junit.After; +import org.junit.Before; import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.context.support.AnnotationConfigContextLoader; -import org.springframework.transaction.annotation.Propagation; -import org.springframework.transaction.annotation.Transactional; import redis.clients.jedis.Jedis; import org.ethereum.TestContext; import java.net.URI; +import javax.inject.Inject; + import static org.junit.Assert.assertFalse; -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(loader = AnnotationConfigContextLoader.class) public abstract class AbstractRedisTest { - @Configuration - @ComponentScan(basePackages = "org.ethereum") static class ContextConfiguration extends TestContext { static { SystemProperties.CONFIG.setDataBaseDir("test_db/" + "RedisAll"); SystemProperties.CONFIG.setDatabaseReset(true); } - @Bean - @Transactional(propagation = Propagation.SUPPORTS) public BlockStore blockStore(SessionFactory sessionFactory){ return new InMemoryBlockStore(); } } - @Autowired - private RedisConnection redisConnection; + TestEthereumComponent component; - @Autowired + @Inject + RedisConnection redisConnection; + + @Inject WorldManager worldManager; + @Before + public void setup() { + component = DaggerTestEthereumComponent.builder() + .testEthereumModule(new TestEthereumModule()) + .build(); + redisConnection = component.redisConnection(); + worldManager = component.worldManager(); + } + @After public void close(){ worldManager.close(); diff --git a/ethereumj-core/src/test/java/org/ethereum/di/components/TestEthereumComponent.java b/ethereumj-core/src/test/java/org/ethereum/di/components/TestEthereumComponent.java index ef004c4e..fe67799d 100644 --- a/ethereumj-core/src/test/java/org/ethereum/di/components/TestEthereumComponent.java +++ b/ethereumj-core/src/test/java/org/ethereum/di/components/TestEthereumComponent.java @@ -1,6 +1,7 @@ package org.ethereum.di.components; -import org.ethereum.di.modules.EthereumModule; +import org.ethereum.datasource.redis.RedisConnection; +import org.ethereum.di.modules.TestEthereumModule; import org.ethereum.facade.Ethereum; import org.ethereum.listener.EthereumListener; import org.ethereum.manager.WorldManager; @@ -11,7 +12,7 @@ import javax.inject.Singleton; import dagger.Component; @Singleton -@Component(modules = EthereumModule.class) +@Component(modules = TestEthereumModule.class) public interface TestEthereumComponent { void inject(ChannelManager channelManager); @@ -21,4 +22,5 @@ public interface TestEthereumComponent { EthereumListener listener(); ChannelManager channelManager(); WorldManager worldManager(); + RedisConnection redisConnection(); } \ No newline at end of file diff --git a/ethereumj-core/src/test/java/org/ethereum/di/modules/TestEthereumModule.java b/ethereumj-core/src/test/java/org/ethereum/di/modules/TestEthereumModule.java index 1b7365b8..b6d937f8 100644 --- a/ethereumj-core/src/test/java/org/ethereum/di/modules/TestEthereumModule.java +++ b/ethereumj-core/src/test/java/org/ethereum/di/modules/TestEthereumModule.java @@ -4,6 +4,8 @@ import org.ethereum.config.SystemProperties; import org.ethereum.core.BlockchainImpl; import org.ethereum.core.Wallet; import org.ethereum.datasource.LevelDbDataSource; +import org.ethereum.datasource.redis.RedisConnection; +import org.ethereum.datasource.redis.RedisConnectionImpl; import org.ethereum.db.BlockStore; import org.ethereum.db.InMemoryBlockStore; import org.ethereum.db.RepositoryImpl; @@ -115,6 +117,13 @@ public class TestEthereumModule { return new ProgramInvokeFactoryImpl(); } + @Provides + @Singleton + RedisConnection provideRedisConnection() { + return new RedisConnectionImpl(); + } + + @Provides EthHandler provideEthHandler(Blockchain blockchain, EthereumListener listener, Wallet wallet) { return new EthHandler(blockchain, listener, wallet); @@ -151,6 +160,8 @@ public class TestEthereumModule { return new WorkerThread(discoveryChannelProvider); } + + @Provides String provideRemoteId() { return SystemProperties.CONFIG.activePeerNodeid(); diff --git a/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/GitHubBlockTest.java b/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/GitHubBlockTest.java index 39f47b66..5fb5a49a 100644 --- a/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/GitHubBlockTest.java +++ b/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/GitHubBlockTest.java @@ -1,6 +1,10 @@ package org.ethereum.jsontestsuite; +import org.ethereum.di.modules.TestEthereumModule; +import org.ethereum.di.components.DaggerTestEthereumComponent; +import org.ethereum.facade.Ethereum; import org.json.simple.parser.ParseException; +import org.junit.Before; import org.junit.FixMethodOrder; import org.junit.Ignore; import org.junit.Test; @@ -16,6 +20,13 @@ public class GitHubBlockTest { //SHACOMMIT of tested commit, ethereum/tests.git public String shacommit = "d2ba02fe0507da205e3d17d79612ae15282b35a2"; + @Before + public void setup() { + DaggerTestEthereumComponent.builder() + .testEthereumModule(new TestEthereumModule()) + .build(); + } + @Ignore @Test public void runSingleTest() throws ParseException, IOException { diff --git a/ethereumj-core/src/test/java/org/ethereum/net/wire/AdaptiveMessageIdsTest.java b/ethereumj-core/src/test/java/org/ethereum/net/wire/AdaptiveMessageIdsTest.java index f12fa886..280050d4 100644 --- a/ethereumj-core/src/test/java/org/ethereum/net/wire/AdaptiveMessageIdsTest.java +++ b/ethereumj-core/src/test/java/org/ethereum/net/wire/AdaptiveMessageIdsTest.java @@ -1,10 +1,12 @@ package org.ethereum.net.wire; +import org.ethereum.listener.CompositeEthereumListener; import org.ethereum.net.client.Capability; import org.ethereum.net.eth.EthHandler; import org.ethereum.net.eth.EthMessageCodes; import org.ethereum.net.p2p.P2pHandler; import org.ethereum.net.p2p.P2pMessageCodes; +import org.ethereum.net.peerdiscovery.PeerDiscovery; import org.ethereum.net.shh.ShhHandler; import org.ethereum.net.shh.ShhMessageCodes; @@ -97,7 +99,7 @@ public class AdaptiveMessageIdsTest { @Test public void test4() { - P2pHandler p2pHandler = new P2pHandler(); + P2pHandler p2pHandler = new P2pHandler(new PeerDiscovery(), new CompositeEthereumListener()); List capabilities = Arrays.asList( new Capability(Capability.ETH, EthHandler.VERSION), @@ -124,7 +126,7 @@ public class AdaptiveMessageIdsTest { @Test // Capabilities should be read in alphabetical order public void test5() { - P2pHandler p2pHandler = new P2pHandler(); + P2pHandler p2pHandler = new P2pHandler(new PeerDiscovery(), new CompositeEthereumListener()); List capabilities = Arrays.asList( new Capability(Capability.SHH, ShhHandler.VERSION),