Solidity transfer function failed?


#1

My code is as follows, The code is passed in remix and eth network , but failed on test net.
The transfer did not send etc from contract to user wallet.

contract test{

mapping(address => uint256 ) public usermoney;

function save() payable public{
    usermoney[msg.sender] = usermoney[msg.sender] + msg.value;
}

function fetch() public {
    uint256 amount = usermoney[msg.sender];
    
    usermoney[msg.sender] = 0;
    msg.sender.transfer(amount);
}

}


#2

It compiles and functions for me. Did your tx run out of gas?