Skip to content
This repository was archived by the owner on Jan 18, 2023. It is now read-only.

Conversation

felix2feng
Copy link
Contributor

No description provided.

Copy link
Contributor

@asoong asoong left a comment

Choose a reason for hiding this comment

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

Don't do it works. Be descriptive and separate out test cases

using SafeMath for uint256;
using LibBytes for bytes;

/* ============ Constants ============ */
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: remove empty section headers



/* ============ State Variables ============ */
address public ZERO_EX_EXCHANGE;
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: whitespace

/* ============ Modifiers ============ */


/* ============ Constructor ============ */
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: remove constructor



/* ============ Public Functions ============ */
function exchange(
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: add blank space

// | | order | 160+signatureLength | orderLength | ZeroEx Order |

/*
* Parses the header of
Copy link
Contributor

Choose a reason for hiding this comment

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

header of what?

let subjectOrderData: Bytes32;

beforeEach(async () => {
const zeroExOrderBuffer = bufferZeroExOrder(zeroExOrder);
Copy link
Contributor

Choose a reason for hiding this comment

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

move this setup into test/utils/zeroExExchangeWrapper.ts. give it a descriptive name

let subjectOrderData: Bytes32;

beforeEach(async () => {
const zeroExOrderBuffer = bufferZeroExOrder(zeroExOrder);
Copy link
Contributor

Choose a reason for hiding this comment

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

move this setup into test/utils/zeroExExchangeWrapper.ts. give it a descriptive name

subjectOrderData = bufferArrayToHex(zeroExOrderBuffer);
});

it("works", async () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

I would really like these to be their own test each, but that might be redundant. try a clever grouping: it parses the correct maker data, it parses the correct taker data...

@coveralls
Copy link

coveralls commented Jul 3, 2018

Pull Request Test Coverage Report for Build 402

  • 23 of 23 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 100.0%

Totals Coverage Status
Change from base Build 389: 0.0%
Covered Lines: 205
Relevant Lines: 205

💛 - Coveralls

});

it("should correctly parse the order data header", async () => {
const result = await zeroExExchangeWrapper.parseOrderDataHeader.callAsync(subjectOrderData);
Copy link
Contributor

Choose a reason for hiding this comment

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

Put this in a subject

mstore(add(order, 288), mload(add(orderDataAddr, 288))) // salt
}

order.makerAssetData = _zeroExOrder.slice(320, _makerAssetDataLength.add(320));
Copy link
Contributor

Choose a reason for hiding this comment

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

What's 320? can you make it into a constant?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll add / update a table

});

it("should correctly parse the zeroEx order", async () => {
const result = await zeroExExchangeWrapper.parseZeroExOrderData.callAsync(subjectOrderData);
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like you don't need this result variable. Assign to the expected outputs. Maybe split up parsing the return variables and do the correct expectations after each one. Or better yet, add a separate spec for each.

pure
returns (Order memory)
{

Copy link
Contributor

Choose a reason for hiding this comment

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

nit: whitespace

takerAssetData,
);


Copy link
Contributor

Choose a reason for hiding this comment

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

nit: whitespace

Order memory order;
uint256 orderDataAddr = _zeroExOrder.contentAddress();


Copy link
Contributor

Choose a reason for hiding this comment

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

nit: whitespace

return ethUtil.setLengthLeft(ethUtil.toBuffer(input), 32);
}


Copy link
Contributor

Choose a reason for hiding this comment

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

nit: whitespace

let makerAssetDataLength: BigNumber;
let takerAssetDataLength: BigNumber;


Copy link
Contributor

Choose a reason for hiding this comment

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

nit: whitespace

@felix2feng felix2feng merged commit 0f99aaa into master Jul 3, 2018
@felix2feng felix2feng deleted the felix/0x-exchange-wrapper-4 branch July 3, 2018 21:01
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants