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

fix: verification of fuel-core node killing #2759

Merged
merged 7 commits into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 4 additions & 0 deletions .changeset/neat-bikes-melt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
---

fix: verification of all test nodes being killed

This file was deleted.

23 changes: 23 additions & 0 deletions packages/account/src/test-utils/launchNode.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,29 @@ describe('launchNode', () => {
await waitUntilUnreachable(url);
});

/**
* Spawning the child process in a detached state
* Results in the OS assigning a process group to the child.
* Combining that with `process.kill(-pid)`,
* which sends a "kill process group" signal to the OS,
* ensures that the node will be killed.
*/
it('spawns the fuel-core node in a detached state and kills the process group on cleanup', async () => {
const spawnSpy = vi.spyOn(childProcessMod, 'spawn');
const killSpy = vi.spyOn(process, 'kill');

const { cleanup, pid } = await launchNode();

const spawnOptions = spawnSpy.mock.calls[0][2];
expect(spawnOptions.detached).toBeTruthy();

cleanup();

expect(killSpy).toHaveBeenCalledTimes(1);
// adding a minus prefix kills the process group
expect(killSpy).toHaveBeenCalledWith(-pid);
});

test('should start `fuel-core` node using system binary', async () => {
const spawnSpy = vi.spyOn(childProcessMod, 'spawn');

Expand Down
Loading