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
|
@@ -2,7 +2,8 @@ import type { Account } from "@aptos-labs/ts-sdk";
|
|
|
2
2
|
import type { MovehatRuntime } from "../types/runtime.js";
|
|
3
3
|
import type { MoveContract } from "../core/contract.js";
|
|
4
4
|
import { AccountManager } from "../core/AccountManager.js";
|
|
5
|
-
import { setupLocalTesting
|
|
5
|
+
import { setupLocalTesting } from "./setupLocalTesting.js";
|
|
6
|
+
import { logger } from "../ui/index.js";
|
|
6
7
|
import type { LocalTestOptions } from "../types/config.js";
|
|
7
8
|
|
|
8
9
|
/**
|
|
@@ -24,6 +25,16 @@ export interface TestFixture<TModules extends string = string> {
|
|
|
24
25
|
|
|
25
26
|
/** Deployed contracts by module name - type-safe based on modules parameter */
|
|
26
27
|
contracts: Record<TModules, MoveContract>;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Stop the local node / fork server this fixture started.
|
|
31
|
+
*
|
|
32
|
+
* Does **not** clear the shared `AccountManager` pool — clearing it
|
|
33
|
+
* would break parallel `setupTestFixture` invocations that share the
|
|
34
|
+
* pool. The pool grows for the lifetime of the process; the process
|
|
35
|
+
* exit reclaims it.
|
|
36
|
+
*/
|
|
37
|
+
teardown: () => Promise<void>;
|
|
27
38
|
}
|
|
28
39
|
|
|
29
40
|
/**
|
|
@@ -38,43 +49,30 @@ export interface TestFixture<TModules extends string = string> {
|
|
|
38
49
|
* @param modules Array of module names to auto-deploy
|
|
39
50
|
* @param accountLabels Optional array of account labels (defaults to ['alice', 'bob'])
|
|
40
51
|
* @param options Optional LocalTestOptions for advanced configuration
|
|
41
|
-
* @returns TestFixture with runtime, accounts, and
|
|
52
|
+
* @returns TestFixture with runtime, accounts, contracts, and a teardown closure
|
|
42
53
|
*
|
|
43
54
|
* @example
|
|
44
55
|
* ```typescript
|
|
45
|
-
* import { setupTestFixture } from "movehat/helpers";
|
|
56
|
+
* import { setupTestFixture, type TestFixture } from "movehat/helpers";
|
|
46
57
|
*
|
|
47
58
|
* describe("Counter Contract", () => {
|
|
48
|
-
* let fixture: TestFixture
|
|
59
|
+
* let fixture: TestFixture<"counter">;
|
|
49
60
|
*
|
|
50
61
|
* before(async function () {
|
|
51
|
-
* this.timeout(60000);
|
|
52
|
-
*
|
|
53
|
-
* fixture = await setupTestFixture(['counter'], ['alice', 'bob']);
|
|
62
|
+
* this.timeout(60000);
|
|
63
|
+
* fixture = await setupTestFixture(['counter'] as const, ['alice', 'bob']);
|
|
54
64
|
* });
|
|
55
65
|
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
* const value = await counter.view<number>("get", [
|
|
59
|
-
* fixture.accounts.deployer.accountAddress.toString()
|
|
60
|
-
* ]);
|
|
61
|
-
*
|
|
62
|
-
* expect(value).to.equal(0);
|
|
66
|
+
* after(async () => {
|
|
67
|
+
* await fixture.teardown();
|
|
63
68
|
* });
|
|
64
69
|
*
|
|
65
|
-
* it("alice can increment
|
|
70
|
+
* it("alice can increment", async () => {
|
|
66
71
|
* const tx = await fixture.contracts.counter.call(
|
|
67
|
-
* fixture.accounts.alice,
|
|
68
|
-
* "increment",
|
|
69
|
-
* []
|
|
72
|
+
* fixture.accounts.alice, "increment", []
|
|
70
73
|
* );
|
|
71
|
-
*
|
|
72
74
|
* expect(tx.success).to.be.true;
|
|
73
75
|
* });
|
|
74
|
-
*
|
|
75
|
-
* after(async () => {
|
|
76
|
-
* await teardownTestFixture();
|
|
77
|
-
* });
|
|
78
76
|
* });
|
|
79
77
|
* ```
|
|
80
78
|
*/
|
|
@@ -83,85 +81,76 @@ export async function setupTestFixture<TModules extends readonly string[]>(
|
|
|
83
81
|
accountLabels: string[] = ["alice", "bob"],
|
|
84
82
|
options: Partial<LocalTestOptions> = {}
|
|
85
83
|
): Promise<TestFixture<TModules[number]>> {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
84
|
+
logger.newline();
|
|
85
|
+
logger.step("Setting up test fixture...");
|
|
86
|
+
logger.plain(` Modules to deploy: ${modules.join(", ")}`);
|
|
87
|
+
logger.plain(` Account labels: deployer, ${accountLabels.join(", ")}`);
|
|
88
|
+
logger.newline();
|
|
89
89
|
|
|
90
|
-
// Ensure 'deployer' is always in the account labels
|
|
91
90
|
const allLabels = ["deployer", ...accountLabels.filter((l) => l !== "deployer")];
|
|
92
91
|
|
|
93
|
-
// Setup local testing environment with auto-deploy
|
|
94
92
|
const setupOptions: LocalTestOptions = {
|
|
95
93
|
...options,
|
|
96
94
|
accountLabels: allLabels,
|
|
97
|
-
autoDeploy: modules,
|
|
95
|
+
autoDeploy: modules,
|
|
98
96
|
};
|
|
99
97
|
|
|
100
|
-
const
|
|
101
|
-
|
|
102
|
-
//
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
//
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
98
|
+
const ctx = await setupLocalTesting(setupOptions);
|
|
99
|
+
|
|
100
|
+
// Assembly is fallible — a missing deployment address (autoDeploy
|
|
101
|
+
// silently failed) or any unexpected throw would leak the started
|
|
102
|
+
// infrastructure. Tear down ctx on failure; the outer caller sees
|
|
103
|
+
// the original assembly error unchanged.
|
|
104
|
+
try {
|
|
105
|
+
const mh = ctx.runtime;
|
|
106
|
+
|
|
107
|
+
const labeledAccounts = AccountManager.getLabeledAccounts();
|
|
108
|
+
|
|
109
|
+
// any: TestFixture.accounts has a structural shape with required
|
|
110
|
+
// `deployer/alice/bob` plus a `[key: string]: Account` index. The
|
|
111
|
+
// builder fills the index dynamically; typing this as the exact
|
|
112
|
+
// intersection would require a generic over `accountLabels` and
|
|
113
|
+
// produce noisy errors for the dynamic key assignment below.
|
|
114
|
+
const accounts: any = {
|
|
115
|
+
// non-null: setupLocalTesting → setupWithLocalNode/Fork unconditionally
|
|
116
|
+
// funds the deployer account via accountLabels[0]; deployer is always
|
|
117
|
+
// first by construction at L93 above.
|
|
118
|
+
deployer: labeledAccounts.deployer!,
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
for (const label of accountLabels) {
|
|
122
|
+
accounts[label] = labeledAccounts[label] || AccountManager.getOrCreateLabeled(label);
|
|
123
|
+
}
|
|
109
124
|
|
|
110
|
-
|
|
111
|
-
for (const label of accountLabels) {
|
|
112
|
-
accounts[label] = labeledAccounts[label] || AccountManager.getOrCreateLabeled(label);
|
|
113
|
-
}
|
|
125
|
+
const contracts = {} as Record<TModules[number], MoveContract>;
|
|
114
126
|
|
|
115
|
-
|
|
116
|
-
|
|
127
|
+
for (const moduleName of modules) {
|
|
128
|
+
const deploymentAddress = mh.getDeploymentAddress(moduleName);
|
|
117
129
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
130
|
+
if (!deploymentAddress) {
|
|
131
|
+
throw new Error(
|
|
132
|
+
`Module "${moduleName}" was not deployed. Check auto-deploy logs.`
|
|
133
|
+
);
|
|
134
|
+
}
|
|
121
135
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
`Module "${moduleName}" was not deployed. Check auto-deploy logs.`
|
|
125
|
-
);
|
|
136
|
+
contracts[moduleName as TModules[number]] = mh.getContract(deploymentAddress, moduleName);
|
|
137
|
+
logger.success(`Contract "${moduleName}" ready at ${deploymentAddress}`, 2);
|
|
126
138
|
}
|
|
127
139
|
|
|
128
|
-
|
|
129
|
-
|
|
140
|
+
logger.newline();
|
|
141
|
+
logger.success("Test fixture ready!");
|
|
142
|
+
logger.newline();
|
|
143
|
+
|
|
144
|
+
return {
|
|
145
|
+
mh,
|
|
146
|
+
accounts,
|
|
147
|
+
contracts,
|
|
148
|
+
teardown: ctx.teardown,
|
|
149
|
+
} as TestFixture<TModules[number]>;
|
|
150
|
+
} catch (error) {
|
|
151
|
+
await ctx.teardown().catch(() => {});
|
|
152
|
+
throw error;
|
|
130
153
|
}
|
|
131
|
-
|
|
132
|
-
console.log(`\n✅ Test fixture ready!\n`);
|
|
133
|
-
|
|
134
|
-
return {
|
|
135
|
-
mh,
|
|
136
|
-
accounts,
|
|
137
|
-
contracts,
|
|
138
|
-
} as TestFixture<TModules[number]>;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
/**
|
|
142
|
-
* Teardown test fixture and cleanup resources
|
|
143
|
-
*
|
|
144
|
-
* Call this in your test suite's `after` hook to properly cleanup:
|
|
145
|
-
* - Stops fork server
|
|
146
|
-
* - Clears account pool
|
|
147
|
-
*
|
|
148
|
-
* @example
|
|
149
|
-
* ```typescript
|
|
150
|
-
* after(async () => {
|
|
151
|
-
* await teardownTestFixture();
|
|
152
|
-
* });
|
|
153
|
-
* ```
|
|
154
|
-
*/
|
|
155
|
-
export async function teardownTestFixture(): Promise<void> {
|
|
156
|
-
console.log(`\n🧹 Tearing down test fixture...`);
|
|
157
|
-
|
|
158
|
-
// Stop fork server
|
|
159
|
-
await stopLocalTesting();
|
|
160
|
-
|
|
161
|
-
// Clear account pool for test isolation
|
|
162
|
-
AccountManager.clearPool();
|
|
163
|
-
|
|
164
|
-
console.log(`✓ Teardown complete\n`);
|
|
165
154
|
}
|
|
166
155
|
|
|
167
156
|
/**
|
|
@@ -170,53 +159,52 @@ export async function teardownTestFixture(): Promise<void> {
|
|
|
170
159
|
*
|
|
171
160
|
* @param accountLabels Account labels to create (defaults to ['alice', 'bob'])
|
|
172
161
|
* @param options Optional LocalTestOptions
|
|
173
|
-
* @returns Partial TestFixture (without contracts)
|
|
174
|
-
*
|
|
175
|
-
* @example
|
|
176
|
-
* ```typescript
|
|
177
|
-
* let fixture: Partial<TestFixture>;
|
|
178
|
-
*
|
|
179
|
-
* before(async function () {
|
|
180
|
-
* this.timeout(30000);
|
|
181
|
-
* fixture = await setupMinimalFixture(['alice', 'bob', 'charlie']);
|
|
182
|
-
* });
|
|
183
|
-
*
|
|
184
|
-
* it("should deploy contract manually", async () => {
|
|
185
|
-
* await fixture.mh!.deployContract("counter");
|
|
186
|
-
* // ...
|
|
187
|
-
* });
|
|
188
|
-
* ```
|
|
162
|
+
* @returns Partial TestFixture (without contracts) plus a teardown closure
|
|
189
163
|
*/
|
|
190
164
|
export async function setupMinimalFixture(
|
|
191
165
|
accountLabels: string[] = ["alice", "bob"],
|
|
192
166
|
options: Partial<LocalTestOptions> = {}
|
|
193
167
|
): Promise<Omit<TestFixture, "contracts">> {
|
|
194
|
-
|
|
168
|
+
logger.newline();
|
|
169
|
+
logger.step("Setting up minimal test fixture (no auto-deploy)...");
|
|
195
170
|
|
|
196
171
|
const allLabels = ["deployer", ...accountLabels.filter((l) => l !== "deployer")];
|
|
197
172
|
|
|
198
173
|
const setupOptions: LocalTestOptions = {
|
|
199
174
|
...options,
|
|
200
175
|
accountLabels: allLabels,
|
|
201
|
-
autoDeploy: [],
|
|
176
|
+
autoDeploy: [],
|
|
202
177
|
};
|
|
203
178
|
|
|
204
|
-
const
|
|
179
|
+
const ctx = await setupLocalTesting(setupOptions);
|
|
205
180
|
|
|
206
|
-
|
|
181
|
+
// Same teardown-on-assembly-failure pattern as setupTestFixture.
|
|
182
|
+
try {
|
|
183
|
+
const mh = ctx.runtime;
|
|
207
184
|
|
|
208
|
-
|
|
209
|
-
deployer: labeledAccounts.deployer!,
|
|
210
|
-
};
|
|
185
|
+
const labeledAccounts = AccountManager.getLabeledAccounts();
|
|
211
186
|
|
|
212
|
-
|
|
213
|
-
accounts
|
|
214
|
-
|
|
187
|
+
// any: see setupTestFixture above — same dynamic-key builder pattern.
|
|
188
|
+
const accounts: any = {
|
|
189
|
+
// non-null: deployer is unconditionally added to allLabels at L156 above.
|
|
190
|
+
deployer: labeledAccounts.deployer!,
|
|
191
|
+
};
|
|
215
192
|
|
|
216
|
-
|
|
193
|
+
for (const label of accountLabels) {
|
|
194
|
+
accounts[label] = labeledAccounts[label] || AccountManager.getOrCreateLabeled(label);
|
|
195
|
+
}
|
|
217
196
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
197
|
+
logger.newline();
|
|
198
|
+
logger.success("Minimal fixture ready!");
|
|
199
|
+
logger.newline();
|
|
200
|
+
|
|
201
|
+
return {
|
|
202
|
+
mh,
|
|
203
|
+
accounts,
|
|
204
|
+
teardown: ctx.teardown,
|
|
205
|
+
};
|
|
206
|
+
} catch (error) {
|
|
207
|
+
await ctx.teardown().catch(() => {});
|
|
208
|
+
throw error;
|
|
209
|
+
}
|
|
222
210
|
}
|
package/src/index.ts
CHANGED
|
@@ -2,8 +2,10 @@
|
|
|
2
2
|
export * from "./helpers/index.js";
|
|
3
3
|
export type { MovehatConfig } from "./types/config.js";
|
|
4
4
|
|
|
5
|
-
//
|
|
6
|
-
|
|
5
|
+
// Movehat Runtime Environment. `initRuntime` is a public utility but
|
|
6
|
+
// external callers should prefer Harness; it's the construction primitive
|
|
7
|
+
// `Harness.createLive` uses.
|
|
8
|
+
export { initRuntime } from "./runtime.js";
|
|
7
9
|
export type { MovehatRuntime, NetworkInfo } from "./types/runtime.js";
|
|
8
10
|
|
|
9
11
|
// Export Fork system
|
|
@@ -14,4 +16,8 @@ export { ForkServer } from "./fork/server.js";
|
|
|
14
16
|
export type { ForkMetadata, AccountState, LedgerInfo, AccountData, AccountResource } from "./types/fork.js";
|
|
15
17
|
|
|
16
18
|
// Export custom errors
|
|
17
|
-
export { ModuleAlreadyDeployedError } from "./errors.js";
|
|
19
|
+
export { ModuleAlreadyDeployedError, PostPublishError } from "./errors.js";
|
|
20
|
+
|
|
21
|
+
// Export Harness (Hardhat-style API — primary public surface from M2 onward)
|
|
22
|
+
export { Harness, HarnessDisposedError } from "./harness/index.js";
|
|
23
|
+
export type { HarnessMode } from "./harness/index.js";
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
import { spawn, ChildProcess } from "child_process";
|
|
2
1
|
import { existsSync, rmSync } from "fs";
|
|
3
2
|
import { join } from "path";
|
|
4
3
|
import { Account } from "@aptos-labs/ts-sdk";
|
|
4
|
+
import {
|
|
5
|
+
defaultChildProcessAdapter,
|
|
6
|
+
type ChildProcessAdapter,
|
|
7
|
+
type SpawnedProcess,
|
|
8
|
+
} from "../utils/childProcessAdapter.js";
|
|
9
|
+
import { logger } from "../ui/index.js";
|
|
5
10
|
|
|
6
11
|
export interface LocalNodeOptions {
|
|
7
12
|
testDir?: string; // Directory for node data (default: .movehat/local-node)
|
|
@@ -10,6 +15,11 @@ export interface LocalNodeOptions {
|
|
|
10
15
|
apiPort?: number; // API/RPC port (default: 8080)
|
|
11
16
|
readyPort?: number; // Ready server port (default: 8070)
|
|
12
17
|
silent?: boolean; // Suppress node output
|
|
18
|
+
/**
|
|
19
|
+
* Override the child-process adapter. Tests inject a fake adapter so
|
|
20
|
+
* the daemon spawn never reaches the real `movement` binary.
|
|
21
|
+
*/
|
|
22
|
+
adapter?: ChildProcessAdapter;
|
|
13
23
|
}
|
|
14
24
|
|
|
15
25
|
export interface LocalNodeInfo {
|
|
@@ -29,11 +39,14 @@ export interface LocalNodeInfo {
|
|
|
29
39
|
* - Cleanup on shutdown
|
|
30
40
|
*/
|
|
31
41
|
export class LocalNodeManager {
|
|
32
|
-
private
|
|
33
|
-
private
|
|
42
|
+
private spawned: SpawnedProcess | null = null;
|
|
43
|
+
private killed = false;
|
|
44
|
+
private options: Required<Omit<LocalNodeOptions, "adapter">>;
|
|
45
|
+
private readonly adapter: ChildProcessAdapter;
|
|
34
46
|
private starting: boolean = false;
|
|
35
47
|
|
|
36
48
|
constructor(options: LocalNodeOptions = {}) {
|
|
49
|
+
this.adapter = options.adapter ?? defaultChildProcessAdapter;
|
|
37
50
|
this.options = {
|
|
38
51
|
testDir: options.testDir || join(process.cwd(), ".movehat", "local-node"),
|
|
39
52
|
forceRestart: options.forceRestart ?? false,
|
|
@@ -50,7 +63,7 @@ export class LocalNodeManager {
|
|
|
50
63
|
* @returns LocalNodeInfo with connection details
|
|
51
64
|
*/
|
|
52
65
|
async start(): Promise<LocalNodeInfo> {
|
|
53
|
-
if (this.
|
|
66
|
+
if (this.spawned) {
|
|
54
67
|
console.log("Local node already running");
|
|
55
68
|
return this.getNodeInfo();
|
|
56
69
|
}
|
|
@@ -62,15 +75,17 @@ export class LocalNodeManager {
|
|
|
62
75
|
this.starting = true;
|
|
63
76
|
|
|
64
77
|
try {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
78
|
+
logger.newline();
|
|
79
|
+
logger.step("Starting local Movement node...");
|
|
80
|
+
logger.plain(` Test directory: ${this.options.testDir}`);
|
|
81
|
+
logger.plain(` RPC port: ${this.options.apiPort}`);
|
|
82
|
+
logger.plain(` Faucet port: ${this.options.faucetPort}`);
|
|
83
|
+
logger.plain(` Ready port: ${this.options.readyPort}`);
|
|
84
|
+
logger.newline();
|
|
70
85
|
|
|
71
86
|
// Clean state if force restart
|
|
72
87
|
if (this.options.forceRestart && existsSync(this.options.testDir)) {
|
|
73
|
-
|
|
88
|
+
logger.step("Cleaning previous node state...");
|
|
74
89
|
rmSync(this.options.testDir, { recursive: true, force: true });
|
|
75
90
|
}
|
|
76
91
|
|
|
@@ -88,22 +103,24 @@ export class LocalNodeManager {
|
|
|
88
103
|
args.push("--force-restart");
|
|
89
104
|
}
|
|
90
105
|
|
|
91
|
-
// Start the node process
|
|
92
|
-
this.
|
|
106
|
+
// Start the node process via the injectable adapter.
|
|
107
|
+
this.killed = false;
|
|
108
|
+
this.spawned = this.adapter.spawn({
|
|
109
|
+
command: "movement",
|
|
110
|
+
args,
|
|
93
111
|
stdio: this.options.silent ? "ignore" : "pipe",
|
|
94
|
-
detached: false,
|
|
95
112
|
});
|
|
96
113
|
|
|
97
114
|
// Handle process output
|
|
98
|
-
if (!this.options.silent && this.
|
|
99
|
-
this.
|
|
115
|
+
if (!this.options.silent && this.spawned.stdout && this.spawned.stderr) {
|
|
116
|
+
this.spawned.stdout.on("data", (data: Buffer) => {
|
|
100
117
|
const output = data.toString().trim();
|
|
101
118
|
if (output) {
|
|
102
119
|
console.log(`[Node] ${output}`);
|
|
103
120
|
}
|
|
104
121
|
});
|
|
105
122
|
|
|
106
|
-
this.
|
|
123
|
+
this.spawned.stderr.on("data", (data: Buffer) => {
|
|
107
124
|
const output = data.toString().trim();
|
|
108
125
|
if (output && !output.includes("WARN")) {
|
|
109
126
|
console.error(`[Node Error] ${output}`);
|
|
@@ -111,24 +128,23 @@ export class LocalNodeManager {
|
|
|
111
128
|
});
|
|
112
129
|
}
|
|
113
130
|
|
|
114
|
-
//
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
131
|
+
// The adapter's `exited` promise settles on both natural exit and on
|
|
132
|
+
// spawn-time error (e.g. ENOENT). On error the code is `null` — we don't
|
|
133
|
+
// log a generic "spawn failed" message here because `waitForReady` will
|
|
134
|
+
// surface a detailed timeout-with-hints error if movement never starts.
|
|
135
|
+
void this.spawned.exited.then(({ code }) => {
|
|
136
|
+
if (code !== null && code !== 0) {
|
|
137
|
+
logger.error(`Local node exited with code ${code}`);
|
|
118
138
|
}
|
|
119
|
-
this.
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
this.process.on("error", (error) => {
|
|
123
|
-
console.error(`\n❌ Failed to start local node: ${error.message}`);
|
|
124
|
-
this.process = null;
|
|
139
|
+
this.spawned = null;
|
|
125
140
|
});
|
|
126
141
|
|
|
127
142
|
// Wait for node to be ready
|
|
128
|
-
|
|
143
|
+
logger.step("Waiting for node to be ready...");
|
|
129
144
|
await this.waitForReady(60000); // 60 second timeout
|
|
130
145
|
|
|
131
|
-
|
|
146
|
+
logger.success("Local Movement node is ready!");
|
|
147
|
+
logger.newline();
|
|
132
148
|
|
|
133
149
|
this.starting = false;
|
|
134
150
|
return this.getNodeInfo();
|
|
@@ -137,9 +153,10 @@ export class LocalNodeManager {
|
|
|
137
153
|
this.starting = false;
|
|
138
154
|
|
|
139
155
|
// Cleanup on failure
|
|
140
|
-
if (this.
|
|
141
|
-
this.
|
|
142
|
-
this.
|
|
156
|
+
if (this.spawned) {
|
|
157
|
+
this.killed = true;
|
|
158
|
+
this.spawned.kill();
|
|
159
|
+
this.spawned = null;
|
|
143
160
|
}
|
|
144
161
|
|
|
145
162
|
throw error;
|
|
@@ -150,42 +167,47 @@ export class LocalNodeManager {
|
|
|
150
167
|
* Stop the local node
|
|
151
168
|
*/
|
|
152
169
|
async stop(): Promise<void> {
|
|
153
|
-
if (!this.
|
|
170
|
+
if (!this.spawned) {
|
|
154
171
|
return;
|
|
155
172
|
}
|
|
156
173
|
|
|
157
|
-
|
|
174
|
+
logger.newline();
|
|
175
|
+
logger.step("Stopping local Movement node...");
|
|
158
176
|
|
|
159
|
-
|
|
160
|
-
if (!this.process) {
|
|
161
|
-
resolve();
|
|
162
|
-
return;
|
|
163
|
-
}
|
|
177
|
+
const spawned = this.spawned;
|
|
164
178
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
resolve();
|
|
169
|
-
});
|
|
179
|
+
// Mark killed synchronously so isRunning() reflects the intent right away,
|
|
180
|
+
// mirroring node's ChildProcess.killed semantics.
|
|
181
|
+
this.killed = true;
|
|
170
182
|
|
|
171
|
-
|
|
172
|
-
|
|
183
|
+
// Send SIGTERM for graceful shutdown
|
|
184
|
+
spawned.kill("SIGTERM");
|
|
173
185
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
186
|
+
// Force kill after 5 seconds if still running
|
|
187
|
+
const forceTimer = setTimeout(() => {
|
|
188
|
+
if (this.spawned === spawned) {
|
|
189
|
+
logger.warning("Force killing node...");
|
|
190
|
+
spawned.kill("SIGKILL");
|
|
191
|
+
}
|
|
192
|
+
}, 5000);
|
|
193
|
+
|
|
194
|
+
try {
|
|
195
|
+
await spawned.exited;
|
|
196
|
+
logger.success("Local node stopped");
|
|
197
|
+
logger.newline();
|
|
198
|
+
} finally {
|
|
199
|
+
clearTimeout(forceTimer);
|
|
200
|
+
if (this.spawned === spawned) {
|
|
201
|
+
this.spawned = null;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
182
204
|
}
|
|
183
205
|
|
|
184
206
|
/**
|
|
185
207
|
* Check if the node is running
|
|
186
208
|
*/
|
|
187
209
|
isRunning(): boolean {
|
|
188
|
-
return this.
|
|
210
|
+
return this.spawned !== null && !this.killed;
|
|
189
211
|
}
|
|
190
212
|
|
|
191
213
|
/**
|
|
@@ -245,7 +267,7 @@ export class LocalNodeManager {
|
|
|
245
267
|
? account
|
|
246
268
|
: account.accountAddress.toString();
|
|
247
269
|
|
|
248
|
-
// Use query parameters for
|
|
270
|
+
// Use query parameters for the Movement faucet
|
|
249
271
|
const faucetUrl = `http://127.0.0.1:${this.options.faucetPort}/mint?amount=${amount}&address=${address}`;
|
|
250
272
|
|
|
251
273
|
try {
|
|
@@ -259,11 +281,12 @@ export class LocalNodeManager {
|
|
|
259
281
|
}
|
|
260
282
|
|
|
261
283
|
const result = await response.json();
|
|
262
|
-
|
|
284
|
+
logger.success(`Funded ${address} with ${amount} octas`, 2);
|
|
263
285
|
|
|
264
286
|
return result;
|
|
265
|
-
} catch (error
|
|
266
|
-
|
|
287
|
+
} catch (error) {
|
|
288
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
289
|
+
throw new Error(`Failed to fund account: ${msg}`);
|
|
267
290
|
}
|
|
268
291
|
}
|
|
269
292
|
|
|
@@ -271,13 +294,15 @@ export class LocalNodeManager {
|
|
|
271
294
|
* Fund multiple accounts in batch
|
|
272
295
|
*/
|
|
273
296
|
async fundAccounts(accounts: (Account | string)[], amount: number = 100_000_000): Promise<void> {
|
|
274
|
-
|
|
297
|
+
logger.newline();
|
|
298
|
+
logger.step(`Funding ${accounts.length} accounts from local faucet...`);
|
|
275
299
|
|
|
276
300
|
for (const account of accounts) {
|
|
277
301
|
await this.fundAccount(account, amount);
|
|
278
302
|
}
|
|
279
303
|
|
|
280
|
-
|
|
304
|
+
logger.success("All accounts funded successfully");
|
|
305
|
+
logger.newline();
|
|
281
306
|
}
|
|
282
307
|
|
|
283
308
|
/**
|
|
@@ -289,9 +314,9 @@ export class LocalNodeManager {
|
|
|
289
314
|
}
|
|
290
315
|
|
|
291
316
|
if (existsSync(this.options.testDir)) {
|
|
292
|
-
|
|
317
|
+
logger.step(`Cleaning node data at ${this.options.testDir}...`);
|
|
293
318
|
rmSync(this.options.testDir, { recursive: true, force: true });
|
|
294
|
-
|
|
319
|
+
logger.success("Node data cleaned");
|
|
295
320
|
}
|
|
296
321
|
}
|
|
297
322
|
}
|