Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Blockchain By Example

You're reading from  Blockchain By Example

Product type Book
Published in Nov 2018
Publisher Packt
ISBN-13 9781788475686
Pages 528 pages
Edition 1st Edition
Languages
Concepts
Authors (3):
Bellaj Badr Bellaj Badr
Profile icon Bellaj Badr
Richard Horrocks Richard Horrocks
Profile icon Richard Horrocks
Xun (Brian) Wu Xun (Brian) Wu
Profile icon Xun (Brian) Wu
View More author details

Table of Contents (13) Chapters

Preface Say Hello to Blockchain Building a Bitcoin Payment System Building Your Own Cryptocurrency Peer-to-Peer Auctions in Ethereum Tontine Game with Truffle and Drizzle Blockchain-Based Futures System Blockchains in Business Creating an ICO Distributed Storage IPFS and Swarm Supply Chain on Hyperledger Letter of Credit (LC) Hyperledger Other Books You May Enjoy

Truffle unit tests

I believe software developers are artists, and they love testing their chefd'oeuvres before deploying them. If you’re one of them then that's good news for you, as Truffle allows you to easily test your Solidity smart contract.

Under the hood, Truffle leverages an adapted version of the famous Mochajs (https://mochajs.org/) unit-testing framework to test Solidity contracts. Consequently, you can write your tests in JavaScript and take advantage of all the patterns Mocha provides. In addition, Truffle enables you to write tests using Solidity directly. In this section, I will opt for starting with JavaScript to implement all of the Tontine test cases, then we will explore how to use Solidity as a testing framework.

Let's start by writing our test files.

...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}