Skip to content

Commit 63a5037

Browse files
author
andraz maier
committed
feat: update invalid status messages for payment responses and add new test cases
1 parent 2d91392 commit 63a5037

File tree

11 files changed

+152
-15
lines changed

11 files changed

+152
-15
lines changed

src/verification/payment/payment.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ export function responsePayment<T extends TransactionBase<unknown>>(
7575
return { status: AttestationResponseStatus.INVALID };
7676
}
7777

78-
//TODO!!!!!!!!!!!!!!!!!!!
7978
const status = paymentSummary.status;
8079
if (status === PaymentSummaryStatus.Coinbase) {
8180
return { status: AttestationResponseStatus.COINBASE_TRANSACTION };
@@ -94,7 +93,7 @@ export function responsePayment<T extends TransactionBase<unknown>>(
9493
} else if (status === PaymentSummaryStatus.NoIntendedReceiveAmountAddress) {
9594
return { status: AttestationResponseStatus.NO_INTENDED_RECEIVING_ADDRESS };
9695
} else if (status !== PaymentSummaryStatus.Success) {
97-
return { status: AttestationResponseStatus.INVALID };
96+
return { status: AttestationResponseStatus.INVALID_UTXOS };
9897
}
9998

10099
if (!paymentSummary.response) {

src/verification/response-status.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@ export enum AttestationResponseStatus {
1111
// VALID STATUS
1212
VALID = 'VALID',
1313

14-
// TEMPORARY STATUS
15-
// Temporary status during checks
16-
NEEDS_MORE_CHECKS = 'INDETERMINATE: NEEDS_MORE_CHECKS',
17-
1814
// MALFORMED STATUS
1915
MALFORMED = 'MALFORMED ATTESTATION REQUEST',
2016

@@ -27,8 +23,8 @@ export enum AttestationResponseStatus {
2723
BLOCK_AVAILABILITY_ISSUE = 'INVALID: BLOCK DOES NOT EXIST',
2824
TRANSACTION_AVAILABILITY_ISSUE = 'INVALID: TRANSACTION DOES NOT EXIST',
2925
COINBASE_TRANSACTION = 'INVALID: COINBASE TRANSACTION',
30-
INVALID_UTXOS = 'INVALID: INVALID INPUTS OR OUTPUTS OF THE TRANSACTION',
31-
NO_SOURCE_ADDRESS = 'INVALID: NO SOURCE ADDRESS',
26+
INVALID_UTXOS = 'INVALID: INVALID INPUT OR OUTPUT OF THE TRANSACTION',
27+
NO_SOURCE_ADDRESS = 'INVALID: INVALID SOURCE ADDRESS',
3228
NO_INTENDED_SOURCE_ADDRESS = 'INVALID: NO INTENDED SOURCE ADDRESS',
3329
INVALID_ADDRESS_FORMAT = 'INVALID: INVALID ADDRESS FORMAT',
3430
NO_RECEIVING_ADDRESS = 'INVALID: NO RECEIVING ADDRESS',
@@ -48,6 +44,10 @@ export enum AttestationResponseStatus {
4844
UNSUPPORTED_ADDRESS_VERSION = 'INVALID: UNSUPPORTED ADDRESS VERSION',
4945
INVALID_ADDRESS_TYPE = 'INVALID: INVALID ADDRESS TYPE',
5046
INVALID_ADDRESS_PREFIX = 'INVALID: INVALID_ADDRESS_PREFIX',
47+
48+
// TEMPORARY STATUS
49+
// Temporary status during checks
50+
NEEDS_MORE_CHECKS = 'INDETERMINATE: NEEDS_MORE_CHECKS',
5151
}
5252

5353
export interface VerificationResponse<T> {

test/e2e_tests/btc/balance_decreasing_transaction/balance_decreasing_transaction_mic.e2e-spec.ts

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,4 +301,49 @@ describe('/BalanceDecreasingTransaction/mic', () => {
301301
.set('X-API-KEY', '12345')
302302
.expect(400);
303303
});
304+
it('should get invalid - coinbase status', async () => {
305+
const payload = {
306+
attestationType:
307+
'0x42616c616e636544656372656173696e675472616e73616374696f6e00000000',
308+
sourceId:
309+
'0x7465737442544300000000000000000000000000000000000000000000000000',
310+
requestBody: {
311+
transactionId:
312+
'8eafe07f4cefe64ce55482ea6aa1f9a191778f286d57135cae30a4591467bf4d',
313+
sourceAddressIndicator: standardAddressHash(
314+
'mkgR3eqsvDdnVGJcW5Wxo8Cgywg3a5pbkB',
315+
),
316+
},
317+
};
318+
const response = await request(app.getHttpServer())
319+
.post('/BalanceDecreasingTransaction/mic')
320+
.send(payload)
321+
.set('X-API-KEY', '12345')
322+
.expect(200)
323+
.expect('Content-Type', /json/);
324+
325+
expect(response.body.status).to.be.equal('INVALID: COINBASE TRANSACTION');
326+
});
327+
it('should get invalid - invalid source address', async () => {
328+
const payload = {
329+
attestationType:
330+
'0x42616c616e636544656372656173696e675472616e73616374696f6e00000000',
331+
sourceId:
332+
'0x7465737442544300000000000000000000000000000000000000000000000000',
333+
requestBody: {
334+
transactionId:
335+
'7c511c2deeea412ecd77491ed8e6275aacb8c3f9dfc9ce19509781a75f8d3936',
336+
sourceAddressIndicator:
337+
'7c511c2deeea412ecd77491ed8e6275aacb8c3f9dfc9ce19509781a75f8d3936',
338+
},
339+
};
340+
const response = await request(app.getHttpServer())
341+
.post('/BalanceDecreasingTransaction/mic')
342+
.send(payload)
343+
.set('X-API-KEY', '12345')
344+
.expect(200)
345+
.expect('Content-Type', /json/);
346+
347+
expect(response.body.status).to.be.equal('INVALID: INVALID SOURCE ADDRESS');
348+
});
304349
});

test/e2e_tests/btc/payment/payment_mic.e2e-spec.ts

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ describe('/Payment/mic', () => {
4646
.expect(200)
4747
.expect('Content-Type', /json/);
4848

49-
expect(response.body.status).to.be.equal('INVALID');
49+
expect(response.body.status).to.be.equal(
50+
'INVALID: INVALID INPUT OR OUTPUT OF THE TRANSACTION',
51+
);
5052
});
5153
it('should get 400 for negative inUtxo', async () => {
5254
const payload = {
@@ -474,4 +476,27 @@ describe('/Payment/mic', () => {
474476
expect(response.body.status).to.be.equal('VALID');
475477
expect(response.body.messageIntegrityCode.length).to.be.equal(66);
476478
});
479+
it('should get abiEncodedRequest', async () => {
480+
const payload = {
481+
attestationType:
482+
'0x5061796d656e7400000000000000000000000000000000000000000000000000',
483+
sourceId:
484+
'0x7465737442544300000000000000000000000000000000000000000000000000',
485+
requestBody: {
486+
transactionId:
487+
'783c249c9e84ebb91e350d15403a0d741f530b43361ace8042a736242e68fc06',
488+
inUtxo: '0',
489+
utxo: '0',
490+
},
491+
};
492+
const response = await request(app.getHttpServer())
493+
.post('/Payment/mic')
494+
.send(payload)
495+
.set('X-API-KEY', '12345')
496+
.expect(200)
497+
.expect('Content-Type', /json/);
498+
499+
expect(response.body.status).to.be.equal('VALID');
500+
expect(response.body.messageIntegrityCode.length).to.be.equal(66);
501+
});
477502
});

test/e2e_tests/btc/payment/payment_prepare_request.e2e-spec.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ describe('/Payment/prepareRequest', () => {
4545
.expect(200)
4646
.expect('Content-Type', /json/);
4747

48-
expect(response.body.status).to.be.equal('INVALID');
48+
expect(response.body.status).to.be.equal(
49+
'INVALID: INVALID INPUT OR OUTPUT OF THE TRANSACTION',
50+
);
4951
});
5052
it('should get 400 for negative inUtxo', async () => {
5153
const payload = {

test/e2e_tests/btc/payment/payment_prepare_response.e2e-spec.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,9 @@ describe('/Payment/prepareResponse', () => {
101101
.expect(200)
102102
.expect('Content-Type', /json/);
103103

104-
expect(response.body.status).to.be.equal('INVALID');
104+
expect(response.body.status).to.be.equal(
105+
'INVALID: INVALID INPUT OR OUTPUT OF THE TRANSACTION',
106+
);
105107
});
106108
it('should get 400 for negative inUtxo', async () => {
107109
const payload = {

test/e2e_tests/doge/payment/payment_mic.e2e-spec.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ describe('/Payment/mic', () => {
4646
.expect(200)
4747
.expect('Content-Type', /json/);
4848

49-
expect(response.body.status).to.be.equal('INVALID');
49+
expect(response.body.status).to.be.equal(
50+
'INVALID: INVALID INPUT OR OUTPUT OF THE TRANSACTION',
51+
);
5052
});
5153
it('should get 400 for negative inUtxo', async () => {
5254
const payload = {
@@ -108,7 +110,9 @@ describe('/Payment/mic', () => {
108110
.expect(200)
109111
.expect('Content-Type', /json/);
110112

111-
expect(response.body.status).to.be.equal('INVALID');
113+
expect(response.body.status).to.be.equal(
114+
'INVALID: INVALID INPUT OR OUTPUT OF THE TRANSACTION',
115+
);
112116
});
113117
it('should get bad request (400) for empty transactionId', async () => {
114118
const payload = {

test/e2e_tests/doge/payment/payment_prepare_request.e2e-spec.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ describe('/Payment/prepareRequest', () => {
4545
.expect(200)
4646
.expect('Content-Type', /json/);
4747

48-
expect(response.body.status).to.be.equal('INVALID');
48+
expect(response.body.status).to.be.equal(
49+
'INVALID: INVALID INPUT OR OUTPUT OF THE TRANSACTION',
50+
);
4951
});
5052
it('should get 400 for negative inUtxo', async () => {
5153
const payload = {

test/e2e_tests/doge/payment/payment_prepare_response.e2e-spec.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,9 @@ describe('/Payment/prepareResponse', () => {
9898
.expect(200)
9999
.expect('Content-Type', /json/);
100100

101-
expect(response.body.status).to.be.equal('INVALID');
101+
expect(response.body.status).to.be.equal(
102+
'INVALID: INVALID INPUT OR OUTPUT OF THE TRANSACTION',
103+
);
102104
});
103105
it('should get 400 for negative inUtxo', async () => {
104106
const payload = {

test/e2e_tests/xrp/payment/payment_mic.e2e-spec.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,4 +474,28 @@ describe('/Payment/mic', () => {
474474
expect(response.body.status).to.be.equal('VALID');
475475
expect(response.body.messageIntegrityCode.length).to.be.equal(66);
476476
});
477+
it('should get no native payment', async () => {
478+
const payload = {
479+
attestationType:
480+
'0x5061796d656e7400000000000000000000000000000000000000000000000000',
481+
sourceId:
482+
'0x7465737458525000000000000000000000000000000000000000000000000000',
483+
requestBody: {
484+
transactionId:
485+
'14c6e5ba6fb9fefaac1e0853acdff74e0898c1a2d5e9572585d7774fb4ccdd01',
486+
inUtxo: '0',
487+
utxo: '0',
488+
},
489+
};
490+
const response = await request(app.getHttpServer())
491+
.post('/Payment/mic')
492+
.send(payload)
493+
.set('X-API-KEY', '12345')
494+
.expect(200)
495+
.expect('Content-Type', /json/);
496+
497+
expect(response.body.status).to.be.equal(
498+
'INVALID: NOT NATIVE PAYMENT TRANSACTION',
499+
);
500+
});
477501
});

0 commit comments

Comments
 (0)