I am doing a test that checks if a reward can't be claimed as soon as the bought is done but 60 seconds later. Banaces are not precise and I am going crazy due to BN and comparision units. this is the test code:
it('Should not let user3 accounts[12] to claim rewards just after buy, but after one day: # claims must update, balance should be OK', async() => {
const busd = await BUSD.deployed();
const nftMinter = await NFTMinter.deployed();
const busdPreBalance = await busd.balanceOf(accounts[12]);
const op1 = await nftMinter.getMyTokens({from: accounts[12]});
const nftValue = op1[0].value;
const expectedReward = op1[0].rewardPerInterval ;
await catchNotEnoughTimePassed(nftMinter.claimReward({from: accounts[12]}));
await increase(60);
await nftMinter.claimReward({from: accounts[12]});
const busdPostBalance = await busd.balanceOf(accounts[12]);
const busdExpectedBal = busdPreBalance + expectedReward;
// actual , expected
assert.equal(busdPostBalance.toString(), busdExpectedBal, "reward quant is not ok");
})
And this is the error it throws on last comparision:
1) Contract: NFTMinter
Should not let user3 accounts[12] to claim rewards just after buy, but after one day: # claims must update, balance should be OK:
reward quant is not ok
+ expected - actual
-992028027681660899653976
+9920249134948096885813123460207612456747404
can you help please? I'll be grateful!
edit: My real problem is that I can't find the way to multiply an uint256 value from an smart contract, store it on a variable, and multiply itself for 0.9.
const op1 = await nftMinter.getMyTokens({from: accounts[12]});
const expectedReward = op1[0].rewardPerInterval * 0.9;