Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
b0a54509
Unverified
Commit
b0a54509
authored
May 13, 2022
by
smartcontracts
Committed by
GitHub
May 13, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
maint(ct): simplify test helpers (#2523)
Simplifies test helpers slightly by cutting out unnecessary code.
parent
2e0b6330
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
62 deletions
+4
-62
FailingReceiver.sol
...ages/contracts/contracts/test-helpers/FailingReceiver.sol
+0
-6
TestERC20.sol
packages/contracts/contracts/test-helpers/TestERC20.sol
+4
-56
No files found.
packages/contracts/contracts/test-helpers/FailingReceiver.sol
View file @
b0a54509
// SPDX-License-Identifier: MIT
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.9;
pragma solidity >=0.8.9;
/**
* @title FailingReceiver
*/
contract FailingReceiver {
contract FailingReceiver {
/**
* @notice Receiver that always reverts upon receiving ether.
*/
receive() external payable {
receive() external payable {
require(false, "FailingReceiver");
require(false, "FailingReceiver");
}
}
...
...
packages/contracts/contracts/test-helpers/TestERC20.sol
View file @
b0a54509
// SPDX-License-Identifier: MIT
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;
pragma solidity ^0.8.9;
// a test ERC20 token with an open mint function
import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
contract TestERC20 {
string public constant name = "Test";
string public constant symbol = "TST";
uint8 public constant decimals = 18;
uint256 public totalSupply;
mapping(address => uint256) public balanceOf;
mapping(address => mapping(address => uint256)) public allowance;
event Approval(address indexed owner, address indexed spender, uint256 value);
contract TestERC20 is ERC20 {
event Transfer(address indexed from, address indexed to, uint256 value);
constructor() ERC20("TEST", "TST") {}
constructor() {}
function mint(address to, uint256 value) public {
function mint(address to, uint256 value) public {
totalSupply = totalSupply + value;
_mint(to, value);
balanceOf[to] = balanceOf[to] + value;
emit Transfer(address(0), to, value);
}
function _approve(
address owner,
address spender,
uint256 value
) private {
allowance[owner][spender] = value;
emit Approval(owner, spender, value);
}
function _transfer(
address from,
address to,
uint256 value
) private {
balanceOf[from] = balanceOf[from] - value;
balanceOf[to] = balanceOf[to] + value;
emit Transfer(from, to, value);
}
function approve(address spender, uint256 value) external returns (bool) {
_approve(msg.sender, spender, value);
return true;
}
function transfer(address to, uint256 value) external returns (bool) {
_transfer(msg.sender, to, value);
return true;
}
function transferFrom(
address from,
address to,
uint256 value
) external returns (bool) {
if (allowance[from][msg.sender] != type(uint256).max) {
allowance[from][msg.sender] = allowance[from][msg.sender] - value;
}
_transfer(from, to, value);
return true;
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment