Skip to content
A simple example on how to do unit tests and catch bugs before hitting the blockchain
TypeScript JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
images
packages/mybuggychaincode-cc
.convector
.gitignore
LICENSE
README.md
lerna.json
org1.mybuggychaincode.config.json
org2.mybuggychaincode.config.json
package-lock.json
package.json
tsconfig.json
update-paths.js

README.md

Bug Hunting demo project

This is a example project on how to debug and test a Convector Smart Contracts project.

Find the details in this Medium post.

Beware that this project uses Convector 1.3.0

Start

npm i

Tests

npm t

Details on the use case

The controller in this project has 3 main functions.

Functions

  • create. This will create a dummy model in the ledger and set the owner to this.sender (a.k.a the wallet/certificate sending the request).
  • getOne. This will just return one item by it's id.
  • update. This will try to update the model but will first check that the requesting wallet/cert is the authorized (the one set in the owner property), if not, a Ups, the requesting identity is not authorized to update the model will be returned.

The test is fairly simple ./packages/mybuggychaincode-cc/tests/mybuggychaincode.spec.ts:

  • should create a default model. Create a dummy model.
  • should find the model. Find it to check it the create function still works fine.
  • try to update without success. Change the identity of the mock adapter and expect a rejection.
  • try to update with success. Switch to the original certificate and expect a successful modification of data.

Check all the information to work with Convector in the DOCS site.

Collaborate to the Convector Suite projects

You can’t perform that action at this time.