Skip to content

Commit

Permalink
Add contract serialize test
Browse files Browse the repository at this point in the history
  • Loading branch information
dincho committed Sep 28, 2023
1 parent ea3e985 commit b0b6162
Showing 1 changed file with 37 additions and 28 deletions.
65 changes: 37 additions & 28 deletions tests/ChainObjectSerializer.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,36 +178,45 @@ test('Deserialize Light MicroBlock', t => {
)
})

test('Deserialize contract', t => {
const contractData = new Uint8Array([
248, 114, 70, 3, 160, 144, 2, 203, 30, 239, 26, 171,
141, 199, 191, 152, 59, 237, 121, 38, 75, 206, 160, 74,
96, 79, 9, 108, 232, 235, 229, 249, 64, 98, 98, 163,
200, 192, 184, 69, 169, 254, 68, 214, 68, 31, 0, 55,
0, 55, 0, 26, 14, 130, 17, 116, 101, 115, 116, 26,
14, 132, 17, 101, 99, 104, 111, 1, 3, 63, 254, 98,
168, 180, 140, 4, 55, 0, 7, 1, 3, 4, 151, 47,
2, 17, 68, 214, 68, 31, 17, 105, 110, 105, 116, 17,
98, 168, 180, 140, 21, 116, 101, 115, 116, 50, 130, 47,
0, 133, 54, 46, 49, 46, 48, 1
])
const contract = new ChainObject('compiler_sophia', {
vsn: 3n,
sourceHash: '9002cb1eef1aab8dc7bf983bed79264bcea04a604f096ce8ebe5f9406262a3c8',
compilerVersion: '6.1.0',
payable: true,
typeInfo: [],
byteCode: new Uint8Array([
169, 254, 68, 214, 68, 31, 0, 55, 0, 55, 0, 26,
14, 130, 17, 116, 101, 115, 116, 26, 14, 132, 17, 101,
99, 104, 111, 1, 3, 63, 254, 98, 168, 180, 140, 4,
55, 0, 7, 1, 3, 4, 151, 47, 2, 17, 68, 214,
68, 31, 17, 105, 110, 105, 116, 17, 98, 168, 180, 140,
21, 116, 101, 115, 116, 50, 130, 47, 0
])
})

test('Serialize contract', t => {
t.plan(1)

const contractData = new Uint8Array([
248, 114, 70, 3, 160, 144, 2, 203, 30, 239, 26, 171,
141, 199, 191, 152, 59, 237, 121, 38, 75, 206, 160, 74,
96, 79, 9, 108, 232, 235, 229, 249, 64, 98, 98, 163,
200, 192, 184, 69, 169, 254, 68, 214, 68, 31, 0, 55,
0, 55, 0, 26, 14, 130, 17, 116, 101, 115, 116, 26,
14, 132, 17, 101, 99, 104, 111, 1, 3, 63, 254, 98,
168, 180, 140, 4, 55, 0, 7, 1, 3, 4, 151, 47,
2, 17, 68, 214, 68, 31, 17, 105, 110, 105, 116, 17,
98, 168, 180, 140, 21, 116, 101, 115, 116, 50, 130, 47,
0, 133, 54, 46, 49, 46, 48, 1
])
const contract = new ChainObject('compiler_sophia', {
vsn: 3n,
sourceHash: '9002cb1eef1aab8dc7bf983bed79264bcea04a604f096ce8ebe5f9406262a3c8',
compilerVersion: '6.1.0',
payable: true,
typeInfo: [],
byteCode: new Uint8Array([
169, 254, 68, 214, 68, 31, 0, 55, 0, 55, 0, 26,
14, 130, 17, 116, 101, 115, 116, 26, 14, 132, 17, 101,
99, 104, 111, 1, 3, 63, 254, 98, 168, 180, 140, 4,
55, 0, 7, 1, 3, 4, 151, 47, 2, 17, 68, 214,
68, 31, 17, 105, 110, 105, 116, 17, 98, 168, 180, 140,
21, 116, 101, 115, 116, 50, 130, 47, 0
])
})
t.deepEqual(
serializer.serialize(contract),
contractData
)
})

test('Deserialize contract', t => {
t.plan(1)

t.deepEqual(
serializer.deserialize(contractData),
Expand Down

0 comments on commit b0b6162

Please sign in to comment.