Skip to content

Commit

Permalink
Fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dapplion committed Sep 14, 2021
1 parent 06f3da5 commit 62279f7
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ import {generateEmptySignedBlockHeader} from "../../../../../utils/block";
import {setupApiImplTestServer} from "../../index.test";
import {SinonStubFn} from "../../../../../utils/types";
import {testLogger} from "../../../../../utils/logger";
import {AggregatedAttestationPool} from "../../../../../../src/chain/opPools";
import {AggregatedAttestationPool, OpPool} from "../../../../../../src/chain/opPools";

describe("beacon pool api impl", function () {
const logger = testLogger();
let poolApi: ReturnType<typeof getBeaconPoolApi>;
let chainStub: SinonStubbedInstance<IBeaconChain>;
let opPool: SinonStubbedInstance<OpPool>;
let networkStub: SinonStubbedInstance<Network>;
let gossipStub: SinonStubbedInstance<Eth2Gossipsub>;
let validateGossipAttesterSlashing: SinonStubFn<typeof attesterSlashingValidation["validateGossipAttesterSlashing"]>;
Expand All @@ -40,6 +41,10 @@ describe("beacon pool api impl", function () {
((chainStub as unknown) as {
aggregatedAttestationPool: SinonStubbedInstance<AggregatedAttestationPool>;
}).aggregatedAttestationPool = aggregatedAttestationPool;
opPool = sinon.createStubInstance(OpPool);
((chainStub as unknown) as {
opPool: SinonStubbedInstance<OpPool>;
}).opPool = opPool;
gossipStub = sinon.createStubInstance(Eth2Gossipsub);
gossipStub.publishAttesterSlashing = sinon.stub();
gossipStub.publishProposerSlashing = sinon.stub();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe("GossipMessageValidator", () => {
let chainStub: StubbedChain;
let opPool: OpPool & SinonStubbedInstance<OpPool>;

before(() => {
beforeEach(() => {
chainStub = sandbox.createStubInstance(BeaconChain) as StubbedChain;
chainStub.forkChoice = sandbox.createStubInstance(ForkChoice);
chainStub.bls = {verifySignatureSets: async () => true};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe("validate proposer slashing", () => {
let chainStub: StubbedChain;
let opPool: OpPool & SinonStubbedInstance<OpPool>;

before(() => {
beforeEach(() => {
chainStub = sandbox.createStubInstance(BeaconChain) as StubbedChain;
chainStub.forkChoice = sandbox.createStubInstance(ForkChoice);
chainStub.bls = {verifySignatureSets: async () => true};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ describe("validate voluntary exit", () => {
};

// Return SignedVoluntaryExit known
opPool.hasSeenProposerSlashing.returns(true);
opPool.hasSeenVoluntaryExit.returns(true);

await expectRejectedWithLodestarError(
validateGossipVoluntaryExit(chainStub, signedVoluntaryExitInvalidSig),
Expand Down

0 comments on commit 62279f7

Please sign in to comment.