如何解决松露测试 - 不向 msg.sender 发送资金
这是我已经在 stackexchange - ethereum (https://ethereum.stackexchange.com/questions/97124/truffle-test-doesnt-send-funds-to-msg-sender) 上问过的一个问题,但看起来活动并不多,所以我希望我能在这里找到一些帮助。
看来我的 gnache 或 truffle 设置有误...
我已经在这里问了一个类似的问题:https://ethereum.stackexchange.com/questions/96681/owner-of-contract-is-set-to-contract-address
我的本地链上的地址基本上有些混乱(它适用于测试网)。
设置/迁移与链接中的相同。
实际功能:
function claim(uint256 pid,uint256 cAmount,address test) external nonReentrant returns (bool){
return _claim(pid,cAmount,test);
}
function _claim(uint256 pid,address test) internal returns (bool){
require(test == msg.sender,"ERROR");
bool success;
uint256 possibleClaim = _getClaimableAmount(pid,test);
require(possibleClaim >= cAmount,"Claim: Not enough claimable amount");
_reflow(pid);
uint256 tempDaoFee = cAmount.mul(_poolInfo[pid].claimFee);
uint256 daoFee = tempDaoFee.div(100);
success = IERC20(_poolInfo[pid].poolT.rewardToken).transfer(test,cAmount.sub(daoFee));
_poolInfo[pid].poolT.rewardToken.transfer(_poolInfo[pid].daoWallet,daoFee);
return success;
}
测试:
it("7.1 Claim: ...",async ()=> {
const adr = await irs.getRewardToken("0");
console.log("Address: ",adr)
console.log("TokenAddress: ",iwbtc.address)
console.log("ContractAddress: ",irs.address)
const balanceOFContract0 = await iwbtc.balanceOf(irs.address);
const bal0 = await iwbtc.balanceOf(accounts[6])
console.log("balanceOFContract = ",balanceOFContract0.toString())
console.log("balanceBeforClaim = ",bal0.toString())
const claimable = await irs.getClaimableAmount("0",accounts[6]);
const val = claimable / 2;
console.log("Val = ",val.toString())
const success = await irs.claim("0",val,accounts[6],{from: accounts[6]});
const bal1 = await iwbtc.balanceOf(accounts[6])
const balanceOFContract1 = await iwbtc.balanceOf(irs.address);
console.log("balanceOFContract = ",balanceOFContract1.toString())
console.log("balanceBeforClaim = ",bal1.toString())
console.log("Transaction:",success)
});
输出:
Address: 0xFFCb10BeEE65E616cc231e1760C1fdbcb70ce821
TokenAddress: 0xFFCb10BeEE65E616cc231e1760C1fdbcb70ce821
ContractAddress: 0xdCA8a4625c00f739Adc6F245DaC8E1d5cB5fd06A
balanceOFContract = 154000
balanceBeforClaim = 70000
Val = 70000
balanceOFContract = 84000
balanceAfterClaim = 70000
Transaction: {
tx: '0xe455ce4e24fe1aaeaa0d82dec41ffe5fedb647832dcc5421babd25aae44f901e',receipt: {
transactionHash: '0xe455ce4e24fe1aaeaa0d82dec41ffe5fedb647832dcc5421babd25aae44f901e',transactionIndex: 0,blockHash: '0x8538f51b7266acc730e3e5bd344e5bbe2c67f335f8c427c40454751dee42e73a',blockNumber: 538,from: '0xb8917e63f9d6603366ff30871610f9af48804557',to: '0xdca8a4625c00f739adc6f245dac8e1d5cb5fd06a',gasUsed: 218583,cumulativeGasUsed: 218583,contractAddress: null,logs: [],status: true,logsBloom: '0x00000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000010000000000000000000000000000000100000000000000000000000000400000000000000000000000010000000000000000000000000400000001000000000000000000000000000000000000000000000000000000000000000000000000000000040000000020400000000000000000002000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000020001000000000000000000000',rawLogs: [ [Object],[Object] ]
},logs: []
}
√ 7.1 Claim: ... (3795ms)
所以……
尝试使用 IERC20() 并且没有......没有区别(无论如何都会让我想知道)。
有人知道这里发生了什么吗?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。