-
-
Save sriharish/46bf6f30d831ed37dff2b6bf6a74f5be to your computer and use it in GitHub Desktop.
A test of the ETC treasury system
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity >=0.4.22 <0.7.0; | |
import "remix_tests.sol"; // this import is automatically injected by Remix. | |
import "remix_accounts.sol"; // this import gets test accounts. | |
import "../Treasury.sol"; | |
// File name has to end with '_test.sol', this file can contain more than one testSuite contracts | |
contract testSuite is Treasury { | |
address acc0; | |
address acc1; | |
address acc2; | |
address acc3; // Claimer | |
bytes32 sampleProposalHash; // used to test a sample proposal | |
/// 'beforeAll' runs before all other tests | |
/// More special functions are: 'beforeEach', 'beforeAll', 'afterEach' & 'afterAll' | |
function beforeAll() public { | |
acc0 = TestsAccounts.getAccount(0); | |
acc1 = TestsAccounts.getAccount(1); | |
acc2 = TestsAccounts.getAccount(2); | |
acc3 = TestsAccounts.getAccount(3); | |
sampleProposalHash = keccak256(abi.encode(acc3, 100 ether, 12000000)); | |
} | |
function checkTreasuryCreation() public { | |
Assert.equal(ALPHA, 0x1111111111111111111111111111111111111111, "Incorrect ALPHA"); | |
Assert.equal(BETA, 0x2222222222222222222222222222222222222222, "Incorrect BETA"); | |
Assert.equal(GAMMA, 0x3333333333333333333333333333333333333333, "Incorrect GAMMA"); | |
Assert.equal(BURN_ADDRESS, 0x0000000000000000000000000000000000000000, "Incorrect BURN"); | |
bytes32 initialConfidence = keccak256(abi.encode([true,true,true])); | |
Assert.equal(keccak256(abi.encode(confidence_[ALPHA])), initialConfidence, "Incorrect initial confidence for ALPHA"); | |
Assert.equal(keccak256(abi.encode(confidence_[BETA])), initialConfidence, "Incorrect initial confidence for BETA"); | |
Assert.equal(keccak256(abi.encode(confidence_[GAMMA])), initialConfidence, "Incorrect initial confidence for GAMMA"); | |
} | |
/// #sender: account-3 | |
/// #value: 100 | |
function checkDeposit() public payable { | |
uint initialValue = address(this).balance; | |
uint valueDeposited = deposit(false); // burn = false | |
Assert.equal(address(this).balance, valueDeposited, "Failed to deposit"); | |
} | |
/// #sender: account-3 | |
/// #value: 100 | |
function checkBurntDeposit() public payable { | |
uint initialValue = BURN_ADDRESS.balance; | |
deposit(true); // burn = true | |
Assert.greaterThan(BURN_ADDRESS.balance, initialValue, "Failed to burn"); | |
} | |
/// #sender: account-3 | |
function checkProposal() public { | |
propose(acc3, 100 ether, 12000000); | |
bytes32 initialProposalConfidence = keccak256(abi.encode([false, false, false])); | |
Assert.equal(keccak256(abi.encode(proposalLibrary_[sampleProposalHash])), initialProposalConfidence, "Failed to initialize proposal"); | |
} | |
/* | |
/// #sender: 0x1111111111111111111111111111111111111111 | |
function checkVoteOnProposal() public { | |
voteOnProposal(sampleProposalHash, true); | |
Assert.ok(proposalLibrary_[sampleProposalHash][0], "Failed to vote on proposal"); | |
} | |
*/ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment