movehat 0.1.9 → 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 +6 -4
- 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 +28 -239
- 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 +39 -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 +6 -4
- 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 +30 -288
- 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 +39 -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,245 @@
|
|
|
1
|
+
import { afterEach, beforeEach, describe, expect, it } from "vitest";
|
|
2
|
+
import { existsSync, mkdirSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
|
|
5
|
+
import { Harness } from "../../harness/index.js";
|
|
6
|
+
import { CliExecutionError } from "../../errors.js";
|
|
7
|
+
import type {
|
|
8
|
+
ChildProcessAdapter,
|
|
9
|
+
RunInput,
|
|
10
|
+
RunResult,
|
|
11
|
+
} from "../../utils/childProcessAdapter.js";
|
|
12
|
+
import { setupHarnessTestFixture, type HarnessTestFixture } from "./_fixture.js";
|
|
13
|
+
|
|
14
|
+
describe("Harness.runMoveScript", () => {
|
|
15
|
+
let fixture: HarnessTestFixture;
|
|
16
|
+
|
|
17
|
+
const TX_HASH =
|
|
18
|
+
"0x9999999999999999999999999999999999999999999999999999999999999999";
|
|
19
|
+
|
|
20
|
+
beforeEach(() => {
|
|
21
|
+
fixture = setupHarnessTestFixture({ withTmpHome: true });
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
afterEach(() => {
|
|
25
|
+
fixture.teardown();
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
function makeAdapter(result: RunResult): {
|
|
29
|
+
adapter: ChildProcessAdapter;
|
|
30
|
+
calls: RunInput[];
|
|
31
|
+
} {
|
|
32
|
+
const calls: RunInput[] = [];
|
|
33
|
+
const adapter: ChildProcessAdapter = {
|
|
34
|
+
async run(input) {
|
|
35
|
+
calls.push(input);
|
|
36
|
+
if (input.args[1] === "run-script") return result;
|
|
37
|
+
throw new Error(`unexpected movement subcommand: ${input.args[1]}`);
|
|
38
|
+
},
|
|
39
|
+
spawn() {
|
|
40
|
+
throw new Error("spawn not used in script tests");
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
return { adapter, calls };
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function successStdout(): string {
|
|
47
|
+
return [
|
|
48
|
+
`transaction hash: ${TX_HASH}`,
|
|
49
|
+
'{ "Result": { "success": true, "vm_status": "Executed successfully" } }',
|
|
50
|
+
].join("\n");
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
it("happy path with .move source: uses --script-path and returns parsed MoveScriptResult", async () => {
|
|
54
|
+
const scriptPath = join(fixture.tmpCwd, "scripts", "init.move");
|
|
55
|
+
mkdirSync(join(fixture.tmpCwd, "scripts"), { recursive: true });
|
|
56
|
+
writeFileSync(scriptPath, "// dummy move script\n");
|
|
57
|
+
|
|
58
|
+
const { adapter, calls } = makeAdapter({
|
|
59
|
+
exitCode: 0,
|
|
60
|
+
stdout: successStdout(),
|
|
61
|
+
stderr: "",
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
const harness = await Harness.createLive("testnet");
|
|
65
|
+
try {
|
|
66
|
+
const result = await harness.runMoveScript({
|
|
67
|
+
scriptPath,
|
|
68
|
+
args: ["u64:42", "bool:true"],
|
|
69
|
+
typeArgs: ["0x1::aptos_coin::AptosCoin"],
|
|
70
|
+
adapter,
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
expect(result.txHash).toBe(TX_HASH);
|
|
74
|
+
expect(result.success).toBe(true);
|
|
75
|
+
expect(result.vmStatus).toBe("Executed successfully");
|
|
76
|
+
|
|
77
|
+
expect(calls).toHaveLength(1);
|
|
78
|
+
const call = calls[0]!;
|
|
79
|
+
expect(call.args.slice(0, 2)).toEqual(["move", "run-script"]);
|
|
80
|
+
expect(call.args).toContain("--script-path");
|
|
81
|
+
expect(call.args).not.toContain("--compiled-script-path");
|
|
82
|
+
expect(call.args).toContain(scriptPath);
|
|
83
|
+
expect(call.args).toContain("--type-args");
|
|
84
|
+
expect(call.args).toContain("0x1::aptos_coin::AptosCoin");
|
|
85
|
+
expect(call.args).toContain("--args");
|
|
86
|
+
expect(call.args).toContain("u64:42");
|
|
87
|
+
expect(call.args).toContain("bool:true");
|
|
88
|
+
} finally {
|
|
89
|
+
await harness.cleanup();
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it("happy path with .mv compiled: uses --compiled-script-path", async () => {
|
|
94
|
+
const scriptPath = join(fixture.tmpCwd, "build", "init.mv");
|
|
95
|
+
mkdirSync(join(fixture.tmpCwd, "build"), { recursive: true });
|
|
96
|
+
writeFileSync(scriptPath, "compiled bytecode placeholder");
|
|
97
|
+
|
|
98
|
+
const { adapter, calls } = makeAdapter({
|
|
99
|
+
exitCode: 0,
|
|
100
|
+
stdout: successStdout(),
|
|
101
|
+
stderr: "",
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
const harness = await Harness.createLive("testnet");
|
|
105
|
+
try {
|
|
106
|
+
const result = await harness.runMoveScript({ scriptPath, adapter });
|
|
107
|
+
|
|
108
|
+
expect(result.txHash).toBe(TX_HASH);
|
|
109
|
+
const call = calls[0]!;
|
|
110
|
+
expect(call.args).toContain("--compiled-script-path");
|
|
111
|
+
expect(call.args).not.toContain("--script-path");
|
|
112
|
+
} finally {
|
|
113
|
+
await harness.cleanup();
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
it("unsupported extension throws synchronously before any CLI call", async () => {
|
|
118
|
+
const scriptPath = join(fixture.tmpCwd, "notes.txt");
|
|
119
|
+
writeFileSync(scriptPath, "not a script");
|
|
120
|
+
|
|
121
|
+
const { adapter, calls } = makeAdapter({
|
|
122
|
+
exitCode: 0,
|
|
123
|
+
stdout: successStdout(),
|
|
124
|
+
stderr: "",
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
const harness = await Harness.createLive("testnet");
|
|
128
|
+
try {
|
|
129
|
+
let caught: unknown;
|
|
130
|
+
try {
|
|
131
|
+
await harness.runMoveScript({ scriptPath, adapter });
|
|
132
|
+
} catch (err) {
|
|
133
|
+
caught = err;
|
|
134
|
+
}
|
|
135
|
+
expect(caught).toBeInstanceOf(Error);
|
|
136
|
+
expect((caught as Error).message).toMatch(/unsupported script extension/i);
|
|
137
|
+
expect(calls).toHaveLength(0);
|
|
138
|
+
} finally {
|
|
139
|
+
await harness.cleanup();
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
it("missing script file throws before any CLI call", async () => {
|
|
144
|
+
const scriptPath = join(fixture.tmpCwd, "scripts", "missing.move");
|
|
145
|
+
const { adapter, calls } = makeAdapter({
|
|
146
|
+
exitCode: 0,
|
|
147
|
+
stdout: successStdout(),
|
|
148
|
+
stderr: "",
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
const harness = await Harness.createLive("testnet");
|
|
152
|
+
try {
|
|
153
|
+
let caught: unknown;
|
|
154
|
+
try {
|
|
155
|
+
await harness.runMoveScript({ scriptPath, adapter });
|
|
156
|
+
} catch (err) {
|
|
157
|
+
caught = err;
|
|
158
|
+
}
|
|
159
|
+
expect(caught).toBeInstanceOf(Error);
|
|
160
|
+
expect((caught as Error).message).toMatch(/script not found/i);
|
|
161
|
+
expect(calls).toHaveLength(0);
|
|
162
|
+
} finally {
|
|
163
|
+
await harness.cleanup();
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
it("CLI failure rethrows CliExecutionError and removes the temp profile", async () => {
|
|
168
|
+
const scriptPath = join(fixture.tmpCwd, "scripts", "fail.move");
|
|
169
|
+
mkdirSync(join(fixture.tmpCwd, "scripts"), { recursive: true });
|
|
170
|
+
writeFileSync(scriptPath, "// dummy\n");
|
|
171
|
+
|
|
172
|
+
const { adapter } = makeAdapter({
|
|
173
|
+
exitCode: 1,
|
|
174
|
+
stdout: "",
|
|
175
|
+
stderr: "compile error: undefined identifier",
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
const harness = await Harness.createLive("testnet");
|
|
179
|
+
try {
|
|
180
|
+
let caught: unknown;
|
|
181
|
+
try {
|
|
182
|
+
await harness.runMoveScript({ scriptPath, adapter });
|
|
183
|
+
} catch (err) {
|
|
184
|
+
caught = err;
|
|
185
|
+
}
|
|
186
|
+
expect(caught).toBeInstanceOf(CliExecutionError);
|
|
187
|
+
// Temp profile cleaned up in finally.
|
|
188
|
+
expect(existsSync(join(fixture.tmpHome!, ".aptos", "config.yaml"))).toBe(false);
|
|
189
|
+
} finally {
|
|
190
|
+
await harness.cleanup();
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
it("CLI succeeded but output has no txHash: throws clear non-CliExecutionError", async () => {
|
|
195
|
+
const scriptPath = join(fixture.tmpCwd, "scripts", "weird.move");
|
|
196
|
+
mkdirSync(join(fixture.tmpCwd, "scripts"), { recursive: true });
|
|
197
|
+
writeFileSync(scriptPath, "// dummy\n");
|
|
198
|
+
|
|
199
|
+
const { adapter } = makeAdapter({
|
|
200
|
+
exitCode: 0,
|
|
201
|
+
stdout: "ran successfully but no hash here",
|
|
202
|
+
stderr: "",
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
const harness = await Harness.createLive("testnet");
|
|
206
|
+
try {
|
|
207
|
+
let caught: unknown;
|
|
208
|
+
try {
|
|
209
|
+
await harness.runMoveScript({ scriptPath, adapter });
|
|
210
|
+
} catch (err) {
|
|
211
|
+
caught = err;
|
|
212
|
+
}
|
|
213
|
+
expect(caught).toBeInstanceOf(Error);
|
|
214
|
+
expect(caught).not.toBeInstanceOf(CliExecutionError);
|
|
215
|
+
expect((caught as Error).message).toMatch(/Could not parse transaction hash/);
|
|
216
|
+
} finally {
|
|
217
|
+
await harness.cleanup();
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
it("`success: false` in Result JSON surfaces in MoveScriptResult.success", async () => {
|
|
222
|
+
const scriptPath = join(fixture.tmpCwd, "scripts", "bad.move");
|
|
223
|
+
mkdirSync(join(fixture.tmpCwd, "scripts"), { recursive: true });
|
|
224
|
+
writeFileSync(scriptPath, "// dummy\n");
|
|
225
|
+
|
|
226
|
+
const { adapter } = makeAdapter({
|
|
227
|
+
exitCode: 0,
|
|
228
|
+
stdout: [
|
|
229
|
+
`transaction hash: ${TX_HASH}`,
|
|
230
|
+
'{ "Result": { "success": false, "vm_status": "ABORTED" } }',
|
|
231
|
+
].join("\n"),
|
|
232
|
+
stderr: "",
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
const harness = await Harness.createLive("testnet");
|
|
236
|
+
try {
|
|
237
|
+
const result = await harness.runMoveScript({ scriptPath, adapter });
|
|
238
|
+
expect(result.txHash).toBe(TX_HASH);
|
|
239
|
+
expect(result.success).toBe(false);
|
|
240
|
+
expect(result.vmStatus).toBe("ABORTED");
|
|
241
|
+
} finally {
|
|
242
|
+
await harness.cleanup();
|
|
243
|
+
}
|
|
244
|
+
});
|
|
245
|
+
});
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
2
|
+
|
|
3
|
+
import { Harness } from "../../harness/index.js";
|
|
4
|
+
import { setupHarnessTestFixture, type HarnessTestFixture } from "./_fixture.js";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Tests for `Harness.runViewFunction` — the SDK delegation path.
|
|
8
|
+
*
|
|
9
|
+
* The Aptos SDK isn't behind an injectable adapter, so we monkey-patch
|
|
10
|
+
* `harness.runtime.aptos.view` after `createLive`. One-off for M2.3.
|
|
11
|
+
* Acceptable here because the function under test is a 6-line wrapper
|
|
12
|
+
* that only forwards options.
|
|
13
|
+
*/
|
|
14
|
+
describe("Harness.runViewFunction", () => {
|
|
15
|
+
let fixture: HarnessTestFixture;
|
|
16
|
+
|
|
17
|
+
beforeEach(() => {
|
|
18
|
+
fixture = setupHarnessTestFixture();
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
afterEach(() => {
|
|
22
|
+
fixture.teardown();
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it("happy path: forwards correct payload to aptos.view and returns the raw result array", async () => {
|
|
26
|
+
const harness = await Harness.createLive("testnet");
|
|
27
|
+
try {
|
|
28
|
+
const fake = vi.fn().mockResolvedValue([42n, "hello"]);
|
|
29
|
+
// Monkey-patch — the SDK boundary isn't behind an adapter.
|
|
30
|
+
harness.runtime.aptos.view = fake as never;
|
|
31
|
+
|
|
32
|
+
const result = await harness.runViewFunction({
|
|
33
|
+
function: "0xCAFE::counter::get",
|
|
34
|
+
typeArguments: ["0x1::aptos_coin::AptosCoin"],
|
|
35
|
+
functionArguments: ["0xdeployer", 1n],
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
expect(result).toEqual([42n, "hello"]);
|
|
39
|
+
expect(fake).toHaveBeenCalledTimes(1);
|
|
40
|
+
expect(fake).toHaveBeenCalledWith({
|
|
41
|
+
payload: {
|
|
42
|
+
function: "0xCAFE::counter::get",
|
|
43
|
+
typeArguments: ["0x1::aptos_coin::AptosCoin"],
|
|
44
|
+
functionArguments: ["0xdeployer", 1n],
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
} finally {
|
|
48
|
+
await harness.cleanup();
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it("defaults typeArguments and functionArguments to empty arrays when omitted", async () => {
|
|
53
|
+
const harness = await Harness.createLive("testnet");
|
|
54
|
+
try {
|
|
55
|
+
const fake = vi.fn().mockResolvedValue([0n]);
|
|
56
|
+
harness.runtime.aptos.view = fake as never;
|
|
57
|
+
|
|
58
|
+
const result = await harness.runViewFunction({
|
|
59
|
+
function: "0xCAFE::counter::count",
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
expect(result).toEqual([0n]);
|
|
63
|
+
expect(fake).toHaveBeenCalledWith({
|
|
64
|
+
payload: {
|
|
65
|
+
function: "0xCAFE::counter::count",
|
|
66
|
+
typeArguments: [],
|
|
67
|
+
functionArguments: [],
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
} finally {
|
|
71
|
+
await harness.cleanup();
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it("passes empty results through unchanged", async () => {
|
|
76
|
+
const harness = await Harness.createLive("testnet");
|
|
77
|
+
try {
|
|
78
|
+
const fake = vi.fn().mockResolvedValue([]);
|
|
79
|
+
harness.runtime.aptos.view = fake as never;
|
|
80
|
+
|
|
81
|
+
const result = await harness.runViewFunction({
|
|
82
|
+
function: "0xCAFE::nothing::nothing",
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
expect(result).toEqual([]);
|
|
86
|
+
} finally {
|
|
87
|
+
await harness.cleanup();
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it("rethrows errors from aptos.view", async () => {
|
|
92
|
+
const harness = await Harness.createLive("testnet");
|
|
93
|
+
try {
|
|
94
|
+
const fake = vi.fn().mockRejectedValue(new Error("module not found"));
|
|
95
|
+
harness.runtime.aptos.view = fake as never;
|
|
96
|
+
|
|
97
|
+
await expect(
|
|
98
|
+
harness.runViewFunction({ function: "0xCAFE::missing::get" })
|
|
99
|
+
).rejects.toThrow(/module not found/);
|
|
100
|
+
} finally {
|
|
101
|
+
await harness.cleanup();
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
});
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { afterEach, beforeEach, describe, expect, it } from "vitest";
|
|
2
|
+
import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { tmpdir } from "node:os";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
|
|
6
|
+
import { initRuntime } from "../runtime.js";
|
|
7
|
+
import { _resetConfigCache } from "../core/config.js";
|
|
8
|
+
import { AccountManager } from "../core/AccountManager.js";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Behavioral tests for `runtime.ts` covering the paths
|
|
12
|
+
* `__tests__/deployContract.test.ts` doesn't exercise:
|
|
13
|
+
* - initRuntime returns a fully-wired MovehatRuntime
|
|
14
|
+
* - accountIndex selection + out-of-range error
|
|
15
|
+
* - config override merging
|
|
16
|
+
* - getAccountByIndex bounds error
|
|
17
|
+
* - switchNetwork delegates back into initRuntime
|
|
18
|
+
*
|
|
19
|
+
* Mainnet/security gates live in `resolveNetworkConfig` and are
|
|
20
|
+
* covered in `core/__tests__/config.test.ts` to avoid re-driving the
|
|
21
|
+
* same branch through two layers.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
const TEST_KEY_A =
|
|
25
|
+
"0x0000000000000000000000000000000000000000000000000000000000000001";
|
|
26
|
+
const TEST_KEY_B =
|
|
27
|
+
"0x0000000000000000000000000000000000000000000000000000000000000002";
|
|
28
|
+
|
|
29
|
+
function writeConfig(cwd: string, body: string): void {
|
|
30
|
+
writeFileSync(join(cwd, "movehat.config.js"), body);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const CONFIG_TWO_NETWORKS_TWO_ACCOUNTS = `export default {
|
|
34
|
+
defaultNetwork: "testnet",
|
|
35
|
+
networks: {
|
|
36
|
+
testnet: {
|
|
37
|
+
url: "https://testnet.movementnetwork.xyz/v1",
|
|
38
|
+
chainId: "testnet",
|
|
39
|
+
accounts: ["${TEST_KEY_A}", "${TEST_KEY_B}"]
|
|
40
|
+
},
|
|
41
|
+
custom: {
|
|
42
|
+
url: "https://custom.example.com/v1",
|
|
43
|
+
chainId: "custom",
|
|
44
|
+
accounts: ["${TEST_KEY_A}"]
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
`;
|
|
49
|
+
|
|
50
|
+
describe("initRuntime", () => {
|
|
51
|
+
let tmpCwd: string;
|
|
52
|
+
let origCwd: string;
|
|
53
|
+
|
|
54
|
+
beforeEach(() => {
|
|
55
|
+
origCwd = process.cwd();
|
|
56
|
+
tmpCwd = mkdtempSync(join(tmpdir(), "movehat-runtime-test-"));
|
|
57
|
+
process.chdir(tmpCwd);
|
|
58
|
+
_resetConfigCache();
|
|
59
|
+
AccountManager.clearPool();
|
|
60
|
+
writeConfig(tmpCwd, CONFIG_TWO_NETWORKS_TWO_ACCOUNTS);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
afterEach(() => {
|
|
64
|
+
process.chdir(origCwd);
|
|
65
|
+
rmSync(tmpCwd, { recursive: true, force: true });
|
|
66
|
+
_resetConfigCache();
|
|
67
|
+
AccountManager.clearPool();
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it("returns a runtime bound to defaultNetwork when no network is passed", async () => {
|
|
71
|
+
const runtime = await initRuntime();
|
|
72
|
+
|
|
73
|
+
expect(runtime.network.name).toBe("testnet");
|
|
74
|
+
expect(runtime.network.rpc).toContain("testnet.movementnetwork.xyz");
|
|
75
|
+
expect(runtime.config.network).toBe("testnet");
|
|
76
|
+
expect(runtime.aptos).toBeDefined();
|
|
77
|
+
expect(runtime.account).toBeDefined();
|
|
78
|
+
// accounts array reflects both keys configured.
|
|
79
|
+
expect(runtime.accounts).toHaveLength(2);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it("switches network via the `network` option", async () => {
|
|
83
|
+
const runtime = await initRuntime({ network: "custom" });
|
|
84
|
+
|
|
85
|
+
expect(runtime.network.name).toBe("custom");
|
|
86
|
+
expect(runtime.network.rpc).toContain("custom.example.com");
|
|
87
|
+
expect(runtime.accounts).toHaveLength(1);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it("selects a specific account via `accountIndex`", async () => {
|
|
91
|
+
const runtime = await initRuntime({ accountIndex: 1 });
|
|
92
|
+
|
|
93
|
+
// The primary `account` is the indexed pick.
|
|
94
|
+
expect(runtime.account.accountAddress.toString()).toBe(
|
|
95
|
+
runtime.accounts[1]!.accountAddress.toString()
|
|
96
|
+
);
|
|
97
|
+
expect(runtime.account.accountAddress.toString()).not.toBe(
|
|
98
|
+
runtime.accounts[0]!.accountAddress.toString()
|
|
99
|
+
);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it("throws a clear error when accountIndex is out of range", async () => {
|
|
103
|
+
await expect(initRuntime({ accountIndex: 5 })).rejects.toThrow(
|
|
104
|
+
/Account index 5 not found/
|
|
105
|
+
);
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
it("merges `configOverride` on top of the loaded user config", async () => {
|
|
109
|
+
const runtime = await initRuntime({
|
|
110
|
+
configOverride: { defaultNetwork: "custom" },
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
// The override flips defaultNetwork → 'custom' so resolveNetworkConfig
|
|
114
|
+
// picks the custom entry without requiring an explicit `network` arg.
|
|
115
|
+
expect(runtime.network.name).toBe("custom");
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
it("getAccountByIndex returns the account at the given slot", async () => {
|
|
119
|
+
const runtime = await initRuntime();
|
|
120
|
+
expect(runtime.getAccountByIndex(0).accountAddress.toString()).toBe(
|
|
121
|
+
runtime.accounts[0]!.accountAddress.toString()
|
|
122
|
+
);
|
|
123
|
+
expect(runtime.getAccountByIndex(1).accountAddress.toString()).toBe(
|
|
124
|
+
runtime.accounts[1]!.accountAddress.toString()
|
|
125
|
+
);
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
it("getAccountByIndex throws on out-of-range index", async () => {
|
|
129
|
+
const runtime = await initRuntime();
|
|
130
|
+
expect(() => runtime.getAccountByIndex(99)).toThrow(
|
|
131
|
+
/Account index 99 out of range/
|
|
132
|
+
);
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
it("createAccount returns a fresh account each call (pool grows)", async () => {
|
|
136
|
+
const runtime = await initRuntime();
|
|
137
|
+
const before = AccountManager.getPoolSize();
|
|
138
|
+
const a = runtime.createAccount();
|
|
139
|
+
const b = runtime.createAccount();
|
|
140
|
+
expect(a.accountAddress.toString()).not.toBe(b.accountAddress.toString());
|
|
141
|
+
expect(AccountManager.getPoolSize()).toBe(before + 2);
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
it("getAccount loads from a private key hex", async () => {
|
|
145
|
+
const runtime = await initRuntime();
|
|
146
|
+
const acc = runtime.getAccount(TEST_KEY_B);
|
|
147
|
+
expect(acc.accountAddress.toString()).toBe(
|
|
148
|
+
runtime.accounts[1]!.accountAddress.toString()
|
|
149
|
+
);
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
it("switchNetwork returns a new runtime bound to the requested network", async () => {
|
|
153
|
+
const runtime = await initRuntime();
|
|
154
|
+
expect(runtime.network.name).toBe("testnet");
|
|
155
|
+
|
|
156
|
+
const switched = await runtime.switchNetwork("custom");
|
|
157
|
+
expect(switched.network.name).toBe("custom");
|
|
158
|
+
expect(switched.network.rpc).toContain("custom.example.com");
|
|
159
|
+
// Original runtime is unaffected — switchNetwork builds fresh.
|
|
160
|
+
expect(runtime.network.name).toBe("testnet");
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
it("getDeployment / getDeployments / getDeploymentAddress return null/empty for an unused network", async () => {
|
|
164
|
+
const runtime = await initRuntime();
|
|
165
|
+
// Nothing deployed in the tmp cwd, so these all short-circuit.
|
|
166
|
+
expect(runtime.getDeployment("counter")).toBeNull();
|
|
167
|
+
expect(runtime.getDeployments()).toEqual({});
|
|
168
|
+
expect(runtime.getDeploymentAddress("counter")).toBeNull();
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
it("getContract returns a MoveContract bound to the requested address+module", async () => {
|
|
172
|
+
const runtime = await initRuntime();
|
|
173
|
+
const dummyAddr = "0x" + "a".repeat(64);
|
|
174
|
+
const contract = runtime.getContract(dummyAddr, "counter");
|
|
175
|
+
expect(contract).toBeDefined();
|
|
176
|
+
// MoveContract holds the address+module pair; assert shape, not behavior
|
|
177
|
+
// (call/view would require a real chain).
|
|
178
|
+
expect(contract).toHaveProperty("call");
|
|
179
|
+
expect(contract).toHaveProperty("view");
|
|
180
|
+
});
|
|
181
|
+
});
|
|
182
|
+
|
package/src/cli.ts
CHANGED
|
@@ -118,7 +118,7 @@ program
|
|
|
118
118
|
// Fork commands
|
|
119
119
|
const fork = program
|
|
120
120
|
.command('fork')
|
|
121
|
-
.description('Manage local forks of Movement
|
|
121
|
+
.description('Manage local forks of Movement networks');
|
|
122
122
|
|
|
123
123
|
fork
|
|
124
124
|
.command('create')
|
|
@@ -154,6 +154,7 @@ fork
|
|
|
154
154
|
.description('Start a local RPC server serving the fork')
|
|
155
155
|
.option('-f, --fork <path>', 'Path to the fork')
|
|
156
156
|
.option('-p, --port <port>', 'Port to listen on (default: 8080)', parsePort, 8080)
|
|
157
|
+
.option('--host <host>', 'Interface to bind (default: 127.0.0.1; use 0.0.0.0 to expose to LAN)', '127.0.0.1')
|
|
157
158
|
.action((options) => forkServeCommand(options));
|
|
158
159
|
|
|
159
160
|
program.parse(process.argv);
|