|
| 1 | +import { Order } from "../order"; |
1 | 2 | import { OracleErrorType } from "./error"; |
2 | | -import { describe, it, expect, vi, beforeEach, afterEach, assert } from "vitest"; |
3 | 3 | import { OracleConstants, OracleHealthMap, OracleOrderRequest } from "./types"; |
| 4 | +import { describe, it, expect, vi, beforeEach, afterEach, assert } from "vitest"; |
4 | 5 | import { |
5 | 6 | isInCooloff, |
6 | 7 | extractOracleUrl, |
7 | 8 | fetchSignedContext, |
8 | 9 | recordOracleSuccess, |
9 | 10 | recordOracleFailure, |
10 | | - isValidSignedContextV2, |
11 | 11 | } from "./fetch"; |
12 | | -import { Order } from "../order"; |
13 | 12 |
|
14 | 13 | // Mock fetch globally |
15 | 14 | const mockFetch = vi.fn(); |
@@ -725,106 +724,3 @@ describe("recordOracleFailure", () => { |
725 | 724 | expect(state?.cooloffUntil).toBe(existingCooloff); |
726 | 725 | }); |
727 | 726 | }); |
728 | | - |
729 | | -describe("isValidSignedContextV2", () => { |
730 | | - it("returns true for valid SignedContextV2 object", () => { |
731 | | - const valid = { |
732 | | - signer: "0x1234567890abcdef", |
733 | | - context: ["0x01", "0x02"], |
734 | | - signature: "0xabcdef", |
735 | | - }; |
736 | | - expect(isValidSignedContextV2(valid)).toBe(true); |
737 | | - }); |
738 | | - |
739 | | - it("returns true for valid object with empty context array", () => { |
740 | | - const valid = { |
741 | | - signer: "0x1234", |
742 | | - context: [], |
743 | | - signature: "0xsig", |
744 | | - }; |
745 | | - expect(isValidSignedContextV2(valid)).toBe(true); |
746 | | - }); |
747 | | - |
748 | | - it("returns false for null", () => { |
749 | | - expect(isValidSignedContextV2(null)).toBe(false); |
750 | | - }); |
751 | | - |
752 | | - it("returns false for undefined", () => { |
753 | | - expect(isValidSignedContextV2(undefined)).toBe(false); |
754 | | - }); |
755 | | - |
756 | | - it("returns false for non-object types", () => { |
757 | | - expect(isValidSignedContextV2("string")).toBe(false); |
758 | | - expect(isValidSignedContextV2(123)).toBe(false); |
759 | | - expect(isValidSignedContextV2(true)).toBe(false); |
760 | | - }); |
761 | | - |
762 | | - it("returns false when signer is missing", () => { |
763 | | - const invalid = { |
764 | | - context: ["0x01"], |
765 | | - signature: "0xsig", |
766 | | - }; |
767 | | - expect(isValidSignedContextV2(invalid)).toBe(false); |
768 | | - }); |
769 | | - |
770 | | - it("returns false when signer is not a string", () => { |
771 | | - const invalid = { |
772 | | - signer: 12345, |
773 | | - context: ["0x01"], |
774 | | - signature: "0xsig", |
775 | | - }; |
776 | | - expect(isValidSignedContextV2(invalid)).toBe(false); |
777 | | - }); |
778 | | - |
779 | | - it("returns false when context is missing", () => { |
780 | | - const invalid = { |
781 | | - signer: "0x1234", |
782 | | - signature: "0xsig", |
783 | | - }; |
784 | | - expect(isValidSignedContextV2(invalid)).toBe(false); |
785 | | - }); |
786 | | - |
787 | | - it("returns false when context is not an array", () => { |
788 | | - const invalid = { |
789 | | - signer: "0x1234", |
790 | | - context: "not-an-array", |
791 | | - signature: "0xsig", |
792 | | - }; |
793 | | - expect(isValidSignedContextV2(invalid)).toBe(false); |
794 | | - }); |
795 | | - |
796 | | - it("returns false when signature is missing", () => { |
797 | | - const invalid = { |
798 | | - signer: "0x1234", |
799 | | - context: ["0x01"], |
800 | | - }; |
801 | | - expect(isValidSignedContextV2(invalid)).toBe(false); |
802 | | - }); |
803 | | - |
804 | | - it("returns false when signature is not a string", () => { |
805 | | - const invalid = { |
806 | | - signer: "0x1234", |
807 | | - context: ["0x01"], |
808 | | - signature: 12345, |
809 | | - }; |
810 | | - expect(isValidSignedContextV2(invalid)).toBe(false); |
811 | | - }); |
812 | | - |
813 | | - it("returns true when extra properties are present", () => { |
814 | | - const valid = { |
815 | | - signer: "0x1234", |
816 | | - context: ["0x01"], |
817 | | - signature: "0xsig", |
818 | | - extraField: "extra", |
819 | | - }; |
820 | | - expect(isValidSignedContextV2(valid)).toBe(true); |
821 | | - }); |
822 | | - |
823 | | - it("returns false for empty object", () => { |
824 | | - expect(isValidSignedContextV2({})).toBe(false); |
825 | | - }); |
826 | | - |
827 | | - it("returns false for array", () => { |
828 | | - expect(isValidSignedContextV2([])).toBe(false); |
829 | | - }); |
830 | | -}); |
0 commit comments