Skip to content

Commit

Permalink
Pass test gossipHandlers
Browse files Browse the repository at this point in the history
  • Loading branch information
dapplion committed Mar 1, 2023
1 parent 86450f8 commit 0e803d0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion packages/beacon-node/src/network/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ export class Network implements INetwork {
chain,
reqRespHandlers,
signal,
gossipHandlers,
}: NetworkInitModules): Promise<Network> {
const clock = chain.clock;
const peersData = new PeersData();
Expand Down Expand Up @@ -229,7 +230,7 @@ export class Network implements INetwork {
);

const networkProcessor = new NetworkProcessor(
{attnetsService, chain, config, logger, metrics, peerRpcScores, events: networkEventBus},
{attnetsService, chain, config, logger, metrics, peerRpcScores, events: networkEventBus, gossipHandlers},
opts
);

Expand Down
6 changes: 4 additions & 2 deletions packages/beacon-node/src/network/processor/worker.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {IBeaconChain} from "../../chain/interface.js";
import {Metrics} from "../../metrics/metrics.js";
import {NetworkEvent, NetworkEventBus} from "../events.js";
import {GossipValidatorFn} from "../gossip/interface.js";
import {GossipHandlers, GossipValidatorFn} from "../gossip/interface.js";
import {getGossipHandlers, GossipHandlerOpts, ValidatorFnsModules} from "./gossipHandlers.js";
import {getGossipValidatorFn, ValidatorFnModules} from "./gossipValidatorFn.js";
import {PendingGossipsubMessage} from "./types.js";
Expand All @@ -11,6 +11,8 @@ export type NetworkWorkerModules = ValidatorFnsModules &
chain: IBeaconChain;
events: NetworkEventBus;
metrics: Metrics | null;
// Optionally pass custom GossipHandlers, for testing
gossipHandlers?: GossipHandlers;
};

export class NetworkWorker {
Expand All @@ -21,7 +23,7 @@ export class NetworkWorker {
constructor(modules: NetworkWorkerModules, opts: GossipHandlerOpts) {
this.events = modules.events;
this.metrics = modules.metrics;
this.gossipValidatorFn = getGossipValidatorFn(getGossipHandlers(modules, opts), modules);
this.gossipValidatorFn = getGossipValidatorFn(modules.gossipHandlers ?? getGossipHandlers(modules, opts), modules);
}

async processPendingGossipsubMessage(message: PendingGossipsubMessage): Promise<void> {
Expand Down

0 comments on commit 0e803d0

Please sign in to comment.