Skip to content

Commit

Permalink
🪚 Add a stub of OApp config initialization task (#187)
Browse files Browse the repository at this point in the history
  • Loading branch information
janjakubnanista authored Jan 11, 2024
1 parent 12f1d2a commit 131c1d4
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/ua-devtools-evm-hardhat/src/constants/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ export const TASK_LZ_OAPP_WIRE = 'lz:oapp:wire'
export const TASK_LZ_OAPP_CONFIG_GET_DEFAULT = 'lz:oapp:config:get:default'
export const TASK_LZ_OAPP_CONFIG_GET = 'lz:oapp:config:get'
export const TASK_LZ_OAPP_CONFIG_CHECK = 'lz:oapp:config:check'
export const TASK_LZ_OAPP_CONFIG_INIT = 'lz:oapp:config:init'
25 changes: 25 additions & 0 deletions packages/ua-devtools-evm-hardhat/src/tasks/oapp/config.init.ts
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)
1 change: 1 addition & 0 deletions packages/ua-devtools-evm-hardhat/src/tasks/oapp/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ import './wire'
import './config.check'
import './config.get.default'
import './config.get'
import './config.init'
29 changes: 29 additions & 0 deletions tests/ua-devtools-evm-hardhat-test/test/task/oapp/init.test.ts
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()
})
})

0 comments on commit 131c1d4

Please sign in to comment.