Skip to content

Commit

Permalink
Transcoder needs non-zero bonded stake
Browse files Browse the repository at this point in the history
  • Loading branch information
yondonfu committed Jan 23, 2018
1 parent bb1d8e0 commit dd0c9d4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
4 changes: 2 additions & 2 deletions contracts/bonding/BondingManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,8 @@ contract BondingManager is ManagerProxyTarget, IBondingManager {

Delegator storage del = delegators[msg.sender];

// Must be bonded to self
require(del.delegateAddress == msg.sender);
// Must have a non-zero amount bonded to self
require(del.delegateAddress == msg.sender && del.bondedAmount > 0);

Transcoder storage t = transcoders[msg.sender];
t.pendingBlockRewardCut = _blockRewardCut;
Expand Down
1 change: 0 additions & 1 deletion contracts/jobs/JobsManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,6 @@ contract JobsManager is ManagerProxyTarget, IVerifiable, IJobsManager {
// Sender must be elected transcoder
require(job.transcoderAddress == msg.sender);

uint256 blockNum = roundsManager().blockNum();
uint256 challengeBlock = claim.claimBlock + 1;
// Segment must be eligible for verification
// roundsManager().blockHash() ensures that the challenge block is within the last 256 blocks from the current block
Expand Down
11 changes: 7 additions & 4 deletions test/unit/BondingManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,6 @@ contract("BondingManager", accounts => {
await expectThrow(bondingManager.transcoder(blockRewardCut, feeShare, pricePerSegment), {from: tAddr})
})

it("should fail with zero delegated amount", async () => {
await expectThrow(bondingManager.transcoder(blockRewardCut, feeShare, pricePerSegment), {from: tAddr})
})

it("should fail if transcoder is not bonded to self", async () => {
await fixture.token.setApproved(true)
await bondingManager.bond(2000, tAddr, {from: accounts[2]})
Expand All @@ -69,6 +65,13 @@ contract("BondingManager", accounts => {
await expectThrow(bondingManager.transcoder(blockRewardCut, feeShare, pricePerSegment), {from: tAddr})
})

it("should fail if transcoder does not have a non-zero amount bonded to self", async () => {
await bondingManager.bond(0, tAddr, {from: tAddr})

// Fails because transcoder is delegated to self but has zero bonded stake
await expectThrow(bondingManager.transcoder(blockRewardCut, feeShare, pricePerSegment), {from: tAddr})
})

it("should fail if blockRewardCut is an invalid percentage", async () => {
const invalidBlockRewardCut = 101 * PERC_MULTIPLIER
await expectThrow(bondingManager.transcoder(invalidBlockRewardCut, feeShare, pricePerSegment, {from: tAddr}))
Expand Down

0 comments on commit dd0c9d4

Please sign in to comment.