Let’s test it.

Again, do the truffle test command in the 02-Testing folder,

$ truffle test ./test/hello_eth_salon.js

First, you see it compile and … and…. Boom, another Error:

Using network 'development'. Contract: HelloEthSalon:GetMessage

1) should return a correct string

> No events were emitted 0 passing (22ms)

1 failing 1) Contract: HelloEthSalon:GetMessage should return a correct string:

Error: HelloEthSalon has not been deployed to detected network (network/artifact mismatch)

at /Users/andy/.nvm/versions/node/v8.5.0/lib/node_modules/truffle/build/cli.bundled.js:318327:17

at <anonymous>

at process._tickCallback (internal/process/next_tick.js:188:7)

The Error said HelloEthSalon has not been deployed to detected network (network/artifact mismatch).

Okay, so the thing is that besides starting the testrpc up, we also need to deploy our contract to the just-started testrpc Ethereum Simulator. What we need to do is to update our 1_initial_migration.js file under migrations folder. It should be looked

var Migrations = artifacts.require("./Migrations.sol"); module.exports = function(deployer) {

deployer.deploy(Migrations);

};

Let’s import our HelloEthSalon contract right after the MetaCoin importing statement and add a new deploy call right after the deployer.deploy(MetaCoin); . The updated deploy javascript file should be this:

If you are done, again, do the truffle test command in the 02-Testing folder

$ truffle test ./test/hello_eth_salon.js

First, you see it compile and do the testing as following:

Using network 'development'. Contract: HelloEthSalon:GetMessage

✓ should return a correct string 1 passing (44ms)

if you see the ✓ checking mark, congrats, we finish your first ever smart contract testing.

In case you need, here is the whole testcase codes: