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
d5bf9d20
Commit
d5bf9d20
authored
Dec 09, 2022
by
Will Cory
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
didn't mean to delete Transactor.t.sol
parent
282c0cc7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
84 additions
and
0 deletions
+84
-0
Transactor.t.sol
...tracts-periphery/contracts/foundry-tests/Transactor.t.sol
+84
-0
No files found.
packages/contracts-periphery/contracts/foundry-tests/Transactor.t.sol
0 → 100644
View file @
d5bf9d20
//SPDX-License-Identifier: MIT
pragma solidity 0.8.15;
/* Testing utilities */
import { Test } from "forge-std/Test.sol";
import { CallRecorder } from "../testing/helpers/CallRecorder.sol";
import { Reverter } from "../testing/helpers/Reverter.sol";
import { Transactor } from "../universal/Transactor.sol";
contract Transactor_Initializer is Test {
address alice = address(128);
address bob = address(256);
Transactor transactor;
Reverter reverter;
CallRecorder callRecorded;
function _setUp() public {
// Deploy Reverter and CallRecorder helper contracts
reverter = new Reverter();
callRecorded = new CallRecorder();
// Deploy Transactor contract
transactor = new Transactor(address(alice));
vm.label(address(transactor), "Transactor");
// Give alice and bob some ETH
vm.deal(alice, 1 ether);
vm.deal(bob, 1 ether);
vm.label(alice, "alice");
vm.label(bob, "bob");
}
}
contract TransactorTest is Transactor_Initializer {
function setUp() public {
super._setUp();
}
// Tests if the owner was set correctly during deploy
function test_constructor() external {
assertEq(address(alice), transactor.owner());
}
// Tests CALL, should do a call to target
function test_CALL() external {
// Initialize call data
bytes memory data = abi.encodeWithSelector(callRecorded.record.selector);
// Run CALL
vm.prank(alice);
vm.expectCall(address(callRecorded), data);
transactor.CALL(address(callRecorded), data, 200_000 wei, 420);
}
// It should revert if called by non-owner
function testFail_CALL() external {
// Initialize call data
bytes memory data = abi.encodeWithSelector(callRecorded.record.selector);
// Run CALL
vm.prank(bob);
transactor.CALL(address(callRecorded), data, 200_000 wei, 420);
vm.expectRevert("UNAUTHORIZED");
}
function test_DELEGATECALL() external {
// Initialize call data
bytes memory data = abi.encodeWithSelector(reverter.doRevert.selector);
// Run CALL
vm.prank(alice);
vm.expectCall(address(reverter), data);
transactor.DELEGATECALL(address(reverter), data, 200_000 wei);
}
// It should revert if called by non-owner
function testFail_DELEGATECALLL() external {
// Initialize call data
bytes memory data = abi.encodeWithSelector(reverter.doRevert.selector);
// Run CALL
vm.prank(bob);
transactor.DELEGATECALL(address(reverter), data, 200_000 wei);
vm.expectRevert("UNAUTHORIZED");
}
}
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