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

Commit

Permalink
Update Debug
Browse files Browse the repository at this point in the history
kill the chaincode container if running
move instantiate and upgrade to when play is pressed
update readme

closes #1118

Signed-off-by: Caroline Fletcher <caroline.fletcher@uk.ibm.com>
  • Loading branch information
Caroline Fletcher committed Jul 16, 2019
1 parent b868955 commit b9b3ee7
Show file tree
Hide file tree
Showing 24 changed files with 669 additions and 526 deletions.
17 changes: 12 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,19 @@ To debug your smart contract follow these steps:
1. Ensure you are connected to the `local_fabric` runtime and that the `local_fabric` peer is in development mode. Development mode is indicated by an infinity symbol on a peer, under `Nodes` in the `Local Fabric Ops` panel. To toggle development mode, right-click the peer and select `Toggle Development Mode`. By toggling development mode, transactions will now have a large timeout value.
2. Open your smart contract project in your workspace.
3. Open the debug view in Visual Studio Code using the left-hand navigation bar.
4. Select the `Debug Smart Contract` configuration by using the dropdown in the upper-left and click the **play** button on the debug toolbar.
5. Select `Instantiate Smart Contract` from the blockchain icon on the debug toolbar. This action will package, install and instantiate a debug version of the selected smart contract. If there is a version of the selected smart contract already instantiated, select `Upgrade Smart Contract`.
6. Add breakpoints to the smart contract by clicking on the relevant line numbers in your smart contract files.
7. To submit or evaluate a transaction, click the blockchain icon on the debug toolbar. Alternatively, in the `Fabric Gateways` panel, you can right click on transactions to submit or evaluate them. Execution will be paused on any breakpoints you've defined.
4. Select the `Debug Smart Contract` configuration by using the dropdown in the upper-left and click the **play** button on the debug toolbar. The extension will automatically instantiate or upgrade the smart contract as appropriate. If you want to test out a function that is called on instantiate or upgrade add the following to the launch configuration, where `name` is the name of the smart contract and `version` is different to the previous version used. Alternatively if you are using JavaScript or TypeScript then you can update the `version` in the package.json file.

To make iterative changes to your smart contract while debugging, after making your changes click the **restart** button. You can also stop the debugging session, make futher changes and start debugging again, without needing to upgrade your smart contract. Please note, as this stores the smart contract in local memory, for many changes to large smart contracts, you may need to reinstantiate the smart contract. If you restart the `local_fabric` runtime after stopping a debugging session, you must select `Upgrade Smart Contract` by clicking the blockchain icon on the debug toolbar. This will install a new `vscode-debug-XXXXXXX` version of your smart contract, which then allows you to continue submitting and debugging transactions.
```
"env": {
"CORE_CHAINCODE_ID_NAME": <name>:<version>
}
```

5. Add breakpoints to the smart contract by clicking on the relevant line numbers in your smart contract files.
6. To submit or evaluate a transaction, click the blockchain icon on the debug toolbar. Alternatively, in the `Fabric Gateways` panel, you can right click on transactions to submit or evaluate them. Execution will be paused on any breakpoints you've defined.

#### Making changes to your contract while debugging
To make iterative changes to your smart contract while debugging, after making your changes click the **restart** button. You can also stop the debugging session, make further changes and start debugging again, without needing to upgrade your smart contract.

### Add a gateway for connecting to your own Hyperledger Fabric instance
To connect to our own Hyperledger Fabric instance, it must be running [Hyperledger Fabric v1.4.1](https://hyperledger-fabric.readthedocs.io/en/release-1.4/install.html) or later.
Expand Down
17 changes: 12 additions & 5 deletions client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,19 @@ To debug your smart contract follow these steps:
1. Ensure you are connected to the `local_fabric` runtime and that the `local_fabric` peer is in development mode. Development mode is indicated by an infinity symbol on a peer, under `Nodes` in the `Local Fabric Ops` panel. To toggle development mode, right-click the peer and select `Toggle Development Mode`. By toggling development mode, transactions will now have a large timeout value.
2. Open your smart contract project in your workspace.
3. Open the debug view in Visual Studio Code using the left-hand navigation bar.
4. Select the `Debug Smart Contract` configuration by using the dropdown in the upper-left and click the **play** button on the debug toolbar.
5. Select `Instantiate Smart Contract` from the blockchain icon on the debug toolbar. This action will package, install and instantiate a debug version of the selected smart contract. If there is a version of the selected smart contract already instantiated, select `Upgrade Smart Contract`.
6. Add breakpoints to the smart contract by clicking on the relevant line numbers in your smart contract files.
7. To submit or evaluate a transaction, click the blockchain icon on the debug toolbar. Alternatively, in the `Fabric Gateways` panel, you can right click on transactions to submit or evaluate them. Execution will be paused on any breakpoints you've defined.
4. Select the `Debug Smart Contract` configuration by using the dropdown in the upper-left and click the **play** button on the debug toolbar. The extension will automatically instantiate or upgrade the smart contract as appropriate. If you want to test out a function that is called on instantiate or upgrade add the following to the launch configuration, where `name` is the name of the smart contract and `version` is different to the previous version used. Alternatively if you are using JavaScript or TypeScript then you can update the `version` in the package.json file.

To make iterative changes to your smart contract while debugging, after making your changes click the **restart** button. You can also stop the debugging session, make futher changes and start debugging again, without needing to upgrade your smart contract. Please note, as this stores the smart contract in local memory, for many changes to large smart contracts, you may need to reinstantiate the smart contract. If you restart the `local_fabric` runtime after stopping a debugging session, you must select `Upgrade Smart Contract` by clicking the blockchain icon on the debug toolbar. This will install a new `vscode-debug-XXXXXXX` version of your smart contract, which then allows you to continue submitting and debugging transactions.
```
"env": {
"CORE_CHAINCODE_ID_NAME": <name>:<version>
}
```

5. Add breakpoints to the smart contract by clicking on the relevant line numbers in your smart contract files.
6. To submit or evaluate a transaction, click the blockchain icon on the debug toolbar. Alternatively, in the `Fabric Gateways` panel, you can right click on transactions to submit or evaluate them. Execution will be paused on any breakpoints you've defined.

#### Making changes to your contract while debugging
To make iterative changes to your smart contract while debugging, after making your changes click the **restart** button. You can also stop the debugging session, make further changes and start debugging again, without needing to upgrade your smart contract.

### Add a gateway for connecting to your own Hyperledger Fabric instance
To connect to our own Hyperledger Fabric instance, it must be running [Hyperledger Fabric v1.4.1](https://hyperledger-fabric.readthedocs.io/en/release-1.4/install.html) or later.
Expand Down
Loading

0 comments on commit b9b3ee7

Please sign in to comment.