-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🪚 Add a stub of OApp config initialization task (#187)
- Loading branch information
1 parent
12f1d2a
commit 131c1d4
Showing
4 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
packages/ua-devtools-evm-hardhat/src/tasks/oapp/config.init.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { task, types } from 'hardhat/config' | ||
import type { ActionType } from 'hardhat/types' | ||
import { TASK_LZ_OAPP_CONFIG_INIT } from '@/constants/tasks' | ||
import { printLogo } from '@layerzerolabs/io-devtools/swag' | ||
|
||
interface TaskArgs { | ||
oappConfig: string | ||
logLevel?: string | ||
ci?: boolean | ||
} | ||
|
||
const action: ActionType<TaskArgs> = async (): Promise<void> => { | ||
printLogo() | ||
} | ||
|
||
task(TASK_LZ_OAPP_CONFIG_INIT, 'Initialize an OApp configuration file') | ||
.addParam('oappConfig', 'Path to the new LayerZero OApp config', './layerzero.config', types.string) | ||
.addParam('logLevel', 'Logging level. One of: error, warn, info, verbose, debug, silly', 'info', types.string) | ||
.addParam( | ||
'ci', | ||
'Continuous integration (non-interactive) mode. Will not ask for any input from the user', | ||
false, | ||
types.boolean | ||
) | ||
.setAction(action) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
tests/ua-devtools-evm-hardhat-test/test/task/oapp/init.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import hre from 'hardhat' | ||
import { promptToContinue } from '@layerzerolabs/io-devtools' | ||
import { TASK_LZ_OAPP_CONFIG_INIT } from '@layerzerolabs/ua-devtools-evm-hardhat' | ||
import { deployOAppFixture } from '../../__utils__/oapp' | ||
|
||
jest.mock('@layerzerolabs/io-devtools', () => { | ||
const original = jest.requireActual('@layerzerolabs/io-devtools') | ||
|
||
return { | ||
...original, | ||
promptToContinue: jest.fn().mockRejectedValue('Not mocked'), | ||
} | ||
}) | ||
|
||
const promptToContinueMock = promptToContinue as jest.Mock | ||
|
||
describe(`task ${TASK_LZ_OAPP_CONFIG_INIT}`, () => { | ||
beforeAll(async () => { | ||
await deployOAppFixture() | ||
}) | ||
|
||
beforeEach(async () => { | ||
promptToContinueMock.mockReset() | ||
}) | ||
|
||
it('should do nothing', async () => { | ||
await expect(hre.run(TASK_LZ_OAPP_CONFIG_INIT, {})).resolves.toBeUndefined() | ||
}) | ||
}) |