Skip to content

Commit

Permalink
Fixing comments
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Stefanov <[email protected]>
  • Loading branch information
stefan-stefanooov committed Oct 19, 2023
1 parent 6459727 commit 2e41b95
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
6 changes: 3 additions & 3 deletions contracts/solidity/account/NonExisting.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ pragma solidity ^0.8.20;

contract NonExisting {
function callOnNonExistingAccount(address nonExistingAddr) external {
nonExistingAddr.call{value: 0}(
nonExistingAddr.call(
abi.encodeWithSignature("doesNotExist()")
);
}

function delegatecallOnNoneExistingAccount(address nonExistingAddr) external {
(bool success, bytes memory data) = nonExistingAddr.delegatecall(
nonExistingAddr.delegatecall(
abi.encodeWithSignature("doesNotExist()")
);
}

function staticcallOnNoneExistingAccount(address nonExistingAddr) external {
(bool success, bytes memory data) = nonExistingAddr.staticcall(
nonExistingAddr.staticcall(
abi.encodeWithSignature("doesNotExist()")
);
}
Expand Down
16 changes: 6 additions & 10 deletions test/solidity/account/nonExisting.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
const { expect, assert } = require('chai')
const { expect } = require('chai')
const { ethers } = require('hardhat')
const Constants = require('../../constants')

describe('Solidity Account non Existing', function () {
let contract, wallet
let contract, randomAddress

before(async function () {
const signers = await ethers.getSigners()
wallet = signers[0]
randomAddress = ethers.Wallet.createRandom().address;
const factory = await ethers.getContractFactory(Constants.Contract.NonExisting)
contract = await factory.deploy()
})

it('should confirm `call` on a non existing account', async function () {
try {
const addr = wallet.address << 3;
const tx = await contract.callOnNonExistingAccount(addr)
const tx = await contract.callOnNonExistingAccount(randomAddress)
await tx.wait()
} catch (err) {
expect(err.reason).to.equal("invalid address or ENS name")
Expand All @@ -24,8 +22,7 @@ describe('Solidity Account non Existing', function () {

it('should confirm `delegatecall` on a non existing account', async function () {
try {
const addr = wallet.address << 3;
const tx = await contract.delegatecallOnNoneExistingAccount(addr)
const tx = await contract.delegatecallOnNoneExistingAccount(randomAddress)
await tx.wait()
} catch (err) {
expect(err.reason).to.equal("invalid address or ENS name")
Expand All @@ -34,8 +31,7 @@ describe('Solidity Account non Existing', function () {

it('should confirm `staticcall` on a non existing account', async function () {
try {
const addr = wallet.address << 3;
const tx = await contract.staticcallOnNoneExistingAccount(addr)
const tx = await contract.staticcallOnNoneExistingAccount(randomAddress)
await tx.wait()
} catch (err) {
expect(err.reason).to.equal("invalid address or ENS name")
Expand Down

0 comments on commit 2e41b95

Please sign in to comment.