Skip to content

Commit

Permalink
test: add comments in test contracts (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
agusduha authored Apr 18, 2024
1 parent f0a963f commit d2325db
Show file tree
Hide file tree
Showing 14 changed files with 71 additions and 0 deletions.
4 changes: 4 additions & 0 deletions solidity/contracts/ContractTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ pragma solidity ^0.8.0;

import {IContractTest, MyContract} from '../interfaces/IContractTest.sol';

/**
* @notice This contract is for general testing
* @dev It contains the most common variables types and functions
*/
contract ContractTest is IContractTest {
uint256 public immutable immutableUintVariable = 10;

Expand Down
3 changes: 3 additions & 0 deletions solidity/contracts/Lib.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

/**
* @notice This contract library is for testing that libraries mocks are not generated
*/
library Lib {
function add(uint256 a, uint256 b) public pure returns (uint256) {
return a + b;
Expand Down
3 changes: 3 additions & 0 deletions solidity/contracts/utils/ContractA.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import {IContractA} from '../../interfaces/IContractA.sol';
import {IContractZ} from '../../interfaces/IContractZ.sol';
import {ContractB} from './ContractB.sol';

/**
* @notice This contract is for testing contracts with interfaces and inheritance
*/
contract ContractA is IContractA, ContractB {
uint256 public uintVariable;

Expand Down
3 changes: 3 additions & 0 deletions solidity/contracts/utils/ContractAbstract.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
pragma solidity ^0.8.0;

/**
* @notice This contract is for testing abstract contracts with implemented and unimplemented functions
*/
abstract contract ContractAbstract {
uint256 public uintVariable;

Expand Down
3 changes: 3 additions & 0 deletions solidity/contracts/utils/ContractB.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ pragma solidity ^0.8.0;

import {IContractB} from '../../interfaces/IContractB.sol';

/**
* @notice This contract is for testing string variables and function with return values
*/
contract ContractB is IContractB {
string public stringVariable;

Expand Down
3 changes: 3 additions & 0 deletions solidity/contracts/utils/ContractBAbstract.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ pragma solidity ^0.8.0;
import {IContractBAbstract} from '../../interfaces/IContractBAbstract.sol';
import {IContractB2Abstract} from '../../interfaces/IContractB2Abstract.sol';

/**
* @notice This contract is for testing abstract contracts with multiple inherited unimplemented functions
*/
abstract contract ContractBAbstract is IContractBAbstract, IContractB2Abstract {
uint256 public uintVariable;

Expand Down
3 changes: 3 additions & 0 deletions solidity/contracts/utils/ContractC.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ pragma solidity ^0.8.0;

import {IContractCA} from '../../interfaces/IContractCA.sol';

/**
* @notice This contract is for testing uint256 variables and function with return values
*/
contract ContractCA is IContractCA {
uint256 public uint256Variable;

Expand Down
3 changes: 3 additions & 0 deletions solidity/contracts/utils/ContractD.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
pragma solidity ^0.8.0;

/**
* @notice This contract is for testing functions with multiple return values
*/
contract ContractD {
uint256 internal _internalUintVar;

Expand Down
3 changes: 3 additions & 0 deletions solidity/contracts/utils/ContractE.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ pragma solidity ^0.8.0;

import {ContractD} from './ContractD.sol';

/**
* @notice This contract is for testing a contract with internal variables and inheritance from another contract
*/
contract ContractE is ContractD {
uint256 internal _internalUintVar2;

Expand Down
17 changes: 17 additions & 0 deletions solidity/contracts/utils/ContractF.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
pragma solidity ^0.8.0;

/**
* @notice Simple Ownable contract
*/
contract Ownable {
address public owner;

Expand All @@ -8,19 +11,33 @@ contract Ownable {
}
}

/**
* @notice Simple abstract contract inheriting from a contract
*/
abstract contract ContractFAbstract2 is Ownable {
function setVariablesB(uint256 _newValue) public virtual returns (bool _result);
}

/**
* @notice Interface for ContractFAbstract
*/
interface IContractFAbstract {
function QUORUM() external view returns (uint256 _quorum);
function setVariablesA(uint256 _newValue) external returns (bool _result);
}

/**
* @notice Contract for testing abstract contracts with a variable and a unimplemented function
* while inheriting from another abstract contract and its interface
*/
abstract contract ContractFAbstract is IContractFAbstract, ContractFAbstract2 {
uint256 public constant QUORUM = 70;

function setVariablesA(uint256 _newValue) public virtual returns (bool _result);
}

/**
* @notice Contract for testing abstract contracts with multiple inheritance of same functions
* Also testing multiple levels of abstract inheritance
*/
abstract contract ContractF is IContractFAbstract, ContractFAbstract {}
7 changes: 7 additions & 0 deletions solidity/contracts/utils/ContractG.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
pragma solidity ^0.8.0;

/**
* @notice This contract is for testing complex data structures with mappings using them
* - Structs with nestep mapings
* - Nested structs
* - Nested structs arrays
* - Structs with multiple structs
*/
contract ContractG {
struct Set {
bytes32[] _values;
Expand Down
3 changes: 3 additions & 0 deletions solidity/contracts/utils/ContractH.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
pragma solidity ^0.8.0;

/**
* @notice This contract is for testing receive and fallback functions
*/
contract ContractH {
address public owner;

Expand Down
12 changes: 12 additions & 0 deletions solidity/contracts/utils/ContractI.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
pragma solidity ^0.8.0;

/**
* @notice Simple Ownable contract
*/
contract Ownable {
address public owner;

Expand All @@ -8,6 +11,9 @@ contract Ownable {
}
}

/**
* @notice Simple Pausable contract
*/
contract Pausable {
bool public paused;

Expand All @@ -16,8 +22,14 @@ contract Pausable {
}
}

/**
* @notice Testing abstract contract with multiple inherited contracts
*/
abstract contract ContractI is Ownable, Pausable {}

/**
* @notice Testing abstract contract with constructor and with multiple inherited contracts
*/
abstract contract ContractI2 is Ownable, Pausable {
bool public boolean;

Expand Down
4 changes: 4 additions & 0 deletions solidity/interfaces/IContractTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ pragma solidity ^0.8.0;

contract MyContract {}

/**
* @notice This interface is for general testing
* @dev It contains the most common variables types and functions
*/
interface IContractTest {
// Structs
struct MyStruct {
Expand Down

0 comments on commit d2325db

Please sign in to comment.