Skip to content

Commit

Permalink
chore: linter changes
Browse files Browse the repository at this point in the history
  • Loading branch information
r4mmer committed Jan 8, 2025
1 parent 692ad57 commit ddfaf12
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 42 deletions.
51 changes: 11 additions & 40 deletions __tests__/integration/tx-template.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ describe('tx-template build', () => {
const response = await TestUtils.request
.post('/wallet/tx-template/build')
.send([
{ type: 'action/setvar', name: 'addr', call: { method: 'get_wallet_address' }},
{ type: 'action/setvar', name: 'addr', call: { method: 'get_wallet_address' } },
{ type: 'input/utxo', fill: 1 },
{ type: 'output/token', amount: 1, address: '{addr}'},
{ type: 'output/token', amount: 1, address: '{addr}' },
])
.set({ 'x-wallet-id': wallet.walletId });

Expand All @@ -50,9 +50,9 @@ describe('tx-template build', () => {
const response = await TestUtils.request
.post('/wallet/tx-template/build')
.send([
{ type: 'action/setvar', name: 'addr', call: { method: 'get_wallet_address' }},
{ type: 'action/setvar', name: 'addr', call: { method: 'get_wallet_address' } },
{ type: 'input/utxo', fill: 1 },
{ type: 'output/token', amount: 1, address: '{addr}'},
{ type: 'output/token', amount: 1, address: '{addr}' },
])
.query({ debug: true })
.set({ 'x-wallet-id': wallet.walletId });
Expand All @@ -65,7 +65,7 @@ describe('tx-template build', () => {
const response = await TestUtils.request
.post('/wallet/tx-template/build')
.send([
{ type: 'action/setvar', name: 'addr', call: { method: 'get_wallet_address' }},
{ type: 'action/setvar', name: 'addr', call: { method: 'get_wallet_address' } },
{ type: 'action/config', tokenName: 'Test Token', tokenSymbol: 'TT' },
{ type: 'input/utxo', fill: 1 },
{ type: 'output/token', amount: 100, address: '{addr}', useCreatedToken: true },
Expand All @@ -76,35 +76,6 @@ describe('tx-template build', () => {
expect(response.status).toBe(200);
expect(response.body.success).toBe(true);
});

it('should make a successful transaction with change address', async () => {
const changeAddress = await wallet.getAddressAt(5);

const response = await TestUtils.request
.post('/wallet/simple-send-tx')
.send({
address: await wallet2.getAddressAt(0),
value: 200,
change_address: changeAddress,
})
.set({ 'x-wallet-id': wallet.walletId });

expect(response.status).toBe(200);
expect(response.body.success).toBe(true);
expect(response.body.outputs).toHaveLength(2);

await TestUtils.waitForTxReceived(wallet.walletId, response.body.hash);
await TestUtils.waitForTxReceived(wallet2.walletId, response.body.hash);

// Check if the transaction arrived at the correct address

// The wallet1 started with 1000, transferred 400 to wallet2. Change should be 600
const addr5 = await wallet.getAddressInfo(5);
expect(addr5.total_amount_received).toBe(600);

const addr0 = await wallet2.getAddressInfo(0);
expect(addr0.total_amount_available).toBe(400);
});
});

describe('tx-template run', () => {
Expand Down Expand Up @@ -143,9 +114,9 @@ describe('tx-template run', () => {
const response = await TestUtils.request
.post('/wallet/tx-template/run')
.send([
{ type: 'action/setvar', name: 'addr', call: { method: 'get_wallet_address' }},
{ type: 'action/setvar', name: 'addr', call: { method: 'get_wallet_address' } },
{ type: 'input/utxo', fill: 1 },
{ type: 'output/token', amount: 1, address: '{addr}'},
{ type: 'output/token', amount: 1, address: '{addr}' },
])
.set({ 'x-wallet-id': wallet.walletId });

Expand All @@ -159,9 +130,9 @@ describe('tx-template run', () => {
const response = await TestUtils.request
.post('/wallet/tx-template/run')
.send([
{ type: 'action/setvar', name: 'addr', call: { method: 'get_wallet_address' }},
{ type: 'action/setvar', name: 'addr', call: { method: 'get_wallet_address' } },
{ type: 'input/utxo', fill: 1 },
{ type: 'output/token', amount: 1, address: '{addr}'},
{ type: 'output/token', amount: 1, address: '{addr}' },
])
.query({ debug: true })
.set({ 'x-wallet-id': wallet.walletId });
Expand All @@ -176,7 +147,7 @@ describe('tx-template run', () => {
const response = await TestUtils.request
.post('/wallet/tx-template/run')
.send([
{ type: 'action/setvar', name: 'addr', call: { method: 'get_wallet_address' }},
{ type: 'action/setvar', name: 'addr', call: { method: 'get_wallet_address' } },
{ type: 'action/config', tokenName: 'Test Token', tokenSymbol: 'TT' },
{ type: 'input/utxo', fill: 1 },
{ type: 'output/token', amount: 100, address: '{addr}', useCreatedToken: true },
Expand All @@ -203,7 +174,7 @@ describe('tx-template run', () => {
const response = await TestUtils.request
.post('/wallet/tx-template/run')
.send([
{ type: 'action/setvar', name: 'addr', call: { method: 'get_wallet_address' }},
{ type: 'action/setvar', name: 'addr', call: { method: 'get_wallet_address' } },
{ type: 'input/utxo', fill: 1 },
{ type: 'input/authority', authority: 'mint', token: tokenId },
{ type: 'output/token', amount: 100, address: '{addr}', token: tokenId },
Expand Down
3 changes: 1 addition & 2 deletions src/helpers/validations.helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* LICENSE file in the root directory of this source tree.
*/

import { z } from 'zod';
import { validationResult } from 'express-validator';

/**
Expand All @@ -32,5 +31,5 @@ export function validateZodSchema(schema) {
const errorMessages = error.errors.map(issue => (`${issue.path.join('.')} is ${issue.message}`));
res.status(400).json({ success: false, details: errorMessages });

Check warning on line 32 in src/helpers/validations.helper.js

View check run for this annotation

Codecov / codecov/patch

src/helpers/validations.helper.js#L31-L32

Added lines #L31 - L32 were not covered by tests
}
}
};
}

0 comments on commit ddfaf12

Please sign in to comment.