Skip to content

Commit dbb40cf

Browse files
committed
chore: linter changes
1 parent d560690 commit dbb40cf

File tree

9 files changed

+231
-129
lines changed

9 files changed

+231
-129
lines changed

__tests__/nano_contracts/deserializer.test.ts

Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,9 @@ test('SignedData', () => {
235235

236236
expect((deserializedBytes as NanoContractSignedData).type).toEqual(valueBytes.type);
237237
// @ts-expect-error: toMatchBuffer is defined in our setupTests.js so the type check fails.
238-
expect((deserializedBytes as NanoContractSignedData).signature).toMatchBuffer(valueBytes.signature);
238+
expect((deserializedBytes as NanoContractSignedData).signature).toMatchBuffer(
239+
valueBytes.signature
240+
);
239241
// @ts-expect-error: toMatchBuffer is defined in our setupTests.js so the type check fails.
240242
expect((deserializedBytes as NanoContractSignedData).value[0]).toMatchBuffer(valueBytes.value[0]);
241243
// @ts-expect-error: toMatchBuffer is defined in our setupTests.js so the type check fails.
@@ -254,10 +256,16 @@ test('SignedData', () => {
254256

255257
expect((deserializedBoolFalse as NanoContractSignedData).type).toEqual(valueBoolFalse.type);
256258
// @ts-expect-error: toMatchBuffer is defined in our setupTests.js so the type check fails.
257-
expect((deserializedBoolFalse as NanoContractSignedData).signature).toMatchBuffer(valueBoolFalse.signature);
259+
expect((deserializedBoolFalse as NanoContractSignedData).signature).toMatchBuffer(
260+
valueBoolFalse.signature
261+
);
258262
// @ts-expect-error: toMatchBuffer is defined in our setupTests.js so the type check fails.
259-
expect((deserializedBoolFalse as NanoContractSignedData).value[0]).toMatchBuffer(valueBoolFalse.value[0]);
260-
expect((deserializedBoolFalse as NanoContractSignedData).value[1]).toEqual(valueBoolFalse.value[1]);
263+
expect((deserializedBoolFalse as NanoContractSignedData).value[0]).toMatchBuffer(
264+
valueBoolFalse.value[0]
265+
);
266+
expect((deserializedBoolFalse as NanoContractSignedData).value[1]).toEqual(
267+
valueBoolFalse.value[1]
268+
);
261269

262270
const valueBoolTrue: NanoContractSignedData = {
263271
type: 'bool',
@@ -272,9 +280,13 @@ test('SignedData', () => {
272280

273281
expect((deserializedBoolTrue as NanoContractSignedData).type).toEqual(valueBoolTrue.type);
274282
// @ts-expect-error: toMatchBuffer is defined in our setupTests.js so the type check fails.
275-
expect((deserializedBoolTrue as NanoContractSignedData).signature).toMatchBuffer(valueBoolTrue.signature);
283+
expect((deserializedBoolTrue as NanoContractSignedData).signature).toMatchBuffer(
284+
valueBoolTrue.signature
285+
);
276286
// @ts-expect-error: toMatchBuffer is defined in our setupTests.js so the type check fails.
277-
expect((deserializedBoolTrue as NanoContractSignedData).value[0]).toMatchBuffer(valueBoolTrue.value[0]);
287+
expect((deserializedBoolTrue as NanoContractSignedData).value[0]).toMatchBuffer(
288+
valueBoolTrue.value[0]
289+
);
278290
expect((deserializedBoolTrue as NanoContractSignedData).value[1]).toEqual(valueBoolTrue.value[1]);
279291

280292
const valueVarInt: NanoContractSignedData = {
@@ -290,9 +302,13 @@ test('SignedData', () => {
290302

291303
expect((deserializedVarInt as NanoContractSignedData).type).toEqual(valueVarInt.type);
292304
// @ts-expect-error: toMatchBuffer is defined in our setupTests.js so the type check fails.
293-
expect((deserializedVarInt as NanoContractSignedData).signature).toMatchBuffer(valueVarInt.signature);
305+
expect((deserializedVarInt as NanoContractSignedData).signature).toMatchBuffer(
306+
valueVarInt.signature
307+
);
294308
// @ts-expect-error: toMatchBuffer is defined in our setupTests.js so the type check fails.
295-
expect((deserializedVarInt as NanoContractSignedData).value[0]).toMatchBuffer(valueVarInt.value[0]);
309+
expect((deserializedVarInt as NanoContractSignedData).value[0]).toMatchBuffer(
310+
valueVarInt.value[0]
311+
);
296312
expect((deserializedVarInt as NanoContractSignedData).value[1]).toEqual(valueVarInt.value[1]);
297313
});
298314

@@ -305,19 +321,22 @@ test('Address', () => {
305321

306322
const { value: deserialized } = deserializer.deserializeFromType(
307323
Buffer.concat([leb128.encodeUnsigned(addressBuffer.length), addressBuffer]),
308-
'Address');
324+
'Address'
325+
);
309326
expect(deserialized).toBe(address);
310327

311328
const wrongNetworkAddress = 'HDeadDeadDeadDeadDeadDeadDeagTPgmn';
312329
const wrongNetworkAddressBuffer = new Address(wrongNetworkAddress).decode();
313330

314-
expect(() => deserializer.deserializeFromType(
315-
Buffer.concat([
316-
leb128.encodeUnsigned(wrongNetworkAddressBuffer.length),
317-
wrongNetworkAddressBuffer,
318-
]),
319-
'Address',
320-
)).toThrow();
331+
expect(() =>
332+
deserializer.deserializeFromType(
333+
Buffer.concat([
334+
leb128.encodeUnsigned(wrongNetworkAddressBuffer.length),
335+
wrongNetworkAddressBuffer,
336+
]),
337+
'Address'
338+
)
339+
).toThrow();
321340
});
322341

323342
test('VarInt', () => {

__tests__/nano_contracts/methodArg.test.ts

Lines changed: 77 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,118 +5,166 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
import { NanoContractMethodArgument } from "../../src/nano_contracts/methodArg";
9-
import { NanoContractSignedData } from "../../src/nano_contracts/types";
8+
import { NanoContractMethodArgument } from '../../src/nano_contracts/methodArg';
9+
import { NanoContractSignedData } from '../../src/nano_contracts/types';
1010

1111
describe('fromApiInput', () => {
1212
it('should read SignedData[int]', () => {
13-
const arg = NanoContractMethodArgument.fromApiInput('a-test', 'SignedData[int]', '74657374,6e634944,300,int')
13+
const arg = NanoContractMethodArgument.fromApiInput(
14+
'a-test',
15+
'SignedData[int]',
16+
'74657374,6e634944,300,int'
17+
);
1418
expect(arg).toMatchObject({
1519
name: 'a-test',
1620
type: 'SignedData[int]',
1721
value: {
1822
type: 'int',
1923
signature: expect.anything(),
2024
value: expect.anything(),
21-
}
25+
},
2226
});
2327
// @ts-expect-error: toMatchBuffer is defined in our setupTests.js so the type check fails.
24-
expect((arg.value as NanoContractSignedData).signature).toMatchBuffer(Buffer.from([0x74, 0x65, 0x73, 0x74]));
28+
expect((arg.value as NanoContractSignedData).signature).toMatchBuffer(
29+
Buffer.from([0x74, 0x65, 0x73, 0x74])
30+
);
2531
// @ts-expect-error: toMatchBuffer is defined in our setupTests.js so the type check fails.
26-
expect((arg.value as NanoContractSignedData).value[0]).toMatchBuffer(Buffer.from([0x6e, 0x63, 0x49, 0x44]));
32+
expect((arg.value as NanoContractSignedData).value[0]).toMatchBuffer(
33+
Buffer.from([0x6e, 0x63, 0x49, 0x44])
34+
);
2735
expect((arg.value as NanoContractSignedData).value[1]).toEqual(300);
2836
});
2937

3038
it('should read SignedData[VarInt]', () => {
31-
const arg = NanoContractMethodArgument.fromApiInput('a-test', 'SignedData[VarInt]', '74657374,6e634944,300,VarInt')
39+
const arg = NanoContractMethodArgument.fromApiInput(
40+
'a-test',
41+
'SignedData[VarInt]',
42+
'74657374,6e634944,300,VarInt'
43+
);
3244
expect(arg).toMatchObject({
3345
name: 'a-test',
3446
type: 'SignedData[VarInt]',
3547
value: {
3648
type: 'VarInt',
3749
signature: expect.anything(),
3850
value: expect.anything(),
39-
}
51+
},
4052
});
4153
// @ts-expect-error: toMatchBuffer is defined in our setupTests.js so the type check fails.
42-
expect((arg.value as NanoContractSignedData).signature).toMatchBuffer(Buffer.from([0x74, 0x65, 0x73, 0x74]));
54+
expect((arg.value as NanoContractSignedData).signature).toMatchBuffer(
55+
Buffer.from([0x74, 0x65, 0x73, 0x74])
56+
);
4357
// @ts-expect-error: toMatchBuffer is defined in our setupTests.js so the type check fails.
44-
expect((arg.value as NanoContractSignedData).value[0]).toMatchBuffer(Buffer.from([0x6e, 0x63, 0x49, 0x44]));
58+
expect((arg.value as NanoContractSignedData).value[0]).toMatchBuffer(
59+
Buffer.from([0x6e, 0x63, 0x49, 0x44])
60+
);
4561
expect((arg.value as NanoContractSignedData).value[1]).toEqual(300n);
4662
});
4763

4864
it('should read SignedData[str]', () => {
49-
const arg = NanoContractMethodArgument.fromApiInput('a-test', 'SignedData[str]', '74657374,6e634944,test,str')
65+
const arg = NanoContractMethodArgument.fromApiInput(
66+
'a-test',
67+
'SignedData[str]',
68+
'74657374,6e634944,test,str'
69+
);
5070
expect(arg).toMatchObject({
5171
name: 'a-test',
5272
type: 'SignedData[str]',
5373
value: {
5474
type: 'str',
5575
signature: expect.anything(),
5676
value: expect.anything(),
57-
}
77+
},
5878
});
5979
// @ts-expect-error: toMatchBuffer is defined in our setupTests.js so the type check fails.
60-
expect((arg.value as NanoContractSignedData).signature).toMatchBuffer(Buffer.from([0x74, 0x65, 0x73, 0x74]));
80+
expect((arg.value as NanoContractSignedData).signature).toMatchBuffer(
81+
Buffer.from([0x74, 0x65, 0x73, 0x74])
82+
);
6183
// @ts-expect-error: toMatchBuffer is defined in our setupTests.js so the type check fails.
62-
expect((arg.value as NanoContractSignedData).value[0]).toMatchBuffer(Buffer.from([0x6e, 0x63, 0x49, 0x44]));
84+
expect((arg.value as NanoContractSignedData).value[0]).toMatchBuffer(
85+
Buffer.from([0x6e, 0x63, 0x49, 0x44])
86+
);
6387
expect((arg.value as NanoContractSignedData).value[1]).toEqual('test');
6488
});
6589

6690
it('should read SignedData[bytes]', () => {
67-
const arg = NanoContractMethodArgument.fromApiInput('a-test', 'SignedData[bytes]', '74657374,6e634944,74657374,bytes')
91+
const arg = NanoContractMethodArgument.fromApiInput(
92+
'a-test',
93+
'SignedData[bytes]',
94+
'74657374,6e634944,74657374,bytes'
95+
);
6896
expect(arg).toMatchObject({
6997
name: 'a-test',
7098
type: 'SignedData[bytes]',
7199
value: {
72100
type: 'bytes',
73101
signature: expect.anything(),
74102
value: expect.anything(),
75-
}
103+
},
76104
});
77105
// @ts-expect-error: toMatchBuffer is defined in our setupTests.js so the type check fails.
78-
expect((arg.value as NanoContractSignedData).signature).toMatchBuffer(Buffer.from([0x74, 0x65, 0x73, 0x74]));
106+
expect((arg.value as NanoContractSignedData).signature).toMatchBuffer(
107+
Buffer.from([0x74, 0x65, 0x73, 0x74])
108+
);
79109
// @ts-expect-error: toMatchBuffer is defined in our setupTests.js so the type check fails.
80-
expect((arg.value as NanoContractSignedData).value[0]).toMatchBuffer(Buffer.from([0x6e, 0x63, 0x49, 0x44]));
110+
expect((arg.value as NanoContractSignedData).value[0]).toMatchBuffer(
111+
Buffer.from([0x6e, 0x63, 0x49, 0x44])
112+
);
81113
// @ts-expect-error: toMatchBuffer is defined in our setupTests.js so the type check fails.
82-
expect((arg.value as NanoContractSignedData).value[1]).toMatchBuffer(Buffer.from([0x74, 0x65, 0x73, 0x74]));
114+
expect((arg.value as NanoContractSignedData).value[1]).toMatchBuffer(
115+
Buffer.from([0x74, 0x65, 0x73, 0x74])
116+
);
83117
});
84118

85-
86119
it('should read true SignedData[bool]', () => {
87-
const arg = NanoContractMethodArgument.fromApiInput('a-test', 'SignedData[bool]', '74657374,6e634944,true,bool')
120+
const arg = NanoContractMethodArgument.fromApiInput(
121+
'a-test',
122+
'SignedData[bool]',
123+
'74657374,6e634944,true,bool'
124+
);
88125
expect(arg).toMatchObject({
89126
name: 'a-test',
90127
type: 'SignedData[bool]',
91128
value: {
92129
type: 'bool',
93130
signature: expect.anything(),
94131
value: expect.anything(),
95-
}
132+
},
96133
});
97134
// @ts-expect-error: toMatchBuffer is defined in our setupTests.js so the type check fails.
98-
expect((arg.value as NanoContractSignedData).signature).toMatchBuffer(Buffer.from([0x74, 0x65, 0x73, 0x74]));
135+
expect((arg.value as NanoContractSignedData).signature).toMatchBuffer(
136+
Buffer.from([0x74, 0x65, 0x73, 0x74])
137+
);
99138
// @ts-expect-error: toMatchBuffer is defined in our setupTests.js so the type check fails.
100-
expect((arg.value as NanoContractSignedData).value[0]).toMatchBuffer(Buffer.from([0x6e, 0x63, 0x49, 0x44]));
139+
expect((arg.value as NanoContractSignedData).value[0]).toMatchBuffer(
140+
Buffer.from([0x6e, 0x63, 0x49, 0x44])
141+
);
101142
expect((arg.value as NanoContractSignedData).value[1]).toEqual(true);
102143
});
103144

104-
105145
it('should read false SignedData[bool]', () => {
106-
const arg = NanoContractMethodArgument.fromApiInput('a-test', 'SignedData[bool]', '74657374,6e634944,false,bool')
146+
const arg = NanoContractMethodArgument.fromApiInput(
147+
'a-test',
148+
'SignedData[bool]',
149+
'74657374,6e634944,false,bool'
150+
);
107151
expect(arg).toMatchObject({
108152
name: 'a-test',
109153
type: 'SignedData[bool]',
110154
value: {
111155
type: 'bool',
112156
signature: expect.anything(),
113157
value: expect.anything(),
114-
}
158+
},
115159
});
116160
// @ts-expect-error: toMatchBuffer is defined in our setupTests.js so the type check fails.
117-
expect((arg.value as NanoContractSignedData).signature).toMatchBuffer(Buffer.from([0x74, 0x65, 0x73, 0x74]));
161+
expect((arg.value as NanoContractSignedData).signature).toMatchBuffer(
162+
Buffer.from([0x74, 0x65, 0x73, 0x74])
163+
);
118164
// @ts-expect-error: toMatchBuffer is defined in our setupTests.js so the type check fails.
119-
expect((arg.value as NanoContractSignedData).value[0]).toMatchBuffer(Buffer.from([0x6e, 0x63, 0x49, 0x44]));
165+
expect((arg.value as NanoContractSignedData).value[0]).toMatchBuffer(
166+
Buffer.from([0x6e, 0x63, 0x49, 0x44])
167+
);
120168
expect((arg.value as NanoContractSignedData).value[1]).toEqual(false);
121169
});
122170
});

0 commit comments

Comments
 (0)