diff --git a/ts/wasm/__tests__/detailed/proto-protocol.ts b/ts/wasm/__tests__/detailed/proto-protocol.ts index db74bde543ecc974c3611fc9c88aacce1e95f5b0..c61e166af922a760dac46dbde8d68efca44283b8 100644 --- a/ts/wasm/__tests__/detailed/proto-protocol.ts +++ b/ts/wasm/__tests__/detailed/proto-protocol.ts @@ -33,7 +33,7 @@ test.describe('WASM Proto Protocol', () => { test('Should be able to serialize the transaction', async ({ wasmTest }) => { const retVal = await wasmTest(({ proto_protocol }, transaction) => { - return proto_protocol.cpp_serialize_transaction(transaction); + return proto_protocol.cpp_serialize_transaction(transaction, false); }, protoTx); expect(retVal.exception_message).toHaveLength(0); diff --git a/ts/wasm/__tests__/detailed/protocol.ts b/ts/wasm/__tests__/detailed/protocol.ts index cf2691faad878fc744a17cfd07ec0159dbd8eeee..a638b1231a91d32d10c97b3c5d246ea63283496e 100644 --- a/ts/wasm/__tests__/detailed/protocol.ts +++ b/ts/wasm/__tests__/detailed/protocol.ts @@ -35,7 +35,7 @@ test.describe('WASM Protocol', () => { }); test('Should be able to generate binary metadata information - tx with vote operation', async ({ wasmTest }) => { const retVal = await wasmTest.dynamic(({ protocol }, transaction, parseChildrenFn) => { - const values = protocol.cpp_generate_binary_transaction_metadata(transaction, true); + const values = protocol.cpp_generate_binary_transaction_metadata(transaction, true, false); const parseBinaryChildren = eval(parseChildrenFn); @@ -50,7 +50,7 @@ test.describe('WASM Protocol', () => { }); test('Should be able to generate binary metadata information using hf26 pack type - tx with transfer', async ({ wasmTest }) => { const retVal = await wasmTest.dynamic(({ protocol }, transaction, parseChildrenFn) => { - const values = protocol.cpp_generate_binary_transaction_metadata(transaction, true); + const values = protocol.cpp_generate_binary_transaction_metadata(transaction, true, false); const parseBinaryChildren = eval(parseChildrenFn); @@ -66,7 +66,7 @@ test.describe('WASM Protocol', () => { test('Should be able to generate binary metadata information using legacy pack type - tx with transfer', async ({ wasmTest }) => { const retVal = await wasmTest.dynamic(({ protocol }, transaction, parseChildrenFn) => { - const values = protocol.cpp_generate_binary_transaction_metadata(transaction, false); + const values = protocol.cpp_generate_binary_transaction_metadata(transaction, false, false); const parseBinaryChildren = eval(parseChildrenFn); @@ -168,13 +168,24 @@ test.describe('WASM Protocol', () => { test('Should be able to serialize the transaction', async ({ wasmTest }) => { const retVal = await wasmTest(({ protocol }, transaction) => { - return protocol.cpp_serialize_transaction(transaction); + return protocol.cpp_serialize_transaction(transaction, false); }, transaction); expect(retVal.exception_message).toHaveLength(0); expect(retVal.content).toBe("ff86c404c24b152fb7610100046f746f6d076330666633336108657778686e6a626a98080000"); }); + test('Should be able to serialize the (stripped) transaction', async ({ wasmTest }) => { + const retVal = await wasmTest(({ protocol }, transaction) => { + /// Even transaction is unsigned, we can strip the signature container to preserve original binary form + // of the transaction i.e. specific to calculate its id + return protocol.cpp_serialize_transaction(transaction, true); + }, transaction); + + expect(retVal.exception_message).toHaveLength(0); + expect(retVal.content).toBe("ff86c404c24b152fb7610100046f746f6d076330666633336108657778686e6a626a980800"); + }); + test('Should be able to calculate sig digest of the transaction', async ({ wasmTest }) => { const retVal = await wasmTest(({ protocol }, transaction) => { return protocol.cpp_calculate_sig_digest(transaction, "beeab0de00000000000000000000000000000000000000000000000000000000"); diff --git a/ts/wasm/__tests__/detailed/protocol_benchmarks.ts b/ts/wasm/__tests__/detailed/protocol_benchmarks.ts index ff42b0a5054633a8703b8911da0271d121f165a0..ede49df46fccdb3589ea859ac5292a5757571b21 100644 --- a/ts/wasm/__tests__/detailed/protocol_benchmarks.ts +++ b/ts/wasm/__tests__/detailed/protocol_benchmarks.ts @@ -111,7 +111,7 @@ test.describe('WASM Protocol benchmarks', () => { utilFunctionTest('Serialize transaction', 7_500, () => { for(let i = 0; i < 7_500; ++i) - noDiscard += (protocol.cpp_serialize_transaction(transaction).content as string).length % 10 + i; + noDiscard += (protocol.cpp_serialize_transaction(transaction, false).content as string).length % 10 + i; return noDiscard; });