Commit 47f9989d authored by Developer's avatar Developer

update

parent f8f2596d
Pipeline #923 canceled with stages
[submodule "lib/forge-std"]
path = lib/forge-std
url = https://github.com/foundry-rs/forge-std
{
"lib/forge-std": {
"tag": {
"name": "v1.14.0",
"rev": "1801b0541f4fda118a10798fd3486bb7051c5dd6"
}
}
}
\ No newline at end of file
Subproject commit 1801b0541f4fda118a10798fd3486bb7051c5dd6
console.log("");
// 3. 进行一些初始化操作
address testUser = 0x70997970C51812dc3A010C7d01b50e0d17dc79C8; // 测试账户
uint256 transferAmount = 10000 * 10**18;
// 给测试账户转一些代币
token.transfer(testUser, transferAmount);
console.log("=== Initial Setup ===");
console.log("Transferred", transferAmount, "tokens to", testUser);
console.log("Test user balance:", token.balanceOf(testUser));
vm.stopBroadcast();
}
}
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity ^0.8.20; pragma solidity ^0.8.20;
...@@ -40,4 +25,18 @@ contract DeployAll is Script { ...@@ -40,4 +25,18 @@ contract DeployAll is Script {
console.log("=== InternalTransfer Deployed ==="); console.log("=== InternalTransfer Deployed ===");
console.log("Address:", address(transferContract)); console.log("Address:", address(transferContract));
console.log("Owner:", transferContract.owner()); console.log("Owner:", transferContract.owner());
console.log("");
// 3. 进行一些初始化操作
address testUser = 0x70997970C51812dc3A010C7d01b50e0d17dc79C8; // 测试账户
uint256 transferAmount = 10000 * 10**18;
// 给测试账户转一些代币
token.transfer(testUser, transferAmount);
console.log("=== Initial Setup ===");
console.log("Transferred", transferAmount, "tokens to", testUser);
console.log("Test user balance:", token.balanceOf(testUser));
vm.stopBroadcast();
}
}
...@@ -14,6 +14,10 @@ contract InternalTransferTest is Test { ...@@ -14,6 +14,10 @@ contract InternalTransferTest is Test {
address public user2; address public user2;
address public user3; address public user3;
// 声明事件用于测试
event BatchTransfer(address indexed token, address indexed from, uint256 totalAmount, uint256 recipientCount);
event ProxyTransfer(address indexed token, address indexed from, address indexed to, uint256 amount);
function setUp() public { function setUp() public {
owner = address(this); owner = address(this);
user1 = address(0x1); user1 = address(0x1);
...@@ -94,7 +98,7 @@ contract InternalTransferTest is Test { ...@@ -94,7 +98,7 @@ contract InternalTransferTest is Test {
function testProxyTransferFailNoApproval() public { function testProxyTransferFailNoApproval() public {
uint256 amount = 500 * 10**18; uint256 amount = 500 * 10**18;
vm.expectRevert("Proxy transfer failed"); vm.expectRevert("ERC20: insufficient allowance");
transferContract.proxyTransfer(address(token), user1, user2, amount); transferContract.proxyTransfer(address(token), user1, user2, amount);
} }
...@@ -181,8 +185,7 @@ contract InternalTransferTest is Test { ...@@ -181,8 +185,7 @@ contract InternalTransferTest is Test {
vm.prank(user1); vm.prank(user1);
vm.expectEmit(true, true, false, true); vm.expectEmit(true, true, false, true);
emit InternalTransfer.BatchTransfer(address(token), user1, amount1 + amount2, 2); emit BatchTransfer(address(token), user1, amount1 + amount2, 2);
transferContract.batchTransfer(address(token), recipients, amounts); transferContract.batchTransfer(address(token), recipients, amounts);
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment