Skip to content
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

Dynamically select emulator ports from machine instead of static ports specified by user or defaults #117

Merged
merged 5 commits into from
Jun 30, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/rare-starfishes-mate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"flow-js-testing": minor
---

Dynamically select ports for emulator instead of supplying admin port statically through emulator.start arguments, deprecate use of this argument
12 changes: 12 additions & 0 deletions TRANSITIONS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Transitions

## 0001 Deprecate `emulator.start()` port argument

- **Date:** Jun 28 2022
- **Type:** Depreaction of `port` argument for `emulator.start()`

`emulator.start` was previously called with the arguments: `emulator.start(port, options = {})`. The `port` argument has now been removed and manual specification of the ports is no longer recommended.

However, the `adminPort`, `restPort`, and `grpcPort` of the emulator may be overriden as fields in `options` (i.e. `options.restPort = 1234`) if absolutely necessary - however their use is not advisable and may cause unintended consequences.

Instead, it is recommended omit supplying a static a port and allow flow-js-testing to automatically determine available ports to supply the emululator. Flow-js-testing will automatically configure @onflow/fcl to use these ports for all of its functionality.
3 changes: 1 addition & 2 deletions dev-test/deploy.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ describe("interactions - sendTransaction", () => {
// Instantiate emulator and path to Cadence files
beforeEach(async () => {
const basePath = path.resolve(__dirname, "./cadence");
const port = 8080;
await init(basePath);
return emulator.start(port);
return emulator.start();
});

// Stop emulator, so it could be restarted
Expand Down
2 changes: 1 addition & 1 deletion dev-test/imports.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe("import resolver", () => {
const basePath = path.resolve(__dirname, "./cadence");
const port = 8081;
await init(basePath, { port });
return emulator.start(port, false);
return emulator.start();
});

// Stop emulator, so it could be restarted
Expand Down
16 changes: 7 additions & 9 deletions dev-test/interaction.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ describe("interactions - sendTransaction", () => {
// Instantiate emulator and path to Cadence files
beforeEach(async () => {
const basePath = path.resolve(__dirname, "./cadence");
const port = 8082;
await init(basePath, { port });
return emulator.start(port);
await init(basePath);
return emulator.start();
});

// Stop emulator, so it could be restarted
Expand Down Expand Up @@ -132,9 +131,8 @@ describe("interactions - executeScript", () => {
// Instantiate emulator and path to Cadence files
beforeEach(async () => {
const basePath = path.resolve(__dirname, "./cadence");
const port = 8080;
await init(basePath, { port });
return emulator.start(port, false);
await init(basePath);
return emulator.start();
});

// Stop emulator, so it could be restarted
Expand Down Expand Up @@ -167,7 +165,7 @@ describe("interactions - executeScript", () => {
});

test("executeScript - shall pass with short notation", async () => {
const [result,err] = await shallResolve(executeScript("log-message"));
const [result, err] = await shallResolve(executeScript("log-message"));
expect(err).toBe(null);
expect(result).toBe(42);
});
Expand All @@ -191,8 +189,8 @@ describe("interactions - executeScript", () => {
}
`;
const args = [[]];
return executeScript({ code, args });
})
return executeScript({ code, args });
});
expect(err).toBe(null);
expect(result.length).toBe(0);
});
Expand Down
3 changes: 1 addition & 2 deletions dev-test/metadata.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ jest.setTimeout(10000);
describe("metadata examples", () => {
beforeEach(async () => {
const basePath = path.resolve("./cadence");
const port = 8083;
await init(basePath);
return emulator.start(port);
return emulator.start();
});

afterEach(async () => {
Expand Down
9 changes: 3 additions & 6 deletions dev-test/usage.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ describe("Basic Usage test", () => {
// Instantiate emulator and path to Cadence files
beforeEach(async () => {
const basePath = path.resolve(__dirname, "./cadence");
const port = 8084;
await init(basePath);
return emulator.start(port);
return emulator.start();
});

// Stop emulator, so it could be restarted
Expand Down Expand Up @@ -80,9 +79,8 @@ describe("Basic Usage test", () => {
describe("jest methods", () => {
beforeEach(async () => {
const basePath = path.resolve(__dirname, "./cadence");
const port = 8082;
await init(basePath);
return emulator.start(port);
return emulator.start();
});

// Stop emulator, so it could be restarted
Expand Down Expand Up @@ -146,10 +144,9 @@ describe("jest methods", () => {
describe("Path arguments", () => {
beforeEach(async () => {
const basePath = path.resolve(__dirname, "./cadence");
const port = 8082;
await init(basePath);

return emulator.start(port, true);
return emulator.start();
});

// Stop emulator, so it could be restarted
Expand Down
16 changes: 6 additions & 10 deletions dev-test/utilities.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ describe("block height offset", () => {
// Instantiate emulator and path to Cadence files
beforeEach(async () => {
const base = path.resolve(__dirname, "../cadence");
const port = 8085;
await init({ base },);
return emulator.start(port);
await init({ base });
return emulator.start();
});

// Stop emulator, so it could be restarted
Expand Down Expand Up @@ -59,7 +58,6 @@ describe("block height offset", () => {
const [offSet] = await getBlockOffset({ addressMap });

expect(offSet).toBe(0);

});

it("should update offset with utility method", async () => {
Expand Down Expand Up @@ -87,9 +85,8 @@ describe("block height offset utilities", () => {
// Instantiate emulator and path to Cadence files
beforeEach(async () => {
const base = path.resolve(__dirname, "../cadence");
const port = 8080;
await init({ base }, { port });
return emulator.start(port);
await init({ base });
return emulator.start();
});

// Stop emulator, so it could be restarted
Expand Down Expand Up @@ -118,9 +115,8 @@ describe("dev tests", () => {
// Instantiate emulator and path to Cadence files
beforeEach(async () => {
const base = path.resolve(__dirname, "../cadence");
const port = 8080;
await init({ base }, { port });
return emulator.start(port, false);
await init({ base });
return emulator.start();
});

// Stop emulator, so it could be restarted
Expand Down
Loading