Skip to content

Commit

Permalink
update: invalid vote test.
Browse files Browse the repository at this point in the history
  • Loading branch information
christopherbrumm committed Oct 5, 2023
1 parent 7dd7949 commit 4330860
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions common/protocol/test/vote_invalid.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
Validator,
sha256,
standardizeJSON,
VOTE
} from "../src/index";
import { runNode } from "../src/methods/main/runNode";
import { genesis_pool } from "./mocks/constants";
Expand Down Expand Up @@ -82,12 +83,7 @@ describe("invalid votes tests", () => {
global.setTimeout = setTimeoutMock as any;

// mock logger
v.logger = new Logger();

v.logger.info = jest.fn();
v.logger.debug = jest.fn();
v.logger.warn = jest.fn();
v.logger.error = jest.fn();
v.logger = new Logger({minLevel: "warn"});

v["poolId"] = 0;
v["staker"] = "test_staker";
Expand Down Expand Up @@ -115,7 +111,7 @@ describe("invalid votes tests", () => {

test("vote invalid because runtime validate function returns false", async () => {
// ARRANGE
const validateBundleMock = jest.fn().mockResolvedValue(false);
const validateBundleMock = jest.fn().mockResolvedValue(VOTE.INVALID);
v["runtime"].validateDataItem = validateBundleMock;

const bundle = [
Expand Down Expand Up @@ -949,7 +945,7 @@ describe("invalid votes tests", () => {

test("try to vote invalid after validator has voted abstain bebore", async () => {
// ARRANGE
const validateBundleMock = jest.fn().mockResolvedValue(false);
const validateBundleMock = jest.fn().mockResolvedValue(VOTE.INVALID);

v["runtime"].validateDataItem = validateBundleMock;

Expand Down Expand Up @@ -1096,7 +1092,7 @@ describe("invalid votes tests", () => {

test("try to vote invalid after validator has voted invalid before", async () => {
// ARRANGE
const validateBundleMock = jest.fn().mockResolvedValue(false);
const validateBundleMock = jest.fn().mockResolvedValue(VOTE.INVALID);

v["runtime"].validateDataItem = validateBundleMock;

Expand Down Expand Up @@ -1226,7 +1222,7 @@ describe("invalid votes tests", () => {

test("try to vote invalid after validator has voted valid before", async () => {
// ARRANGE
const validateBundleMock = jest.fn().mockResolvedValue(false);
const validateBundleMock = jest.fn().mockResolvedValue(VOTE.INVALID);

v["runtime"].validateDataItem = validateBundleMock;

Expand Down Expand Up @@ -1354,7 +1350,7 @@ describe("invalid votes tests", () => {

test("vote invalid but local bundle could not be loaded in the first try", async () => {
// ARRANGE
v["runtime"].validateDataItem = jest.fn().mockResolvedValue(false);
v["runtime"].validateDataItem = jest.fn().mockResolvedValue(VOTE.INVALID);

const bundle = [
{ key: "test_key_1", value: "test_value_1" },
Expand Down Expand Up @@ -1513,7 +1509,7 @@ describe("invalid votes tests", () => {

test("vote invalid but bundle from storage provider could not be loaded in the first try", async () => {
// ARRANGE
v["runtime"].validateDataItem = jest.fn().mockResolvedValue(false);
v["runtime"].validateDataItem = jest.fn().mockResolvedValue(VOTE.INVALID);

const bundle = [
{ key: "test_key_1", value: "test_value_1" },
Expand Down Expand Up @@ -1690,7 +1686,7 @@ describe("invalid votes tests", () => {
.mockReturnValueOnce(true)
.mockReturnValue(false);

v["runtime"].validateDataItem = jest.fn().mockResolvedValue(false);
v["runtime"].validateDataItem = jest.fn().mockResolvedValue(VOTE.INVALID);

v["client"][0].kyve.bundles.v1beta1.voteBundleProposal = jest
.fn()
Expand Down

0 comments on commit 4330860

Please sign in to comment.