Created
August 25, 2023 11:40
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {Test, console} from 'forge-std/Test.sol'; | |
import {DePayForwarderV2} from '../contracts/DePayForwarderV2.sol'; | |
import {DePayRouterV2} from '../contracts/DePayRouterV2.sol'; | |
import {TestReceiver} from '../contracts/TestReceiver.sol'; | |
import {IDePayRouterV2} from '../contracts/interfaces/IDePayRouterV2.sol'; | |
contract DePayRouterV2Test is Test { | |
DePayForwarderV2 public forwarder; | |
DePayRouterV2 public router; | |
TestReceiver receiver; | |
address USDC = 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48; | |
function setUp() public { | |
forwarder = new DePayForwarderV2(); | |
router = new DePayRouterV2(address(0), address(forwarder)); | |
receiver = new TestReceiver(); | |
} | |
function testEthertoAddressZero() public { | |
address NATIVE = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE; | |
uint paymentAmount = 5 ether; | |
uint feeAmount = 0; | |
uint amountIn = paymentAmount + feeAmount; | |
address feeReceiver = address(0); | |
//setting up a payment struct for user who want to use native to pay native while passing an exchange address | |
IDePayRouterV2.Payment memory payment = IDePayRouterV2.Payment( | |
amountIn, | |
false, | |
paymentAmount, | |
feeAmount, | |
NATIVE, | |
address(0), | |
NATIVE, | |
address(0), | |
feeReceiver, | |
0, | |
0, | |
'', | |
'', | |
block.timestamp + 7 days | |
); | |
// checking the value of address zero before making transaction | |
uint paymentReceiverb4Call = address(0).balance; | |
//pranking a user with eth on mainnet | |
vm.startPrank(0x267be1C1D684F78cb4F6a176C4911b741E4Ffdc0); | |
// ether sent along with the transaction is 5 ether | |
router.pay{value: 5 ether}(payment); | |
vm.stopPrank(); | |
uint paymentReceiveraftercall = address(0).balance; | |
console.log('address zero Diff after call', paymentReceiveraftercall - paymentReceiverb4Call); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment