Skip to content
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

Merged
merged 41 commits into from
Feb 27, 2018

Conversation

saturnial
Copy link
Contributor

No description provided.

Copy link
Contributor

@nadavhollander nadavhollander left a 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(
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it 👍

Copy link
Contributor

@nadavhollander nadavhollander left a 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);
Copy link
Contributor

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(
Copy link
Contributor

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 =
Copy link
Contributor

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),
Copy link
Contributor

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 () => {
Copy link
Contributor

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

Copy link
Contributor

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

@nadavhollander nadavhollander merged commit 5b1f136 into collateral Feb 27, 2018
@nadavhollander nadavhollander deleted the collateral-tests branch February 27, 2018 10:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants