From ae5e0b9599358415eb3491706edbcc39ba8e32e5 Mon Sep 17 00:00:00 2001 From: Brian Faust Date: Thu, 3 Jan 2019 07:32:06 +0200 Subject: [PATCH 1/2] refactor: extract jest matchers into its own package --- .circleci/config.yml | 118 ++++++++++-------- packages/core-jest-matchers/.gitattributes | 11 ++ packages/core-jest-matchers/README.md | 24 ++++ .../__tests__}/blockchain/dispatch.test.ts | 2 +- .../blockchain/execute-on-entry.test.ts | 2 +- .../__tests__}/blockchain/transition.test.ts | 2 +- .../__tests__}/fields/address.test.ts | 2 +- .../__tests__}/fields/public-key.test.ts | 2 +- .../__tests__}/models/delegate.test.ts | 2 +- .../__tests__}/models/transaction.test.ts | 2 +- .../__tests__}/models/wallet.test.ts | 2 +- .../types/delegate-resignation.test.ts | 2 +- .../transactions/types/delegate.test.ts | 2 +- .../transactions/types/ipfs.test.ts | 2 +- .../transactions/types/multi-payment.test.ts | 2 +- .../types/multi-signature.test.ts | 2 +- .../types/second-signature.test.ts | 2 +- .../types/timelock-transfer.test.ts | 2 +- .../transactions/types/transfer.test.ts | 2 +- .../transactions/types/vote.test.ts | 2 +- .../valid-second-signature.test.ts | 84 +++++++++++++ .../__tests__}/transactions/valid.test.ts | 2 +- packages/core-jest-matchers/package.json | 54 ++++++++ .../src}/api/block.ts | 0 .../src}/api/index.ts | 0 .../src}/api/peer.ts | 0 .../src}/api/response.ts | 0 .../src}/api/transaction.ts | 0 .../src}/blockchain/dispatch.ts | 0 .../src}/blockchain/execute-on-entry.ts | 0 .../src}/blockchain/index.ts | 0 .../src}/blockchain/transition.ts | 0 .../src}/fields/address.ts | 0 .../src}/fields/index.ts | 0 .../src}/fields/public-key.ts | 0 .../src}/index.ts | 0 .../src}/models/delegate.ts | 0 .../src}/models/index.ts | 0 .../src}/models/transaction.ts | 0 .../src}/models/wallet.ts | 0 .../src}/transactions/index.ts | 0 .../types/delegate-resignation.ts | 0 .../src}/transactions/types/delegate.ts | 0 .../src}/transactions/types/index.ts | 0 .../src}/transactions/types/ipfs.ts | 0 .../src}/transactions/types/multi-payment.ts | 0 .../transactions/types/multi-signature.ts | 0 .../transactions/types/second-signature.ts | 0 .../transactions/types/timelock-transfer.ts | 0 .../src}/transactions/types/transfer.ts | 0 .../src}/transactions/types/vote.ts | 0 .../transactions/valid-second-signature.ts | 0 .../src}/transactions/valid.ts | 0 packages/core-jest-matchers/tsconfig.json | 7 ++ .../valid-second-signature.test.ts | 23 ---- packages/core-test-utils/package.json | 5 +- packages/core-test-utils/src/index.ts | 4 +- 57 files changed, 270 insertions(+), 96 deletions(-) create mode 100644 packages/core-jest-matchers/.gitattributes create mode 100644 packages/core-jest-matchers/README.md rename packages/{core-test-utils/__tests__/matchers => core-jest-matchers/__tests__}/blockchain/dispatch.test.ts (92%) rename packages/{core-test-utils/__tests__/matchers => core-jest-matchers/__tests__}/blockchain/execute-on-entry.test.ts (94%) rename packages/{core-test-utils/__tests__/matchers => core-jest-matchers/__tests__}/blockchain/transition.test.ts (96%) rename packages/{core-test-utils/__tests__/matchers => core-jest-matchers/__tests__}/fields/address.test.ts (86%) rename packages/{core-test-utils/__tests__/matchers => core-jest-matchers/__tests__}/fields/public-key.test.ts (80%) rename packages/{core-test-utils/__tests__/matchers => core-jest-matchers/__tests__}/models/delegate.test.ts (90%) rename packages/{core-test-utils/__tests__/matchers => core-jest-matchers/__tests__}/models/transaction.test.ts (94%) rename packages/{core-test-utils/__tests__/matchers => core-jest-matchers/__tests__}/models/wallet.test.ts (90%) rename packages/{core-test-utils/__tests__/matchers => core-jest-matchers/__tests__}/transactions/types/delegate-resignation.test.ts (86%) rename packages/{core-test-utils/__tests__/matchers => core-jest-matchers/__tests__}/transactions/types/delegate.test.ts (87%) rename packages/{core-test-utils/__tests__/matchers => core-jest-matchers/__tests__}/transactions/types/ipfs.test.ts (86%) rename packages/{core-test-utils/__tests__/matchers => core-jest-matchers/__tests__}/transactions/types/multi-payment.test.ts (85%) rename packages/{core-test-utils/__tests__/matchers => core-jest-matchers/__tests__}/transactions/types/multi-signature.test.ts (86%) rename packages/{core-test-utils/__tests__/matchers => core-jest-matchers/__tests__}/transactions/types/second-signature.test.ts (86%) rename packages/{core-test-utils/__tests__/matchers => core-jest-matchers/__tests__}/transactions/types/timelock-transfer.test.ts (86%) rename packages/{core-test-utils/__tests__/matchers => core-jest-matchers/__tests__}/transactions/types/transfer.test.ts (86%) rename packages/{core-test-utils/__tests__/matchers => core-jest-matchers/__tests__}/transactions/types/vote.test.ts (86%) create mode 100644 packages/core-jest-matchers/__tests__/transactions/valid-second-signature.test.ts rename packages/{core-test-utils/__tests__/matchers => core-jest-matchers/__tests__}/transactions/valid.test.ts (94%) create mode 100644 packages/core-jest-matchers/package.json rename packages/{core-test-utils/src/matchers => core-jest-matchers/src}/api/block.ts (100%) rename packages/{core-test-utils/src/matchers => core-jest-matchers/src}/api/index.ts (100%) rename packages/{core-test-utils/src/matchers => core-jest-matchers/src}/api/peer.ts (100%) rename packages/{core-test-utils/src/matchers => core-jest-matchers/src}/api/response.ts (100%) rename packages/{core-test-utils/src/matchers => core-jest-matchers/src}/api/transaction.ts (100%) rename packages/{core-test-utils/src/matchers => core-jest-matchers/src}/blockchain/dispatch.ts (100%) rename packages/{core-test-utils/src/matchers => core-jest-matchers/src}/blockchain/execute-on-entry.ts (100%) rename packages/{core-test-utils/src/matchers => core-jest-matchers/src}/blockchain/index.ts (100%) rename packages/{core-test-utils/src/matchers => core-jest-matchers/src}/blockchain/transition.ts (100%) rename packages/{core-test-utils/src/matchers => core-jest-matchers/src}/fields/address.ts (100%) rename packages/{core-test-utils/src/matchers => core-jest-matchers/src}/fields/index.ts (100%) rename packages/{core-test-utils/src/matchers => core-jest-matchers/src}/fields/public-key.ts (100%) rename packages/{core-test-utils/src/matchers => core-jest-matchers/src}/index.ts (100%) rename packages/{core-test-utils/src/matchers => core-jest-matchers/src}/models/delegate.ts (100%) rename packages/{core-test-utils/src/matchers => core-jest-matchers/src}/models/index.ts (100%) rename packages/{core-test-utils/src/matchers => core-jest-matchers/src}/models/transaction.ts (100%) rename packages/{core-test-utils/src/matchers => core-jest-matchers/src}/models/wallet.ts (100%) rename packages/{core-test-utils/src/matchers => core-jest-matchers/src}/transactions/index.ts (100%) rename packages/{core-test-utils/src/matchers => core-jest-matchers/src}/transactions/types/delegate-resignation.ts (100%) rename packages/{core-test-utils/src/matchers => core-jest-matchers/src}/transactions/types/delegate.ts (100%) rename packages/{core-test-utils/src/matchers => core-jest-matchers/src}/transactions/types/index.ts (100%) rename packages/{core-test-utils/src/matchers => core-jest-matchers/src}/transactions/types/ipfs.ts (100%) rename packages/{core-test-utils/src/matchers => core-jest-matchers/src}/transactions/types/multi-payment.ts (100%) rename packages/{core-test-utils/src/matchers => core-jest-matchers/src}/transactions/types/multi-signature.ts (100%) rename packages/{core-test-utils/src/matchers => core-jest-matchers/src}/transactions/types/second-signature.ts (100%) rename packages/{core-test-utils/src/matchers => core-jest-matchers/src}/transactions/types/timelock-transfer.ts (100%) rename packages/{core-test-utils/src/matchers => core-jest-matchers/src}/transactions/types/transfer.ts (100%) rename packages/{core-test-utils/src/matchers => core-jest-matchers/src}/transactions/types/vote.ts (100%) rename packages/{core-test-utils/src/matchers => core-jest-matchers/src}/transactions/valid-second-signature.ts (100%) rename packages/{core-test-utils/src/matchers => core-jest-matchers/src}/transactions/valid.ts (100%) create mode 100644 packages/core-jest-matchers/tsconfig.json delete mode 100644 packages/core-test-utils/__tests__/matchers/transactions/valid-second-signature.test.ts diff --git a/.circleci/config.yml b/.circleci/config.yml index 5ab0d714ee..ff4fbdb08d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -46,6 +46,7 @@ jobs: - ./packages/core-forger/node_modules - ./packages/core-graphql/node_modules - ./packages/core-http-utils/node_modules + - ./packages/core-jest-matchers/node_modules - ./packages/core-json-rpc/node_modules - ./packages/core-logger/node_modules - ./packages/core-logger-winston/node_modules @@ -64,17 +65,20 @@ jobs: name: Create .ark/database directory command: mkdir -p $HOME/.ark/database - run: - name: core-webhooks - command: 'cd ~/ark-core/packages/core-webhooks && yarn test:coverage' + name: core-vote-report + command: 'cd ~/ark-core/packages/core-vote-report && yarn test:coverage' - run: - name: core-transaction-pool - command: 'cd ~/ark-core/packages/core-transaction-pool && yarn test:coverage' + name: core-tester-cli + command: 'cd ~/ark-core/packages/core-tester-cli && yarn test:coverage' - run: - name: core-logger-winston - command: 'cd ~/ark-core/packages/core-logger-winston && yarn test:coverage' + name: core-snapshots + command: 'cd ~/ark-core/packages/core-snapshots && yarn test:coverage' - run: - name: core-api - command: 'cd ~/ark-core/packages/core-api && yarn test:coverage' + name: core-logger + command: 'cd ~/ark-core/packages/core-logger && yarn test:coverage' + - run: + name: core-graphql + command: 'cd ~/ark-core/packages/core-graphql && yarn test:coverage' - run: name: core-debugger-cli command: 'cd ~/ark-core/packages/core-debugger-cli && yarn test:coverage' @@ -82,8 +86,8 @@ jobs: name: core-container command: 'cd ~/ark-core/packages/core-container && yarn test:coverage' - run: - name: core-graphql - command: 'cd ~/ark-core/packages/core-graphql && yarn test:coverage' + name: core-http-utils + command: 'cd ~/ark-core/packages/core-http-utils && yarn test:coverage' - run: name: Last 1000 lines of test output when: on_fail @@ -137,6 +141,7 @@ jobs: - ./packages/core-forger/node_modules - ./packages/core-graphql/node_modules - ./packages/core-http-utils/node_modules + - ./packages/core-jest-matchers/node_modules - ./packages/core-json-rpc/node_modules - ./packages/core-logger/node_modules - ./packages/core-logger-winston/node_modules @@ -155,17 +160,20 @@ jobs: name: Create .ark/database directory command: mkdir -p $HOME/.ark/database - run: - name: core-webhooks - command: 'cd ~/ark-core/packages/core-webhooks && yarn test:coverage' + name: core-vote-report + command: 'cd ~/ark-core/packages/core-vote-report && yarn test:coverage' - run: - name: core-transaction-pool - command: 'cd ~/ark-core/packages/core-transaction-pool && yarn test:coverage' + name: core-tester-cli + command: 'cd ~/ark-core/packages/core-tester-cli && yarn test:coverage' - run: - name: core-logger-winston - command: 'cd ~/ark-core/packages/core-logger-winston && yarn test:coverage' + name: core-snapshots + command: 'cd ~/ark-core/packages/core-snapshots && yarn test:coverage' - run: - name: core-api - command: 'cd ~/ark-core/packages/core-api && yarn test:coverage' + name: core-logger + command: 'cd ~/ark-core/packages/core-logger && yarn test:coverage' + - run: + name: core-graphql + command: 'cd ~/ark-core/packages/core-graphql && yarn test:coverage' - run: name: core-debugger-cli command: 'cd ~/ark-core/packages/core-debugger-cli && yarn test:coverage' @@ -173,8 +181,8 @@ jobs: name: core-container command: 'cd ~/ark-core/packages/core-container && yarn test:coverage' - run: - name: core-graphql - command: 'cd ~/ark-core/packages/core-graphql && yarn test:coverage' + name: core-http-utils + command: 'cd ~/ark-core/packages/core-http-utils && yarn test:coverage' - run: name: Last 1000 lines of test output when: on_fail @@ -228,6 +236,7 @@ jobs: - ./packages/core-forger/node_modules - ./packages/core-graphql/node_modules - ./packages/core-http-utils/node_modules + - ./packages/core-jest-matchers/node_modules - ./packages/core-json-rpc/node_modules - ./packages/core-logger/node_modules - ./packages/core-logger-winston/node_modules @@ -307,6 +316,7 @@ jobs: - ./packages/core-forger/node_modules - ./packages/core-graphql/node_modules - ./packages/core-http-utils/node_modules + - ./packages/core-jest-matchers/node_modules - ./packages/core-json-rpc/node_modules - ./packages/core-logger/node_modules - ./packages/core-logger-winston/node_modules @@ -325,17 +335,17 @@ jobs: name: Create .ark/database directory command: mkdir -p $HOME/.ark/database - run: - name: core-utils - command: 'cd ~/ark-core/packages/core-utils && yarn test:coverage' + name: core-webhooks + command: 'cd ~/ark-core/packages/core-webhooks && yarn test:coverage' - run: - name: core-test-utils - command: 'cd ~/ark-core/packages/core-test-utils && yarn test:coverage' + name: core-transaction-pool + command: 'cd ~/ark-core/packages/core-transaction-pool && yarn test:coverage' - run: - name: core-p2p - command: 'cd ~/ark-core/packages/core-p2p && yarn test:coverage' + name: core-logger-winston + command: 'cd ~/ark-core/packages/core-logger-winston && yarn test:coverage' - run: - name: core-http-utils - command: 'cd ~/ark-core/packages/core-http-utils && yarn test:coverage' + name: core-api + command: 'cd ~/ark-core/packages/core-api && yarn test:coverage' - run: name: core-event-emitter command: 'cd ~/ark-core/packages/core-event-emitter && yarn test:coverage' @@ -398,6 +408,7 @@ jobs: - ./packages/core-forger/node_modules - ./packages/core-graphql/node_modules - ./packages/core-http-utils/node_modules + - ./packages/core-jest-matchers/node_modules - ./packages/core-json-rpc/node_modules - ./packages/core-logger/node_modules - ./packages/core-logger-winston/node_modules @@ -416,17 +427,17 @@ jobs: name: Create .ark/database directory command: mkdir -p $HOME/.ark/database - run: - name: core-vote-report - command: 'cd ~/ark-core/packages/core-vote-report && yarn test:coverage' + name: core-utils + command: 'cd ~/ark-core/packages/core-utils && yarn test:coverage' - run: - name: core-tester-cli - command: 'cd ~/ark-core/packages/core-tester-cli && yarn test:coverage' + name: core-test-utils + command: 'cd ~/ark-core/packages/core-test-utils && yarn test:coverage' - run: - name: core-snapshots - command: 'cd ~/ark-core/packages/core-snapshots && yarn test:coverage' + name: core-p2p + command: 'cd ~/ark-core/packages/core-p2p && yarn test:coverage' - run: - name: core-logger - command: 'cd ~/ark-core/packages/core-logger && yarn test:coverage' + name: core-jest-matchers + command: 'cd ~/ark-core/packages/core-jest-matchers && yarn test:coverage' - run: name: core-forger command: 'cd ~/ark-core/packages/core-forger && yarn test:coverage' @@ -486,6 +497,7 @@ jobs: - ./packages/core-forger/node_modules - ./packages/core-graphql/node_modules - ./packages/core-http-utils/node_modules + - ./packages/core-jest-matchers/node_modules - ./packages/core-json-rpc/node_modules - ./packages/core-logger/node_modules - ./packages/core-logger-winston/node_modules @@ -565,6 +577,7 @@ jobs: - ./packages/core-forger/node_modules - ./packages/core-graphql/node_modules - ./packages/core-http-utils/node_modules + - ./packages/core-jest-matchers/node_modules - ./packages/core-json-rpc/node_modules - ./packages/core-logger/node_modules - ./packages/core-logger-winston/node_modules @@ -583,17 +596,17 @@ jobs: name: Create .ark/database directory command: mkdir -p $HOME/.ark/database - run: - name: core-utils - command: 'cd ~/ark-core/packages/core-utils && yarn test:coverage' + name: core-webhooks + command: 'cd ~/ark-core/packages/core-webhooks && yarn test:coverage' - run: - name: core-test-utils - command: 'cd ~/ark-core/packages/core-test-utils && yarn test:coverage' + name: core-transaction-pool + command: 'cd ~/ark-core/packages/core-transaction-pool && yarn test:coverage' - run: - name: core-p2p - command: 'cd ~/ark-core/packages/core-p2p && yarn test:coverage' + name: core-logger-winston + command: 'cd ~/ark-core/packages/core-logger-winston && yarn test:coverage' - run: - name: core-http-utils - command: 'cd ~/ark-core/packages/core-http-utils && yarn test:coverage' + name: core-api + command: 'cd ~/ark-core/packages/core-api && yarn test:coverage' - run: name: core-event-emitter command: 'cd ~/ark-core/packages/core-event-emitter && yarn test:coverage' @@ -656,6 +669,7 @@ jobs: - ./packages/core-forger/node_modules - ./packages/core-graphql/node_modules - ./packages/core-http-utils/node_modules + - ./packages/core-jest-matchers/node_modules - ./packages/core-json-rpc/node_modules - ./packages/core-logger/node_modules - ./packages/core-logger-winston/node_modules @@ -674,17 +688,17 @@ jobs: name: Create .ark/database directory command: mkdir -p $HOME/.ark/database - run: - name: core-vote-report - command: 'cd ~/ark-core/packages/core-vote-report && yarn test:coverage' + name: core-utils + command: 'cd ~/ark-core/packages/core-utils && yarn test:coverage' - run: - name: core-tester-cli - command: 'cd ~/ark-core/packages/core-tester-cli && yarn test:coverage' + name: core-test-utils + command: 'cd ~/ark-core/packages/core-test-utils && yarn test:coverage' - run: - name: core-snapshots - command: 'cd ~/ark-core/packages/core-snapshots && yarn test:coverage' + name: core-p2p + command: 'cd ~/ark-core/packages/core-p2p && yarn test:coverage' - run: - name: core-logger - command: 'cd ~/ark-core/packages/core-logger && yarn test:coverage' + name: core-jest-matchers + command: 'cd ~/ark-core/packages/core-jest-matchers && yarn test:coverage' - run: name: core-forger command: 'cd ~/ark-core/packages/core-forger && yarn test:coverage' diff --git a/packages/core-jest-matchers/.gitattributes b/packages/core-jest-matchers/.gitattributes new file mode 100644 index 0000000000..60cc52db63 --- /dev/null +++ b/packages/core-jest-matchers/.gitattributes @@ -0,0 +1,11 @@ +# Path-based git attributes +# https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html + +# Ignore all test and documentation with "export-ignore". +/.editorconfig export-ignore +/.gitattributes export-ignore +/.gitignore export-ignore +/.travis.yml export-ignore +/__tests__ export-ignore +/docs export-ignore +/README.md export-ignore diff --git a/packages/core-jest-matchers/README.md b/packages/core-jest-matchers/README.md new file mode 100644 index 0000000000..24cba42650 --- /dev/null +++ b/packages/core-jest-matchers/README.md @@ -0,0 +1,24 @@ +# Ark Core - Jest Matchers + +

