diff --git a/.github/workflows/pr-momoka-node.yml b/.github/workflows/pr-momoka-node.yml new file mode 100644 index 0000000..f7fa6ec --- /dev/null +++ b/.github/workflows/pr-momoka-node.yml @@ -0,0 +1,32 @@ +name: Build, Lint and Unit Tests for Momoka NODE + +on: + pull_request: + types: [labeled, opened, synchronize, unlabeled] + # Run only when some modifications are perform in the momoka-node directory + paths: + - 'momoka-node/**' + +jobs: + build-lint-test: + name: Build-Lint-Test + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - uses: pnpm/action-setup@v2 + with: + version: 8 + + - name: Install dependencies + run: cd momoka-node && pnpm install + + - name: Lint the code + run: cd momoka-node && pnpm run lint + + - name: Build the packages + run: cd momoka-node && pnpm run build + + - name: Run the unit tests + run: cd momoka-node && pnpm run test:ci diff --git a/.github/workflows/pr-momoka-rs.yml b/.github/workflows/pr-momoka-rs.yml new file mode 100644 index 0000000..6c0eb76 --- /dev/null +++ b/.github/workflows/pr-momoka-rs.yml @@ -0,0 +1,22 @@ +name: Build, Lint and Unit Tests for Momoka RUST + +on: + pull_request: + types: [labeled, opened, synchronize, unlabeled] + # Run only when some modifications are perform in the momoka-rs directory + paths: + - 'momoka-rs/**' + +jobs: + build-lint-test: + name: Build-Lint-Test + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Build + run: cd momoka-rs && cargo build + + - name: Run the unit tests + run: cd momoka-rs && cargo test diff --git a/momoka-node/.env.ci b/momoka-node/.env.ci new file mode 100644 index 0000000..de4777f --- /dev/null +++ b/momoka-node/.env.ci @@ -0,0 +1,3 @@ +ETHEREUM_NETWORK=MUMBAI +NODE_URL="https://polygon-mumbai.g.alchemy.com/v2/s1Hq6Tyswh1mDXOlgawIqSCndvsNfYb6" +CONCURRENCY=3 diff --git a/momoka-node/jest.config.js b/momoka-node/jest.config.js index ecfc5bd..29dee2c 100644 --- a/momoka-node/jest.config.js +++ b/momoka-node/jest.config.js @@ -1,9 +1,11 @@ /** @type {import('ts-jest').JestConfigWithTsJest} */ +const { resolve } = require('path'); + module.exports = { preset: 'ts-jest', testEnvironment: 'node', - collectCoverage: true, coverageDirectory: 'coverage', + testRegex: [resolve(__dirname, '/src/__TESTS__/*/.*\\.test\\.ts$')], setupFiles: ['/src/__TESTS__/config/jest.setup.js'], coveragePathIgnorePatterns: [ 'node_modules', diff --git a/momoka-node/package.json b/momoka-node/package.json index 3344d80..7a93021 100644 --- a/momoka-node/package.json +++ b/momoka-node/package.json @@ -16,15 +16,16 @@ "README.md" ], "scripts": { - "build": "tsc", + "build": "rm -rf lib/ && tsc", "eslint:fix": "eslint \"src/**/*.ts\" --quiet --fix", "eslint": "eslint \"src/**/*.ts\" --quiet", "start:fork": "REQ_TIMEOUT=100000 anvil --fork-url NODE_URL --silent", "start": "env-cmd -f .env node lib/runnable/da-verifier-node.runnable.js", "start:failed": "env-cmd -f .env ts-node src/failed-submissons.runnable.ts", - "debug:playground": "npm run build && env-cmd -f .env node lib/__PLAYGROUND__/index.js", + "debug:playground": "pnpm run build && env-cmd -f .env node lib/__PLAYGROUND__/index.js", "generate": "graphql-codegen", - "test": "npm run build && env-cmd -f .env.test jest", + "test": "env-cmd -f .env.test jest --forceExit --coverage", + "test:ci": "env-cmd -f .env.ci jest --forceExit", "lint": "pnpm run prettier && pnpm run tsc", "lint:fix": "pnpm run prettier:fix && pnpm run eslint", "prettier:fix": "prettier --write .", diff --git a/momoka-node/src/__TESTS__/comment.e2e.test.ts b/momoka-node/src/__TESTS__/comment.e2e.test.ts index 14bf3bb..81a848f 100644 --- a/momoka-node/src/__TESTS__/comment.e2e.test.ts +++ b/momoka-node/src/__TESTS__/comment.e2e.test.ts @@ -1,5 +1,4 @@ // apply mocks! -jest.setTimeout(3000); jest.mock('../input-output/db'); jest.mock('../input-output/bundlr/get-bundlr-by-id.api'); jest.mock('../submitters'); @@ -16,7 +15,7 @@ describe('comment', () => { describe('with delegate', () => { let baseMock = commentCreatedDelegateArweaveResponse; - beforeEach(() => { + beforeAll(() => { baseMock = commentCreatedDelegateArweaveResponse; sharedMocks.mockGetDAPublicationByIdAPI.mockImplementation(async () => deepClone(commentCreatedDelegateArweaveResponse) @@ -24,7 +23,7 @@ describe('comment', () => { }); describe('should return success when', () => { - test('signed by delegate is true', async () => { + test('signed by delegate is true', () => { expect(baseMock.chainProofs.thisPublication.signedByDelegate).toBe(true); }); @@ -43,13 +42,11 @@ describe('comment', () => { describe('should return failure when', () => { test('NO_SIGNATURE_SUBMITTER', async () => { sharedMocks.mockImpl__NO_SIGNATURE_SUBMITTER(baseMock); - await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.NO_SIGNATURE_SUBMITTER); }); xtest('INVALID_SIGNATURE_SUBMITTER', async () => { sharedMocks.mockIsValidSubmitter.mockImplementationOnce(() => false); - await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.INVALID_SIGNATURE_SUBMITTER); }); @@ -116,11 +113,12 @@ describe('comment', () => { await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.PUBLICATION_NONCE_INVALID); }); - xtest('PUBLICATION_SIGNER_NOT_ALLOWED', async () => {}); + xtest('PUBLICATION_SIGNER_NOT_ALLOWED', () => { + // TODO: implement + }); test('INVALID_FORMATTED_TYPED_DATA', async () => { sharedMocks.mockImpl__INVALID_FORMATTED_TYPED_DATA(baseMock); - await sharedMocks.checkAndValidateDAProof( MomokaValidatorError.INVALID_FORMATTED_TYPED_DATA ); @@ -252,16 +250,20 @@ describe('comment', () => { await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.EVENT_MISMATCH); }); - xtest('SIMULATION_NODE_COULD_NOT_RUN', async () => {}); + xtest('SIMULATION_NODE_COULD_NOT_RUN', () => { + // TODO: implement + }); - xtest('UNKNOWN', () => {}); + xtest('UNKNOWN', () => { + // TODO: implement + }); }); }); describe('without delegate', () => { let baseMock = commentCreatedWithoutDelegateArweaveResponse; - beforeEach(() => { + beforeAll(() => { baseMock = commentCreatedWithoutDelegateArweaveResponse; sharedMocks.mockGetDAPublicationByIdAPI.mockImplementation(async () => deepClone(commentCreatedWithoutDelegateArweaveResponse) @@ -269,12 +271,12 @@ describe('comment', () => { }); describe('should return success when', () => { - test('signed by delegate is false', async () => { + test('signed by delegate is false', () => { expect(baseMock.chainProofs.thisPublication.signedByDelegate).toBe(false); }); test('txExists in the db already', async () => { - sharedMocks.mockGetTxDb.mockImplementationOnce(async () => mockTxValidationResult); + sharedMocks.mockGetTxDb.mockImplementationOnce(async () => await mockTxValidationResult); const result = await sharedMocks.callCheckDAProof(); expect(result.isSuccess()).toBe(true); }); @@ -361,11 +363,12 @@ describe('comment', () => { await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.PUBLICATION_NONCE_INVALID); }); - xtest('PUBLICATION_SIGNER_NOT_ALLOWED', async () => {}); + xtest('PUBLICATION_SIGNER_NOT_ALLOWED', async () => { + // TODO: implement + }); test('INVALID_FORMATTED_TYPED_DATA', async () => { sharedMocks.mockImpl__INVALID_FORMATTED_TYPED_DATA(baseMock); - await sharedMocks.checkAndValidateDAProof( MomokaValidatorError.INVALID_FORMATTED_TYPED_DATA ); @@ -381,7 +384,6 @@ describe('comment', () => { }, }; }); - await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.EVENT_MISMATCH); }); @@ -395,7 +397,6 @@ describe('comment', () => { }, }; }); - await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.EVENT_MISMATCH); }); @@ -497,9 +498,13 @@ describe('comment', () => { await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.EVENT_MISMATCH); }); - xtest('SIMULATION_NODE_COULD_NOT_RUN', async () => {}); + xtest('SIMULATION_NODE_COULD_NOT_RUN', () => { + // TODO: implement + }); - xtest('UNKNOWN', () => {}); + xtest('UNKNOWN', () => { + // TODO: implement + }); }); }); }); diff --git a/momoka-node/src/__TESTS__/config/jest.setup.js b/momoka-node/src/__TESTS__/config/jest.setup.js index d91b50f..9e0f0c0 100644 --- a/momoka-node/src/__TESTS__/config/jest.setup.js +++ b/momoka-node/src/__TESTS__/config/jest.setup.js @@ -7,4 +7,4 @@ Object.defineProperty(globalThis, 'crypto', { }); // eslint-disable-next-line no-undef -jest.setTimeout(15000); +jest.setTimeout(30000); diff --git a/momoka-node/src/__TESTS__/mirror.e2e.test.ts b/momoka-node/src/__TESTS__/mirror.e2e.test.ts deleted file mode 100644 index 7153edb..0000000 --- a/momoka-node/src/__TESTS__/mirror.e2e.test.ts +++ /dev/null @@ -1,849 +0,0 @@ -// apply mocks! -jest.setTimeout(30000); -jest.mock('../input-output/db'); -jest.mock('../input-output/bundlr/get-bundlr-by-id.api'); -jest.mock('../submitters'); - -import { MomokaValidatorError } from '..'; -import { deepClone } from '../common/helpers'; -import { DAPublicationPointerType } from '../data-availability-models/publications/data-availability-structure-publication'; -import { mirrorCreatedDelegateCommentArweaveResponse } from './mocks/mirror/mirror-created-delegate-comment-arweave-response.mock'; -import { mirrorCreatedDelegatePostArweaveResponse } from './mocks/mirror/mirror-created-delegate-post-arweave-response.mock'; -import { mirrorCreatedWithoutDelegateCommentArweaveResponse } from './mocks/mirror/mirror-created-without-delegate-comment-arweave-response.mock'; -import { mirrorCreatedWithoutDelegatePostArweaveResponse } from './mocks/mirror/mirror-created-without-delegate-post-arweave-response.mock'; -import * as sharedMocks from './mocks/shared.mock'; -import { mockTxValidationResult } from './mocks/shared.mock'; - -describe('mirror', () => { - describe('post', () => { - describe('with delegate', () => { - let baseMock = mirrorCreatedDelegatePostArweaveResponse; - - beforeEach(() => { - baseMock = mirrorCreatedDelegatePostArweaveResponse; - sharedMocks.mockGetDAPublicationByIdAPI.mockImplementation(async () => - deepClone(mirrorCreatedDelegatePostArweaveResponse) - ); - }); - - describe('should return success when', () => { - test('signed by delegate is true', () => { - expect(baseMock.chainProofs.thisPublication.signedByDelegate).toBe(true); - }); - - test('txExists in the db already', async () => { - sharedMocks.mockGetTxDb.mockImplementationOnce(async () => mockTxValidationResult); - const result = await sharedMocks.callCheckDAProof(); - expect(result.isSuccess()).toBe(true); - }); - - test('tx is valid and passes all the simulation checks', async () => { - sharedMocks.mockIsValidSubmitter.mockImplementationOnce(() => true); - const result = await sharedMocks.callCheckDAProof(); - expect(result.isSuccess()).toBe(true); - }); - }); - - describe('should return failure when', () => { - test('NO_SIGNATURE_SUBMITTER', async () => { - sharedMocks.mockImpl__NO_SIGNATURE_SUBMITTER(baseMock); - await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.NO_SIGNATURE_SUBMITTER); - }); - - xtest('INVALID_SIGNATURE_SUBMITTER', async () => { - sharedMocks.mockIsValidSubmitter.mockImplementationOnce(() => false); - - await sharedMocks.checkAndValidateDAProof( - MomokaValidatorError.INVALID_SIGNATURE_SUBMITTER - ); - }); - - test('TIMESTAMP_PROOF_INVALID_SIGNATURE', async () => { - sharedMocks.mockImpl__TIMESTAMP_PROOF_INVALID_SIGNATURE(baseMock); - - await sharedMocks.checkAndValidateDAProof( - MomokaValidatorError.TIMESTAMP_PROOF_INVALID_SIGNATURE - ); - }); - - test('TIMESTAMP_PROOF_NOT_SUBMITTER', async () => { - sharedMocks.mockImpl__TIMESTAMP_PROOF_NOT_SUBMITTER(); - - await sharedMocks.checkAndValidateDAProof( - MomokaValidatorError.TIMESTAMP_PROOF_NOT_SUBMITTER - ); - }); - - test('INVALID_EVENT_TIMESTAMP', async () => { - sharedMocks.mockImpl__INVALID_EVENT_TIMESTAMP(baseMock); - - await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.INVALID_EVENT_TIMESTAMP); - }); - - xtest('NOT_CLOSEST_BLOCK', async () => { - await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.NOT_CLOSEST_BLOCK); - }); - - test('PUBLICATION_NO_POINTER', async () => { - sharedMocks.mockImpl__INVALID_POINTER_SET(baseMock, null); - - await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.PUBLICATION_NO_POINTER); - }); - - test('PUBLICATION_NONE_DA', async () => { - sharedMocks.mockImpl__INVALID_POINTER_SET(baseMock, { - type: DAPublicationPointerType.ON_EVM_CHAIN, - }); - - await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.PUBLICATION_NONE_DA); - }); - - test('PUBLICATION_NONCE_INVALID', async () => { - sharedMocks.mockGetDAPublicationByIdAPI.mockImplementationOnce(async () => { - return { - ...baseMock, - chainProofs: { - ...baseMock.chainProofs, - thisPublication: { - ...baseMock.chainProofs.thisPublication, - typedData: { - ...baseMock.chainProofs.thisPublication.typedData, - value: { - ...baseMock.chainProofs.thisPublication.typedData.value, - nonce: 13234452346523, - }, - }, - }, - }, - }; - }); - - await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.PUBLICATION_NONCE_INVALID); - }); - - xtest('PUBLICATION_SIGNER_NOT_ALLOWED', async () => {}); - - test('INVALID_FORMATTED_TYPED_DATA', async () => { - sharedMocks.mockImpl__INVALID_FORMATTED_TYPED_DATA(baseMock); - - await sharedMocks.checkAndValidateDAProof( - MomokaValidatorError.INVALID_FORMATTED_TYPED_DATA - ); - }); - - test('EVENT_MISMATCH - pub id does not match simulated result', async () => { - sharedMocks.mockGetDAPublicationByIdAPI.mockImplementationOnce(async () => { - return await { - ...baseMock, - event: { - ...baseMock.event, - pubId: '0x000000000000002', - }, - }; - }); - - await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.EVENT_MISMATCH); - }); - - test('EVENT_MISMATCH - profile id does not match typed data', async () => { - sharedMocks.mockGetDAPublicationByIdAPI.mockImplementationOnce(async () => { - return { - ...baseMock, - event: { - ...baseMock.event, - profileId: '0x02', - }, - }; - }); - - await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.EVENT_MISMATCH); - }); - - test('EVENT_MISMATCH - profileIdPointed does not match typed data', async () => { - sharedMocks.mockGetDAPublicationByIdAPI.mockImplementationOnce(async () => { - return { - ...baseMock, - event: { - ...baseMock.event, - profileIdPointed: '0x01', - }, - }; - }); - - await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.EVENT_MISMATCH); - }); - - test('EVENT_MISMATCH - pubIdPointed does not match typed data', async () => { - sharedMocks.mockGetDAPublicationByIdAPI.mockImplementationOnce(async () => { - return { - ...baseMock, - event: { - ...baseMock.event, - pubIdPointed: '0x01', - }, - }; - }); - - await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.EVENT_MISMATCH); - }); - - test('EVENT_MISMATCH - referenceModule does not match typed data', async () => { - sharedMocks.mockGetDAPublicationByIdAPI.mockImplementationOnce(async () => { - return { - ...baseMock, - event: { - ...baseMock.event, - referenceModule: '0x0000000000000000000000000000000000001', - }, - }; - }); - - await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.EVENT_MISMATCH); - }); - - test('EVENT_MISMATCH - referenceModuleReturnData is not empty bytes', async () => { - sharedMocks.mockGetDAPublicationByIdAPI.mockImplementationOnce(async () => { - return { - ...baseMock, - event: { - ...baseMock.event, - referenceModuleReturnData: 'not_empty_bytes', - }, - }; - }); - - await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.EVENT_MISMATCH); - }); - - xtest('SIMULATION_NODE_COULD_NOT_RUN', async () => {}); - - xtest('INVALID_POINTER_SET_NOT_NEEDED', () => {}); - - xtest('UNKNOWN', () => {}); - }); - }); - - describe('without delegate', () => { - let baseMock = mirrorCreatedWithoutDelegatePostArweaveResponse; - - beforeEach(() => { - baseMock = mirrorCreatedWithoutDelegatePostArweaveResponse; - sharedMocks.mockGetDAPublicationByIdAPI.mockImplementation(async () => - deepClone(mirrorCreatedWithoutDelegatePostArweaveResponse) - ); - }); - - describe('should return success when', () => { - test('signed by delegate is false', async () => { - expect(baseMock.chainProofs.thisPublication.signedByDelegate).toBe(false); - }); - - test('txExists in the db already', async () => { - sharedMocks.mockGetTxDb.mockImplementationOnce(async () => mockTxValidationResult); - const result = await sharedMocks.callCheckDAProof(); - expect(result.isSuccess()).toBe(true); - }); - - test('tx is valid and passes all the simulation checks', async () => { - const result = await sharedMocks.callCheckDAProof(); - expect(result.isSuccess()).toBe(true); - }); - }); - - describe('should return failure when', () => { - test('NO_SIGNATURE_SUBMITTER', async () => { - sharedMocks.mockImpl__NO_SIGNATURE_SUBMITTER(baseMock); - - await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.NO_SIGNATURE_SUBMITTER); - }); - - xtest('INVALID_SIGNATURE_SUBMITTER', async () => { - sharedMocks.mockIsValidSubmitter.mockImplementationOnce(() => false); - - await sharedMocks.checkAndValidateDAProof( - MomokaValidatorError.INVALID_SIGNATURE_SUBMITTER - ); - }); - - test('TIMESTAMP_PROOF_INVALID_SIGNATURE', async () => { - sharedMocks.mockImpl__TIMESTAMP_PROOF_INVALID_SIGNATURE(baseMock); - - await sharedMocks.checkAndValidateDAProof( - MomokaValidatorError.TIMESTAMP_PROOF_INVALID_SIGNATURE - ); - }); - - test('TIMESTAMP_PROOF_NOT_SUBMITTER', async () => { - sharedMocks.mockImpl__TIMESTAMP_PROOF_NOT_SUBMITTER(); - - await sharedMocks.checkAndValidateDAProof( - MomokaValidatorError.TIMESTAMP_PROOF_NOT_SUBMITTER - ); - }); - - test('INVALID_EVENT_TIMESTAMP', async () => { - sharedMocks.mockImpl__INVALID_EVENT_TIMESTAMP(baseMock); - - await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.INVALID_EVENT_TIMESTAMP); - }); - - xtest('NOT_CLOSEST_BLOCK', async () => { - await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.NOT_CLOSEST_BLOCK); - }); - - test('PUBLICATION_NO_POINTER', async () => { - sharedMocks.mockImpl__INVALID_POINTER_SET(baseMock, null); - - await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.PUBLICATION_NO_POINTER); - }); - - test('PUBLICATION_NONE_DA', async () => { - sharedMocks.mockImpl__INVALID_POINTER_SET(baseMock, { - type: DAPublicationPointerType.ON_EVM_CHAIN, - }); - - await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.PUBLICATION_NONE_DA); - }); - - test('PUBLICATION_NONCE_INVALID', async () => { - sharedMocks.mockGetDAPublicationByIdAPI.mockImplementationOnce(async () => { - return { - ...baseMock, - chainProofs: { - ...baseMock.chainProofs, - thisPublication: { - ...baseMock.chainProofs.thisPublication, - typedData: { - ...baseMock.chainProofs.thisPublication.typedData, - value: { - ...baseMock.chainProofs.thisPublication.typedData.value, - nonce: 13234452346523, - }, - }, - }, - }, - }; - }); - - await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.PUBLICATION_NONCE_INVALID); - }); - - xtest('PUBLICATION_SIGNER_NOT_ALLOWED', async () => {}); - - test('INVALID_FORMATTED_TYPED_DATA', async () => { - sharedMocks.mockImpl__INVALID_FORMATTED_TYPED_DATA(baseMock); - - await sharedMocks.checkAndValidateDAProof( - MomokaValidatorError.INVALID_FORMATTED_TYPED_DATA - ); - }); - - test('EVENT_MISMATCH - pub id does not match simulated result', async () => { - sharedMocks.mockGetDAPublicationByIdAPI.mockImplementationOnce(async () => { - return { - ...baseMock, - event: { - ...baseMock.event, - pubId: '0x000000000000002', - }, - }; - }); - - await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.EVENT_MISMATCH); - }); - - test('EVENT_MISMATCH - profile id does not match typed data', async () => { - sharedMocks.mockGetDAPublicationByIdAPI.mockImplementationOnce(async () => { - return { - ...baseMock, - event: { - ...baseMock.event, - profileId: '0x02', - }, - }; - }); - - await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.EVENT_MISMATCH); - }); - - test('EVENT_MISMATCH - profileIdPointed does not match typed data', async () => { - sharedMocks.mockGetDAPublicationByIdAPI.mockImplementationOnce(async () => { - return { - ...baseMock, - event: { - ...baseMock.event, - profileIdPointed: '0x01', - }, - }; - }); - - await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.EVENT_MISMATCH); - }); - - test('EVENT_MISMATCH - pubIdPointed does not match typed data', async () => { - sharedMocks.mockGetDAPublicationByIdAPI.mockImplementationOnce(async () => { - return { - ...baseMock, - event: { - ...baseMock.event, - pubIdPointed: '0x01', - }, - }; - }); - - await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.EVENT_MISMATCH); - }); - - test('EVENT_MISMATCH - referenceModule does not match typed data', async () => { - sharedMocks.mockGetDAPublicationByIdAPI.mockImplementationOnce(async () => { - return { - ...baseMock, - event: { - ...baseMock.event, - referenceModule: '0x0000000000000000000000000000000000001', - }, - }; - }); - - await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.EVENT_MISMATCH); - }); - - test('EVENT_MISMATCH - referenceModuleReturnData is not empty bytes', async () => { - sharedMocks.mockGetDAPublicationByIdAPI.mockImplementationOnce(async () => { - return { - ...baseMock, - event: { - ...baseMock.event, - referenceModuleReturnData: 'not_empty_bytes', - }, - }; - }); - - await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.EVENT_MISMATCH); - }); - - xtest('SIMULATION_NODE_COULD_NOT_RUN', async () => {}); - - xtest('INVALID_POINTER_SET_NOT_NEEDED', () => {}); - - xtest('UNKNOWN', () => {}); - }); - }); - }); - - describe('comment', () => { - describe('with delegate', () => { - let baseMock = mirrorCreatedDelegateCommentArweaveResponse; - - beforeEach(() => { - baseMock = mirrorCreatedDelegateCommentArweaveResponse; - sharedMocks.mockGetDAPublicationByIdAPI.mockImplementation(async () => - deepClone(mirrorCreatedDelegateCommentArweaveResponse) - ); - }); - - describe('should return success when', () => { - test('signed by delegate is true', async () => { - expect(baseMock.chainProofs.thisPublication.signedByDelegate).toBe(true); - }); - - test('txExists in the db already', async () => { - sharedMocks.mockGetTxDb.mockImplementationOnce(async () => mockTxValidationResult); - const result = await sharedMocks.callCheckDAProof(); - expect(result.isSuccess()).toBe(true); - }); - - test('tx is valid and passes all the simulation checks', async () => { - const result = await sharedMocks.callCheckDAProof(); - expect(result.isSuccess()).toBe(true); - }); - }); - - describe('should return failure when', () => { - test('NO_SIGNATURE_SUBMITTER', async () => { - sharedMocks.mockImpl__NO_SIGNATURE_SUBMITTER(baseMock); - - await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.NO_SIGNATURE_SUBMITTER); - }); - - xtest('INVALID_SIGNATURE_SUBMITTER', async () => { - sharedMocks.mockIsValidSubmitter.mockImplementationOnce(() => false); - - await sharedMocks.checkAndValidateDAProof( - MomokaValidatorError.INVALID_SIGNATURE_SUBMITTER - ); - }); - - test('TIMESTAMP_PROOF_INVALID_SIGNATURE', async () => { - sharedMocks.mockImpl__TIMESTAMP_PROOF_INVALID_SIGNATURE(baseMock); - - await sharedMocks.checkAndValidateDAProof( - MomokaValidatorError.TIMESTAMP_PROOF_INVALID_SIGNATURE - ); - }); - - test('TIMESTAMP_PROOF_NOT_SUBMITTER', async () => { - sharedMocks.mockImpl__TIMESTAMP_PROOF_NOT_SUBMITTER(); - - await sharedMocks.checkAndValidateDAProof( - MomokaValidatorError.TIMESTAMP_PROOF_NOT_SUBMITTER - ); - }); - - test('INVALID_EVENT_TIMESTAMP', async () => { - sharedMocks.mockImpl__INVALID_EVENT_TIMESTAMP(baseMock); - - await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.INVALID_EVENT_TIMESTAMP); - }); - - xtest('NOT_CLOSEST_BLOCK', async () => { - await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.NOT_CLOSEST_BLOCK); - }); - - test('PUBLICATION_NO_POINTER', async () => { - sharedMocks.mockImpl__INVALID_POINTER_SET(baseMock, null); - - await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.PUBLICATION_NO_POINTER); - }); - - test('PUBLICATION_NONE_DA', async () => { - sharedMocks.mockImpl__INVALID_POINTER_SET(baseMock, { - type: DAPublicationPointerType.ON_EVM_CHAIN, - }); - - await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.PUBLICATION_NONE_DA); - }); - - test('PUBLICATION_NONCE_INVALID', async () => { - sharedMocks.mockGetDAPublicationByIdAPI.mockImplementationOnce(async () => { - return { - ...baseMock, - chainProofs: { - ...baseMock.chainProofs, - thisPublication: { - ...baseMock.chainProofs.thisPublication, - typedData: { - ...baseMock.chainProofs.thisPublication.typedData, - value: { - ...baseMock.chainProofs.thisPublication.typedData.value, - nonce: 13234452346523, - }, - }, - }, - }, - }; - }); - - await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.PUBLICATION_NONCE_INVALID); - }); - - xtest('PUBLICATION_SIGNER_NOT_ALLOWED', async () => {}); - - test('INVALID_FORMATTED_TYPED_DATA', async () => { - sharedMocks.mockImpl__INVALID_FORMATTED_TYPED_DATA(baseMock); - - await sharedMocks.checkAndValidateDAProof( - MomokaValidatorError.INVALID_FORMATTED_TYPED_DATA - ); - }); - - test('EVENT_MISMATCH - pub id does not match simulated result', async () => { - sharedMocks.mockGetDAPublicationByIdAPI.mockImplementationOnce(async () => { - return { - ...baseMock, - event: { - ...baseMock.event, - pubId: '0x000000000000002', - }, - }; - }); - - await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.EVENT_MISMATCH); - }); - - test('EVENT_MISMATCH - profile id does not match typed data', async () => { - sharedMocks.mockGetDAPublicationByIdAPI.mockImplementationOnce(async () => { - return { - ...baseMock, - event: { - ...baseMock.event, - profileId: '0x02', - }, - }; - }); - - await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.EVENT_MISMATCH); - }); - - test('EVENT_MISMATCH - profileIdPointed does not match typed data', async () => { - sharedMocks.mockGetDAPublicationByIdAPI.mockImplementationOnce(async () => { - return { - ...baseMock, - event: { - ...baseMock.event, - profileIdPointed: '0x01', - }, - }; - }); - - await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.EVENT_MISMATCH); - }); - - test('EVENT_MISMATCH - pubIdPointed does not match typed data', async () => { - sharedMocks.mockGetDAPublicationByIdAPI.mockImplementationOnce(async () => { - return { - ...baseMock, - event: { - ...baseMock.event, - pubIdPointed: '0x01', - }, - }; - }); - - await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.EVENT_MISMATCH); - }); - - test('EVENT_MISMATCH - referenceModule does not match typed data', async () => { - sharedMocks.mockGetDAPublicationByIdAPI.mockImplementationOnce(async () => { - return { - ...baseMock, - event: { - ...baseMock.event, - referenceModule: '0x0000000000000000000000000000000000001', - }, - }; - }); - - await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.EVENT_MISMATCH); - }); - - test('EVENT_MISMATCH - referenceModuleReturnData is not empty bytes', async () => { - sharedMocks.mockGetDAPublicationByIdAPI.mockImplementationOnce(async () => { - return { - ...baseMock, - event: { - ...baseMock.event, - referenceModuleReturnData: 'not_empty_bytes', - }, - }; - }); - - await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.EVENT_MISMATCH); - }); - - xtest('SIMULATION_NODE_COULD_NOT_RUN', async () => {}); - - xtest('INVALID_POINTER_SET_NOT_NEEDED', () => {}); - - xtest('UNKNOWN', () => {}); - }); - }); - - describe('without delegate', () => { - let baseMock = mirrorCreatedWithoutDelegateCommentArweaveResponse; - - beforeEach(() => { - baseMock = mirrorCreatedWithoutDelegateCommentArweaveResponse; - sharedMocks.mockGetDAPublicationByIdAPI.mockImplementation(async () => - deepClone(mirrorCreatedWithoutDelegateCommentArweaveResponse) - ); - }); - - describe('should return success when', () => { - test('signed by delegate is false', async () => { - expect(baseMock.chainProofs.thisPublication.signedByDelegate).toBe(false); - }); - - test('txExists in the db already', async () => { - sharedMocks.mockGetTxDb.mockImplementationOnce(async () => mockTxValidationResult); - const result = await sharedMocks.callCheckDAProof(); - expect(result.isSuccess()).toBe(true); - }); - - test('tx is valid and passes all the simulation checks', async () => { - const result = await sharedMocks.callCheckDAProof(); - expect(result.isSuccess()).toBe(true); - }); - }); - - describe('should return failure when', () => { - test('NO_SIGNATURE_SUBMITTER', async () => { - sharedMocks.mockImpl__NO_SIGNATURE_SUBMITTER(baseMock); - - await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.NO_SIGNATURE_SUBMITTER); - }); - - xtest('INVALID_SIGNATURE_SUBMITTER', async () => { - sharedMocks.mockIsValidSubmitter.mockImplementationOnce(() => false); - - await sharedMocks.checkAndValidateDAProof( - MomokaValidatorError.INVALID_SIGNATURE_SUBMITTER - ); - }); - - test('TIMESTAMP_PROOF_INVALID_SIGNATURE', async () => { - sharedMocks.mockImpl__TIMESTAMP_PROOF_INVALID_SIGNATURE(baseMock); - - await sharedMocks.checkAndValidateDAProof( - MomokaValidatorError.TIMESTAMP_PROOF_INVALID_SIGNATURE - ); - }); - - test('TIMESTAMP_PROOF_NOT_SUBMITTER', async () => { - sharedMocks.mockImpl__TIMESTAMP_PROOF_NOT_SUBMITTER(); - - await sharedMocks.checkAndValidateDAProof( - MomokaValidatorError.TIMESTAMP_PROOF_NOT_SUBMITTER - ); - }); - - test('INVALID_EVENT_TIMESTAMP', async () => { - sharedMocks.mockImpl__INVALID_EVENT_TIMESTAMP(baseMock); - - await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.INVALID_EVENT_TIMESTAMP); - }); - - xtest('NOT_CLOSEST_BLOCK', async () => { - await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.NOT_CLOSEST_BLOCK); - }); - - test('PUBLICATION_NO_POINTER', async () => { - sharedMocks.mockImpl__INVALID_POINTER_SET(baseMock, null); - - await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.PUBLICATION_NO_POINTER); - }); - - test('PUBLICATION_NONE_DA', async () => { - sharedMocks.mockImpl__INVALID_POINTER_SET(baseMock, { - type: DAPublicationPointerType.ON_EVM_CHAIN, - }); - - await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.PUBLICATION_NONE_DA); - }); - - test('PUBLICATION_NONCE_INVALID', async () => { - sharedMocks.mockGetDAPublicationByIdAPI.mockImplementationOnce(async () => { - return { - ...baseMock, - chainProofs: { - ...baseMock.chainProofs, - thisPublication: { - ...baseMock.chainProofs.thisPublication, - typedData: { - ...baseMock.chainProofs.thisPublication.typedData, - value: { - ...baseMock.chainProofs.thisPublication.typedData.value, - nonce: 13234452346523, - }, - }, - }, - }, - }; - }); - - await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.PUBLICATION_NONCE_INVALID); - }); - - xtest('PUBLICATION_SIGNER_NOT_ALLOWED', async () => {}); - - test('INVALID_FORMATTED_TYPED_DATA', async () => { - sharedMocks.mockImpl__INVALID_FORMATTED_TYPED_DATA(baseMock); - - await sharedMocks.checkAndValidateDAProof( - MomokaValidatorError.INVALID_FORMATTED_TYPED_DATA - ); - }); - - test('EVENT_MISMATCH - pub id does not match simulated result', async () => { - sharedMocks.mockGetDAPublicationByIdAPI.mockImplementationOnce(async () => { - return { - ...baseMock, - event: { - ...baseMock.event, - pubId: '0x000000000000002', - }, - }; - }); - - await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.EVENT_MISMATCH); - }); - - test('EVENT_MISMATCH - profile id does not match typed data', async () => { - sharedMocks.mockGetDAPublicationByIdAPI.mockImplementationOnce(async () => { - return { - ...baseMock, - event: { - ...baseMock.event, - profileId: '0x02', - }, - }; - }); - - await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.EVENT_MISMATCH); - }); - - test('EVENT_MISMATCH - profileIdPointed does not match typed data', async () => { - sharedMocks.mockGetDAPublicationByIdAPI.mockImplementationOnce(async () => { - return { - ...baseMock, - event: { - ...baseMock.event, - profileIdPointed: '0x01', - }, - }; - }); - - await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.EVENT_MISMATCH); - }); - - test('EVENT_MISMATCH - pubIdPointed does not match typed data', async () => { - sharedMocks.mockGetDAPublicationByIdAPI.mockImplementationOnce(async () => { - return { - ...baseMock, - event: { - ...baseMock.event, - pubIdPointed: '0x01', - }, - }; - }); - - await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.EVENT_MISMATCH); - }); - - test('EVENT_MISMATCH - referenceModule does not match typed data', async () => { - sharedMocks.mockGetDAPublicationByIdAPI.mockImplementationOnce(async () => { - return { - ...baseMock, - event: { - ...baseMock.event, - referenceModule: '0x0000000000000000000000000000000000001', - }, - }; - }); - - await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.EVENT_MISMATCH); - }); - - test('EVENT_MISMATCH - referenceModuleReturnData is not empty bytes', async () => { - sharedMocks.mockGetDAPublicationByIdAPI.mockImplementationOnce(async () => { - return { - ...baseMock, - event: { - ...baseMock.event, - referenceModuleReturnData: 'not_empty_bytes', - }, - }; - }); - - await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.EVENT_MISMATCH); - }); - - xtest('SIMULATION_NODE_COULD_NOT_RUN', async () => {}); - - xtest('INVALID_POINTER_SET_NOT_NEEDED', () => {}); - - xtest('UNKNOWN', () => {}); - }); - }); - }); -}); diff --git a/momoka-node/src/__TESTS__/mirrorComment.e2e.test.ts b/momoka-node/src/__TESTS__/mirrorComment.e2e.test.ts new file mode 100644 index 0000000..19fc552 --- /dev/null +++ b/momoka-node/src/__TESTS__/mirrorComment.e2e.test.ts @@ -0,0 +1,424 @@ +// apply mocks! +jest.mock('../input-output/db'); +jest.mock('../input-output/bundlr/get-bundlr-by-id.api'); +jest.mock('../submitters'); + +import { MomokaValidatorError } from '..'; +import { deepClone } from '../common/helpers'; +import { DAPublicationPointerType } from '../data-availability-models/publications/data-availability-structure-publication'; +import { mirrorCreatedDelegateCommentArweaveResponse } from './mocks/mirror/mirror-created-delegate-comment-arweave-response.mock'; +import { mirrorCreatedWithoutDelegateCommentArweaveResponse } from './mocks/mirror/mirror-created-without-delegate-comment-arweave-response.mock'; +import * as sharedMocks from './mocks/shared.mock'; +import { mockTxValidationResult } from './mocks/shared.mock'; + +describe('mirror comment', () => { + describe('with delegate', () => { + let baseMock = mirrorCreatedDelegateCommentArweaveResponse; + + beforeAll(() => { + baseMock = mirrorCreatedDelegateCommentArweaveResponse; + sharedMocks.mockGetDAPublicationByIdAPI.mockImplementation(async () => + deepClone(mirrorCreatedDelegateCommentArweaveResponse) + ); + }); + + describe('should return success when', () => { + test('signed by delegate is true', async () => { + expect(baseMock.chainProofs.thisPublication.signedByDelegate).toBe(true); + }); + + test('txExists in the db already', async () => { + sharedMocks.mockGetTxDb.mockImplementationOnce(async () => mockTxValidationResult); + const result = await sharedMocks.callCheckDAProof(); + expect(result.isSuccess()).toBe(true); + }); + + test('tx is valid and passes all the simulation checks', async () => { + const result = await sharedMocks.callCheckDAProof(); + expect(result.isSuccess()).toBe(true); + }); + }); + + describe('should return failure when', () => { + test('NO_SIGNATURE_SUBMITTER', async () => { + sharedMocks.mockImpl__NO_SIGNATURE_SUBMITTER(baseMock); + + await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.NO_SIGNATURE_SUBMITTER); + }); + + xtest('INVALID_SIGNATURE_SUBMITTER', async () => { + sharedMocks.mockIsValidSubmitter.mockImplementationOnce(() => false); + + await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.INVALID_SIGNATURE_SUBMITTER); + }); + + test('TIMESTAMP_PROOF_INVALID_SIGNATURE', async () => { + sharedMocks.mockImpl__TIMESTAMP_PROOF_INVALID_SIGNATURE(baseMock); + + await sharedMocks.checkAndValidateDAProof( + MomokaValidatorError.TIMESTAMP_PROOF_INVALID_SIGNATURE + ); + }); + + test('TIMESTAMP_PROOF_NOT_SUBMITTER', async () => { + sharedMocks.mockImpl__TIMESTAMP_PROOF_NOT_SUBMITTER(); + + await sharedMocks.checkAndValidateDAProof( + MomokaValidatorError.TIMESTAMP_PROOF_NOT_SUBMITTER + ); + }); + + test('INVALID_EVENT_TIMESTAMP', async () => { + sharedMocks.mockImpl__INVALID_EVENT_TIMESTAMP(baseMock); + + await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.INVALID_EVENT_TIMESTAMP); + }); + + xtest('NOT_CLOSEST_BLOCK', async () => { + await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.NOT_CLOSEST_BLOCK); + }); + + test('PUBLICATION_NO_POINTER', async () => { + sharedMocks.mockImpl__INVALID_POINTER_SET(baseMock, null); + + await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.PUBLICATION_NO_POINTER); + }); + + test('PUBLICATION_NONE_DA', async () => { + sharedMocks.mockImpl__INVALID_POINTER_SET(baseMock, { + type: DAPublicationPointerType.ON_EVM_CHAIN, + }); + + await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.PUBLICATION_NONE_DA); + }); + + test('PUBLICATION_NONCE_INVALID', async () => { + sharedMocks.mockGetDAPublicationByIdAPI.mockImplementationOnce(async () => { + return { + ...baseMock, + chainProofs: { + ...baseMock.chainProofs, + thisPublication: { + ...baseMock.chainProofs.thisPublication, + typedData: { + ...baseMock.chainProofs.thisPublication.typedData, + value: { + ...baseMock.chainProofs.thisPublication.typedData.value, + nonce: 13234452346523, + }, + }, + }, + }, + }; + }); + + await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.PUBLICATION_NONCE_INVALID); + }); + + xtest('PUBLICATION_SIGNER_NOT_ALLOWED', async () => {}); + + test('INVALID_FORMATTED_TYPED_DATA', async () => { + sharedMocks.mockImpl__INVALID_FORMATTED_TYPED_DATA(baseMock); + + await sharedMocks.checkAndValidateDAProof( + MomokaValidatorError.INVALID_FORMATTED_TYPED_DATA + ); + }); + + test('EVENT_MISMATCH - pub id does not match simulated result', async () => { + sharedMocks.mockGetDAPublicationByIdAPI.mockImplementationOnce(async () => { + return { + ...baseMock, + event: { + ...baseMock.event, + pubId: '0x000000000000002', + }, + }; + }); + + await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.EVENT_MISMATCH); + }); + + test('EVENT_MISMATCH - profile id does not match typed data', async () => { + sharedMocks.mockGetDAPublicationByIdAPI.mockImplementationOnce(async () => { + return { + ...baseMock, + event: { + ...baseMock.event, + profileId: '0x02', + }, + }; + }); + + await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.EVENT_MISMATCH); + }); + + test('EVENT_MISMATCH - profileIdPointed does not match typed data', async () => { + sharedMocks.mockGetDAPublicationByIdAPI.mockImplementationOnce(async () => { + return { + ...baseMock, + event: { + ...baseMock.event, + profileIdPointed: '0x01', + }, + }; + }); + + await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.EVENT_MISMATCH); + }); + + test('EVENT_MISMATCH - pubIdPointed does not match typed data', async () => { + sharedMocks.mockGetDAPublicationByIdAPI.mockImplementationOnce(async () => { + return { + ...baseMock, + event: { + ...baseMock.event, + pubIdPointed: '0x01', + }, + }; + }); + + await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.EVENT_MISMATCH); + }); + + test('EVENT_MISMATCH - referenceModule does not match typed data', async () => { + sharedMocks.mockGetDAPublicationByIdAPI.mockImplementationOnce(async () => { + return { + ...baseMock, + event: { + ...baseMock.event, + referenceModule: '0x0000000000000000000000000000000000001', + }, + }; + }); + + await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.EVENT_MISMATCH); + }); + + test('EVENT_MISMATCH - referenceModuleReturnData is not empty bytes', async () => { + sharedMocks.mockGetDAPublicationByIdAPI.mockImplementationOnce(async () => { + return { + ...baseMock, + event: { + ...baseMock.event, + referenceModuleReturnData: 'not_empty_bytes', + }, + }; + }); + + await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.EVENT_MISMATCH); + }); + + xtest('SIMULATION_NODE_COULD_NOT_RUN', async () => {}); + + xtest('INVALID_POINTER_SET_NOT_NEEDED', () => {}); + + xtest('UNKNOWN', () => {}); + }); + }); + + describe('without delegate', () => { + let baseMock = mirrorCreatedWithoutDelegateCommentArweaveResponse; + + beforeAll(() => { + baseMock = mirrorCreatedWithoutDelegateCommentArweaveResponse; + sharedMocks.mockGetDAPublicationByIdAPI.mockImplementation(async () => + deepClone(mirrorCreatedWithoutDelegateCommentArweaveResponse) + ); + }); + + describe('should return success when', () => { + test('signed by delegate is false', async () => { + expect(baseMock.chainProofs.thisPublication.signedByDelegate).toBe(false); + }); + + test('txExists in the db already', async () => { + sharedMocks.mockGetTxDb.mockImplementationOnce(async () => mockTxValidationResult); + const result = await sharedMocks.callCheckDAProof(); + expect(result.isSuccess()).toBe(true); + }); + + test('tx is valid and passes all the simulation checks', async () => { + const result = await sharedMocks.callCheckDAProof(); + expect(result.isSuccess()).toBe(true); + }); + }); + + describe('should return failure when', () => { + test('NO_SIGNATURE_SUBMITTER', async () => { + sharedMocks.mockImpl__NO_SIGNATURE_SUBMITTER(baseMock); + + await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.NO_SIGNATURE_SUBMITTER); + }); + + xtest('INVALID_SIGNATURE_SUBMITTER', async () => { + sharedMocks.mockIsValidSubmitter.mockImplementationOnce(() => false); + + await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.INVALID_SIGNATURE_SUBMITTER); + }); + + test('TIMESTAMP_PROOF_INVALID_SIGNATURE', async () => { + sharedMocks.mockImpl__TIMESTAMP_PROOF_INVALID_SIGNATURE(baseMock); + + await sharedMocks.checkAndValidateDAProof( + MomokaValidatorError.TIMESTAMP_PROOF_INVALID_SIGNATURE + ); + }); + + test('TIMESTAMP_PROOF_NOT_SUBMITTER', async () => { + sharedMocks.mockImpl__TIMESTAMP_PROOF_NOT_SUBMITTER(); + + await sharedMocks.checkAndValidateDAProof( + MomokaValidatorError.TIMESTAMP_PROOF_NOT_SUBMITTER + ); + }); + + test('INVALID_EVENT_TIMESTAMP', async () => { + sharedMocks.mockImpl__INVALID_EVENT_TIMESTAMP(baseMock); + + await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.INVALID_EVENT_TIMESTAMP); + }); + + xtest('NOT_CLOSEST_BLOCK', async () => { + await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.NOT_CLOSEST_BLOCK); + }); + + test('PUBLICATION_NO_POINTER', async () => { + sharedMocks.mockImpl__INVALID_POINTER_SET(baseMock, null); + + await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.PUBLICATION_NO_POINTER); + }); + + test('PUBLICATION_NONE_DA', async () => { + sharedMocks.mockImpl__INVALID_POINTER_SET(baseMock, { + type: DAPublicationPointerType.ON_EVM_CHAIN, + }); + + await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.PUBLICATION_NONE_DA); + }); + + test('PUBLICATION_NONCE_INVALID', async () => { + sharedMocks.mockGetDAPublicationByIdAPI.mockImplementationOnce(async () => { + return { + ...baseMock, + chainProofs: { + ...baseMock.chainProofs, + thisPublication: { + ...baseMock.chainProofs.thisPublication, + typedData: { + ...baseMock.chainProofs.thisPublication.typedData, + value: { + ...baseMock.chainProofs.thisPublication.typedData.value, + nonce: 13234452346523, + }, + }, + }, + }, + }; + }); + + await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.PUBLICATION_NONCE_INVALID); + }); + + xtest('PUBLICATION_SIGNER_NOT_ALLOWED', async () => {}); + + test('INVALID_FORMATTED_TYPED_DATA', async () => { + sharedMocks.mockImpl__INVALID_FORMATTED_TYPED_DATA(baseMock); + + await sharedMocks.checkAndValidateDAProof( + MomokaValidatorError.INVALID_FORMATTED_TYPED_DATA + ); + }); + + test('EVENT_MISMATCH - pub id does not match simulated result', async () => { + sharedMocks.mockGetDAPublicationByIdAPI.mockImplementationOnce(async () => { + return { + ...baseMock, + event: { + ...baseMock.event, + pubId: '0x000000000000002', + }, + }; + }); + + await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.EVENT_MISMATCH); + }); + + test('EVENT_MISMATCH - profile id does not match typed data', async () => { + sharedMocks.mockGetDAPublicationByIdAPI.mockImplementationOnce(async () => { + return { + ...baseMock, + event: { + ...baseMock.event, + profileId: '0x02', + }, + }; + }); + + await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.EVENT_MISMATCH); + }); + + test('EVENT_MISMATCH - profileIdPointed does not match typed data', async () => { + sharedMocks.mockGetDAPublicationByIdAPI.mockImplementationOnce(async () => { + return { + ...baseMock, + event: { + ...baseMock.event, + profileIdPointed: '0x01', + }, + }; + }); + + await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.EVENT_MISMATCH); + }); + + test('EVENT_MISMATCH - pubIdPointed does not match typed data', async () => { + sharedMocks.mockGetDAPublicationByIdAPI.mockImplementationOnce(async () => { + return { + ...baseMock, + event: { + ...baseMock.event, + pubIdPointed: '0x01', + }, + }; + }); + + await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.EVENT_MISMATCH); + }); + + test('EVENT_MISMATCH - referenceModule does not match typed data', async () => { + sharedMocks.mockGetDAPublicationByIdAPI.mockImplementationOnce(async () => { + return { + ...baseMock, + event: { + ...baseMock.event, + referenceModule: '0x0000000000000000000000000000000000001', + }, + }; + }); + + await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.EVENT_MISMATCH); + }); + + test('EVENT_MISMATCH - referenceModuleReturnData is not empty bytes', async () => { + sharedMocks.mockGetDAPublicationByIdAPI.mockImplementationOnce(async () => { + return { + ...baseMock, + event: { + ...baseMock.event, + referenceModuleReturnData: 'not_empty_bytes', + }, + }; + }); + + await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.EVENT_MISMATCH); + }); + + xtest('SIMULATION_NODE_COULD_NOT_RUN', async () => {}); + + xtest('INVALID_POINTER_SET_NOT_NEEDED', () => {}); + + xtest('UNKNOWN', () => {}); + }); + }); +}); diff --git a/momoka-node/src/__TESTS__/mirrorPost.e2e.test.ts b/momoka-node/src/__TESTS__/mirrorPost.e2e.test.ts new file mode 100644 index 0000000..d15779c --- /dev/null +++ b/momoka-node/src/__TESTS__/mirrorPost.e2e.test.ts @@ -0,0 +1,426 @@ +// apply mocks! +jest.mock('../input-output/db'); +jest.mock('../input-output/bundlr/get-bundlr-by-id.api'); +jest.mock('../submitters'); + +import { MomokaValidatorError } from '..'; +import { deepClone } from '../common/helpers'; +import { DAPublicationPointerType } from '../data-availability-models/publications/data-availability-structure-publication'; +import { mirrorCreatedDelegatePostArweaveResponse } from './mocks/mirror/mirror-created-delegate-post-arweave-response.mock'; +import { mirrorCreatedWithoutDelegatePostArweaveResponse } from './mocks/mirror/mirror-created-without-delegate-post-arweave-response.mock'; +import * as sharedMocks from './mocks/shared.mock'; +import { mockTxValidationResult } from './mocks/shared.mock'; + +describe('mirror post', () => { + describe('with delegate', () => { + let baseMock = mirrorCreatedDelegatePostArweaveResponse; + + beforeAll(() => { + baseMock = mirrorCreatedDelegatePostArweaveResponse; + sharedMocks.mockGetDAPublicationByIdAPI.mockImplementation(async () => + deepClone(mirrorCreatedDelegatePostArweaveResponse) + ); + }); + + describe('should return success when', () => { + test('signed by delegate is true', () => { + expect(baseMock.chainProofs.thisPublication.signedByDelegate).toBe(true); + }); + + test('txExists in the db already', async () => { + sharedMocks.mockGetTxDb.mockImplementationOnce( + async () => await Promise.resolve(mockTxValidationResult) + ); + const result = await sharedMocks.callCheckDAProof(); + expect(result.isSuccess()).toBe(true); + }); + + test('tx is valid and passes all the simulation checks', async () => { + sharedMocks.mockIsValidSubmitter.mockImplementationOnce(() => true); + const result = await sharedMocks.callCheckDAProof(); + expect(result.isSuccess()).toBe(true); + }); + }); + + describe('should return failure when', () => { + test('NO_SIGNATURE_SUBMITTER', async () => { + sharedMocks.mockImpl__NO_SIGNATURE_SUBMITTER(baseMock); + await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.NO_SIGNATURE_SUBMITTER); + }); + + xtest('INVALID_SIGNATURE_SUBMITTER', async () => { + sharedMocks.mockIsValidSubmitter.mockImplementationOnce(() => false); + + await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.INVALID_SIGNATURE_SUBMITTER); + }); + + test('TIMESTAMP_PROOF_INVALID_SIGNATURE', async () => { + sharedMocks.mockImpl__TIMESTAMP_PROOF_INVALID_SIGNATURE(baseMock); + + await sharedMocks.checkAndValidateDAProof( + MomokaValidatorError.TIMESTAMP_PROOF_INVALID_SIGNATURE + ); + }); + + test('TIMESTAMP_PROOF_NOT_SUBMITTER', async () => { + sharedMocks.mockImpl__TIMESTAMP_PROOF_NOT_SUBMITTER(); + + await sharedMocks.checkAndValidateDAProof( + MomokaValidatorError.TIMESTAMP_PROOF_NOT_SUBMITTER + ); + }); + + test('INVALID_EVENT_TIMESTAMP', async () => { + sharedMocks.mockImpl__INVALID_EVENT_TIMESTAMP(baseMock); + + await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.INVALID_EVENT_TIMESTAMP); + }); + + xtest('NOT_CLOSEST_BLOCK', async () => { + await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.NOT_CLOSEST_BLOCK); + }); + + test('PUBLICATION_NO_POINTER', async () => { + sharedMocks.mockImpl__INVALID_POINTER_SET(baseMock, null); + + await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.PUBLICATION_NO_POINTER); + }); + + test('PUBLICATION_NONE_DA', async () => { + sharedMocks.mockImpl__INVALID_POINTER_SET(baseMock, { + type: DAPublicationPointerType.ON_EVM_CHAIN, + }); + + await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.PUBLICATION_NONE_DA); + }); + + test('PUBLICATION_NONCE_INVALID', async () => { + sharedMocks.mockGetDAPublicationByIdAPI.mockImplementationOnce(async () => { + return { + ...baseMock, + chainProofs: { + ...baseMock.chainProofs, + thisPublication: { + ...baseMock.chainProofs.thisPublication, + typedData: { + ...baseMock.chainProofs.thisPublication.typedData, + value: { + ...baseMock.chainProofs.thisPublication.typedData.value, + nonce: 13234452346523, + }, + }, + }, + }, + }; + }); + + await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.PUBLICATION_NONCE_INVALID); + }); + + xtest('PUBLICATION_SIGNER_NOT_ALLOWED', async () => {}); + + test('INVALID_FORMATTED_TYPED_DATA', async () => { + sharedMocks.mockImpl__INVALID_FORMATTED_TYPED_DATA(baseMock); + + await sharedMocks.checkAndValidateDAProof( + MomokaValidatorError.INVALID_FORMATTED_TYPED_DATA + ); + }); + + test('EVENT_MISMATCH - pub id does not match simulated result', async () => { + sharedMocks.mockGetDAPublicationByIdAPI.mockImplementationOnce(async () => { + return await { + ...baseMock, + event: { + ...baseMock.event, + pubId: '0x000000000000002', + }, + }; + }); + + await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.EVENT_MISMATCH); + }); + + test('EVENT_MISMATCH - profile id does not match typed data', async () => { + sharedMocks.mockGetDAPublicationByIdAPI.mockImplementationOnce(async () => { + return { + ...baseMock, + event: { + ...baseMock.event, + profileId: '0x02', + }, + }; + }); + + await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.EVENT_MISMATCH); + }); + + test('EVENT_MISMATCH - profileIdPointed does not match typed data', async () => { + sharedMocks.mockGetDAPublicationByIdAPI.mockImplementationOnce(async () => { + return { + ...baseMock, + event: { + ...baseMock.event, + profileIdPointed: '0x01', + }, + }; + }); + + await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.EVENT_MISMATCH); + }); + + test('EVENT_MISMATCH - pubIdPointed does not match typed data', async () => { + sharedMocks.mockGetDAPublicationByIdAPI.mockImplementationOnce(async () => { + return { + ...baseMock, + event: { + ...baseMock.event, + pubIdPointed: '0x01', + }, + }; + }); + + await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.EVENT_MISMATCH); + }); + + test('EVENT_MISMATCH - referenceModule does not match typed data', async () => { + sharedMocks.mockGetDAPublicationByIdAPI.mockImplementationOnce(async () => { + return { + ...baseMock, + event: { + ...baseMock.event, + referenceModule: '0x0000000000000000000000000000000000001', + }, + }; + }); + + await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.EVENT_MISMATCH); + }); + + test('EVENT_MISMATCH - referenceModuleReturnData is not empty bytes', async () => { + sharedMocks.mockGetDAPublicationByIdAPI.mockImplementationOnce(async () => { + return { + ...baseMock, + event: { + ...baseMock.event, + referenceModuleReturnData: 'not_empty_bytes', + }, + }; + }); + + await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.EVENT_MISMATCH); + }); + + xtest('SIMULATION_NODE_COULD_NOT_RUN', async () => {}); + + xtest('INVALID_POINTER_SET_NOT_NEEDED', () => {}); + + xtest('UNKNOWN', () => {}); + }); + }); + + describe('without delegate', () => { + let baseMock = mirrorCreatedWithoutDelegatePostArweaveResponse; + + beforeAll(() => { + baseMock = mirrorCreatedWithoutDelegatePostArweaveResponse; + sharedMocks.mockGetDAPublicationByIdAPI.mockImplementation(async () => + deepClone(mirrorCreatedWithoutDelegatePostArweaveResponse) + ); + }); + + describe('should return success when', () => { + test('signed by delegate is false', async () => { + expect(baseMock.chainProofs.thisPublication.signedByDelegate).toBe(false); + }); + + test('txExists in the db already', async () => { + sharedMocks.mockGetTxDb.mockImplementationOnce(async () => mockTxValidationResult); + const result = await sharedMocks.callCheckDAProof(); + expect(result.isSuccess()).toBe(true); + }); + + test('tx is valid and passes all the simulation checks', async () => { + const result = await sharedMocks.callCheckDAProof(); + expect(result.isSuccess()).toBe(true); + }); + }); + + describe('should return failure when', () => { + test('NO_SIGNATURE_SUBMITTER', async () => { + sharedMocks.mockImpl__NO_SIGNATURE_SUBMITTER(baseMock); + + await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.NO_SIGNATURE_SUBMITTER); + }); + + xtest('INVALID_SIGNATURE_SUBMITTER', async () => { + sharedMocks.mockIsValidSubmitter.mockImplementationOnce(() => false); + + await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.INVALID_SIGNATURE_SUBMITTER); + }); + + test('TIMESTAMP_PROOF_INVALID_SIGNATURE', async () => { + sharedMocks.mockImpl__TIMESTAMP_PROOF_INVALID_SIGNATURE(baseMock); + + await sharedMocks.checkAndValidateDAProof( + MomokaValidatorError.TIMESTAMP_PROOF_INVALID_SIGNATURE + ); + }); + + test('TIMESTAMP_PROOF_NOT_SUBMITTER', async () => { + sharedMocks.mockImpl__TIMESTAMP_PROOF_NOT_SUBMITTER(); + + await sharedMocks.checkAndValidateDAProof( + MomokaValidatorError.TIMESTAMP_PROOF_NOT_SUBMITTER + ); + }); + + test('INVALID_EVENT_TIMESTAMP', async () => { + sharedMocks.mockImpl__INVALID_EVENT_TIMESTAMP(baseMock); + + await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.INVALID_EVENT_TIMESTAMP); + }); + + xtest('NOT_CLOSEST_BLOCK', async () => { + await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.NOT_CLOSEST_BLOCK); + }); + + test('PUBLICATION_NO_POINTER', async () => { + sharedMocks.mockImpl__INVALID_POINTER_SET(baseMock, null); + + await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.PUBLICATION_NO_POINTER); + }); + + test('PUBLICATION_NONE_DA', async () => { + sharedMocks.mockImpl__INVALID_POINTER_SET(baseMock, { + type: DAPublicationPointerType.ON_EVM_CHAIN, + }); + + await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.PUBLICATION_NONE_DA); + }); + + test('PUBLICATION_NONCE_INVALID', async () => { + sharedMocks.mockGetDAPublicationByIdAPI.mockImplementationOnce(async () => { + return { + ...baseMock, + chainProofs: { + ...baseMock.chainProofs, + thisPublication: { + ...baseMock.chainProofs.thisPublication, + typedData: { + ...baseMock.chainProofs.thisPublication.typedData, + value: { + ...baseMock.chainProofs.thisPublication.typedData.value, + nonce: 13234452346523, + }, + }, + }, + }, + }; + }); + + await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.PUBLICATION_NONCE_INVALID); + }); + + xtest('PUBLICATION_SIGNER_NOT_ALLOWED', async () => {}); + + test('INVALID_FORMATTED_TYPED_DATA', async () => { + sharedMocks.mockImpl__INVALID_FORMATTED_TYPED_DATA(baseMock); + + await sharedMocks.checkAndValidateDAProof( + MomokaValidatorError.INVALID_FORMATTED_TYPED_DATA + ); + }); + + test('EVENT_MISMATCH - pub id does not match simulated result', async () => { + sharedMocks.mockGetDAPublicationByIdAPI.mockImplementationOnce(async () => { + return { + ...baseMock, + event: { + ...baseMock.event, + pubId: '0x000000000000002', + }, + }; + }); + + await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.EVENT_MISMATCH); + }); + + test('EVENT_MISMATCH - profile id does not match typed data', async () => { + sharedMocks.mockGetDAPublicationByIdAPI.mockImplementationOnce(async () => { + return { + ...baseMock, + event: { + ...baseMock.event, + profileId: '0x02', + }, + }; + }); + + await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.EVENT_MISMATCH); + }); + + test('EVENT_MISMATCH - profileIdPointed does not match typed data', async () => { + sharedMocks.mockGetDAPublicationByIdAPI.mockImplementationOnce(async () => { + return { + ...baseMock, + event: { + ...baseMock.event, + profileIdPointed: '0x01', + }, + }; + }); + + await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.EVENT_MISMATCH); + }); + + test('EVENT_MISMATCH - pubIdPointed does not match typed data', async () => { + sharedMocks.mockGetDAPublicationByIdAPI.mockImplementationOnce(async () => { + return { + ...baseMock, + event: { + ...baseMock.event, + pubIdPointed: '0x01', + }, + }; + }); + + await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.EVENT_MISMATCH); + }); + + test('EVENT_MISMATCH - referenceModule does not match typed data', async () => { + sharedMocks.mockGetDAPublicationByIdAPI.mockImplementationOnce(async () => { + return { + ...baseMock, + event: { + ...baseMock.event, + referenceModule: '0x0000000000000000000000000000000000001', + }, + }; + }); + + await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.EVENT_MISMATCH); + }); + + test('EVENT_MISMATCH - referenceModuleReturnData is not empty bytes', async () => { + sharedMocks.mockGetDAPublicationByIdAPI.mockImplementationOnce(async () => { + return { + ...baseMock, + event: { + ...baseMock.event, + referenceModuleReturnData: 'not_empty_bytes', + }, + }; + }); + + await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.EVENT_MISMATCH); + }); + + xtest('SIMULATION_NODE_COULD_NOT_RUN', async () => {}); + + xtest('INVALID_POINTER_SET_NOT_NEEDED', () => {}); + + xtest('UNKNOWN', () => {}); + }); + }); +}); diff --git a/momoka-node/src/__TESTS__/mocks/shared.mock.ts b/momoka-node/src/__TESTS__/mocks/shared.mock.ts index 20fc363..010dd41 100644 --- a/momoka-node/src/__TESTS__/mocks/shared.mock.ts +++ b/momoka-node/src/__TESTS__/mocks/shared.mock.ts @@ -19,13 +19,11 @@ import * as submittors from '../../submitters'; import { postCreatedDelegateArweaveResponse } from './post/post-created-delegate-arweave-response.mock'; export const mockGetTxDb = database.getTxDb as jest.MockedFunction; -mockGetTxDb.mockImplementation(async () => null); export const mockhasSignatureBeenUsedBeforeDb = database.hasSignatureBeenUsedBeforeDb as jest.MockedFunction< typeof database.hasSignatureBeenUsedBeforeDb >; -mockhasSignatureBeenUsedBeforeDb.mockImplementation(async () => false); export const mockGetDAPublicationByIdAPI = getBundlrByIdAPIDefault.getBundlrByIdAPI as jest.MockedFunction< diff --git a/momoka-node/src/__TESTS__/post.e2e.test.ts b/momoka-node/src/__TESTS__/post.e2e.test.ts index fa16377..b5c477f 100644 --- a/momoka-node/src/__TESTS__/post.e2e.test.ts +++ b/momoka-node/src/__TESTS__/post.e2e.test.ts @@ -1,5 +1,4 @@ // apply mocks! -jest.setTimeout(30000); jest.mock('../input-output/db'); jest.mock('../input-output/bundlr/get-bundlr-by-id.api'); jest.mock('../submitters'); @@ -15,7 +14,7 @@ describe('post', () => { describe('with delegate', () => { let baseMock = postCreatedDelegateArweaveResponse; - beforeEach(() => { + beforeAll(() => { baseMock = postCreatedDelegateArweaveResponse; sharedMocks.mockGetDAPublicationByIdAPI.mockImplementation(async () => deepClone(postCreatedDelegateArweaveResponse) @@ -207,7 +206,7 @@ describe('post', () => { describe('without delegate', () => { let baseMock = postCreatedWithoutDelegateArweaveResponse; - beforeEach(() => { + beforeAll(() => { baseMock = postCreatedWithoutDelegateArweaveResponse; sharedMocks.mockGetDAPublicationByIdAPI.mockImplementation(async () => deepClone(postCreatedWithoutDelegateArweaveResponse) @@ -234,19 +233,16 @@ describe('post', () => { describe('should return failure when', () => { test('NO_SIGNATURE_SUBMITTER', async () => { sharedMocks.mockImpl__NO_SIGNATURE_SUBMITTER(baseMock); - await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.NO_SIGNATURE_SUBMITTER); }); xtest('INVALID_SIGNATURE_SUBMITTER', async () => { sharedMocks.mockIsValidSubmitter.mockImplementationOnce(() => false); - await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.INVALID_SIGNATURE_SUBMITTER); }); test('TIMESTAMP_PROOF_INVALID_SIGNATURE', async () => { sharedMocks.mockImpl__TIMESTAMP_PROOF_INVALID_SIGNATURE(baseMock); - await sharedMocks.checkAndValidateDAProof( MomokaValidatorError.TIMESTAMP_PROOF_INVALID_SIGNATURE ); @@ -254,7 +250,6 @@ describe('post', () => { test('TIMESTAMP_PROOF_NOT_SUBMITTER', async () => { sharedMocks.mockImpl__TIMESTAMP_PROOF_NOT_SUBMITTER(); - await sharedMocks.checkAndValidateDAProof( MomokaValidatorError.TIMESTAMP_PROOF_NOT_SUBMITTER ); @@ -262,7 +257,6 @@ describe('post', () => { test('INVALID_EVENT_TIMESTAMP', async () => { sharedMocks.mockImpl__INVALID_EVENT_TIMESTAMP(baseMock); - await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.INVALID_EVENT_TIMESTAMP); }); @@ -272,7 +266,6 @@ describe('post', () => { test('INVALID_POINTER_SET_NOT_NEEDED', async () => { sharedMocks.mockImpl__INVALID_POINTER_SET(baseMock, 'mocked'); - await sharedMocks.checkAndValidateDAProof( MomokaValidatorError.INVALID_POINTER_SET_NOT_NEEDED ); @@ -280,13 +273,11 @@ describe('post', () => { test('SIMULATION_FAILED - trying to submit a tx with a profile id not owned', async () => { sharedMocks.mockImpl__SIMULATION_FAILED_BAD_PROFILE_ID(baseMock); - await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.SIMULATION_FAILED); }); test('INVALID_FORMATTED_TYPED_DATA', async () => { sharedMocks.mockImpl__INVALID_FORMATTED_TYPED_DATA(baseMock); - await sharedMocks.checkAndValidateDAProof( MomokaValidatorError.INVALID_FORMATTED_TYPED_DATA ); @@ -390,9 +381,13 @@ describe('post', () => { await sharedMocks.checkAndValidateDAProof(MomokaValidatorError.EVENT_MISMATCH); }); - xtest('SIMULATION_NODE_COULD_NOT_RUN', async () => {}); + xtest('SIMULATION_NODE_COULD_NOT_RUN', () => { + // TODO: implement + }); - xtest('UNKNOWN', () => {}); + xtest('UNKNOWN', () => { + // TODO: implement + }); }); }); }); diff --git a/momoka-node/src/__TESTS__/random.test.ts b/momoka-node/src/__TESTS__/random.test.ts index c0a7963..5593881 100644 --- a/momoka-node/src/__TESTS__/random.test.ts +++ b/momoka-node/src/__TESTS__/random.test.ts @@ -1,9 +1,9 @@ import { getBundlrByIdAPI } from '../input-output/bundlr/get-bundlr-by-id.api'; -import { LibCurlProvider } from '../input-output/lib-curl-provider'; +import { AxiosProvider } from '../client/axios-provider'; describe('random', () => { it('getBundlrByIdAPI', async () => { const txId = 'oWnpbkMpnGxMMnFDxnwxCQVhEK55jJeuiyLGUv2bSrk'; - await getBundlrByIdAPI(txId, { provider: new LibCurlProvider() }); + await getBundlrByIdAPI(txId, { provider: new AxiosProvider() }); }); }); diff --git a/momoka-rs/.env b/momoka-rs/.env index fe39a23..aedf9e0 100644 --- a/momoka-rs/.env +++ b/momoka-rs/.env @@ -1,11 +1,9 @@ -ETHEREUM_NETWORK=POLYGON -# ETHEREUM_NETWORK=MUMBAI +ETHEREUM_NETWORK=MUMBAI # ETHEREUM_NETWORK=POLYGON -NODE_URL=https://polygon-mainnet.g.alchemy.com/v2/WaQlz3BZ9rps6PTOiJmcdTm7XaFVnJhs +NODE_URL=https://polygon-mumbai.g.alchemy.com/v2/s1Hq6Tyswh1mDXOlgawIqSCndvsNfYb6 +# NODE_URL=https://polygon-mainnet.g.alchemy.com/v2/WaQlz3BZ9rps6PTOiJmcdTm7XaFVnJhs # NODE_URL='ws://127.0.0.1:8545/' # NODE_URL=https://matic-mumbai.chainstacklabs.com -# NODE_URL(FREE)=https://polygon-mumbai.g.alchemy.com/v2/s1Hq6Tyswh1mDXOlgawIqSCndvsNfYb6 -DEPLOYMENT=PRODUCTION -# DEPLOYMENT=STAGING +DEPLOYMENT=STAGING # DEPLOYMENT=PRODUCTION -CONCURRENCY=10 +CONCURRENCY=3