Skip to content

Commit fdea37f

Browse files
test: fix serializer tests
1 parent 41cf6ee commit fdea37f

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

__tests__/nano_contracts/serializer.test.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -50,20 +50,20 @@ test('List', () => {
5050

5151
test('Optional', () => {
5252
const serializer = new Serializer();
53-
expect(serializer.fromOptional(true, undefined, 'int').equals(Buffer.from([0x00]))).toBe(true);
54-
expect(serializer.fromOptional(false, 300, 'int').equals(Buffer.from([0x01, 0x00, 0x00, 0x01, 0x2c]))).toBe(true);
53+
expect(serializer.fromOptional(null, 'int').equals(Buffer.from([0x00]))).toBe(true);
54+
expect(serializer.fromOptional(300, 'int').equals(Buffer.from([0x01, 0x00, 0x00, 0x01, 0x2c]))).toBe(true);
5555

56-
expect(serializer.fromOptional(true, undefined, 'bool').equals(Buffer.from([0x00]))).toBe(true);
57-
expect(serializer.fromOptional(false, true, 'bool').equals(Buffer.from([0x01, 0x01]))).toBe(true);
56+
expect(serializer.fromOptional(null, 'bool').equals(Buffer.from([0x00]))).toBe(true);
57+
expect(serializer.fromOptional(true, 'bool').equals(Buffer.from([0x01, 0x01]))).toBe(true);
5858

59-
expect(serializer.fromOptional(true, undefined, 'str').equals(Buffer.from([0x00]))).toBe(true);
60-
expect(serializer.fromOptional(false, 'test', 'str').equals(Buffer.from([0x01, 0x74, 0x65, 0x73, 0x74]))).toBe(true);
59+
expect(serializer.fromOptional(null, 'str').equals(Buffer.from([0x00]))).toBe(true);
60+
expect(serializer.fromOptional('test', 'str').equals(Buffer.from([0x01, 0x74, 0x65, 0x73, 0x74]))).toBe(true);
6161

62-
expect(serializer.fromOptional(true, undefined, 'bytes').equals(Buffer.from([0x00]))).toBe(true);
63-
expect(serializer.fromOptional(false, [0x74, 0x65, 0x73, 0x74], 'bytes').equals(Buffer.from([0x01, 0x74, 0x65, 0x73, 0x74]))).toBe(true);
62+
expect(serializer.fromOptional(null, 'bytes').equals(Buffer.from([0x00]))).toBe(true);
63+
expect(serializer.fromOptional([0x74, 0x65, 0x73, 0x74], 'bytes').equals(Buffer.from([0x01, 0x74, 0x65, 0x73, 0x74]))).toBe(true);
6464

65-
expect(serializer.fromOptional(true, undefined, 'float').equals(Buffer.from([0x00]))).toBe(true);
66-
expect(serializer.fromOptional(false, 10.32134, 'float').equals(Buffer.from([0x01, 0x40, 0x24, 0xa4, 0x86, 0xad, 0x2d, 0xcb, 0x14]))).toBe(true);
65+
expect(serializer.fromOptional(null, 'float').equals(Buffer.from([0x00]))).toBe(true);
66+
expect(serializer.fromOptional(10.32134, 'float').equals(Buffer.from([0x01, 0x40, 0x24, 0xa4, 0x86, 0xad, 0x2d, 0xcb, 0x14]))).toBe(true);
6767
})
6868

6969
test('Signed', () => {

0 commit comments

Comments
 (0)