use of tech.pegasys.teku.services.beaconchain.BeaconChainController in project teku by ConsenSys.
the class TekuConfigurationTest method beaconChainControllerFactory_useCustomFactories.
@Test
void beaconChainControllerFactory_useCustomFactories() {
AtomicBoolean customDiscoveryBuilderMethodCalled = new AtomicBoolean();
AtomicBoolean customLibP2PBuilderMethodCalled = new AtomicBoolean();
AtomicBoolean customGossipNetworkBuilderCalled = new AtomicBoolean();
DiscoveryNetworkBuilder customDiscoveryNetworkBuilder = new DiscoveryNetworkBuilder() {
@Override
public DiscoveryNetwork<?> build() {
customDiscoveryBuilderMethodCalled.set(true);
return super.build();
}
};
LibP2PGossipNetworkBuilder customGossipNetworkBuilder = new LibP2PGossipNetworkBuilder() {
@Override
public LibP2PGossipNetwork build() {
customGossipNetworkBuilderCalled.set(true);
return super.build();
}
};
LibP2PNetworkBuilder customLibP2PNetworkBuilder = new LibP2PNetworkBuilder() {
@Override
public P2PNetwork<Peer> build() {
customLibP2PBuilderMethodCalled.set(true);
return super.build();
}
@Override
protected LibP2PGossipNetworkBuilder createLibP2PGossipNetworkBuilder() {
return customGossipNetworkBuilder;
}
};
Eth2P2PNetworkBuilder customEth2P2PNetworkBuilder = new Eth2P2PNetworkBuilder() {
@Override
protected DiscoveryNetworkBuilder createDiscoveryNetworkBuilder() {
return customDiscoveryNetworkBuilder;
}
@Override
protected LibP2PNetworkBuilder createLibP2PNetworkBuilder() {
return customLibP2PNetworkBuilder;
}
};
BeaconChainControllerFactory customControllerFactory = (serviceConfig, beaconConfig) -> new BeaconChainController(serviceConfig, beaconConfig) {
@Override
protected Eth2P2PNetworkBuilder createEth2P2PNetworkBuilder() {
return customEth2P2PNetworkBuilder;
}
};
TekuConfiguration tekuConfiguration = TekuConfiguration.builder().data(b -> b.dataBasePath(tempDir)).beaconChainControllerFactory(customControllerFactory).build();
try (BeaconNodeFacade beaconNode = TekuFacade.startBeaconNode(tekuConfiguration)) {
assertThat(beaconNode).isNotNull();
assertThat(customDiscoveryBuilderMethodCalled).isTrue();
assertThat(customLibP2PBuilderMethodCalled).isTrue();
assertThat(customGossipNetworkBuilderCalled).isTrue();
}
}
Aggregations