Skip to content
This repository has been archived by the owner on Jan 31, 2023. It is now read-only.

Error when deleting environment with gateway created from it #1966

Closed
2 tasks
Jakeeyturner opened this issue Feb 20, 2020 · 0 comments · Fixed by #2015
Closed
2 tasks

Error when deleting environment with gateway created from it #1966

Jakeeyturner opened this issue Feb 20, 2020 · 0 comments · Fixed by #2015
Assignees
Labels
bug Something isn't working
Milestone

Comments

@Jakeeyturner
Copy link
Contributor

Jakeeyturner commented Feb 20, 2020

Description

Once added a console software environment, you can create a gateway for the environment.
When you delete the ops environment you get the following error:

Screenshot 2020-02-20 at 13 44 48

This is presumably because we refresh the gateways, however, the environment that the gateway belongs to doesn't exist anymore.

This is present in v1.0.20.

Edit: I suspect that this isn't a console environment problem only - we should make sure we have stricter tests to catch things like this in future.

Expected Behavior

Actual Behavior

Possible Fix

I created a test which reproduces this problem and should actually fail.
I haven't written a fix, as we will probably need to change our REFRESH_GATEWAYS command to be a bit more complex than just refreshing the tree.

it('should delete a environment which has gateways created from it', async () => {
    const environmentRegistryEntry: FabricEnvironmentRegistryEntry = new FabricEnvironmentRegistryEntry();
    environmentRegistryEntry.name = 'myEnvironmentB';
    geConnectedEnvironmentRegistryStub.returns(environmentRegistryEntry);

    const gatewayRegistryEntry: FabricGatewayRegistryEntry = new FabricGatewayRegistryEntry({name: 'myGateway', fromEnvironment: 'myEnvironmentB', associatedWallet: ''});

    await FabricGatewayRegistry.instance().add(gatewayRegistryEntry);

    await vscode.commands.executeCommand(ExtensionCommands.DELETE_ENVIRONMENT);

    environments =  await FabricEnvironmentRegistry.instance().getAll();
    environments.length.should.equal(2);

    await vscode.commands.executeCommand('gatewaysExplorer.focus');

    environments[0].name.should.equal(FabricRuntimeUtil.LOCAL_FABRIC);
    environments[1].should.deep.equal(myEnvironmentA);

    commandSpy.should.have.been.calledWith(ExtensionCommands.DISCONNECT_ENVIRONMENT);
    commandSpy.should.not.have.been.calledWith(ExtensionCommands.DISCONNECT_GATEWAY);

    await ExtensionUtil.sleep(3000);
    logSpy.getCall(0).should.have.been.calledWithExactly(LogType.INFO, undefined, `delete environment`);
    logSpy.getCall(1).should.have.been.calledWithExactly(LogType.SUCCESS, `Successfully deleted ${myEnvironmentB.name} environment`);
    logSpy.should.not.have.been.calledWith(LogType.ERROR);
});

Steps to Reproduce

Existing issues

Log File

Your Environment

  • IBM Blockchain Platform Extension Version:
  • Visual Studio Code version:
  • Environment name and version (e.g. Node.js v8.12.0, npm v6.4.1):
  • Operating System and version:
  • Link to your project:
@Jakeeyturner Jakeeyturner added the bug Something isn't working label Feb 20, 2020
@Jakeeyturner Jakeeyturner changed the title Error when deleting console environment (with gateway) Error when deleting console environment with gateway created from it Feb 20, 2020
@Jakeeyturner Jakeeyturner changed the title Error when deleting console environment with gateway created from it Error when deleting environment with gateway created from it Feb 20, 2020
@cazfletch cazfletch modified the milestones: Sprint 26, Sprint 25 Feb 21, 2020
@cazfletch cazfletch added the next label Mar 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
3 participants