Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Extend the coverage of account nonce discrepancies tests #703

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
[
{
"inputs": [],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "address",
"name": "",
"type": "address"
}
],
"name": "DeployedContract2Address",
"type": "event"
},
{
"inputs": [],
"name": "childContract",
"outputs": [
{
"internalType": "contract Deploys1Contract",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "owner",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
[
{
"inputs": [],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "address",
"name": "",
"type": "address"
}
],
"name": "DeployedContract1Address",
"type": "event"
},
{
"inputs": [],
"name": "childContract",
"outputs": [
{
"internalType": "contract EmptyContract",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "owner",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
[
{
"inputs": [],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "address",
"name": "",
"type": "address"
}
],
"name": "Deploys2ContractsAddress",
"type": "event"
},
{
"inputs": [],
"name": "childContract1",
"outputs": [
{
"internalType": "contract Deploys1Contract",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "childContract2",
"outputs": [
{
"internalType": "contract EmptyContract",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "owner",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
[
{
"inputs": [],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "address",
"name": "",
"type": "address"
}
],
"name": "DeployedContract0Address",
"type": "event"
},
{
"inputs": [],
"name": "owner",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
}
]
Original file line number Diff line number Diff line change
@@ -1,4 +1,36 @@
[
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "address",
"name": "",
"type": "address"
}
],
"name": "DeployedContractAddress",
"type": "event"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "_salt",
"type": "uint256"
}
],
"name": "deployViaCreate2",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "externalFunction",
Expand All @@ -25,6 +57,24 @@
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address payable",
"name": "_contract",
"type": "address"
},
{
"internalType": "address payable",
"name": "_receiver",
"type": "address"
}
],
"name": "internalTransfer",
"outputs": [],
"stateMutability": "payable",
"type": "function"
},
{
"inputs": [],
"name": "revertWithRevertReason",
Expand Down Expand Up @@ -63,5 +113,18 @@
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address payable",
"name": "sampleAddress",
"type": "address"
}
],
"name": "selfdestructSample",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[
{
"inputs": [],
"name": "selfDestructSample",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}
]
52 changes: 52 additions & 0 deletions contracts/discrepancies/nonce/ChainedContracts.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;

contract EmptyContract {
address public owner;
constructor(){
emit DeployedContract0Address(address(this));
}

event DeployedContract0Address(address);
}

contract Deploys1Contract {
address public owner;
EmptyContract public childContract;

constructor() {
owner = msg.sender;
childContract = new EmptyContract();
emit DeployedContract1Address(address(this));
}

event DeployedContract1Address(address);
}

contract ChainedContracts {
address public owner;
Deploys1Contract public childContract;

constructor() {
owner = msg.sender;
childContract = new Deploys1Contract();
emit DeployedContract2Address(address(this));
}

event DeployedContract2Address(address);
}

contract Deploys2Contracts {
address public owner;
Deploys1Contract public childContract1;
EmptyContract public childContract2;

constructor() {
owner = msg.sender;
childContract1 = new Deploys1Contract();
childContract2 = new EmptyContract();
emit Deploys2ContractsAddress(address(this));
}

event Deploys2ContractsAddress(address);
}
35 changes: 28 additions & 7 deletions contracts/discrepancies/nonce/InternalCallee.sol
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;

contract Sample {}
contract Sample {

function selfDestructSample() external {
selfdestruct(payable(msg.sender));
}
}

contract InternalCallee {
uint calledTimes = 0;
uint calledTimes = 0;

function factorySample() external returns (address) {
return address(new Sample());
}
function factorySample() external returns (address) {
return address(new Sample());
}

function externalFunction() external returns (uint) {
// mutate state to maintain non-view function status
return ++calledTimes;
}

function revertWithRevertReason() public returns (bool) {
// mutate state to maintain non-view function status
++calledTimes;
revert("RevertReason");
}
Expand All @@ -28,4 +31,22 @@ contract InternalCallee {
function selfDestruct(address payable _addr) external {
selfdestruct(_addr);
}

function selfdestructSample(address payable sampleAddress) external {
Sample(sampleAddress).selfDestructSample();
}

function internalTransfer(address payable _contract, address payable _receiver) payable external {
(bool success,) = _contract.call(abi.encodeWithSignature("transferTo(address)", _receiver));
require(success, "Function call failed");
}

event DeployedContractAddress(address);

function deployViaCreate2(uint256 _salt) external returns (address) {
Sample temp = new Sample{salt: bytes32(_salt)}();
emit DeployedContractAddress(address(temp));

return address(temp);
}
}
Loading
Loading