Skip to content

Instantly share code, notes, and snippets.

@nobodyzxc
Created January 20, 2019 20:57
Show Gist options
  • Save nobodyzxc/19e0c625562b994afe0046b3b0646e42 to your computer and use it in GitHub Desktop.
Save nobodyzxc/19e0c625562b994afe0046b3b0646e42 to your computer and use it in GitHub Desktop.
Remix Unit Tests
◼ MyTest
[02:35:23] payload method is eth_gasPrice
[02:35:23] payload method is eth_sendTransaction
[02:35:23] payload method is eth_getTransactionReceipt
[02:35:23] payload method is eth_gasPrice
[02:35:23] payload method is eth_sendTransaction
[02:35:23] payload method is eth_getTransactionReceipt
[02:35:23] payload method is eth_gasPrice
[02:35:23] payload method is eth_sendTransaction
[02:35:23] payload method is eth_getTransactionReceipt
✓ Initial value should be100
[02:35:23] payload method is eth_gasPrice
[02:35:23] payload method is eth_sendTransaction
[02:35:23] payload method is eth_getTransactionReceipt
[02:35:23] payload method is eth_call
✓ Initial value should be200
2 passing (1s)
pragma solidity ^0.5.0;
contract SimpleStorage {
uint public storedData;
constructor() public {
storedData = 100;
}
function set(uint x) public {
storedData = x;
}
function get() public view returns (uint retVal) {
return storedData;
}
}
pragma solidity ^0.5.0;
import "./simple_storage.sol";
contract MyTest {
SimpleStorage foo;
uint i = 0;
function beforeAll() public {
foo = new SimpleStorage();
}
function beforeEach() public {
if (i == 1) {
foo.set(200);
}
i += 1;
}
function initialValueShouldBe100() public {
Assert.equal(foo.get(), 100, "initial value is not correct");
}
function initialValueShouldBe200() public view returns (bool) {
return foo.get() == 200;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment