aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Hysen <greg.hysen@gmail.com>2018-11-08 03:39:48 +0800
committerGreg Hysen <greg.hysen@gmail.com>2018-11-29 08:38:10 +0800
commitcef254fa8cacdcba37ec41dec574566b9249b84c (patch)
tree695c1347db21d6fc467d03882880d1ec08f20258
parente2b115a15c4745494043697130e7d1980cde05f4 (diff)
downloaddexon-sol-tools-cef254fa8cacdcba37ec41dec574566b9249b84c.tar
dexon-sol-tools-cef254fa8cacdcba37ec41dec574566b9249b84c.tar.gz
dexon-sol-tools-cef254fa8cacdcba37ec41dec574566b9249b84c.tar.bz2
dexon-sol-tools-cef254fa8cacdcba37ec41dec574566b9249b84c.tar.lz
dexon-sol-tools-cef254fa8cacdcba37ec41dec574566b9249b84c.tar.xz
dexon-sol-tools-cef254fa8cacdcba37ec41dec574566b9249b84c.tar.zst
dexon-sol-tools-cef254fa8cacdcba37ec41dec574566b9249b84c.zip
tests for unsigned integer
-rw-r--r--packages/order-utils/test/abi_encoder_test.ts30
1 files changed, 29 insertions, 1 deletions
diff --git a/packages/order-utils/test/abi_encoder_test.ts b/packages/order-utils/test/abi_encoder_test.ts
index f9e28015b..fb149faa1 100644
--- a/packages/order-utils/test/abi_encoder_test.ts
+++ b/packages/order-utils/test/abi_encoder_test.ts
@@ -833,7 +833,7 @@ describe.only('ABI Encoder', () => {
});
});
- describe.only('Integer', () => {
+ describe('Integer', () => {
const testIntDataItem = { name: 'testInt', type: 'int' };
it('Positive - Base case', async () => {
const intDataType = new AbiEncoder.Int(testIntDataItem);
@@ -862,6 +862,34 @@ describe.only('ABI Encoder', () => {
const expectedAbiEncodedInt = '0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffe5e7409f';
expect(intDataType.getHexValue()).to.be.equal(expectedAbiEncodedInt);
});
+
+ // TODO: Add bounds tests + tests for different widths
+ });
+
+ describe('Unsigned Integer', () => {
+ const testIntDataItem = { name: 'testUInt', type: 'uint' };
+ it('Lower Bound', async () => {
+ const uintDataType = new AbiEncoder.UInt(testIntDataItem);
+ uintDataType.assignValue(new BigNumber(0));
+ const expectedAbiEncodedUInt = '0x0000000000000000000000000000000000000000000000000000000000000000';
+ expect(uintDataType.getHexValue()).to.be.equal(expectedAbiEncodedUInt);
+ });
+
+ it('Base Case', async () => {
+ const uintDataType = new AbiEncoder.UInt(testIntDataItem);
+ uintDataType.assignValue(new BigNumber(1));
+ const expectedAbiEncodedUInt = '0x0000000000000000000000000000000000000000000000000000000000000001';
+ expect(uintDataType.getHexValue()).to.be.equal(expectedAbiEncodedUInt);
+ });
+
+ it('Random value', async () => {
+ const uintDataType = new AbiEncoder.UInt(testIntDataItem);
+ uintDataType.assignValue(new BigNumber(437829473));
+ const expectedAbiEncodedUInt = '0x000000000000000000000000000000000000000000000000000000001a18bf61';
+ expect(uintDataType.getHexValue()).to.be.equal(expectedAbiEncodedUInt);
+ });
+
+ // TODO: Add bounds tests + tests for different widths
});
describe('String', () => {