Skip to content

Commit

Permalink
fix: Fix config loading in the wire task
Browse files Browse the repository at this point in the history
  • Loading branch information
janjakubnanista committed Dec 12, 2023
1 parent 1185ca7 commit 96f8454
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 3 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,18 @@ docker compose logs -f

This allows you to monitor logs coming from e.g. the `hardhat` nodes

#### Exposing test networks on `localhost`

It is possible to expose the test networks defined in `docker-compose.yaml` on your host machine. To do this, you can run:

```bash
docker compose -f docker-compose.yaml -f docker-compose.local.yaml up network-britney network-vengaboys
```

You can then adjust your `hardhat.config.ts` to point to `http://localhost:{10001,10002}` for access to `britney`/`vengaboys` networks. You will need to use the `MNEMONIC` defined in `docker-compose.templates.yaml` if you require funded accounts.

**Don't forget that the state of the local networks disappears after they are stopped and any deployment files created in one session will be invalid in the next one.**

### Troubleshooting

#### Problems with committing
Expand Down
24 changes: 24 additions & 0 deletions docker-compose.local.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# .-.-. .-.-. .-.-. .-.-. .-.-. .-.-. .-.-. .-.-
# / / \ \ / / \ \ / / \ \ / / \ \ / / \ \ / / \ \ / / \ \ / / \
# `-' `-`-' `-`-' `-`-' `-`-' `-`-' `-`-' `-`-'
#
# Docker compose for exposed test networks
#
# .-.-. .-.-. .-.-. .-.-. .-.-. .-.-. .-.-. .-.-
# / / \ \ / / \ \ / / \ \ / / \ \ / / \ \ / / \ \ / / \ \ / / \
# `-' `-`-' `-`-' `-`-' `-`-' `-`-' `-`-' `-`-'
version: "3.9"

services:
# ~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~
#
# Expose nodes on host ports
#
# .oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.
network-vengaboys:
ports:
- "10001:8545"

network-britney:
ports:
- "10002:8545"
2 changes: 1 addition & 1 deletion docker-compose.templates.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ services:
# We'll provide a single testing MNEMONIC for the project so that the test EVM nodes
# account are in sync with the hardhat accounts
environment:
- MNEMONIC='test test test test test test test test test test test test'
- MNEMONIC=test test test test test test test test test test test junk
logging:
driver: local
options:
Expand Down
12 changes: 11 additions & 1 deletion packages/ua-utils-evm-hardhat-test/test/task/oapp/wire.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import hre from 'hardhat'
import { isFile, promptToContinue } from '@layerzerolabs/io-utils'
import { resolve } from 'path'
import { relative, resolve } from 'path'
import { TASK_LZ_WIRE_OAPP } from '@layerzerolabs/ua-utils-evm-hardhat'
import { deployOApp } from '../../__utils__/oapp'
import { cwd } from 'process'

jest.mock('@layerzerolabs/io-utils', () => {
const original = jest.requireActual('@layerzerolabs/io-utils')
Expand Down Expand Up @@ -88,6 +89,15 @@ describe('task/oapp/wire', () => {
expect(promptToContinueMock).not.toHaveBeenCalled()
})

it('should work with relative paths', async () => {
const oappConfigAbsolute = configPathFixture('valid.config.empty.js')
const oappConfig = relative(cwd(), oappConfigAbsolute)

await hre.run(TASK_LZ_WIRE_OAPP, { oappConfig })

expect(promptToContinueMock).not.toHaveBeenCalled()
})

it('should have debug output if requested (so called eye test, check the test output)', async () => {
const oappConfig = configPathFixture('valid.config.connected.js')

Expand Down
3 changes: 2 additions & 1 deletion packages/ua-utils-evm-hardhat/src/tasks/oapp/wire.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { createOAppFactory } from '@layerzerolabs/ua-utils-evm'
import { OmniGraphBuilderHardhat, createConnectedContractFactory } from '@layerzerolabs/utils-evm-hardhat'
import { OmniTransaction } from '@layerzerolabs/utils'
import { printTransactions } from '@layerzerolabs/utils'
import { resolve } from 'path'

interface TaskArgs {
oappConfig: string
Expand Down Expand Up @@ -44,7 +45,7 @@ const action: ActionType<TaskArgs> = async ({ oappConfig: oappConfigPath, logLev
try {
logger.verbose(`Loading config file '${oappConfigPath}'`)

rawConfig = require(oappConfigPath)
rawConfig = require(resolve(oappConfigPath))
} catch (error) {
throw new Error(`Unable to read config file '${oappConfigPath}': ${error}`)
}
Expand Down

0 comments on commit 96f8454

Please sign in to comment.