movehat 0.1.8 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/__tests__/deployContract.test.d.ts +2 -0
- package/dist/__tests__/deployContract.test.d.ts.map +1 -0
- package/dist/__tests__/deployContract.test.js +368 -0
- package/dist/__tests__/deployContract.test.js.map +1 -0
- package/dist/__tests__/errors.test.d.ts +2 -0
- package/dist/__tests__/errors.test.d.ts.map +1 -0
- package/dist/__tests__/errors.test.js +46 -0
- package/dist/__tests__/errors.test.js.map +1 -0
- package/dist/__tests__/fixtures/sigint-deploy-harness.d.ts +24 -0
- package/dist/__tests__/fixtures/sigint-deploy-harness.d.ts.map +1 -0
- package/dist/__tests__/fixtures/sigint-deploy-harness.js +82 -0
- package/dist/__tests__/fixtures/sigint-deploy-harness.js.map +1 -0
- package/dist/__tests__/fork/api.test.d.ts +2 -0
- package/dist/__tests__/fork/api.test.d.ts.map +1 -0
- package/dist/__tests__/fork/api.test.js +110 -0
- package/dist/__tests__/fork/api.test.js.map +1 -0
- package/dist/__tests__/harness/Harness.createLive.test.d.ts +2 -0
- package/dist/__tests__/harness/Harness.createLive.test.d.ts.map +1 -0
- package/dist/__tests__/harness/Harness.createLive.test.js +53 -0
- package/dist/__tests__/harness/Harness.createLive.test.js.map +1 -0
- package/dist/__tests__/harness/Harness.proxy.test.d.ts +2 -0
- package/dist/__tests__/harness/Harness.proxy.test.d.ts.map +1 -0
- package/dist/__tests__/harness/Harness.proxy.test.js +93 -0
- package/dist/__tests__/harness/Harness.proxy.test.js.map +1 -0
- package/dist/__tests__/harness/_fixture.d.ts +54 -0
- package/dist/__tests__/harness/_fixture.d.ts.map +1 -0
- package/dist/__tests__/harness/_fixture.js +69 -0
- package/dist/__tests__/harness/_fixture.js.map +1 -0
- package/dist/__tests__/harness/codeObject.deploy.test.d.ts +2 -0
- package/dist/__tests__/harness/codeObject.deploy.test.d.ts.map +1 -0
- package/dist/__tests__/harness/codeObject.deploy.test.js +288 -0
- package/dist/__tests__/harness/codeObject.deploy.test.js.map +1 -0
- package/dist/__tests__/harness/codeObject.upgrade.test.d.ts +2 -0
- package/dist/__tests__/harness/codeObject.upgrade.test.d.ts.map +1 -0
- package/dist/__tests__/harness/codeObject.upgrade.test.js +138 -0
- package/dist/__tests__/harness/codeObject.upgrade.test.js.map +1 -0
- package/dist/__tests__/harness/script.test.d.ts +2 -0
- package/dist/__tests__/harness/script.test.d.ts.map +1 -0
- package/dist/__tests__/harness/script.test.js +219 -0
- package/dist/__tests__/harness/script.test.js.map +1 -0
- package/dist/__tests__/harness/view.test.d.ts +2 -0
- package/dist/__tests__/harness/view.test.d.ts.map +1 -0
- package/dist/__tests__/harness/view.test.js +92 -0
- package/dist/__tests__/harness/view.test.js.map +1 -0
- package/dist/__tests__/runtime.test.d.ts +2 -0
- package/dist/__tests__/runtime.test.d.ts.map +1 -0
- package/dist/__tests__/runtime.test.js +141 -0
- package/dist/__tests__/runtime.test.js.map +1 -0
- package/dist/cli.js +2 -1
- package/dist/cli.js.map +1 -1
- package/dist/commands/__tests__/compile.test.d.ts +2 -0
- package/dist/commands/__tests__/compile.test.d.ts.map +1 -0
- package/dist/commands/__tests__/compile.test.js +351 -0
- package/dist/commands/__tests__/compile.test.js.map +1 -0
- package/dist/commands/__tests__/init.test.d.ts +2 -0
- package/dist/commands/__tests__/init.test.d.ts.map +1 -0
- package/dist/commands/__tests__/init.test.js +101 -0
- package/dist/commands/__tests__/init.test.js.map +1 -0
- package/dist/commands/__tests__/run.test.d.ts +2 -0
- package/dist/commands/__tests__/run.test.d.ts.map +1 -0
- package/dist/commands/__tests__/run.test.js +166 -0
- package/dist/commands/__tests__/run.test.js.map +1 -0
- package/dist/commands/__tests__/test-move.test.d.ts +2 -0
- package/dist/commands/__tests__/test-move.test.d.ts.map +1 -0
- package/dist/commands/__tests__/test-move.test.js +59 -0
- package/dist/commands/__tests__/test-move.test.js.map +1 -0
- package/dist/commands/__tests__/test.test.d.ts +2 -0
- package/dist/commands/__tests__/test.test.d.ts.map +1 -0
- package/dist/commands/__tests__/test.test.js +168 -0
- package/dist/commands/__tests__/test.test.js.map +1 -0
- package/dist/commands/__tests__/update.test.d.ts +2 -0
- package/dist/commands/__tests__/update.test.d.ts.map +1 -0
- package/dist/commands/__tests__/update.test.js +176 -0
- package/dist/commands/__tests__/update.test.js.map +1 -0
- package/dist/commands/compile.d.ts +7 -1
- package/dist/commands/compile.d.ts.map +1 -1
- package/dist/commands/compile.js +150 -33
- package/dist/commands/compile.js.map +1 -1
- package/dist/commands/fork/__tests__/create.test.d.ts +2 -0
- package/dist/commands/fork/__tests__/create.test.d.ts.map +1 -0
- package/dist/commands/fork/__tests__/create.test.js +108 -0
- package/dist/commands/fork/__tests__/create.test.js.map +1 -0
- package/dist/commands/fork/__tests__/fund.test.d.ts +2 -0
- package/dist/commands/fork/__tests__/fund.test.d.ts.map +1 -0
- package/dist/commands/fork/__tests__/fund.test.js +72 -0
- package/dist/commands/fork/__tests__/fund.test.js.map +1 -0
- package/dist/commands/fork/__tests__/list.test.d.ts +2 -0
- package/dist/commands/fork/__tests__/list.test.d.ts.map +1 -0
- package/dist/commands/fork/__tests__/list.test.js +119 -0
- package/dist/commands/fork/__tests__/list.test.js.map +1 -0
- package/dist/commands/fork/__tests__/serve.test.d.ts +2 -0
- package/dist/commands/fork/__tests__/serve.test.d.ts.map +1 -0
- package/dist/commands/fork/__tests__/serve.test.js +97 -0
- package/dist/commands/fork/__tests__/serve.test.js.map +1 -0
- package/dist/commands/fork/__tests__/view-resource.test.d.ts +2 -0
- package/dist/commands/fork/__tests__/view-resource.test.d.ts.map +1 -0
- package/dist/commands/fork/__tests__/view-resource.test.js +77 -0
- package/dist/commands/fork/__tests__/view-resource.test.js.map +1 -0
- package/dist/commands/fork/create.d.ts +1 -1
- package/dist/commands/fork/create.d.ts.map +1 -1
- package/dist/commands/fork/create.js +3 -2
- package/dist/commands/fork/create.js.map +1 -1
- package/dist/commands/fork/fund.d.ts.map +1 -1
- package/dist/commands/fork/fund.js +15 -8
- package/dist/commands/fork/fund.js.map +1 -1
- package/dist/commands/fork/list.d.ts.map +1 -1
- package/dist/commands/fork/list.js +2 -1
- package/dist/commands/fork/list.js.map +1 -1
- package/dist/commands/fork/serve.d.ts +1 -0
- package/dist/commands/fork/serve.d.ts.map +1 -1
- package/dist/commands/fork/serve.js +4 -2
- package/dist/commands/fork/serve.js.map +1 -1
- package/dist/commands/fork/view-resource.d.ts.map +1 -1
- package/dist/commands/fork/view-resource.js +10 -5
- package/dist/commands/fork/view-resource.js.map +1 -1
- package/dist/commands/run.d.ts +15 -0
- package/dist/commands/run.d.ts.map +1 -1
- package/dist/commands/run.js +50 -27
- package/dist/commands/run.js.map +1 -1
- package/dist/commands/test-move.d.ts.map +1 -1
- package/dist/commands/test-move.js +3 -2
- package/dist/commands/test-move.js.map +1 -1
- package/dist/commands/test.js +52 -46
- package/dist/commands/test.js.map +1 -1
- package/dist/commands/update.d.ts.map +1 -1
- package/dist/commands/update.js +15 -13
- package/dist/commands/update.js.map +1 -1
- package/dist/core/AccountManager.d.ts +1 -1
- package/dist/core/AccountManager.d.ts.map +1 -1
- package/dist/core/AccountManager.js +20 -7
- package/dist/core/AccountManager.js.map +1 -1
- package/dist/core/Publisher.d.ts +31 -0
- package/dist/core/Publisher.d.ts.map +1 -0
- package/dist/core/Publisher.js +248 -0
- package/dist/core/Publisher.js.map +1 -0
- package/dist/core/__tests__/AccountManager.test.d.ts +2 -0
- package/dist/core/__tests__/AccountManager.test.d.ts.map +1 -0
- package/dist/core/__tests__/AccountManager.test.js +239 -0
- package/dist/core/__tests__/AccountManager.test.js.map +1 -0
- package/dist/core/__tests__/config.test.d.ts +2 -0
- package/dist/core/__tests__/config.test.d.ts.map +1 -0
- package/dist/core/__tests__/config.test.js +311 -0
- package/dist/core/__tests__/config.test.js.map +1 -0
- package/dist/core/__tests__/deployments.test.d.ts +2 -0
- package/dist/core/__tests__/deployments.test.d.ts.map +1 -0
- package/dist/core/__tests__/deployments.test.js +201 -0
- package/dist/core/__tests__/deployments.test.js.map +1 -0
- package/dist/core/__tests__/shell.test.d.ts +2 -0
- package/dist/core/__tests__/shell.test.d.ts.map +1 -0
- package/dist/core/__tests__/shell.test.js +107 -0
- package/dist/core/__tests__/shell.test.js.map +1 -0
- package/dist/core/config.d.ts +13 -1
- package/dist/core/config.d.ts.map +1 -1
- package/dist/core/config.js +80 -11
- package/dist/core/config.js.map +1 -1
- package/dist/core/contract.d.ts +1 -1
- package/dist/core/contract.d.ts.map +1 -1
- package/dist/core/contract.js +15 -4
- package/dist/core/contract.js.map +1 -1
- package/dist/core/deployments.d.ts +2 -2
- package/dist/core/deployments.d.ts.map +1 -1
- package/dist/core/deployments.js +8 -6
- package/dist/core/deployments.js.map +1 -1
- package/dist/core/movementProfile.d.ts +34 -0
- package/dist/core/movementProfile.d.ts.map +1 -0
- package/dist/core/movementProfile.js +150 -0
- package/dist/core/movementProfile.js.map +1 -0
- package/dist/core/shell.d.ts +23 -7
- package/dist/core/shell.d.ts.map +1 -1
- package/dist/core/shell.js +32 -14
- package/dist/core/shell.js.map +1 -1
- package/dist/errors.d.ts +35 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +54 -0
- package/dist/errors.js.map +1 -1
- package/dist/fork/__tests__/manager.test.d.ts +2 -0
- package/dist/fork/__tests__/manager.test.d.ts.map +1 -0
- package/dist/fork/__tests__/manager.test.js +309 -0
- package/dist/fork/__tests__/manager.test.js.map +1 -0
- package/dist/fork/__tests__/server.test.d.ts +2 -0
- package/dist/fork/__tests__/server.test.d.ts.map +1 -0
- package/dist/fork/__tests__/server.test.js +54 -0
- package/dist/fork/__tests__/server.test.js.map +1 -0
- package/dist/fork/__tests__/storage.test.d.ts +2 -0
- package/dist/fork/__tests__/storage.test.d.ts.map +1 -0
- package/dist/fork/__tests__/storage.test.js +222 -0
- package/dist/fork/__tests__/storage.test.js.map +1 -0
- package/dist/fork/__tests__/test.test.d.ts +2 -0
- package/dist/fork/__tests__/test.test.d.ts.map +1 -0
- package/dist/fork/__tests__/test.test.js +81 -0
- package/dist/fork/__tests__/test.test.js.map +1 -0
- package/dist/fork/api.d.ts +14 -3
- package/dist/fork/api.d.ts.map +1 -1
- package/dist/fork/api.js +25 -14
- package/dist/fork/api.js.map +1 -1
- package/dist/fork/manager.d.ts +23 -9
- package/dist/fork/manager.d.ts.map +1 -1
- package/dist/fork/manager.js +79 -36
- package/dist/fork/manager.js.map +1 -1
- package/dist/fork/server.d.ts +11 -3
- package/dist/fork/server.d.ts.map +1 -1
- package/dist/fork/server.js +45 -13
- package/dist/fork/server.js.map +1 -1
- package/dist/fork/storage.d.ts +4 -4
- package/dist/fork/storage.d.ts.map +1 -1
- package/dist/fork/storage.js +7 -9
- package/dist/fork/storage.js.map +1 -1
- package/dist/fork/test.d.ts +13 -4
- package/dist/fork/test.d.ts.map +1 -1
- package/dist/fork/test.js +36 -27
- package/dist/fork/test.js.map +1 -1
- package/dist/harness/Harness.d.ts +124 -0
- package/dist/harness/Harness.d.ts.map +1 -0
- package/dist/harness/Harness.js +193 -0
- package/dist/harness/Harness.js.map +1 -0
- package/dist/harness/codeObject.d.ts +31 -0
- package/dist/harness/codeObject.d.ts.map +1 -0
- package/dist/harness/codeObject.js +271 -0
- package/dist/harness/codeObject.js.map +1 -0
- package/dist/harness/errors.d.ts +14 -0
- package/dist/harness/errors.d.ts.map +1 -0
- package/dist/harness/errors.js +22 -0
- package/dist/harness/errors.js.map +1 -0
- package/dist/harness/index.d.ts +4 -0
- package/dist/harness/index.d.ts.map +1 -0
- package/dist/harness/index.js +3 -0
- package/dist/harness/index.js.map +1 -0
- package/dist/harness/proxy.d.ts +7 -0
- package/dist/harness/proxy.d.ts.map +1 -0
- package/dist/harness/proxy.js +36 -0
- package/dist/harness/proxy.js.map +1 -0
- package/dist/harness/script.d.ts +21 -0
- package/dist/harness/script.d.ts.map +1 -0
- package/dist/harness/script.js +155 -0
- package/dist/harness/script.js.map +1 -0
- package/dist/harness/view.d.ts +22 -0
- package/dist/harness/view.d.ts.map +1 -0
- package/dist/harness/view.js +28 -0
- package/dist/harness/view.js.map +1 -0
- package/dist/helpers/__tests__/semver-utils.test.d.ts +2 -0
- package/dist/helpers/__tests__/semver-utils.test.d.ts.map +1 -0
- package/dist/helpers/__tests__/semver-utils.test.js +103 -0
- package/dist/helpers/__tests__/semver-utils.test.js.map +1 -0
- package/dist/helpers/index.d.ts +3 -2
- package/dist/helpers/index.d.ts.map +1 -1
- package/dist/helpers/index.js +2 -2
- package/dist/helpers/index.js.map +1 -1
- package/dist/helpers/move-tests.d.ts +3 -3
- package/dist/helpers/move-tests.d.ts.map +1 -1
- package/dist/helpers/move-tests.js +21 -20
- package/dist/helpers/move-tests.js.map +1 -1
- package/dist/helpers/npm-registry.d.ts.map +1 -1
- package/dist/helpers/npm-registry.js +1 -3
- package/dist/helpers/npm-registry.js.map +1 -1
- package/dist/helpers/semver-utils.d.ts.map +1 -1
- package/dist/helpers/semver-utils.js +4 -3
- package/dist/helpers/semver-utils.js.map +1 -1
- package/dist/helpers/setup.d.ts.map +1 -1
- package/dist/helpers/setup.js +10 -6
- package/dist/helpers/setup.js.map +1 -1
- package/dist/helpers/setupLocalTesting.d.ts +32 -27
- package/dist/helpers/setupLocalTesting.d.ts.map +1 -1
- package/dist/helpers/setupLocalTesting.js +179 -180
- package/dist/helpers/setupLocalTesting.js.map +1 -1
- package/dist/helpers/testFixtures.d.ts +19 -53
- package/dist/helpers/testFixtures.d.ts.map +1 -1
- package/dist/helpers/testFixtures.js +89 -107
- package/dist/helpers/testFixtures.js.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -3
- package/dist/index.js.map +1 -1
- package/dist/node/LocalNodeManager.d.ts +9 -1
- package/dist/node/LocalNodeManager.d.ts.map +1 -1
- package/dist/node/LocalNodeManager.js +75 -58
- package/dist/node/LocalNodeManager.js.map +1 -1
- package/dist/node/__tests__/LocalNodeManager.test.d.ts +2 -0
- package/dist/node/__tests__/LocalNodeManager.test.d.ts.map +1 -0
- package/dist/node/__tests__/LocalNodeManager.test.js +349 -0
- package/dist/node/__tests__/LocalNodeManager.test.js.map +1 -0
- package/dist/runtime.d.ts +12 -15
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +32 -241
- package/dist/runtime.js.map +1 -1
- package/dist/templates/README.md +1 -1
- package/dist/templates/movehat.config.ts +10 -0
- package/dist/templates/package.json +2 -1
- package/dist/templates/scripts/deploy-counter.ts +46 -38
- package/dist/templates/tests/Counter.test.ts +51 -51
- package/dist/templates/types/movehat.d.ts +6 -9
- package/dist/types/config.d.ts +8 -0
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/fork.d.ts +7 -1
- package/dist/types/fork.d.ts.map +1 -1
- package/dist/types/harness.d.ts +166 -0
- package/dist/types/harness.d.ts.map +1 -0
- package/dist/types/harness.js +2 -0
- package/dist/types/harness.js.map +1 -0
- package/dist/types/runtime.d.ts +7 -1
- package/dist/types/runtime.d.ts.map +1 -1
- package/dist/ui/__tests__/colors.test.d.ts +2 -0
- package/dist/ui/__tests__/colors.test.d.ts.map +1 -0
- package/dist/ui/__tests__/colors.test.js +127 -0
- package/dist/ui/__tests__/colors.test.js.map +1 -0
- package/dist/ui/colors.d.ts.map +1 -1
- package/dist/ui/colors.js +6 -2
- package/dist/ui/colors.js.map +1 -1
- package/dist/ui/logger.d.ts +17 -0
- package/dist/ui/logger.d.ts.map +1 -1
- package/dist/ui/logger.js +22 -0
- package/dist/ui/logger.js.map +1 -1
- package/dist/ui/symbols.d.ts +1 -0
- package/dist/ui/symbols.d.ts.map +1 -1
- package/dist/ui/symbols.js +7 -1
- package/dist/ui/symbols.js.map +1 -1
- package/dist/utils/__tests__/address.test.d.ts +2 -0
- package/dist/utils/__tests__/address.test.d.ts.map +1 -0
- package/dist/utils/__tests__/address.test.js +70 -0
- package/dist/utils/__tests__/address.test.js.map +1 -0
- package/dist/utils/__tests__/childProcessAdapter.test.d.ts +2 -0
- package/dist/utils/__tests__/childProcessAdapter.test.d.ts.map +1 -0
- package/dist/utils/__tests__/childProcessAdapter.test.js +217 -0
- package/dist/utils/__tests__/childProcessAdapter.test.js.map +1 -0
- package/dist/utils/__tests__/runCli.test.d.ts +2 -0
- package/dist/utils/__tests__/runCli.test.d.ts.map +1 -0
- package/dist/utils/__tests__/runCli.test.js +187 -0
- package/dist/utils/__tests__/runCli.test.js.map +1 -0
- package/dist/utils/address.d.ts +33 -0
- package/dist/utils/address.d.ts.map +1 -0
- package/dist/utils/address.js +52 -0
- package/dist/utils/address.js.map +1 -0
- package/dist/utils/childProcessAdapter.d.ts +93 -0
- package/dist/utils/childProcessAdapter.d.ts.map +1 -0
- package/dist/utils/childProcessAdapter.js +109 -0
- package/dist/utils/childProcessAdapter.js.map +1 -0
- package/dist/utils/parseCliOutput.d.ts +20 -0
- package/dist/utils/parseCliOutput.d.ts.map +1 -0
- package/dist/utils/parseCliOutput.js +26 -0
- package/dist/utils/parseCliOutput.js.map +1 -0
- package/dist/utils/redact.d.ts +15 -0
- package/dist/utils/redact.d.ts.map +1 -0
- package/dist/utils/redact.js +24 -0
- package/dist/utils/redact.js.map +1 -0
- package/dist/utils/runCli.d.ts +24 -0
- package/dist/utils/runCli.d.ts.map +1 -0
- package/dist/utils/runCli.js +37 -0
- package/dist/utils/runCli.js.map +1 -0
- package/package.json +14 -4
- package/src/__tests__/deployContract.test.ts +429 -0
- package/src/__tests__/errors.test.ts +84 -0
- package/src/__tests__/fixtures/sigint-deploy-harness.ts +95 -0
- package/src/__tests__/fork/api.test.ts +143 -0
- package/src/__tests__/harness/Harness.createLive.test.ts +57 -0
- package/src/__tests__/harness/Harness.proxy.test.ts +115 -0
- package/src/__tests__/harness/_fixture.ts +131 -0
- package/src/__tests__/harness/codeObject.deploy.test.ts +319 -0
- package/src/__tests__/harness/codeObject.upgrade.test.ts +156 -0
- package/src/__tests__/harness/script.test.ts +245 -0
- package/src/__tests__/harness/view.test.ts +104 -0
- package/src/__tests__/runtime.test.ts +182 -0
- package/src/cli.ts +2 -1
- package/src/commands/__tests__/compile.test.ts +407 -0
- package/src/commands/__tests__/init.test.ts +125 -0
- package/src/commands/__tests__/run.test.ts +192 -0
- package/src/commands/__tests__/test-move.test.ts +81 -0
- package/src/commands/__tests__/test.test.ts +204 -0
- package/src/commands/__tests__/update.test.ts +223 -0
- package/src/commands/compile.ts +168 -32
- package/src/commands/fork/__tests__/create.test.ts +132 -0
- package/src/commands/fork/__tests__/fund.test.ts +104 -0
- package/src/commands/fork/__tests__/list.test.ts +139 -0
- package/src/commands/fork/__tests__/serve.test.ts +121 -0
- package/src/commands/fork/__tests__/view-resource.test.ts +101 -0
- package/src/commands/fork/create.ts +4 -3
- package/src/commands/fork/fund.ts +16 -9
- package/src/commands/fork/list.ts +3 -2
- package/src/commands/fork/serve.ts +6 -3
- package/src/commands/fork/view-resource.ts +11 -6
- package/src/commands/run.ts +54 -28
- package/src/commands/test-move.ts +4 -3
- package/src/commands/test.ts +56 -44
- package/src/commands/update.ts +19 -16
- package/src/core/AccountManager.ts +23 -10
- package/src/core/Publisher.ts +322 -0
- package/src/core/__tests__/AccountManager.test.ts +290 -0
- package/src/core/__tests__/config.test.ts +377 -0
- package/src/core/__tests__/deployments.test.ts +247 -0
- package/src/core/__tests__/shell.test.ts +138 -0
- package/src/core/config.ts +96 -12
- package/src/core/contract.ts +13 -4
- package/src/core/deployments.ts +13 -11
- package/src/core/movementProfile.ts +179 -0
- package/src/core/shell.ts +34 -14
- package/src/errors.ts +60 -0
- package/src/fork/__tests__/manager.test.ts +385 -0
- package/src/fork/__tests__/server.test.ts +65 -0
- package/src/fork/__tests__/storage.test.ts +281 -0
- package/src/fork/__tests__/test.test.ts +97 -0
- package/src/fork/api.ts +28 -14
- package/src/fork/manager.ts +88 -43
- package/src/fork/server.ts +53 -19
- package/src/fork/storage.ts +12 -15
- package/src/fork/test.ts +58 -32
- package/src/harness/Harness.ts +228 -0
- package/src/harness/codeObject.ts +388 -0
- package/src/harness/errors.ts +22 -0
- package/src/harness/index.ts +3 -0
- package/src/harness/proxy.ts +40 -0
- package/src/harness/script.ts +196 -0
- package/src/harness/view.ts +34 -0
- package/src/helpers/__tests__/semver-utils.test.ts +121 -0
- package/src/helpers/index.ts +2 -8
- package/src/helpers/move-tests.ts +27 -23
- package/src/helpers/npm-registry.ts +4 -3
- package/src/helpers/semver-utils.ts +4 -3
- package/src/helpers/setup.ts +9 -5
- package/src/helpers/setupLocalTesting.ts +219 -200
- package/src/helpers/testFixtures.ts +106 -118
- package/src/index.ts +9 -3
- package/src/node/LocalNodeManager.ts +87 -62
- package/src/node/__tests__/LocalNodeManager.test.ts +452 -0
- package/src/runtime.ts +33 -289
- package/src/templates/README.md +1 -1
- package/src/templates/movehat.config.ts +10 -0
- package/src/templates/package.json +2 -1
- package/src/templates/scripts/deploy-counter.ts +46 -38
- package/src/templates/tests/Counter.test.ts +51 -51
- package/src/templates/types/movehat.d.ts +6 -9
- package/src/types/config.ts +8 -0
- package/src/types/fork.ts +7 -1
- package/src/types/harness.ts +182 -0
- package/src/types/runtime.ts +11 -3
- package/src/ui/__tests__/colors.test.ts +156 -0
- package/src/ui/colors.ts +5 -2
- package/src/ui/logger.ts +22 -0
- package/src/ui/symbols.ts +7 -1
- package/src/utils/__tests__/address.test.ts +93 -0
- package/src/utils/__tests__/childProcessAdapter.test.ts +266 -0
- package/src/utils/__tests__/runCli.test.ts +240 -0
- package/src/utils/address.ts +56 -0
- package/src/utils/childProcessAdapter.ts +215 -0
- package/src/utils/parseCliOutput.ts +27 -0
- package/src/utils/redact.ts +24 -0
- package/src/utils/runCli.ts +64 -0
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
import { describe, it, expect, vi } from 'vitest';
|
|
2
|
+
import { defaultChildProcessAdapter } from '../childProcessAdapter.js';
|
|
3
|
+
|
|
4
|
+
const NODE = process.execPath;
|
|
5
|
+
|
|
6
|
+
describe('defaultChildProcessAdapter', () => {
|
|
7
|
+
it('captures stdout and zero exit code on success', async () => {
|
|
8
|
+
const result = await defaultChildProcessAdapter.run({
|
|
9
|
+
command: NODE,
|
|
10
|
+
args: ['-e', "process.stdout.write('hello-stdout')"],
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
expect(result.exitCode).toBe(0);
|
|
14
|
+
expect(result.stdout).toBe('hello-stdout');
|
|
15
|
+
expect(result.stderr).toBe('');
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('captures stderr separately from stdout', async () => {
|
|
19
|
+
const result = await defaultChildProcessAdapter.run({
|
|
20
|
+
command: NODE,
|
|
21
|
+
args: ['-e', "process.stderr.write('boom'); process.exit(2)"],
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
expect(result.exitCode).toBe(2);
|
|
25
|
+
expect(result.stdout).toBe('');
|
|
26
|
+
expect(result.stderr).toBe('boom');
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('pipes stdin to the child process', async () => {
|
|
30
|
+
const result = await defaultChildProcessAdapter.run({
|
|
31
|
+
command: NODE,
|
|
32
|
+
args: [
|
|
33
|
+
'-e',
|
|
34
|
+
"let d=''; process.stdin.on('data', c => d += c); process.stdin.on('end', () => process.stdout.write(d.toUpperCase()))",
|
|
35
|
+
],
|
|
36
|
+
stdin: 'piped-input',
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
expect(result.exitCode).toBe(0);
|
|
40
|
+
expect(result.stdout).toBe('PIPED-INPUT');
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it('passes env to the child process', async () => {
|
|
44
|
+
const result = await defaultChildProcessAdapter.run({
|
|
45
|
+
command: NODE,
|
|
46
|
+
args: ['-e', 'process.stdout.write(process.env.MH_TEST_VAR ?? "missing")'],
|
|
47
|
+
env: { ...process.env, MH_TEST_VAR: 'present' },
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
expect(result.exitCode).toBe(0);
|
|
51
|
+
expect(result.stdout).toBe('present');
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it('rejects when the command times out', async () => {
|
|
55
|
+
await expect(
|
|
56
|
+
defaultChildProcessAdapter.run({
|
|
57
|
+
command: NODE,
|
|
58
|
+
args: ['-e', 'setTimeout(() => {}, 5000)'],
|
|
59
|
+
timeoutMs: 50,
|
|
60
|
+
})
|
|
61
|
+
).rejects.toThrow(/timed out/);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it('aborts a running command with exitCode -1 and signal SIGTERM', async () => {
|
|
65
|
+
const controller = new AbortController();
|
|
66
|
+
const start = Date.now();
|
|
67
|
+
const promise = defaultChildProcessAdapter.run({
|
|
68
|
+
command: NODE,
|
|
69
|
+
args: ['-e', 'setTimeout(() => {}, 5000)'],
|
|
70
|
+
signal: controller.signal,
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
setTimeout(() => controller.abort(), 20);
|
|
74
|
+
|
|
75
|
+
const result = await promise;
|
|
76
|
+
const elapsed = Date.now() - start;
|
|
77
|
+
|
|
78
|
+
expect(result.exitCode).toBe(-1);
|
|
79
|
+
expect(result.signal).toBe('SIGTERM');
|
|
80
|
+
expect(elapsed).toBeLessThan(500);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it('rejects synchronously when signal is already aborted', async () => {
|
|
84
|
+
const controller = new AbortController();
|
|
85
|
+
controller.abort();
|
|
86
|
+
|
|
87
|
+
await expect(
|
|
88
|
+
defaultChildProcessAdapter.run({
|
|
89
|
+
command: NODE,
|
|
90
|
+
args: ['-e', "process.stdout.write('never')"],
|
|
91
|
+
signal: controller.signal,
|
|
92
|
+
})
|
|
93
|
+
).rejects.toThrow(/aborted/);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it('rejects when the command does not exist', async () => {
|
|
97
|
+
await expect(
|
|
98
|
+
defaultChildProcessAdapter.run({
|
|
99
|
+
command: '/nonexistent/path/to/binary-xyz',
|
|
100
|
+
args: [],
|
|
101
|
+
})
|
|
102
|
+
).rejects.toThrow();
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
describe('defaultChildProcessAdapter.spawn', () => {
|
|
107
|
+
it('returns a handle with pid and streams, and exits cleanly when the child finishes on its own', async () => {
|
|
108
|
+
const child = defaultChildProcessAdapter.spawn({
|
|
109
|
+
command: NODE,
|
|
110
|
+
args: ['-e', "process.stdout.write('hi'); process.exit(0)"],
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
expect(typeof child.pid).toBe('number');
|
|
114
|
+
expect(child.stdout).not.toBeNull();
|
|
115
|
+
expect(child.stderr).not.toBeNull();
|
|
116
|
+
expect(child.stdin).not.toBeNull();
|
|
117
|
+
|
|
118
|
+
let captured = '';
|
|
119
|
+
child.stdout?.on('data', (chunk: Buffer) => {
|
|
120
|
+
captured += chunk.toString('utf8');
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
const result = await child.exited;
|
|
124
|
+
expect(result.code).toBe(0);
|
|
125
|
+
expect(result.signal).toBeNull();
|
|
126
|
+
expect(captured).toBe('hi');
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
it('kill(SIGTERM) terminates a long-running child and surfaces the signal in exited', async () => {
|
|
130
|
+
const child = defaultChildProcessAdapter.spawn({
|
|
131
|
+
command: NODE,
|
|
132
|
+
args: ['-e', 'setInterval(() => {}, 1000)'],
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
const start = Date.now();
|
|
136
|
+
const killed = child.kill('SIGTERM');
|
|
137
|
+
expect(killed).toBe(true);
|
|
138
|
+
|
|
139
|
+
const result = await child.exited;
|
|
140
|
+
const elapsed = Date.now() - start;
|
|
141
|
+
|
|
142
|
+
expect(result.signal).toBe('SIGTERM');
|
|
143
|
+
expect(result.code).toBeNull();
|
|
144
|
+
expect(elapsed).toBeLessThan(500);
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
it('with stdio: ignore, exposes null streams but still resolves exited', async () => {
|
|
148
|
+
const child = defaultChildProcessAdapter.spawn({
|
|
149
|
+
command: NODE,
|
|
150
|
+
args: ['-e', "process.stdout.write('hidden'); process.exit(0)"],
|
|
151
|
+
stdio: 'ignore',
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
expect(child.stdout).toBeNull();
|
|
155
|
+
expect(child.stderr).toBeNull();
|
|
156
|
+
expect(child.stdin).toBeNull();
|
|
157
|
+
|
|
158
|
+
const result = await child.exited;
|
|
159
|
+
expect(result.code).toBe(0);
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
it('exited can be awaited more than once', async () => {
|
|
163
|
+
const child = defaultChildProcessAdapter.spawn({
|
|
164
|
+
command: NODE,
|
|
165
|
+
args: ['-e', 'process.exit(7)'],
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
const first = await child.exited;
|
|
169
|
+
const second = await child.exited;
|
|
170
|
+
|
|
171
|
+
expect(first.code).toBe(7);
|
|
172
|
+
expect(second.code).toBe(7);
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
it('exited resolves when the command does not exist (error event)', async () => {
|
|
176
|
+
// Spawning a nonexistent binary fires `error` (ENOENT), not `exit`.
|
|
177
|
+
// exited must still settle so the caller doesn't hang.
|
|
178
|
+
const child = defaultChildProcessAdapter.spawn({
|
|
179
|
+
command: '/nonexistent/path/to/binary-xyz',
|
|
180
|
+
args: [],
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
const result = await child.exited;
|
|
184
|
+
|
|
185
|
+
// When the OS rejects the spawn, no exit code or signal is meaningful.
|
|
186
|
+
expect(result.code).toBeNull();
|
|
187
|
+
expect(result.signal).toBeNull();
|
|
188
|
+
});
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
describe('defaultChildProcessAdapter.run with inheritStdio', () => {
|
|
192
|
+
it('returns empty stdout and stderr when inheritStdio is true', async () => {
|
|
193
|
+
// The child writes to stdout, but the parent inherits stdio so the bytes
|
|
194
|
+
// never go through the captured pipe — the adapter cannot see them.
|
|
195
|
+
const result = await defaultChildProcessAdapter.run({
|
|
196
|
+
command: NODE,
|
|
197
|
+
args: ['-e', "process.stdout.write('would-be-captured'); process.exit(0)"],
|
|
198
|
+
inheritStdio: true,
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
expect(result.exitCode).toBe(0);
|
|
202
|
+
expect(result.stdout).toBe('');
|
|
203
|
+
expect(result.stderr).toBe('');
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
it('still propagates exit code under inheritStdio', async () => {
|
|
207
|
+
const result = await defaultChildProcessAdapter.run({
|
|
208
|
+
command: NODE,
|
|
209
|
+
args: ['-e', 'process.exit(42)'],
|
|
210
|
+
inheritStdio: true,
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
expect(result.exitCode).toBe(42);
|
|
214
|
+
expect(result.stdout).toBe('');
|
|
215
|
+
expect(result.stderr).toBe('');
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
it('explicit timeoutMs is still honored under inheritStdio', async () => {
|
|
219
|
+
// Positive control: the conditional-skip applies only when timeoutMs
|
|
220
|
+
// is omitted. An explicit value forces the timer back on.
|
|
221
|
+
await expect(
|
|
222
|
+
defaultChildProcessAdapter.run({
|
|
223
|
+
command: NODE,
|
|
224
|
+
args: ['-e', 'setTimeout(() => {}, 5000)'],
|
|
225
|
+
inheritStdio: true,
|
|
226
|
+
timeoutMs: 50,
|
|
227
|
+
})
|
|
228
|
+
).rejects.toThrow(/timed out after 50ms/);
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
it('omits the default timeout when inheritStdio is true (short child completes naturally)', async () => {
|
|
232
|
+
// We can't wait 5 minutes to prove the default timeout isn't set, but
|
|
233
|
+
// we can prove that a child running with inheritStdio:true and no
|
|
234
|
+
// explicit timeoutMs completes via the natural exit path with no
|
|
235
|
+
// timeout-derived rejection. Combined with the test above, the
|
|
236
|
+
// conditional-skip behavior is pinned in both directions.
|
|
237
|
+
const result = await defaultChildProcessAdapter.run({
|
|
238
|
+
command: NODE,
|
|
239
|
+
args: ['-e', "setTimeout(() => process.exit(0), 50)"],
|
|
240
|
+
inheritStdio: true,
|
|
241
|
+
});
|
|
242
|
+
expect(result.exitCode).toBe(0);
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
it('does not schedule a setTimeout when inheritStdio is true and timeoutMs is omitted', async () => {
|
|
246
|
+
// Direct evidence (review follow-up): spy on globalThis.setTimeout and
|
|
247
|
+
// assert no timer scheduled with the DEFAULT_TIMEOUT_MS (300000ms) value.
|
|
248
|
+
// Short-running children may legitimately schedule small timers via
|
|
249
|
+
// their own logic, so we filter the spy calls to the default-timeout
|
|
250
|
+
// duration specifically — that's the value the regression repaired.
|
|
251
|
+
const setTimeoutSpy = vi.spyOn(globalThis, 'setTimeout');
|
|
252
|
+
try {
|
|
253
|
+
await defaultChildProcessAdapter.run({
|
|
254
|
+
command: NODE,
|
|
255
|
+
args: ['-e', 'process.exit(0)'],
|
|
256
|
+
inheritStdio: true,
|
|
257
|
+
});
|
|
258
|
+
const defaultTimeoutCalls = setTimeoutSpy.mock.calls.filter(
|
|
259
|
+
(args) => args[1] === 5 * 60 * 1000
|
|
260
|
+
);
|
|
261
|
+
expect(defaultTimeoutCalls).toHaveLength(0);
|
|
262
|
+
} finally {
|
|
263
|
+
setTimeoutSpy.mockRestore();
|
|
264
|
+
}
|
|
265
|
+
});
|
|
266
|
+
});
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { CliExecutionError } from '../../errors.js';
|
|
3
|
+
import type {
|
|
4
|
+
ChildProcessAdapter,
|
|
5
|
+
RunInput,
|
|
6
|
+
RunResult,
|
|
7
|
+
} from '../childProcessAdapter.js';
|
|
8
|
+
import { redactSecrets, runCli } from '../runCli.js';
|
|
9
|
+
|
|
10
|
+
function makeAdapter(result: RunResult, capture?: { last?: RunInput }): ChildProcessAdapter {
|
|
11
|
+
return {
|
|
12
|
+
async run(input) {
|
|
13
|
+
if (capture) capture.last = input;
|
|
14
|
+
return result;
|
|
15
|
+
},
|
|
16
|
+
spawn() {
|
|
17
|
+
throw new Error('spawn not used in runCli tests');
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
describe('redactSecrets', () => {
|
|
23
|
+
it('replaces ed25519-priv-0x… literals', () => {
|
|
24
|
+
const key = '0x' + 'a'.repeat(64);
|
|
25
|
+
const input = `Loaded key ed25519-priv-${key} ok`;
|
|
26
|
+
expect(redactSecrets(input)).toBe('Loaded key ***REDACTED*** ok');
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('redacts private_key labelled values', () => {
|
|
30
|
+
const input = 'private_key: 0x' + 'b'.repeat(64);
|
|
31
|
+
expect(redactSecrets(input)).toBe('***REDACTED***');
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it('redacts priv-key labelled values with hyphen variants', () => {
|
|
35
|
+
const input = 'priv-key = 0x' + 'c'.repeat(64);
|
|
36
|
+
expect(redactSecrets(input)).toBe('***REDACTED***');
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it('leaves regular hex addresses alone', () => {
|
|
40
|
+
const input = 'Account 0x1234 deployed module counter';
|
|
41
|
+
expect(redactSecrets(input)).toBe(input);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('is a no-op on empty input', () => {
|
|
45
|
+
expect(redactSecrets('')).toBe('');
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
describe('runCli', () => {
|
|
50
|
+
it('returns redacted stdout and stderr on success', async () => {
|
|
51
|
+
const key = 'ed25519-priv-0x' + 'a'.repeat(64);
|
|
52
|
+
const adapter = makeAdapter({
|
|
53
|
+
exitCode: 0,
|
|
54
|
+
stdout: `ok ${key}`,
|
|
55
|
+
stderr: '',
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
const result = await runCli({ command: 'fake', args: [] }, { adapter });
|
|
59
|
+
|
|
60
|
+
expect(result.exitCode).toBe(0);
|
|
61
|
+
expect(result.stdout).toBe('ok ***REDACTED***');
|
|
62
|
+
expect(result.stderr).toBe('');
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it('throws CliExecutionError with redacted stderr on non-zero exit', async () => {
|
|
66
|
+
const adapter = makeAdapter({
|
|
67
|
+
exitCode: 1,
|
|
68
|
+
stdout: '',
|
|
69
|
+
stderr: 'boom private_key: 0x' + 'd'.repeat(64),
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
await expect(
|
|
73
|
+
runCli({ command: 'movement', args: ['publish'] }, { adapter })
|
|
74
|
+
).rejects.toMatchObject({
|
|
75
|
+
name: 'CliExecutionError',
|
|
76
|
+
command: 'movement',
|
|
77
|
+
exitCode: 1,
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
try {
|
|
81
|
+
await runCli({ command: 'movement', args: ['publish'] }, { adapter });
|
|
82
|
+
} catch (e) {
|
|
83
|
+
expect(e).toBeInstanceOf(CliExecutionError);
|
|
84
|
+
const err = e as CliExecutionError;
|
|
85
|
+
expect(err.stderr).toBe('boom ***REDACTED***');
|
|
86
|
+
expect(err.stderr).not.toContain('private_key');
|
|
87
|
+
expect(err.args).toEqual(['publish']);
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it('does not throw on non-zero exit when throwOnNonZeroExit is false', async () => {
|
|
92
|
+
const adapter = makeAdapter({
|
|
93
|
+
exitCode: 2,
|
|
94
|
+
stdout: 'partial',
|
|
95
|
+
stderr: 'warn',
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
const result = await runCli(
|
|
99
|
+
{ command: 'fake', args: [] },
|
|
100
|
+
{ adapter, throwOnNonZeroExit: false }
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
expect(result.exitCode).toBe(2);
|
|
104
|
+
expect(result.stdout).toBe('partial');
|
|
105
|
+
expect(result.stderr).toBe('warn');
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
it('passes the input through to the adapter unchanged', async () => {
|
|
109
|
+
const capture: { last?: RunInput } = {};
|
|
110
|
+
const adapter = makeAdapter({ exitCode: 0, stdout: '', stderr: '' }, capture);
|
|
111
|
+
const env = { FOO: 'bar' };
|
|
112
|
+
const signal = new AbortController().signal;
|
|
113
|
+
|
|
114
|
+
await runCli(
|
|
115
|
+
{
|
|
116
|
+
command: 'movement',
|
|
117
|
+
args: ['move', 'build'],
|
|
118
|
+
cwd: '/tmp/pkg',
|
|
119
|
+
env,
|
|
120
|
+
stdin: 'hello',
|
|
121
|
+
timeoutMs: 1234,
|
|
122
|
+
signal,
|
|
123
|
+
},
|
|
124
|
+
{ adapter }
|
|
125
|
+
);
|
|
126
|
+
|
|
127
|
+
expect(capture.last).toEqual({
|
|
128
|
+
command: 'movement',
|
|
129
|
+
args: ['move', 'build'],
|
|
130
|
+
cwd: '/tmp/pkg',
|
|
131
|
+
env,
|
|
132
|
+
stdin: 'hello',
|
|
133
|
+
timeoutMs: 1234,
|
|
134
|
+
signal,
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
it('truncates stdoutPreview on CliExecutionError', async () => {
|
|
139
|
+
const longStdout = 'x'.repeat(5000);
|
|
140
|
+
const adapter = makeAdapter({
|
|
141
|
+
exitCode: 1,
|
|
142
|
+
stdout: longStdout,
|
|
143
|
+
stderr: '',
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
try {
|
|
147
|
+
await runCli({ command: 'fake', args: [] }, { adapter });
|
|
148
|
+
expect.fail('should have thrown');
|
|
149
|
+
} catch (e) {
|
|
150
|
+
const err = e as CliExecutionError;
|
|
151
|
+
expect(err.stdoutPreview.length).toBe(2000);
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
it('redacts secret-shaped args inside CliExecutionError.args', async () => {
|
|
156
|
+
const key = 'ed25519-priv-0x' + 'a'.repeat(64);
|
|
157
|
+
const adapter = makeAdapter({ exitCode: 1, stdout: '', stderr: '' });
|
|
158
|
+
|
|
159
|
+
try {
|
|
160
|
+
await runCli(
|
|
161
|
+
{ command: 'movement', args: ['publish', '--private-key', key] },
|
|
162
|
+
{ adapter }
|
|
163
|
+
);
|
|
164
|
+
expect.fail('should have thrown');
|
|
165
|
+
} catch (e) {
|
|
166
|
+
const err = e as CliExecutionError;
|
|
167
|
+
expect(err.args[0]).toBe('publish');
|
|
168
|
+
expect(err.args[1]).toBe('--private-key');
|
|
169
|
+
expect(err.args[2]).toBe('***REDACTED***');
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
it('preserves non-secret args unchanged', async () => {
|
|
174
|
+
const adapter = makeAdapter({ exitCode: 1, stdout: '', stderr: '' });
|
|
175
|
+
const args = ['move', 'publish', '--package-dir', '/tmp/pkg'];
|
|
176
|
+
|
|
177
|
+
try {
|
|
178
|
+
await runCli({ command: 'movement', args }, { adapter });
|
|
179
|
+
expect.fail('should have thrown');
|
|
180
|
+
} catch (e) {
|
|
181
|
+
const err = e as CliExecutionError;
|
|
182
|
+
expect(Array.from(err.args)).toEqual(args);
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
it('forwards inheritStdio flag to the adapter unchanged', async () => {
|
|
187
|
+
const capture: { last?: RunInput } = {};
|
|
188
|
+
const adapter = makeAdapter(
|
|
189
|
+
{ exitCode: 0, stdout: '', stderr: '' },
|
|
190
|
+
capture
|
|
191
|
+
);
|
|
192
|
+
|
|
193
|
+
await runCli(
|
|
194
|
+
{ command: 'mocha', args: ['--watch'], inheritStdio: true },
|
|
195
|
+
{ adapter }
|
|
196
|
+
);
|
|
197
|
+
|
|
198
|
+
expect(capture.last?.inheritStdio).toBe(true);
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
it('propagates AbortSignal to a slow adapter and returns the killed result', async () => {
|
|
202
|
+
const slowAdapter: ChildProcessAdapter = {
|
|
203
|
+
run(input) {
|
|
204
|
+
return new Promise((resolve) => {
|
|
205
|
+
const t = setTimeout(
|
|
206
|
+
() => resolve({ exitCode: 0, stdout: '', stderr: '' }),
|
|
207
|
+
5000
|
|
208
|
+
);
|
|
209
|
+
input.signal?.addEventListener('abort', () => {
|
|
210
|
+
clearTimeout(t);
|
|
211
|
+
resolve({
|
|
212
|
+
exitCode: -1,
|
|
213
|
+
stdout: '',
|
|
214
|
+
stderr: '',
|
|
215
|
+
signal: 'SIGTERM',
|
|
216
|
+
});
|
|
217
|
+
});
|
|
218
|
+
});
|
|
219
|
+
},
|
|
220
|
+
spawn() {
|
|
221
|
+
throw new Error('spawn not used in this test');
|
|
222
|
+
},
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
const controller = new AbortController();
|
|
226
|
+
const start = Date.now();
|
|
227
|
+
const promise = runCli(
|
|
228
|
+
{ command: 'movement', args: ['move', 'test'], signal: controller.signal },
|
|
229
|
+
{ adapter: slowAdapter, throwOnNonZeroExit: false }
|
|
230
|
+
);
|
|
231
|
+
setTimeout(() => controller.abort(), 20);
|
|
232
|
+
|
|
233
|
+
const result = await promise;
|
|
234
|
+
const elapsed = Date.now() - start;
|
|
235
|
+
|
|
236
|
+
expect(result.exitCode).toBe(-1);
|
|
237
|
+
expect(result.signal).toBe('SIGTERM');
|
|
238
|
+
expect(elapsed).toBeLessThan(500);
|
|
239
|
+
});
|
|
240
|
+
});
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Address normalization helpers shared across the fork code.
|
|
3
|
+
*
|
|
4
|
+
* Two normalization variants live in production today and are preserved here
|
|
5
|
+
* with identical semantics so the in-place migration in M1.2 is behavior-
|
|
6
|
+
* preserving:
|
|
7
|
+
*
|
|
8
|
+
* - `normalizeAddress` → lowercase + `0x` + left-pad to 64 hex chars.
|
|
9
|
+
* Used by `fork/manager.ts` for storage keys.
|
|
10
|
+
* - `normalizeAddressShort` → lowercase + `0x`, no padding.
|
|
11
|
+
* Used by `fork/api.ts` for HTTP paths.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Lowercase the input, ensure a `0x` prefix, and left-pad the hex tail to
|
|
16
|
+
* 64 characters (66 total). Already-padded inputs are returned unchanged
|
|
17
|
+
* (apart from case folding).
|
|
18
|
+
*
|
|
19
|
+
* No validation: callers that need to reject non-hex input should consult
|
|
20
|
+
* `isHexAddress` first.
|
|
21
|
+
*/
|
|
22
|
+
export function normalizeAddress(input: string): string {
|
|
23
|
+
let normalized = input.toLowerCase();
|
|
24
|
+
|
|
25
|
+
if (!normalized.startsWith('0x')) {
|
|
26
|
+
normalized = `0x${normalized}`;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (normalized.length < 66) {
|
|
30
|
+
normalized = '0x' + normalized.slice(2).padStart(64, '0');
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return normalized;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Lowercase the input and ensure a `0x` prefix. Length is preserved — no
|
|
38
|
+
* padding is applied. Suitable for callers that pass addresses straight to
|
|
39
|
+
* an HTTP endpoint that accepts short forms.
|
|
40
|
+
*/
|
|
41
|
+
export function normalizeAddressShort(input: string): string {
|
|
42
|
+
const lower = input.toLowerCase();
|
|
43
|
+
return lower.startsWith('0x') ? lower : `0x${lower}`;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Returns true when the input is a syntactically valid hex address: optional
|
|
48
|
+
* `0x` prefix followed by 1 to 64 hex characters (case insensitive).
|
|
49
|
+
*/
|
|
50
|
+
export function isHexAddress(input: string): boolean {
|
|
51
|
+
const stripped = input.startsWith('0x') || input.startsWith('0X')
|
|
52
|
+
? input.slice(2)
|
|
53
|
+
: input;
|
|
54
|
+
if (stripped.length === 0 || stripped.length > 64) return false;
|
|
55
|
+
return /^[0-9a-fA-F]+$/.test(stripped);
|
|
56
|
+
}
|