-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create DummyCollateralizedContract
for test
#24
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but I would recommend addressing the comment I added -- it will probably make your life easier when you start writing tests.
return true; | ||
} | ||
|
||
function getExpectedRepaymentValue( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You will want to add some sort of ability to programmatically change the returned expectedRepaymentValue
and valueRepaid
-- these values affect logic of whether a collateralized asset can be seized or not, and you'll want to test for that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup. This is just scaffolding. That functionality will come in a future PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Progress looks 👌 so far 🙌. Left a few comments.
// the lockup period must occur at some point in the future. | ||
require(lockupPeriodEndTimestamp > block.timestamp); | ||
|
||
// the agreement cannot be collateralized more than once. | ||
require(collateralForAgreementID[agreementID].lockupPeriod == 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's explicitly document the assumption we're making here -- i.e. that lockupPeriod
will never be 0 for for an agreement that has already been collateralized
return true; | ||
} | ||
|
||
function getExpectedRepaymentValue( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it 👍
mockRegistry.address | ||
); | ||
|
||
const collateralContractWeb3Contract = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add a comment here similar to that found in charta/test/ts/integration/debt_kernel.ts
about why we use this wonky means of instantiating a new contract. I'm creating a pivotal task for us to add a deploy
method to our generated typings.
|
||
// TransferProxy is granted an allowance of 3 ether from PAYER. | ||
await mockToken.mockAllowanceFor.sendTransactionAsync( | ||
PAYER, collateralContract.address, Units.ether(5), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3 ether or 5 ether?
)).to.eventually.be.rejectedWith(REVERT_ERROR); | ||
}); | ||
|
||
it("should throw if the collateral fails to transfer", async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For all 4 of the above invariants, I think it would be better if we changed the collateral contract to "throw" errors using the LogError
pattern we use in DebtKernel
-- given that Solidity doesn't (yet) support throwing with a reason
string. This makes it easier to output human readable errors in UIs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also -- we should add one more invariant to the Collateralized
contract: outputting a LogError
if allowance to the contract is not sufficient to execute transferFrom
…row once collateral is withdrawn
125c5dd
to
0702923
Compare
This reverts commit 47b6c32.
Changes requested during review of Collateral unit tests
Unit test suite for the `Collateralized` abstract interface
No description provided.