Ensure large >U32 is encoded as hex (#641)
* Ensure large >U32 is enocoded as hex * Update U64 test compares to hex * Update subscribe.spec.ts
This commit is contained in:
@@ -39,7 +39,7 @@ describe('subscribe', () => {
|
||||
|
||||
it('calls back with new headers', (done) => {
|
||||
return mock.subscribe('chain_newHead', 'chain_subscribeNewHead', (_: any, header: any) => {
|
||||
if (header.number === 4) {
|
||||
if (header.number === '0x0000000000000004') {
|
||||
done();
|
||||
}
|
||||
});
|
||||
@@ -55,7 +55,7 @@ describe('subscribe', () => {
|
||||
throw new Error('testing');
|
||||
}
|
||||
|
||||
if (header.number === 3) {
|
||||
if (header.number === '0x0000000000000003') {
|
||||
done();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -15,7 +15,7 @@ describe('Digest', () => {
|
||||
|
||||
expect(log.type).toBe('Seal');
|
||||
expect(log.value.toJSON()).toEqual([
|
||||
256804359,
|
||||
'0x000000000f4e8607',
|
||||
'0x2c0e0ee8a5d1a073da3f8db002b8eaebcd7b1a7eb25662e09f9ef0ac58d96bf17896256cd5f0bc672f96aab49fe5163ca5cb4c1a0f047dc39e89cd4a9eb2ea05'
|
||||
]);
|
||||
});
|
||||
|
||||
@@ -13,6 +13,6 @@ import Int from './codec/Int';
|
||||
*/
|
||||
export default class I128 extends Int {
|
||||
constructor (value?: AnyNumber) {
|
||||
super(value, 128, false);
|
||||
super(value, 128, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,6 @@ import Int from './codec/Int';
|
||||
*/
|
||||
export default class I256 extends Int {
|
||||
constructor (value?: AnyNumber) {
|
||||
super(value, 256, false);
|
||||
super(value, 256, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,6 @@ import Int from './codec/Int';
|
||||
*/
|
||||
export default class I64 extends Int {
|
||||
constructor (value?: AnyNumber) {
|
||||
super(value, 64, false);
|
||||
super(value, 64, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,6 @@ import UInt from './codec/UInt';
|
||||
*/
|
||||
export default class U128 extends UInt {
|
||||
constructor (value?: AnyNumber) {
|
||||
super(value, 128);
|
||||
super(value, 128, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,6 @@ import UInt from './codec/UInt';
|
||||
*/
|
||||
export default class U256 extends UInt {
|
||||
constructor (value?: AnyNumber) {
|
||||
super(value, 256);
|
||||
super(value, 256, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,6 @@ import UInt from './codec/UInt';
|
||||
*/
|
||||
export default class U64 extends UInt {
|
||||
constructor (value?: AnyNumber) {
|
||||
super(value, 64, false);
|
||||
super(value, 64, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,9 @@
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { CodecTo } from '../types';
|
||||
import Option from './Option';
|
||||
import Struct from './Struct';
|
||||
import BlockNumber from '../BlockNumber';
|
||||
import Text from '../Text';
|
||||
import U32 from '../U32';
|
||||
import Vector from './Vector';
|
||||
@@ -172,4 +174,13 @@ describe('Struct', () => {
|
||||
).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
it('allows toString with large numbers', () => {
|
||||
// replicate https://github.com/polkadot-js/api/issues/640
|
||||
expect(
|
||||
new Struct({
|
||||
blockNumber: Option.with(BlockNumber)
|
||||
}, { blockNumber: '0x1234567890abcdef' }).toString()
|
||||
).toEqual('{"blockNumber":"0x1234567890abcdef"}');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user