-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Random port on integrated devnet #202
base: master
Are you sure you want to change the base?
Changes from 8 commits
ff2cbd7
4781e7a
71e782d
abf2ada
78ff511
af7b7fb
77c1e37
ff9edad
25f19a6
8e75630
d615de6
42b9383
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ CONFIG_FILE_NAME="hardhat.config.ts" | |
|
||
# setup example repo | ||
rm -rf starknet-hardhat-example | ||
git clone -b plugin --single-branch [email protected]:Shard-Labs/starknet-hardhat-example.git | ||
git clone -b release-0.7.0 --single-branch [email protected]:Shard-Labs/starknet-hardhat-example.git | ||
cd starknet-hardhat-example | ||
git log -n 1 | ||
npm install | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,7 +26,7 @@ import { getWalletUtil } from "./extend-utils"; | |
import { createIntegratedDevnet } from "./external-server"; | ||
import { Recompiler } from "./recompiler"; | ||
import { version } from "../package.json"; | ||
import { getFreePort } from "./external-server/external-server"; | ||
import { getFreePort, isFreePort } from "./external-server/external-server"; | ||
|
||
function checkSourceExists(sourcePath: string): void { | ||
if (!fs.existsSync(sourcePath)) { | ||
|
@@ -554,9 +554,14 @@ async function runWithDevnet(hre: HardhatRuntimeEnvironment, fn: () => Promise<u | |
return; | ||
} | ||
|
||
const port = await getFreePort(); | ||
const networkUrl = `http://127.0.0.1:${port}`; | ||
hre.config.networks.integratedDevnet.url = networkUrl; | ||
const { hostname, port } = new URL(hre.config.starknet.networkUrl); | ||
const isPortFree = await isFreePort(parseInt(port)); | ||
if (!isPortFree) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why this check? Couldn't it surprise the user if we just silently change the specified port. If the port is occupied, integrated-devnet spawner will inform the user about that, right? My understanding was that we should find a free port only if the user didn't provide a URL? Now I'm actually thinking, is it even possible for the user to omit the URL? Can the type extensions file be modified to allow that? |
||
const newPort = await getFreePort(); | ||
const networkUrl = `http://${hostname}:${newPort}`; | ||
hre.config.networks.integratedDevnet.url = networkUrl; | ||
hre.config.starknet.networkUrl = networkUrl; | ||
} | ||
const devnet = await createIntegratedDevnet(hre); | ||
|
||
await devnet.start(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if the user provided
--port
inargs
in hardhat config?