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
npm i
npm t
The controller in this project has 3 main functions.
create
. This will create a dummy model in the ledger and set theowner
tothis.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 theowner
property), if not, aUps, 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 thecreate
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.