|
5 | 5 | * LICENSE file in the root directory of this source tree.
|
6 | 6 | */
|
7 | 7 |
|
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'; |
10 | 10 |
|
11 | 11 | describe('fromApiInput', () => {
|
12 | 12 | 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 | + ); |
14 | 18 | expect(arg).toMatchObject({
|
15 | 19 | name: 'a-test',
|
16 | 20 | type: 'SignedData[int]',
|
17 | 21 | value: {
|
18 | 22 | type: 'int',
|
19 | 23 | signature: expect.anything(),
|
20 | 24 | value: expect.anything(),
|
21 |
| - } |
| 25 | + }, |
22 | 26 | });
|
23 | 27 | // @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 | + ); |
25 | 31 | // @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 | + ); |
27 | 35 | expect((arg.value as NanoContractSignedData).value[1]).toEqual(300);
|
28 | 36 | });
|
29 | 37 |
|
30 | 38 | 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 | + ); |
32 | 44 | expect(arg).toMatchObject({
|
33 | 45 | name: 'a-test',
|
34 | 46 | type: 'SignedData[VarInt]',
|
35 | 47 | value: {
|
36 | 48 | type: 'VarInt',
|
37 | 49 | signature: expect.anything(),
|
38 | 50 | value: expect.anything(),
|
39 |
| - } |
| 51 | + }, |
40 | 52 | });
|
41 | 53 | // @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 | + ); |
43 | 57 | // @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 | + ); |
45 | 61 | expect((arg.value as NanoContractSignedData).value[1]).toEqual(300n);
|
46 | 62 | });
|
47 | 63 |
|
48 | 64 | 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 | + ); |
50 | 70 | expect(arg).toMatchObject({
|
51 | 71 | name: 'a-test',
|
52 | 72 | type: 'SignedData[str]',
|
53 | 73 | value: {
|
54 | 74 | type: 'str',
|
55 | 75 | signature: expect.anything(),
|
56 | 76 | value: expect.anything(),
|
57 |
| - } |
| 77 | + }, |
58 | 78 | });
|
59 | 79 | // @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 | + ); |
61 | 83 | // @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 | + ); |
63 | 87 | expect((arg.value as NanoContractSignedData).value[1]).toEqual('test');
|
64 | 88 | });
|
65 | 89 |
|
66 | 90 | 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 | + ); |
68 | 96 | expect(arg).toMatchObject({
|
69 | 97 | name: 'a-test',
|
70 | 98 | type: 'SignedData[bytes]',
|
71 | 99 | value: {
|
72 | 100 | type: 'bytes',
|
73 | 101 | signature: expect.anything(),
|
74 | 102 | value: expect.anything(),
|
75 |
| - } |
| 103 | + }, |
76 | 104 | });
|
77 | 105 | // @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 | + ); |
79 | 109 | // @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 | + ); |
81 | 113 | // @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 | + ); |
83 | 117 | });
|
84 | 118 |
|
85 |
| - |
86 | 119 | 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 | + ); |
88 | 125 | expect(arg).toMatchObject({
|
89 | 126 | name: 'a-test',
|
90 | 127 | type: 'SignedData[bool]',
|
91 | 128 | value: {
|
92 | 129 | type: 'bool',
|
93 | 130 | signature: expect.anything(),
|
94 | 131 | value: expect.anything(),
|
95 |
| - } |
| 132 | + }, |
96 | 133 | });
|
97 | 134 | // @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 | + ); |
99 | 138 | // @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 | + ); |
101 | 142 | expect((arg.value as NanoContractSignedData).value[1]).toEqual(true);
|
102 | 143 | });
|
103 | 144 |
|
104 |
| - |
105 | 145 | 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 | + ); |
107 | 151 | expect(arg).toMatchObject({
|
108 | 152 | name: 'a-test',
|
109 | 153 | type: 'SignedData[bool]',
|
110 | 154 | value: {
|
111 | 155 | type: 'bool',
|
112 | 156 | signature: expect.anything(),
|
113 | 157 | value: expect.anything(),
|
114 |
| - } |
| 158 | + }, |
115 | 159 | });
|
116 | 160 | // @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 | + ); |
118 | 164 | // @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 | + ); |
120 | 168 | expect((arg.value as NanoContractSignedData).value[1]).toEqual(false);
|
121 | 169 | });
|
122 | 170 | });
|
0 commit comments