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

Feat/eng 382 unbond function #15

Merged
merged 13 commits into from
Jul 19, 2018
Merged

Feat/eng 382 unbond function #15

merged 13 commits into from
Jul 19, 2018

Conversation

gjgd
Copy link
Contributor

@gjgd gjgd commented Jul 18, 2018

@gjgd
Copy link
Contributor Author

gjgd commented Jul 18, 2018

Code coverage decreased because I added an untested require to temporarily prevent Provider to call unbond() until I fully investigate the implications.
It will be removed in an upcoming PR

@gjgd gjgd requested review from eolszewski and OR13 July 18, 2018 22:46
@coveralls
Copy link

Pull Request Test Coverage Report for Build 102

  • 20 of 20 (100.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.7%) to 97.849%

Totals Coverage Status
Change from base Build 103: -0.7%
Covered Lines: 63
Relevant Lines: 63

💛 - Coveralls

@coveralls
Copy link

coveralls commented Jul 18, 2018

Pull Request Test Coverage Report for Build 104

  • 20 of 20 (100.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.7%) to 97.849%

Totals Coverage Status
Change from base Build 103: -0.7%
Covered Lines: 63
Relevant Lines: 63

💛 - Coveralls

// Only Bonded Delegators can call the function
require(delegatorStatus(msg.sender) == DelegatorStatus.Bonded);
// TODO: What if a Provider calls unbond() on himself ?
// Should he resign ?

Choose a reason for hiding this comment

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

That seems reasonable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will do that next PR

require(delegatorStatus(msg.sender) == DelegatorStatus.Bonded);
// TODO: What if a Provider calls unbond() on himself ?
// Should he resign ?
// What about the tokens of the Delegators that bonded to him ?

Choose a reason for hiding this comment

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

Refunded - but who pays the gas cost for that? Him, I suppose.

Copy link
Contributor Author

@gjgd gjgd Jul 19, 2018

Choose a reason for hiding this comment

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

Yeah, but that could potentially be a huge cost in gas.
An alternative would be to let Delegators unbond() by themselves if they received the event that their Provider resigned.

Copy link
Sponsor Member

Choose a reason for hiding this comment

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

How does Livepeer handle this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They resign the Transcoder without refunding the delegators.

const bondedAmount = (await tdpos.delegators(accounts[3]))[1].toNumber();
const newAmount = totalBondedAmount - bondedAmount;
await tdpos.unbond({from: accounts[3]});
assert.equal(newAmount, (await tdpos.providers([accounts[0]]))[5].toNumber());

Choose a reason for hiding this comment

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

Can you annotate what the values associated with [0] and [5] are here?


it('should emit the DelegateUnbonded event', async () => {
const delegator = await tdpos.delegators.call(accounts[5]);
assert.equal(accounts[0], delegator[0]); // [0] is delegateAddress;

Choose a reason for hiding this comment

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

Can we move these annotations to the first place that they are called in the test?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What do you mean ? Isn't it the first place they are called in this test ?

Copy link
Sponsor Member

Choose a reason for hiding this comment

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

A better approach would be to use variables:

let delegateAddress = delegator[0]
let amountBonded = delegator[1]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah yes good idea

await approveBondProvider(22, 10, 1, 25, 1, accounts[0]);
});

it('should return Unbonded if address in not a Delegator', async() => {

Choose a reason for hiding this comment

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

Typo - is*

assert.equal(DELEGATOR_UNBONDED, await tdpos.delegatorStatus(accounts[3]));
});

it('should return Bonded if delegator has called bond()', async() => {

Choose a reason for hiding this comment

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

You capitalized 'Delegator' in all other tests' descriptions, let's keep that consistent.

@gjgd gjgd merged commit 67d9ed9 into master Jul 19, 2018
@gjgd gjgd deleted the feat/ENG-382-unbond-function branch July 19, 2018 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants