Skip to content

Commit

Permalink
test: construction derive validation for staking key size
Browse files Browse the repository at this point in the history
Refs #198
  • Loading branch information
tomasBustamante committed Nov 6, 2020
1 parent c0e058c commit 0d14712
Showing 1 changed file with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -213,4 +213,28 @@ describe(CONSTRUCTION_DERIVE_ENDPOINT, () => {
expect(response.statusCode).toEqual(StatusCodes.OK);
expect(response.json().address).toEqual('addr1uxnjdq7ma0kqsmrny460fu5azvnqtap3486jvaudacuam3ghuwnnw');
});

test('Should return an error when the staking key has a lower length than 32', async () => {
const response = await server.inject({
method: 'post',
url: CONSTRUCTION_DERIVE_ENDPOINT,
payload: generatePayload({ blockchain: 'cardano', network: 'mainnet', stakingKey: 'smallPublicKey' })
});
expect(response.statusCode).toEqual(StatusCodes.INTERNAL_SERVER_ERROR);
expect(response.json()).toEqual({ code: 4007, message: INVALID_PUBLIC_KEY_FORMAT, retriable: false });
});

test('Should return an error when the staking key has a bigger length than 32', async () => {
const response = await server.inject({
method: 'post',
url: CONSTRUCTION_DERIVE_ENDPOINT,
payload: generatePayload({
blockchain: 'cardano',
network: 'mainnet',
stakingKey: 'ThisIsABiggerPublicKeyForTestingPurposesThisIsABiggerPublicKeyForTestingPurposes'
})
});
expect(response.statusCode).toEqual(StatusCodes.INTERNAL_SERVER_ERROR);
expect(response.json()).toEqual({ code: 4007, message: INVALID_PUBLIC_KEY_FORMAT, retriable: false });
});
});

0 comments on commit 0d14712

Please sign in to comment.