Blockchain Development with Hyperledger
by Salman A. Baset, Luc Desrosiers, Nitin Gaur, Petr Novotny
Testing the Invoke method
It's now time to define the test for the Invoke function. In line 7 of the following codeblock, checkInit is called to initialize the ledger, followed by checkInvoke in line 13, which invokes the requestTrade function. The requestTrade function creates a new trade asset and stores it on the ledger. To verify that the ledger contains the correct state, a new TradeAgreement is created and serialized in lines 15 and 16, before a new composite key is calculated in line 17. Finally, in line 18, the state of the key is verified against the serialized value.
Additionally, as previously outlined, our chaincode contains a series of functions that together define the trade workflow. We will chain the invocations of these functions ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access