Skip to content
This repository has been archived by the owner on Apr 27, 2022. It is now read-only.

Raise transfer stipend #672

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
10 changes: 10 additions & 0 deletions src/contracts/test/FallbackWriteStorage.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// SPDX-License-Identifier: LGPL-3.0-or-later
pragma solidity ^0.7.6;

contract FallbackWriteStorage {
uint256 public receiveCount;

receive() external payable {
receiveCount += 1;
}
}
33 changes: 33 additions & 0 deletions test/GPv2Transfer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ describe("GPv2Transfer", () => {
let token: MockContract;

let NonPayable: ContractFactory;
let FallbackWriteStorage: ContractFactory;

beforeEach(async () => {
const GPv2Transfer = await ethers.getContractFactory(
Expand All @@ -31,6 +32,9 @@ describe("GPv2Transfer", () => {
token = await waffle.deployMockContract(deployer, IERC20.abi);

NonPayable = await ethers.getContractFactory("NonPayable");
FallbackWriteStorage = await ethers.getContractFactory(
"FallbackWriteStorage",
);
});

const amount = ethers.utils.parseEther("0.1337");
Expand Down Expand Up @@ -555,6 +559,35 @@ describe("GPv2Transfer", () => {
).to.be.reverted;
});

it("should revert when transfering Ether to contract writes storage", async () => {
await funder.sendTransaction({
to: transfer.address,
value: amount,
});

const smartWallet = await FallbackWriteStorage.deploy();

await expect(
funder.sendTransaction({
to: smartWallet.address,
value: 1,
}),
).to.not.be.reverted;
expect(await smartWallet.receiveCount()).to.equal(1);

await expect(
transfer.transferToAccountsTest(vault.address, [
{
account: smartWallet.address,
token: BUY_ETH_ADDRESS,
amount,
balance: OrderBalanceId.ERC20,
},
]),
).to.be.reverted;
expect(await smartWallet.receiveCount()).to.not.equal(2);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not equal 2 instead of equal 1?

Copy link
Contributor Author

@nlordell nlordell Jun 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤷 - equal 1 is more specific so will change to this.

});

it("should transfer many external and internal amounts to recipient", async () => {
// NOTE: Make sure we have enough traders for our test :)
expect(traders).to.have.length.above(5);
Expand Down