
Nebulas, a third generation blockchain, is an incentive-based, self-evolving blockchain system. It offers many advantages over other blockchains.Value-based ranking system which works on liquidity and propagation of address, self evolving core protocols, speediness, Proof of Devotion (PoD) consensus algorithm which leverages PoS, PoI and NR are just some of them. Owing to these improved features, one of our recent blockchain projects validated the use of Nebulas for development.Testing is a critical piece of any implementation, most importantly, a blockchain project. Though Nebulas has a well supported community, a strong testing framework for Nebulas smart contracts does not exist in the market. Inspired by Truffle, a testing framework for ethereum smart contracts, we tried to create an automated testing framework for testing Nebulas smart contracts and we open sourced this library as Nebtest.Features:We built the testing framework using Istanbul and it works well with test runners like Mocha as well.
Installation:
Test Cases:You can provide your input test file as a JSON file. Sample test file will look like:[
{
name: 'Test Case Description',
data: [
{
name: 'Test data name',
testInput: {
...test inputs
},
testExpect: {
...test result expect
}
}
]
}
]Run Test:Unit testing the smart contracts with Nebtest is as simple as writing unit tests for any javascript applications with Mocha.Add following command to scripts. The timeout is based on the mining time of the contract you are running. Increase the timeout if you are getting the timeout error."scripts": {..."test": "mocha --timeout 600000"}Run the test as,npm run testTest Result:

Example:You can find the complete example here

