'truffle test, transfer erc20 coin from a smart contract address

I am writing test case and I want to know how to send the ERC20 token from a smart contract to an address. Basically i have this code

 it('should detect contract balance', async () => {
    // needs to approve contract adddress first
    await this.erc20Coin.approve.sendTransaction(this.gameContract.address, new BN(100), { from: user1 });
    await this.erc20Coin.approve.sendTransaction(this.gameContract.address, new BN(100), { from: user2 });

    // let user deposit to the contract 
    await this.gameContract.deposit(1, new BN(100), { from: user1 });
    await this.gameContract.deposit(1, new BN(100), { from: user2 });

    // test withdraw a portion from -- ERROR here:  Error: Returned error: sender account not recognized
    await this.erc20Coin.approve.sendTransaction(user1, new BN(100), { from: this.gameContract.address });
    await this.erc20Coin.transfer(user1, new BN(200),  { from: this.gameContract.address });
    
    //... check balance
    ..

The above code allows transfer from user1 and user2 to the smart contract and the smart contract calls the approriate transfer inside

 function deposit(uint256 gameID, uint256 amount) public returns (bool) {
        ...
        erc20Coin.transferFrom(msg.sender, address(this), amount);

Now i want to simulate withdrawal and make sure the contract has not enough balance so I did the test withdraw (on the first code posted above). The problem is I am getting an error: sender account not recognized.

Anyone familiar of this error and how to do it? Basically transfer back some erc20 coins from contract to an address is what I am asking.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source