这是我已经在 stackexchange - ethereum 上提出的一个问题(https://ethereum.stackexchange.com/questions/97124/truffle-test-doesnt-send-funds-to-msg-sender),但看起来不像有很多活动,所以我希望我能在这里找到一些帮助。
看来我的 gnache 或松露设置有误...
我已经在这里问了一个类似的问题: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, uint256 cAmount, 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)
所以 ...
- 交易发生,但发送方没有收到资金,但合同发送了资金。
- msg.sender 是 givin 参数...(要求在 _claim 中)不要获得资金并且不在交易中
尝试了 IERC20() 并且没有......没有区别(无论如何都会让我想知道)。
有人知道这里发生了什么吗?