add supply test
This commit is contained in:
parent
73f4c628b4
commit
c04362d553
|
@ -49,6 +49,13 @@ contract Subscription {
|
|||
string indexed description
|
||||
);
|
||||
|
||||
event SupplyReceived(
|
||||
address account,
|
||||
uint256 amount,
|
||||
uint256 startingBalance,
|
||||
uint256 newBalance
|
||||
);
|
||||
|
||||
// Employees start at index 1, to allow us to use employees[0] to check for non-existent address
|
||||
// mappings with employeeIds
|
||||
uint256 public nextAgreement;
|
||||
|
@ -119,8 +126,9 @@ contract Subscription {
|
|||
uint256 balance = payorBalances[msg.sender];
|
||||
dai.transferFrom(msg.sender, address(this), amount);
|
||||
compound.supply(daiAddress, amount);
|
||||
payorBalances[msg.sender] = balance.add(amount);
|
||||
//TODO EMIT EVENT
|
||||
uint256 newBalance = balance.add(amount);
|
||||
payorBalances[msg.sender] = newBalance;
|
||||
emit SupplyReceived(msg.sender, amount, balance, newBalance);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -77,19 +77,21 @@ contract("subscription", function () {
|
|||
});
|
||||
|
||||
it('should get amount owed to receiver', async function() {
|
||||
const accured = '35585162410681240'
|
||||
const accrued = '35585162410681240'
|
||||
await utils.increaseTime(10)
|
||||
const owed = await Subscription.methods.getAmountOwed(
|
||||
returnValues.agreementId
|
||||
).call({from: receiver})
|
||||
assert.equal(owed, accured, 'Owned amount returned not equal to expected')
|
||||
assert.equal(owed, accrued, 'Owned amount returned not equal to expected')
|
||||
});
|
||||
|
||||
it('should allow a payor to supply token', async function() {
|
||||
const amount = toWei('100000')
|
||||
const supply = await Subscription.methods.supply(
|
||||
toWei('100000')
|
||||
amount
|
||||
).send({ from: payor })
|
||||
console.log({supply})
|
||||
const returned = supply.events.SupplyReceived.returnValues
|
||||
assert.equal(amount, returned.amount, 'returned amount does not match')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue