Skip to content

Instantly share code, notes, and snippets.

@alexroan
Created March 17, 2020 08:17
Show Gist options
  • Save alexroan/d62dc2a86358b143e7777f19f68c4995 to your computer and use it in GitHub Desktop.
Save alexroan/d62dc2a86358b143e7777f19f68c4995 to your computer and use it in GitHub Desktop.
truffle-smart-contract/TestHelloWorld.sol/0.0.5
pragma solidity >=0.5.0;
import "truffle/Assert.sol";
import "truffle/DeployedAddresses.sol";
import "../contracts/HelloWorld.sol";
contract TestHelloWorld {
function testItGreets() public {
// Get the deployed contract
HelloWorld helloWorld = HelloWorld(DeployedAddresses.HelloWorld());
// Call getGreeting function in deployed contract
string memory greeting = helloWorld.getGreeting();
// Assert that the function returns the correct greeting
Assert.equal(greeting, "Hello World", "It should greet me with Hello World.");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment