Skip to content
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
6 changes: 5 additions & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
MONGO_URL=mongodb://mongo:27017/crpyto
DB_DATABASE=transactions
DB_USER=postgres
DB_PASSWORD=postgres
DB_HOST=db
DB_PORT=5432
16 changes: 16 additions & 0 deletions .github/workflows/integrate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Continuous Integration

on:
pull_request:
branches: [main]

jobs:
test_pull_request:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 14
- run: npm ci
- run: npm test
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ WORKDIR /app

COPY . ./

COPY package.json ./

RUN npm install

CMD [ "npm", "start" ]
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## Usage

To see the result run:

```bash
docker-compuse up
```

# Crypto/Payments Test

we receive thousands of deposits from customers per day. This test is designed to test your ability to work with a transaction set that could get returned by a blockchain daemon like bitcoind.
Expand Down
22 changes: 0 additions & 22 deletions app/models/transactions.ts

This file was deleted.

9 changes: 0 additions & 9 deletions app/models/user.ts

This file was deleted.

61 changes: 61 additions & 0 deletions app/transactions.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import Transactions from './transactions';
import { ITransaction, IKeyValue } from './types';
import { Pool } from 'pg'

const transaction = new Transactions(new Pool());

describe('Transactions', () => {
test('Should remove duplicated data', () => {
const testDuplicatedData: ITransaction[] = [{
"involvesWatchonly": true,
"account": "",
"address": "myAre6hq8uSDAzhmNit1fjkTeajebBzrKZ",
"category": "receive",
"amount": 36.9759613,
"label": "",
"confirmations": 42,
"blockhash": "ceea46e555518b0c7e858476ca2259b1ca91832ea6b35a8e135ac30d9ab7360b",
"blockindex": 59,
"blocktime": 1627633348873,
"txid": "697c9b177ffd64ce3a9ed4814c08d95254095863f3b07867f7fe0f457c474be2",
"vout": 5,
"walletconflicts": [],
"time": 1627633337048,
"timereceived": 1627633337048,
},
{
"involvesWatchonly": true,
"account": "",
"address": "mzzg8fvHXydKs8j9D2a8t7KpSXpGgAnk4n",
"category": "receive",
"amount": 9.19,
"label": "",
"confirmations": 2,
"blockhash": "8aa7f8a5d5db094089dcbfbada744f0542e02d01d12c76c0c3ad039afa63ef5b",
"blockindex": 41,
"blocktime": 1627657348873,
"txid": "697c9b177ffd64ce3a9ed4814c08d95254095863f3b07867f7fe0f457c474be2",
"vout": 9,
"walletconflicts": [],
"time": 1627657303461,
"timereceived": 1627657303461,
}]

const transactions: Array<ITransaction> = transaction.removeDuplicates(testDuplicatedData);
expect(transactions.length).toBe(1)
})

test('Should return transactions', () => {
const users: IKeyValue = transaction.getTransactions();
expect(users.values.length).toBeGreaterThan(0)
})
})


describe('Users', () => {
test('Should return users', () => {
const totalUserAmount = 7;
const users: IKeyValue = transaction.getUsers();
expect(users.values.length).toBe(totalUserAmount)
})
})
Loading