+ +

+ +## Documentation + +You can find installation instructions and detailed instructions on how to use this package at the [dedicated documentation site](https://docs.ark.io/guidebook/core/plugins/core-jest-matchers.html). + +## Security + +If you discover a security vulnerability within this package, please send an e-mail to security@ark.io. All security vulnerabilities will be promptly addressed. + +## Credits + +- [Brian Faust](https://github.com/faustbrian) +- [Erwann Gentric](https://github.com/air1one) +- [Joshua Noack](https://github.com/supaiku0) +- [All Contributors](../../../../contributors) + +## License + +[MIT](LICENSE) © [ArkEcosystem](https://ark.io) diff --git a/packages/core-test-utils/__tests__/matchers/blockchain/dispatch.test.ts b/packages/core-jest-matchers/__tests__/blockchain/dispatch.test.ts similarity index 92% rename from packages/core-test-utils/__tests__/matchers/blockchain/dispatch.test.ts rename to packages/core-jest-matchers/__tests__/blockchain/dispatch.test.ts index e5ddfd296b..2a4c7c6a56 100644 --- a/packages/core-test-utils/__tests__/matchers/blockchain/dispatch.test.ts +++ b/packages/core-jest-matchers/__tests__/blockchain/dispatch.test.ts @@ -1,4 +1,4 @@ -import "../../../src/matchers/blockchain/dispatch"; +import "../../src/blockchain/dispatch"; describe(".toDispatch", () => { const blockchain = { diff --git a/packages/core-test-utils/__tests__/matchers/blockchain/execute-on-entry.test.ts b/packages/core-jest-matchers/__tests__/blockchain/execute-on-entry.test.ts similarity index 94% rename from packages/core-test-utils/__tests__/matchers/blockchain/execute-on-entry.test.ts rename to packages/core-jest-matchers/__tests__/blockchain/execute-on-entry.test.ts index 013566d78f..90d4aab3ff 100644 --- a/packages/core-test-utils/__tests__/matchers/blockchain/execute-on-entry.test.ts +++ b/packages/core-jest-matchers/__tests__/blockchain/execute-on-entry.test.ts @@ -1,5 +1,5 @@ import { Machine } from "xstate"; -import "../../../src/matchers/blockchain/execute-on-entry"; +import "../../src/blockchain/execute-on-entry"; describe(".toExecuteOnEntry", () => { const machine = Machine({ diff --git a/packages/core-test-utils/__tests__/matchers/blockchain/transition.test.ts b/packages/core-jest-matchers/__tests__/blockchain/transition.test.ts similarity index 96% rename from packages/core-test-utils/__tests__/matchers/blockchain/transition.test.ts rename to packages/core-jest-matchers/__tests__/blockchain/transition.test.ts index 0de02f6b52..b04619008a 100644 --- a/packages/core-test-utils/__tests__/matchers/blockchain/transition.test.ts +++ b/packages/core-jest-matchers/__tests__/blockchain/transition.test.ts @@ -1,5 +1,5 @@ import { Machine } from "xstate"; -import "../../../src/matchers/blockchain/transition"; +import "../../src/blockchain/transition"; describe(".toTransition", () => { const machine = Machine({ diff --git a/packages/core-test-utils/__tests__/matchers/fields/address.test.ts b/packages/core-jest-matchers/__tests__/fields/address.test.ts similarity index 86% rename from packages/core-test-utils/__tests__/matchers/fields/address.test.ts rename to packages/core-jest-matchers/__tests__/fields/address.test.ts index c3cf7e7f5c..6bfe690962 100644 --- a/packages/core-test-utils/__tests__/matchers/fields/address.test.ts +++ b/packages/core-jest-matchers/__tests__/fields/address.test.ts @@ -1,4 +1,4 @@ -import "../../../src/matchers/fields/address"; +import "../../src/fields/address"; describe(".toBeArkAddress", () => { test("passes when given a valid address", () => { diff --git a/packages/core-test-utils/__tests__/matchers/fields/public-key.test.ts b/packages/core-jest-matchers/__tests__/fields/public-key.test.ts similarity index 80% rename from packages/core-test-utils/__tests__/matchers/fields/public-key.test.ts rename to packages/core-jest-matchers/__tests__/fields/public-key.test.ts index 80093c0b6a..552259a7cb 100644 --- a/packages/core-test-utils/__tests__/matchers/fields/public-key.test.ts +++ b/packages/core-jest-matchers/__tests__/fields/public-key.test.ts @@ -1,4 +1,4 @@ -import "../../../src/matchers/fields/public-key"; +import "../../src/fields/public-key"; describe(".toBeArkPublicKey", () => { test("passes when given a valid public key", () => { diff --git a/packages/core-test-utils/__tests__/matchers/models/delegate.test.ts b/packages/core-jest-matchers/__tests__/models/delegate.test.ts similarity index 90% rename from packages/core-test-utils/__tests__/matchers/models/delegate.test.ts rename to packages/core-jest-matchers/__tests__/models/delegate.test.ts index 65e9b70008..26af4da898 100644 --- a/packages/core-test-utils/__tests__/matchers/models/delegate.test.ts +++ b/packages/core-jest-matchers/__tests__/models/delegate.test.ts @@ -1,4 +1,4 @@ -import "../../../src/matchers/models/delegate"; +import "../../src/models/delegate"; describe(".toBeDelegate", () => { const delegate = { diff --git a/packages/core-test-utils/__tests__/matchers/models/transaction.test.ts b/packages/core-jest-matchers/__tests__/models/transaction.test.ts similarity index 94% rename from packages/core-test-utils/__tests__/matchers/models/transaction.test.ts rename to packages/core-jest-matchers/__tests__/models/transaction.test.ts index 48060f5508..f92cba0e0f 100644 --- a/packages/core-test-utils/__tests__/matchers/models/transaction.test.ts +++ b/packages/core-jest-matchers/__tests__/models/transaction.test.ts @@ -1,4 +1,4 @@ -import "../../../src/matchers/models/transaction"; +import "../../src/models/transaction"; describe(".toBeTransaction", () => { const transaction = { diff --git a/packages/core-test-utils/__tests__/matchers/models/wallet.test.ts b/packages/core-jest-matchers/__tests__/models/wallet.test.ts similarity index 90% rename from packages/core-test-utils/__tests__/matchers/models/wallet.test.ts rename to packages/core-jest-matchers/__tests__/models/wallet.test.ts index 498942a45b..8971f766f3 100644 --- a/packages/core-test-utils/__tests__/matchers/models/wallet.test.ts +++ b/packages/core-jest-matchers/__tests__/models/wallet.test.ts @@ -1,4 +1,4 @@ -import "../../../src/matchers/models/wallet"; +import "../../src/models/wallet"; describe(".toBeWallet", () => { const wallet = { diff --git a/packages/core-test-utils/__tests__/matchers/transactions/types/delegate-resignation.test.ts b/packages/core-jest-matchers/__tests__/transactions/types/delegate-resignation.test.ts similarity index 86% rename from packages/core-test-utils/__tests__/matchers/transactions/types/delegate-resignation.test.ts rename to packages/core-jest-matchers/__tests__/transactions/types/delegate-resignation.test.ts index 84c0c3d2b1..91dd94b898 100644 --- a/packages/core-test-utils/__tests__/matchers/transactions/types/delegate-resignation.test.ts +++ b/packages/core-jest-matchers/__tests__/transactions/types/delegate-resignation.test.ts @@ -1,4 +1,4 @@ -import "../../../../src/matchers/transactions/types/delegate-resignation"; +import "../../../src/transactions/types/delegate-resignation"; import { constants } from "@arkecosystem/crypto"; const { TransactionTypes } = constants; diff --git a/packages/core-test-utils/__tests__/matchers/transactions/types/delegate.test.ts b/packages/core-jest-matchers/__tests__/transactions/types/delegate.test.ts similarity index 87% rename from packages/core-test-utils/__tests__/matchers/transactions/types/delegate.test.ts rename to packages/core-jest-matchers/__tests__/transactions/types/delegate.test.ts index fb9b2a284c..414ce4461a 100644 --- a/packages/core-test-utils/__tests__/matchers/transactions/types/delegate.test.ts +++ b/packages/core-jest-matchers/__tests__/transactions/types/delegate.test.ts @@ -1,4 +1,4 @@ -import "../../../../src/matchers/transactions/types/delegate"; +import "../../../src/transactions/types/delegate"; import { constants } from "@arkecosystem/crypto"; const { TransactionTypes } = constants; diff --git a/packages/core-test-utils/__tests__/matchers/transactions/types/ipfs.test.ts b/packages/core-jest-matchers/__tests__/transactions/types/ipfs.test.ts similarity index 86% rename from packages/core-test-utils/__tests__/matchers/transactions/types/ipfs.test.ts rename to packages/core-jest-matchers/__tests__/transactions/types/ipfs.test.ts index 7400a8a338..e067183814 100644 --- a/packages/core-test-utils/__tests__/matchers/transactions/types/ipfs.test.ts +++ b/packages/core-jest-matchers/__tests__/transactions/types/ipfs.test.ts @@ -1,4 +1,4 @@ -import "../../../../src/matchers/transactions/types/ipfs"; +import "../../../src/transactions/types/ipfs"; import { constants } from "@arkecosystem/crypto"; const { TransactionTypes } = constants; diff --git a/packages/core-test-utils/__tests__/matchers/transactions/types/multi-payment.test.ts b/packages/core-jest-matchers/__tests__/transactions/types/multi-payment.test.ts similarity index 85% rename from packages/core-test-utils/__tests__/matchers/transactions/types/multi-payment.test.ts rename to packages/core-jest-matchers/__tests__/transactions/types/multi-payment.test.ts index 98879eb1df..c53b42914e 100644 --- a/packages/core-test-utils/__tests__/matchers/transactions/types/multi-payment.test.ts +++ b/packages/core-jest-matchers/__tests__/transactions/types/multi-payment.test.ts @@ -1,4 +1,4 @@ -import "../../../../src/matchers/transactions/types/multi-payment"; +import "../../../src/transactions/types/multi-payment"; import { constants } from "@arkecosystem/crypto"; const { TransactionTypes } = constants; diff --git a/packages/core-test-utils/__tests__/matchers/transactions/types/multi-signature.test.ts b/packages/core-jest-matchers/__tests__/transactions/types/multi-signature.test.ts similarity index 86% rename from packages/core-test-utils/__tests__/matchers/transactions/types/multi-signature.test.ts rename to packages/core-jest-matchers/__tests__/transactions/types/multi-signature.test.ts index 2fba298638..ece4f4b550 100644 --- a/packages/core-test-utils/__tests__/matchers/transactions/types/multi-signature.test.ts +++ b/packages/core-jest-matchers/__tests__/transactions/types/multi-signature.test.ts @@ -1,4 +1,4 @@ -import "../../../../src/matchers/transactions/types/multi-signature"; +import "../../../src/transactions/types/multi-signature"; import { constants } from "@arkecosystem/crypto"; const { TransactionTypes } = constants; diff --git a/packages/core-test-utils/__tests__/matchers/transactions/types/second-signature.test.ts b/packages/core-jest-matchers/__tests__/transactions/types/second-signature.test.ts similarity index 86% rename from packages/core-test-utils/__tests__/matchers/transactions/types/second-signature.test.ts rename to packages/core-jest-matchers/__tests__/transactions/types/second-signature.test.ts index 29f1b03b03..8cf1626def 100644 --- a/packages/core-test-utils/__tests__/matchers/transactions/types/second-signature.test.ts +++ b/packages/core-jest-matchers/__tests__/transactions/types/second-signature.test.ts @@ -1,4 +1,4 @@ -import "../../../../src/matchers/transactions/types/second-signature"; +import "../../../src/transactions/types/second-signature"; import { constants } from "@arkecosystem/crypto"; const { TransactionTypes } = constants; diff --git a/packages/core-test-utils/__tests__/matchers/transactions/types/timelock-transfer.test.ts b/packages/core-jest-matchers/__tests__/transactions/types/timelock-transfer.test.ts similarity index 86% rename from packages/core-test-utils/__tests__/matchers/transactions/types/timelock-transfer.test.ts rename to packages/core-jest-matchers/__tests__/transactions/types/timelock-transfer.test.ts index 408a26dfd7..b80ec4296e 100644 --- a/packages/core-test-utils/__tests__/matchers/transactions/types/timelock-transfer.test.ts +++ b/packages/core-jest-matchers/__tests__/transactions/types/timelock-transfer.test.ts @@ -1,4 +1,4 @@ -import "../../../../src/matchers/transactions/types/timelock-transfer"; +import "../../../src/transactions/types/timelock-transfer"; import { constants } from "@arkecosystem/crypto"; const { TransactionTypes } = constants; diff --git a/packages/core-test-utils/__tests__/matchers/transactions/types/transfer.test.ts b/packages/core-jest-matchers/__tests__/transactions/types/transfer.test.ts similarity index 86% rename from packages/core-test-utils/__tests__/matchers/transactions/types/transfer.test.ts rename to packages/core-jest-matchers/__tests__/transactions/types/transfer.test.ts index fb93db084d..cde99c3332 100644 --- a/packages/core-test-utils/__tests__/matchers/transactions/types/transfer.test.ts +++ b/packages/core-jest-matchers/__tests__/transactions/types/transfer.test.ts @@ -1,4 +1,4 @@ -import "../../../../src/matchers/transactions/types/transfer"; +import "../../../src/transactions/types/transfer"; import { constants } from "@arkecosystem/crypto"; const { TransactionTypes } = constants; diff --git a/packages/core-test-utils/__tests__/matchers/transactions/types/vote.test.ts b/packages/core-jest-matchers/__tests__/transactions/types/vote.test.ts similarity index 86% rename from packages/core-test-utils/__tests__/matchers/transactions/types/vote.test.ts rename to packages/core-jest-matchers/__tests__/transactions/types/vote.test.ts index 4f5e4e7050..5d0fa28fbd 100644 --- a/packages/core-test-utils/__tests__/matchers/transactions/types/vote.test.ts +++ b/packages/core-jest-matchers/__tests__/transactions/types/vote.test.ts @@ -1,4 +1,4 @@ -import "../../../../src/matchers/transactions/types/vote"; +import "../../../src/transactions/types/vote"; import { constants } from "@arkecosystem/crypto"; const { TransactionTypes } = constants; diff --git a/packages/core-jest-matchers/__tests__/transactions/valid-second-signature.test.ts b/packages/core-jest-matchers/__tests__/transactions/valid-second-signature.test.ts new file mode 100644 index 0000000000..1b63cab5db --- /dev/null +++ b/packages/core-jest-matchers/__tests__/transactions/valid-second-signature.test.ts @@ -0,0 +1,84 @@ +import "../../src/transactions/valid-second-signature"; + +// import { generators } from "@arkecosystem/core-test-utils"; +// const wallets = generators.generateWallets("testnet", 2); +// const transaction = generators.generateTransfers("testnet", wallets.map(w => w.passphrase))[0]; + +const wallets = [ + { + address: "AWTRWfm2qdEwxbXnLXxQnviMywFGSHdgkn", + passphrase: "poet virtual attend winter mushroom near manual dish exact palm siren motion", + publicKey: "0322bb7969362a15c78b70be2adcfd270a2ad9f2cd0faed14a5d809c7fd5773e48", + }, + { + address: "AaWAUV5hgDdUnpWHkD1a65AFQBayGgTaFF", + passphrase: "obtain flower vital stone song express combine issue used excite despair trash", + publicKey: "02300c5296527a2ff8586b6d2af383db4e487e6c9a45b6b55dd795393ef460568c", + }, +]; + +const transaction = { + serialized: + "ff01170088795c030322bb7969362a15c78b70be2adcfd270a2ad9f2cd0faed14a5d809c7fd5773e4880969800000000001254657374205472616e73616374696f6e203102000000000000000000000017a10c9543273d90fb4200897a47f51164ae3c92653045022100ef114e808311bd49edc18c7fe83357bb3fdf67d69c32153ed683150aa1b3143802207635a5594c5b394409af49b8289a5c47f4ae5785f5c62ea95a207c66fe30dd943045022100fff70add8db1d54d1c504c354417c2ba5a03401e93cd9ec3f75605a64888d04502203c70c1a86c3c416af913a4d657b461d73f2297061801982463d7bd47f5a91cfe", + verified: true, + id: "ca29499181a5b8145caacb21c638b63de60a9e7cc3a4d4bef367e653c4242f61", + sequence: undefined, + version: 1, + timestamp: 56392072, + senderPublicKey: "0322bb7969362a15c78b70be2adcfd270a2ad9f2cd0faed14a5d809c7fd5773e48", + recipientId: "AWTRWfm2qdEwxbXnLXxQnviMywFGSHdgkn", + type: 0, + vendorField: "Test Transaction 1", + vendorFieldHex: "54657374205472616e73616374696f6e2031", + amount: 2, + fee: 10000000, + blockId: undefined, + signature: + "3045022100ef114e808311bd49edc18c7fe83357bb3fdf67d69c32153ed683150aa1b3143802207635a5594c5b394409af49b8289a5c47f4ae5785f5c62ea95a207c66fe30dd94", + signatures: undefined, + secondSignature: + "3045022100fff70add8db1d54d1c504c354417c2ba5a03401e93cd9ec3f75605a64888d04502203c70c1a86c3c416af913a4d657b461d73f2297061801982463d7bd47f5a91cfe", + signSignature: + "3045022100fff70add8db1d54d1c504c354417c2ba5a03401e93cd9ec3f75605a64888d04502203c70c1a86c3c416af913a4d657b461d73f2297061801982463d7bd47f5a91cfe", + asset: undefined, + expiration: 0, + timelock: undefined, + timelockType: undefined, + data: { + version: 1, + network: 23, + type: 0, + timestamp: 56392072, + senderPublicKey: "0322bb7969362a15c78b70be2adcfd270a2ad9f2cd0faed14a5d809c7fd5773e48", + fee: 10000000, + vendorFieldHex: "54657374205472616e73616374696f6e2031", + amount: 2, + expiration: 0, + recipientId: "AWTRWfm2qdEwxbXnLXxQnviMywFGSHdgkn", + signature: + "3045022100ef114e808311bd49edc18c7fe83357bb3fdf67d69c32153ed683150aa1b3143802207635a5594c5b394409af49b8289a5c47f4ae5785f5c62ea95a207c66fe30dd94", + secondSignature: + "3045022100fff70add8db1d54d1c504c354417c2ba5a03401e93cd9ec3f75605a64888d04502203c70c1a86c3c416af913a4d657b461d73f2297061801982463d7bd47f5a91cfe", + signSignature: + "3045022100fff70add8db1d54d1c504c354417c2ba5a03401e93cd9ec3f75605a64888d04502203c70c1a86c3c416af913a4d657b461d73f2297061801982463d7bd47f5a91cfe", + vendorField: "Test Transaction 1", + id: "ca29499181a5b8145caacb21c638b63de60a9e7cc3a4d4bef367e653c4242f61", + }, +}; + +describe(".toHaveValidSecondSignature", () => { + test("passes when given a valid transaction", () => { + expect(transaction).toHaveValidSecondSignature({ + publicKey: wallets[1].publicKey, + }); + }); + + test("fails when given an invalid transaction", () => { + transaction.secondSignature = "invalid"; + transaction.signSignature = "invalid"; + + expect(transaction).not.toHaveValidSecondSignature({ + publicKey: wallets[1].publicKey, + }); + }); +}); diff --git a/packages/core-test-utils/__tests__/matchers/transactions/valid.test.ts b/packages/core-jest-matchers/__tests__/transactions/valid.test.ts similarity index 94% rename from packages/core-test-utils/__tests__/matchers/transactions/valid.test.ts rename to packages/core-jest-matchers/__tests__/transactions/valid.test.ts index 5b10c34773..be5aee55d1 100644 --- a/packages/core-test-utils/__tests__/matchers/transactions/valid.test.ts +++ b/packages/core-jest-matchers/__tests__/transactions/valid.test.ts @@ -1,4 +1,4 @@ -import "../../../src/matchers/transactions/valid"; +import "../../src/transactions/valid"; const transaction = { version: 1, diff --git a/packages/core-jest-matchers/package.json b/packages/core-jest-matchers/package.json new file mode 100644 index 0000000000..0d272204c9 --- /dev/null +++ b/packages/core-jest-matchers/package.json @@ -0,0 +1,54 @@ +{ + "name": "@arkecosystem/core-jest-matchers", + "description": "Jest matchers for Ark Core", + "version": "2.1.0", + "contributors": [ + "Brian Faust ", + "Erwann Gentric ", + "Joshua Noack " + ], + "license": "MIT", + "main": "dist/index.js", + "files": [ + "dist" + ], + "scripts": { + "prepublishOnly": "yarn test && yarn build", + "pretest": "yarn lint && yarn build", + "compile": "../../node_modules/typescript/bin/tsc", + "build": "yarn clean && yarn compile", + "build:watch": "yarn clean && yarn compile -w", + "clean": "del dist", + "docs": "../../node_modules/typedoc/bin/typedoc src --out docs", + "lint": "../../node_modules/tslint/bin/tslint -c ../../tslint.json 'src/**/*.ts' '__tests__/**/*.ts' --fix", + "test": "cross-env ARK_ENV=test jest --runInBand --forceExit", + "test:coverage": "cross-env ARK_ENV=test jest --coverage --coveragePathIgnorePatterns='/(defaults.ts|index.ts)$' --runInBand --forceExit", + "test:debug": "cross-env ARK_ENV=test node --inspect-brk ../../node_modules/.bin/jest --runInBand", + "test:watch": "cross-env ARK_ENV=test jest --runInBand --watch", + "test:watch:all": "cross-env ARK_ENV=test jest --runInBand --watchAll", + "updates": "../../node_modules/npm-check-updates/bin/npm-check-updates -a" + }, + "dependencies": { + "@arkecosystem/core-container": "^2.1.0", + "@arkecosystem/crypto": "^2.1.0", + "@types/bip39": "^2.4.1", + "@types/lodash.get": "^4.4.4", + "@types/lodash.isequal": "^4.5.3", + "@types/lodash.sortby": "^4.7.4", + "bip39": "^2.5.0", + "lodash.get": "^4.4.2", + "lodash.isequal": "^4.5.0", + "lodash.sortby": "^4.7.0", + "superheroes": "^2.0.0", + "xstate": "^4.2.2" + }, + "publishConfig": { + "access": "public" + }, + "engines": { + "node": ">=10.x" + }, + "jest": { + "preset": "../../jest-preset.json" + } +} diff --git a/packages/core-test-utils/src/matchers/api/block.ts b/packages/core-jest-matchers/src/api/block.ts similarity index 100% rename from packages/core-test-utils/src/matchers/api/block.ts rename to packages/core-jest-matchers/src/api/block.ts diff --git a/packages/core-test-utils/src/matchers/api/index.ts b/packages/core-jest-matchers/src/api/index.ts similarity index 100% rename from packages/core-test-utils/src/matchers/api/index.ts rename to packages/core-jest-matchers/src/api/index.ts diff --git a/packages/core-test-utils/src/matchers/api/peer.ts b/packages/core-jest-matchers/src/api/peer.ts similarity index 100% rename from packages/core-test-utils/src/matchers/api/peer.ts rename to packages/core-jest-matchers/src/api/peer.ts diff --git a/packages/core-test-utils/src/matchers/api/response.ts b/packages/core-jest-matchers/src/api/response.ts similarity index 100% rename from packages/core-test-utils/src/matchers/api/response.ts rename to packages/core-jest-matchers/src/api/response.ts diff --git a/packages/core-test-utils/src/matchers/api/transaction.ts b/packages/core-jest-matchers/src/api/transaction.ts similarity index 100% rename from packages/core-test-utils/src/matchers/api/transaction.ts rename to packages/core-jest-matchers/src/api/transaction.ts diff --git a/packages/core-test-utils/src/matchers/blockchain/dispatch.ts b/packages/core-jest-matchers/src/blockchain/dispatch.ts similarity index 100% rename from packages/core-test-utils/src/matchers/blockchain/dispatch.ts rename to packages/core-jest-matchers/src/blockchain/dispatch.ts diff --git a/packages/core-test-utils/src/matchers/blockchain/execute-on-entry.ts b/packages/core-jest-matchers/src/blockchain/execute-on-entry.ts similarity index 100% rename from packages/core-test-utils/src/matchers/blockchain/execute-on-entry.ts rename to packages/core-jest-matchers/src/blockchain/execute-on-entry.ts diff --git a/packages/core-test-utils/src/matchers/blockchain/index.ts b/packages/core-jest-matchers/src/blockchain/index.ts similarity index 100% rename from packages/core-test-utils/src/matchers/blockchain/index.ts rename to packages/core-jest-matchers/src/blockchain/index.ts diff --git a/packages/core-test-utils/src/matchers/blockchain/transition.ts b/packages/core-jest-matchers/src/blockchain/transition.ts similarity index 100% rename from packages/core-test-utils/src/matchers/blockchain/transition.ts rename to packages/core-jest-matchers/src/blockchain/transition.ts diff --git a/packages/core-test-utils/src/matchers/fields/address.ts b/packages/core-jest-matchers/src/fields/address.ts similarity index 100% rename from packages/core-test-utils/src/matchers/fields/address.ts rename to packages/core-jest-matchers/src/fields/address.ts diff --git a/packages/core-test-utils/src/matchers/fields/index.ts b/packages/core-jest-matchers/src/fields/index.ts similarity index 100% rename from packages/core-test-utils/src/matchers/fields/index.ts rename to packages/core-jest-matchers/src/fields/index.ts diff --git a/packages/core-test-utils/src/matchers/fields/public-key.ts b/packages/core-jest-matchers/src/fields/public-key.ts similarity index 100% rename from packages/core-test-utils/src/matchers/fields/public-key.ts rename to packages/core-jest-matchers/src/fields/public-key.ts diff --git a/packages/core-test-utils/src/matchers/index.ts b/packages/core-jest-matchers/src/index.ts similarity index 100% rename from packages/core-test-utils/src/matchers/index.ts rename to packages/core-jest-matchers/src/index.ts diff --git a/packages/core-test-utils/src/matchers/models/delegate.ts b/packages/core-jest-matchers/src/models/delegate.ts similarity index 100% rename from packages/core-test-utils/src/matchers/models/delegate.ts rename to packages/core-jest-matchers/src/models/delegate.ts diff --git a/packages/core-test-utils/src/matchers/models/index.ts b/packages/core-jest-matchers/src/models/index.ts similarity index 100% rename from packages/core-test-utils/src/matchers/models/index.ts rename to packages/core-jest-matchers/src/models/index.ts diff --git a/packages/core-test-utils/src/matchers/models/transaction.ts b/packages/core-jest-matchers/src/models/transaction.ts similarity index 100% rename from packages/core-test-utils/src/matchers/models/transaction.ts rename to packages/core-jest-matchers/src/models/transaction.ts diff --git a/packages/core-test-utils/src/matchers/models/wallet.ts b/packages/core-jest-matchers/src/models/wallet.ts similarity index 100% rename from packages/core-test-utils/src/matchers/models/wallet.ts rename to packages/core-jest-matchers/src/models/wallet.ts diff --git a/packages/core-test-utils/src/matchers/transactions/index.ts b/packages/core-jest-matchers/src/transactions/index.ts similarity index 100% rename from packages/core-test-utils/src/matchers/transactions/index.ts rename to packages/core-jest-matchers/src/transactions/index.ts diff --git a/packages/core-test-utils/src/matchers/transactions/types/delegate-resignation.ts b/packages/core-jest-matchers/src/transactions/types/delegate-resignation.ts similarity index 100% rename from packages/core-test-utils/src/matchers/transactions/types/delegate-resignation.ts rename to packages/core-jest-matchers/src/transactions/types/delegate-resignation.ts diff --git a/packages/core-test-utils/src/matchers/transactions/types/delegate.ts b/packages/core-jest-matchers/src/transactions/types/delegate.ts similarity index 100% rename from packages/core-test-utils/src/matchers/transactions/types/delegate.ts rename to packages/core-jest-matchers/src/transactions/types/delegate.ts diff --git a/packages/core-test-utils/src/matchers/transactions/types/index.ts b/packages/core-jest-matchers/src/transactions/types/index.ts similarity index 100% rename from packages/core-test-utils/src/matchers/transactions/types/index.ts rename to packages/core-jest-matchers/src/transactions/types/index.ts diff --git a/packages/core-test-utils/src/matchers/transactions/types/ipfs.ts b/packages/core-jest-matchers/src/transactions/types/ipfs.ts similarity index 100% rename from packages/core-test-utils/src/matchers/transactions/types/ipfs.ts rename to packages/core-jest-matchers/src/transactions/types/ipfs.ts diff --git a/packages/core-test-utils/src/matchers/transactions/types/multi-payment.ts b/packages/core-jest-matchers/src/transactions/types/multi-payment.ts similarity index 100% rename from packages/core-test-utils/src/matchers/transactions/types/multi-payment.ts rename to packages/core-jest-matchers/src/transactions/types/multi-payment.ts diff --git a/packages/core-test-utils/src/matchers/transactions/types/multi-signature.ts b/packages/core-jest-matchers/src/transactions/types/multi-signature.ts similarity index 100% rename from packages/core-test-utils/src/matchers/transactions/types/multi-signature.ts rename to packages/core-jest-matchers/src/transactions/types/multi-signature.ts diff --git a/packages/core-test-utils/src/matchers/transactions/types/second-signature.ts b/packages/core-jest-matchers/src/transactions/types/second-signature.ts similarity index 100% rename from packages/core-test-utils/src/matchers/transactions/types/second-signature.ts rename to packages/core-jest-matchers/src/transactions/types/second-signature.ts diff --git a/packages/core-test-utils/src/matchers/transactions/types/timelock-transfer.ts b/packages/core-jest-matchers/src/transactions/types/timelock-transfer.ts similarity index 100% rename from packages/core-test-utils/src/matchers/transactions/types/timelock-transfer.ts rename to packages/core-jest-matchers/src/transactions/types/timelock-transfer.ts diff --git a/packages/core-test-utils/src/matchers/transactions/types/transfer.ts b/packages/core-jest-matchers/src/transactions/types/transfer.ts similarity index 100% rename from packages/core-test-utils/src/matchers/transactions/types/transfer.ts rename to packages/core-jest-matchers/src/transactions/types/transfer.ts diff --git a/packages/core-test-utils/src/matchers/transactions/types/vote.ts b/packages/core-jest-matchers/src/transactions/types/vote.ts similarity index 100% rename from packages/core-test-utils/src/matchers/transactions/types/vote.ts rename to packages/core-jest-matchers/src/transactions/types/vote.ts diff --git a/packages/core-test-utils/src/matchers/transactions/valid-second-signature.ts b/packages/core-jest-matchers/src/transactions/valid-second-signature.ts similarity index 100% rename from packages/core-test-utils/src/matchers/transactions/valid-second-signature.ts rename to packages/core-jest-matchers/src/transactions/valid-second-signature.ts diff --git a/packages/core-test-utils/src/matchers/transactions/valid.ts b/packages/core-jest-matchers/src/transactions/valid.ts similarity index 100% rename from packages/core-test-utils/src/matchers/transactions/valid.ts rename to packages/core-jest-matchers/src/transactions/valid.ts diff --git a/packages/core-jest-matchers/tsconfig.json b/packages/core-jest-matchers/tsconfig.json new file mode 100644 index 0000000000..0b089c5fa8 --- /dev/null +++ b/packages/core-jest-matchers/tsconfig.json @@ -0,0 +1,7 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "outDir": "dist" + }, + "include": ["src/**/**.ts"] +} diff --git a/packages/core-test-utils/__tests__/matchers/transactions/valid-second-signature.test.ts b/packages/core-test-utils/__tests__/matchers/transactions/valid-second-signature.test.ts deleted file mode 100644 index 575acc60ab..0000000000 --- a/packages/core-test-utils/__tests__/matchers/transactions/valid-second-signature.test.ts +++ /dev/null @@ -1,23 +0,0 @@ -import "../../../src/matchers/transactions/valid-second-signature"; - -import { generateTransfers, generateWallets } from "../../../src/generators"; - -const wallets = generateWallets("testnet", 2); -const transaction = generateTransfers("testnet", wallets.map(w => w.passphrase))[0]; - -describe(".toHaveValidSecondSignature", () => { - test("passes when given a valid transaction", () => { - expect(transaction).toHaveValidSecondSignature({ - publicKey: wallets[1].publicKey, - }); - }); - - test("fails when given an invalid transaction", () => { - transaction.secondSignature = "invalid"; - transaction.signSignature = "invalid"; - - expect(transaction).not.toHaveValidSecondSignature({ - publicKey: wallets[1].publicKey, - }); - }); -}); diff --git a/packages/core-test-utils/package.json b/packages/core-test-utils/package.json index 365e0764f6..ca3023fc15 100644 --- a/packages/core-test-utils/package.json +++ b/packages/core-test-utils/package.json @@ -3,7 +3,9 @@ "description": "Test Utilities for Ark Core", "version": "2.1.0", "contributors": [ - "Brian Faust " + "Brian Faust ", + "Erwann Gentric ", + "Joshua Noack " ], "license": "MIT", "main": "dist/index.js", @@ -28,6 +30,7 @@ }, "dependencies": { "@arkecosystem/core-container": "^2.1.0", + "@arkecosystem/core-jest-matchers": "^2.1.0", "@arkecosystem/crypto": "^2.1.0", "@types/bip39": "^2.4.1", "@types/lodash.get": "^4.4.4", diff --git a/packages/core-test-utils/src/index.ts b/packages/core-test-utils/src/index.ts index fcb4b04cad..1edd203f01 100644 --- a/packages/core-test-utils/src/index.ts +++ b/packages/core-test-utils/src/index.ts @@ -1,7 +1,7 @@ +import "@arkecosystem/core-jest-matchers"; + import * as fixtures from "./fixtures"; import * as generators from "./generators"; import * as helpers from "./helpers"; -import "./matchers"; - export { fixtures, generators, helpers }; From cb3949b32d2e496a1ba157afbf813e6b88284d66 Mon Sep 17 00:00:00 2001 From: Brian Faust Date: Thu, 3 Jan 2019 07:44:03 +0200 Subject: [PATCH 2/2] fix(core-test-utils): import core-jest-matchers instead of local files --- packages/core-test-utils/src/helpers/container.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/core-test-utils/src/helpers/container.ts b/packages/core-test-utils/src/helpers/container.ts index a7ef259e77..d0a05394b1 100644 --- a/packages/core-test-utils/src/helpers/container.ts +++ b/packages/core-test-utils/src/helpers/container.ts @@ -1,6 +1,6 @@ import { app, Container } from "@arkecosystem/core-container"; +import "@arkecosystem/core-jest-matchers"; import * as path from "path"; -import "../matchers"; export async function setUpContainer(options: any): Promise { await app.setUp(