Skip to content

Commit 124807b

Browse files
committed
add test
1 parent f4aba8c commit 124807b

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

packages/api/tests/construction/combine.test.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,37 @@ describe('/construction/combine', () => {
7676
assert.ok(body.signed_transaction.length >= unsignedTx.length);
7777
});
7878

79+
test('combines unsigned transaction when signing payload address is omitted', async () => {
80+
// Sign the sighash offline
81+
const signature = addHexPrefix(signWithKey(SENDER_PRIVATE_KEY, removeHexPrefix(sighash)));
82+
83+
const res = await post(fastify, '/construction/combine', {
84+
network_identifier: NETWORK_IDENTIFIER,
85+
unsigned_transaction: unsignedTx,
86+
signatures: [
87+
{
88+
signing_payload: {
89+
hex_bytes: sighash,
90+
account_identifier: {
91+
address: senderAddress,
92+
},
93+
signature_type: 'ecdsa_recovery',
94+
},
95+
public_key: {
96+
hex_bytes: senderPublicKey,
97+
curve_type: 'secp256k1',
98+
},
99+
signature_type: 'ecdsa_recovery',
100+
hex_bytes: signature,
101+
},
102+
],
103+
});
104+
assert.equal(res.statusCode, 200);
105+
const body = JSON.parse(res.body);
106+
assert.ok(body.signed_transaction);
107+
assert.ok(body.signed_transaction.length >= unsignedTx.length);
108+
});
109+
79110
test('rejects when no signatures are provided', async () => {
80111
const res = await post(fastify, '/construction/combine', {
81112
network_identifier: NETWORK_IDENTIFIER,

0 commit comments

Comments
 (0)