Skip to content

Commit

Permalink
review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dvush committed May 30, 2020
1 parent 3921401 commit 8e218f1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
26 changes: 13 additions & 13 deletions contracts/test/unit_tests/operations_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,33 +17,33 @@ describe("Operations unit tests", function () {

it("should return true when offchain and onchain Deposit pubdata match", async () => {
let offchain = "0x" +
"01020304" + // accountId -- not matching
"01020304" + // accountId -- not matching
"0102" + // tokenId
"101112131415161718191a1b1c1d1e1f" + // amount
"823B747710C5bC9b8A47243f2c3d1805F1aA00c5"; // owner
"823B747710C5bC9b8A47243f2c3d1805F1aA00c5"; // owner
expect(await testContract.testDepositMatch(offchain)).to.equal(true)
});

it("should return true when padded offchain and packed onchain Deposit pubdata match", async () => {
let offchain = "0x" +
"01020304" + // accountId -- not matching
"0102" + // tokenId
"101112131415161718191a1b1c1d1e1f" + // amount
"01020304" + // accountId -- not matching
"0102" + // tokenId
"101112131415161718191a1b1c1d1e1f" + // amount
"823B747710C5bC9b8A47243f2c3d1805F1aA00c5" + // owner
"000000"; // padding
expect(await testContract.testDepositMatch(offchain)).to.equal(true)
});

it("should return false when offchain and onchain Deposit pubdata don't match", async () => {
let offchain = "0x" +
"01020304" + // accountId
"0000" + // tokenId -- not matching
"101112131415161718191a1b1c1d1e1f" + // amount
"01020304" + // accountId
"0000" + // tokenId -- not matching
"101112131415161718191a1b1c1d1e1f" + // amount
"823B747710C5bC9b8A47243f2c3d1805F1aA00c5"; // owner
expect(await testContract.testDepositMatch(offchain)).to.equal(false)

offchain = "0x" +
"01020304" + // accountId
"01020304" + // accountId
"0102" + // tokenId
"101112131415161718191a1b1c1d1e1f" + // amount
"823B747710C5bC9b8A47243f2c3d1805F1aA0000"; // owner -- last byte not matching
Expand All @@ -58,7 +58,7 @@ describe("Operations unit tests", function () {

it("should return true when offchain and onchain FullExit pubdata match", async () => {
let offchain = "0x" +
"01020304" + // accountId
"01020304" + // accountId
"823B747710C5bC9b8A47243f2c3d1805F1aA00c5" + // owner
"3132" + // tokenId
"101112131415161718191a1b1c1d1e1f"; // amount -- not matching but should be ignored
Expand All @@ -67,7 +67,7 @@ describe("Operations unit tests", function () {

it("should return true when padded offchain and unpadded onchain FullExit pubdata match", async () => {
let offchain = "0x" +
"01020304" + // accountId
"01020304" + // accountId
"823B747710C5bC9b8A47243f2c3d1805F1aA00c5" + // owner
"3132" + // tokenId
"101112131415161718191a1b1c1d1e1f" + // amount -- not matching but should be ignored
Expand All @@ -77,14 +77,14 @@ describe("Operations unit tests", function () {

it("should return false when offchain and onchain FullExit pubdata match", async () => {
let offchain = "0x" +
"00020304" + // accountId -- not matching
"00020304" + // accountId -- not matching
"823B747710C5bC9b8A47243f2c3d1805F1aA00c5" + // owner
"3132" + // tokenId
"101112131415161718191a1b1c1d1e1f"; // amount -- not matching but should be ignored
expect(await testContract.testFullExitMatch(offchain)).to.equal(false)

offchain = "0x" +
"00020304" + // accountId -- not matching
"00020304" + // accountId -- not matching
"823B747710C5bC9b8A47243f2c3d1805F1aA00c5" + // owner
"3132" + // tokenId
"101112131415161718191a1b1c1d1e00"; // amount -- not matching but should be ignored
Expand Down
2 changes: 1 addition & 1 deletion contracts/test/unit_tests/zksync_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ describe("zkSync test process next operation", function() {
let offset = 1;
pubdata.writeUInt32BE(0xccaabbff, offset);
offset += 4;
// token = 0
pubdata.writeUInt16BE(0, offset); // token
offset += 2;
Buffer.from(depositAmount.toHexString().substr(2).padStart(16 * 2, "0"), "hex").copy(pubdata, offset);
offset += 16;
Expand Down
2 changes: 1 addition & 1 deletion docs/protocol.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ This includes, in particular, the following claims:

|Type|Byte len|Encoding|Comment|
|--|--|--|--|
|AccountId|4|BE integer|Incremented number of accounts in Rollup. New account will have the next free id. Max value is 2^32 = 4.294967296 × 10^9|
|AccountId|4|BE integer|Incremented number of accounts in Rollup. New account will have the next free id. Max value is 2^32 - 1 = 4.294967295 × 10^9|
|TokenId|2|BE integer|Incremented number of tokens in Rollup, max value is 65535|
|PackedTxAmount|5|[Parameters](#amount-packing)|Packed transactions amounts are represented with 40 bit (5 byte) values, encoded as mantissa * 10^exponent where mantissa is represented with 35 bits, exponent is represented with 5 bits. This gives a range from 0 to 34359738368 * 10^31, providing 10 full decimal digit precision.|
|PackedFee|2|[Parameters](#amount-packing)|Packed fees must be represented with 2 bytes: 5 bit for exponent, 11 bit for mantissa.|
Expand Down

0 comments on commit 8e218f1

Please sign in to comment.