From 4330860d2e6a5294e1d9f23232a3e8076fed6ecb Mon Sep 17 00:00:00 2001 From: christopherbrumm Date: Thu, 5 Oct 2023 14:54:28 +0200 Subject: [PATCH] update: invalid vote test. --- common/protocol/test/vote_invalid.test.ts | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/common/protocol/test/vote_invalid.test.ts b/common/protocol/test/vote_invalid.test.ts index 09745314..30e1c66e 100644 --- a/common/protocol/test/vote_invalid.test.ts +++ b/common/protocol/test/vote_invalid.test.ts @@ -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"; @@ -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"; @@ -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 = [ @@ -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; @@ -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; @@ -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; @@ -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" }, @@ -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" }, @@ -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()