Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Era not supported -invalid output address handle test #394

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import { cardanoCliMock, setupOfflineDatabase, setupServer } from '../utils/test
import { ErrorFactory, Errors } from '../../../src/server/utils/errors';
import {
CONSTRUCTION_SIGNED_TRANSACTION_WITH_EXTRA_DATA,
CONSTRUCTION_SIGNED_TRANSACTION_WITH_EXTRA_DATA_INVALID_TTL
CONSTRUCTION_SIGNED_TRANSACTION_WITH_EXTRA_DATA_INVALID_TTL,
CONSTRUCTION_SIGNED_TRANSACTION_WITH_EXTRA_DATA_INVALID_STAKE_OUTPUT_ADDR
} from '../fixture-data';

const CONSTRUCTION_SUBMIT_ENDPOINT = '/construction/submit';
Expand Down Expand Up @@ -132,4 +133,18 @@ describe(CONSTRUCTION_SUBMIT_ENDPOINT, () => {
retriable: false
});
});

it('Should return a valid error when output adresss is a stake one', async () => {
const response = await server.inject({
method: 'post',
url: CONSTRUCTION_SUBMIT_ENDPOINT,
payload: generatePayloadWithSignedTransaction(
'cardano',
'mainnet',
CONSTRUCTION_SIGNED_TRANSACTION_WITH_EXTRA_DATA_INVALID_STAKE_OUTPUT_ADDR
)
});

expect(response.statusCode).toEqual(StatusCodes.INTERNAL_SERVER_ERROR);
});
});
85 changes: 85 additions & 0 deletions cardano-rosetta-server/test/e2e/fixture-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1462,6 +1462,87 @@ export const CONSTRUCTION_PAYLOADS_REQUEST_INVALID_TTL: Components.Schemas.Const
}
};

export const CONSTRUCTION_PAYLOADS_REQUEST_INVALID_STAKE_OUTPUT_ADDR: Components.Schemas.ConstructionPayloadsRequest = {
network_identifier: {
blockchain: 'cardano',
network: 'mainnet'
},
operations: [
{
operation_identifier: {
index: 0,
network_index: 0
},
type: OperationType.INPUT,
status: 'success',
account: {
address: 'addr1vxa5pudxg77g3sdaddecmw8tvc6hmynywn49lltt4fmvn7cpnkcpx'
},
amount: {
value: '-90000',
currency: {
symbol: 'ADA',
decimals: 6
}
},
coin_change: {
coin_identifier: {
// eslint-disable-next-line sonarjs/no-duplicate-string
identifier: '2f23fd8cca835af21f3ac375bac601f97ead75f2e79143bdf71fe2c4be043e8f:1'
},
coin_action: 'coin_spent'
}
},
{
operation_identifier: {
index: 1
},
related_operations: [
{
index: 0
}
],
type: OperationType.OUTPUT,
status: 'success',
account: {
address: 'stake1u999hv7g20rgvy6uh7l6cdz6s4csdzvmx8cp990gdd3v4xsrfs242'
},
amount: {
value: '10000',
currency: {
symbol: 'ADA',
decimals: 6
}
}
},
{
operation_identifier: {
index: 2
},
related_operations: [
{
index: 0
}
],
type: OperationType.OUTPUT,
status: 'success',
account: {
address: 'addr1vxa5pudxg77g3sdaddecmw8tvc6hmynywn49lltt4fmvn7cpnkcpx'
},
amount: {
value: '40000',
currency: {
symbol: 'ADA',
decimals: 6
}
}
}
],
metadata: {
ttl: '1'
}
};

export const CONSTRUCTION_PAYLOADS_REQUEST_WITH_BYRON_INPUT: Components.Schemas.ConstructionPayloadsRequest = {
network_identifier: {
blockchain: 'cardano',
Expand Down Expand Up @@ -4847,6 +4928,10 @@ export const CONSTRUCTION_SIGNED_TRANSACTION_WITH_EXTRA_DATA_INVALID_TTL = cbor
.encode([SIGNED_TRANSACTION, constructionExtraData(CONSTRUCTION_PAYLOADS_REQUEST_INVALID_TTL)])
.toString('hex');

export const CONSTRUCTION_SIGNED_TRANSACTION_WITH_EXTRA_DATA_INVALID_STAKE_OUTPUT_ADDR = cbor
.encode([SIGNED_TRANSACTION, constructionExtraData(CONSTRUCTION_PAYLOADS_REQUEST_INVALID_STAKE_OUTPUT_ADDR)])
.toString('hex');

export const CONSTRUCTION_SIGNED_TX_WITH_POOL_REGISTRATION_AND_PLEDGE = cbor
.encode([
SIGNED_TX_WITH_POOL_REGISTRATION_AND_PLEDGE,
Expand Down