aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--packages/order-utils/test/abi/calldata.ts16
-rw-r--r--packages/order-utils/test/abi/data_type.ts7
-rw-r--r--packages/order-utils/test/abi_encoder_test.ts5
3 files changed, 22 insertions, 6 deletions
diff --git a/packages/order-utils/test/abi/calldata.ts b/packages/order-utils/test/abi/calldata.ts
index aaad332f8..74f0c0924 100644
--- a/packages/order-utils/test/abi/calldata.ts
+++ b/packages/order-utils/test/abi/calldata.ts
@@ -91,10 +91,15 @@ export class DependentCalldataBlock extends CalldataBlock {
public toBuffer(): Buffer {
const dependencyOffset = this.dependency.getOffsetInBytes();
+ console.log("Dependency Offset - ", dependencyOffset);
const parentOffset = this.parent.getOffsetInBytes();
+ console.log("Parent Offset - ", parentOffset);
const parentHeaderSize = this.parent.getHeaderSizeInBytes();
- const pointer = dependencyOffset - parentOffset + parentHeaderSize;
- const pointerBuf = new Buffer(`0x${pointer.toString(16)}`);
+ console.log("Parent Header size - ", parentHeaderSize);
+ const pointer: number = (dependencyOffset - parentOffset) + parentHeaderSize;
+ console.log("DAT PTR = ", pointer);
+ const pointerBuf = ethUtil.toBuffer(`0x${pointer.toString(16)}`);
+ console.log("Chye - ", pointerBuf);
const evmWordWidthInBytes = 32;
const pointerBufPadded = ethUtil.setLengthLeft(pointerBuf, evmWordWidthInBytes);
return pointerBufPadded;
@@ -122,7 +127,7 @@ export class MemberCalldataBlock extends CalldataBlock {
bodySizeInBytes += member.getSizeInBytes();
});
this.members = members;
- this.setBodySize(bodySizeInBytes);
+ this.setBodySize(0);
}
public setHeader(header: Buffer) {
@@ -176,7 +181,9 @@ export class Calldata {
while ((block = blockQueue.pop()) !== undefined) {
console.log(block.getName());
block.setOffset(offset);
+ offset += block.getSizeInBytes();
if (block instanceof DependentCalldataBlock) {
+ console.log(block.getDependency());
blockQueue.push(block.getDependency());
} else if (block instanceof MemberCalldataBlock) {
_.each(block.getMembers(), (member: CalldataBlock) => {
@@ -185,8 +192,11 @@ export class Calldata {
}
}
+ console.log(this.root);
+
// Fetch values using same technique
const valueBufs: Buffer[] = [selectorBuffer];
+ blockQueue.push(this.root);
while ((block = blockQueue.pop()) !== undefined) {
valueBufs.push(block.toBuffer());
diff --git a/packages/order-utils/test/abi/data_type.ts b/packages/order-utils/test/abi/data_type.ts
index be7ae6154..5311ffb81 100644
--- a/packages/order-utils/test/abi/data_type.ts
+++ b/packages/order-utils/test/abi/data_type.ts
@@ -167,12 +167,17 @@ export abstract class MemberDataType extends DataType {
);
}
+ const methodBlock: MemberCalldataBlock = new MemberCalldataBlock(this.getDataItem().name, this.getSignature(), false);
+
let members = this.members;
if (this.isArray && this.arrayLength === undefined) {
[members,] = this.createMembersWithLength(this.getDataItem(), value.length);
+
+ const lenBuf = ethUtil.setLengthLeft(ethUtil.toBuffer(`0x${value.length.toString(16)}`), 32);
+ methodBlock.setHeader(lenBuf);
}
- const methodBlock: MemberCalldataBlock = new MemberCalldataBlock(this.getDataItem().name, this.getSignature(), false);
+
const memberBlocks: CalldataBlock[] = [];
_.each(members, (member: DataType, idx: number) => {
const block = member.generateCalldataBlock(value[idx], methodBlock);
diff --git a/packages/order-utils/test/abi_encoder_test.ts b/packages/order-utils/test/abi_encoder_test.ts
index 0455169a3..e600542b8 100644
--- a/packages/order-utils/test/abi_encoder_test.ts
+++ b/packages/order-utils/test/abi_encoder_test.ts
@@ -116,7 +116,7 @@ describe.only('ABI Encoder', () => {
});
- it.skip('Types with default widths', async () => {
+ it('Types with default widths', async () => {
const method = new AbiEncoder.Method(AbiSamples.typesWithDefaultWidthsAbi);
console.log(method);
const args = [new BigNumber(1), new BigNumber(-1), '0x56', [new BigNumber(1)], [new BigNumber(-1)], ['0x56']];
@@ -303,7 +303,7 @@ describe.only('ABI Encoder', () => {
});
- it('Fixed Length Array / Static Members ABI', async () => {
+ it.only('Fixed Length Array / Static Members ABI', async () => {
const method = new AbiEncoder.Method(AbiSamples.staticArrayAbi);
const args = [[new BigNumber(127), new BigNumber(14), new BigNumber(54)]];
const calldata = method.encode(args);
@@ -338,6 +338,7 @@ describe.only('ABI Encoder', () => {
it('Array ABI', async () => {
const method = new AbiEncoder.Method(AbiSamples.stringAbi);
+ console.log(method);
const calldata = method.encode([['five', 'six', 'seven']]);
console.log(method.getSignature());
console.log(method.selector);