Skip to content

Commit

Permalink
fix: do not require position to have output index when encoding a tx …
Browse files Browse the repository at this point in the history
…position value from it
  • Loading branch information
pgebal committed Dec 11, 2019
1 parent f5daf93 commit 2e06d16
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 14 deletions.
1 change: 0 additions & 1 deletion plasma_framework/contracts/src/utils/PosLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ library PosLib {
* @return Position encoded as an integer
*/
function encodePackedTxPos(Position memory pos) internal pure returns (uint256) {
require(pos.outputIndex == 0, "Invalid transaction position");
return pos.blockNum * BLOCK_OFFSET + pos.txIndex * TX_OFFSET;
}

Expand Down
14 changes: 1 addition & 13 deletions plasma_framework/test/src/utils/PosLib.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,21 +55,9 @@ contract('PosLib', () => {

describe('encodePackedTxPos', () => {
it('should encode a tx position', async () => {
const txPos = {
blockNum: this.blockNumber,
txIndex: this.txIndex,
outputIndex: 0,
};
const result = await this.contract.encodePackedTxPos(txPos);
const result = await this.contract.encodePackedTxPos(this.position);
expect(result).to.be.bignumber.equal(new BN(this.txPos));
});

it('should fail when invalid position is provided as argument', async () => {
await expectRevert(
this.contract.encodePackedTxPos(this.position),
'Invalid transaction position',
);
});
});

describe('decode', () => {
Expand Down

0 comments on commit 2e06d16

Please sign in to comment.