Skip to content

Commit

Permalink
chore: add first tests with mocks
Browse files Browse the repository at this point in the history
  • Loading branch information
vladimirvolek committed Oct 26, 2021
1 parent 5e363f0 commit e3fbd89
Show file tree
Hide file tree
Showing 22 changed files with 374 additions and 37 deletions.
130 changes: 114 additions & 16 deletions .pnp.cjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
4 changes: 3 additions & 1 deletion package.json
Expand Up @@ -8,7 +8,7 @@
"dev": "ts-node-dev ./src/server.ts",
"lint": "eslint ./src/**/*.ts",
"start": "yarn build && yarn node ./dist/src/server.js",
"test": "jest",
"test": "PROJECT_ID='none' jest",
"type-check": "tsc --project tsconfig.json"
},
"dependencies": {
Expand All @@ -32,6 +32,7 @@
"@types/express": "^4.17.13",
"@types/jest": "^27.0.2",
"@types/node": "^16.11.5",
"@types/sinon": "^10.0.6",
"@types/validator": "^13.6.5",
"@types/ws": "^8.2.0",
"@typescript-eslint/eslint-plugin": "^5.0.0",
Expand All @@ -44,6 +45,7 @@
"jest": "^27.3.1",
"prettier": "^2.4.1",
"rimraf": "^3.0.2",
"sinon": "^11.1.2",
"ts-jest": "^27.0.7",
"ts-node-dev": "^1.1.8",
"typescript": "^4.4.4"
Expand Down
57 changes: 57 additions & 0 deletions test/unit/fixtures/estimteFee.ts
@@ -0,0 +1,57 @@
export default [
{
testName: 'estimateFee success',
id: 1,
epochsParameters: {
epoch: 298,
min_fee_a: 44,
min_fee_b: 155381,
max_block_size: 65536,
max_tx_size: 16384,
max_block_header_size: 1100,
key_deposit: '2000000',
pool_deposit: '500000000',
e_max: 18,
n_opt: 500,
a0: 0.3,
rho: 0.003,
tau: 0.2,
decentralisation_param: 0,
extra_entropy: null,
protocol_major_ver: 6,
protocol_minor_ver: 0,
min_utxo: '34482',
min_pool_cost: '340000000',
nonce: 'cb4cf3c0c67676b6c2a6b5929ca141f4e19950fc56f66289e343cfd06b535c7e',
price_mem: 0.0577,
price_step: 0.0000721,
max_tx_ex_mem: '10000000',
max_tx_ex_steps: '10000000000',
max_block_ex_mem: '50000000',
max_block_ex_steps: '40000000000',
max_val_size: '5000',
collateral_percent: 150,
max_collateral_inputs: 3,
coins_per_utxo_word: '34482',
},
epochLatest: {
epoch: 298,
start_time: 1634939091,
end_time: 1635371091,
first_block_time: 1634939263,
last_block_time: 1635261096,
block_count: 15365,
tx_count: 323279,
output: '10876834303613112',
fees: '68565535143',
active_stake: '23511990337865722',
},
result: {
id: 1,
type: 'message',
data: {
lovelacePerByte: 44,
},
},
},
] as const;
44 changes: 44 additions & 0 deletions test/unit/fixtures/getBlock.ts
@@ -0,0 +1,44 @@
export default [
{
testName: 'getBlock success',
id: 1,
blocks: {
time: 1506203091,
height: null,
hash: '5f20df933584822601f9e3f8c024eb5eb252fe8cefb24d1317dc3d432e940ebb',
slot: null,
epoch: null,
epoch_slot: null,
slot_leader: 'Genesis slot leader',
size: 0,
tx_count: 14505,
output: '31112484745000000',
fees: '0',
block_vrf: null,
previous_block: null,
next_block: '89d9b5a5b8ddc8d7e5a6795e9774d97faf1efea59b2caf7eaf9f8c5b32059df4',
confirmations: 6420635,
},
result: {
id: 1,
type: 'message',
data: {
time: 1506203091,
height: null,
hash: '5f20df933584822601f9e3f8c024eb5eb252fe8cefb24d1317dc3d432e940ebb',
slot: null,
epoch: null,
epoch_slot: null,
slot_leader: 'Genesis slot leader',
size: 0,
tx_count: 14505,
output: '31112484745000000',
fees: '0',
block_vrf: null,
previous_block: null,
next_block: '89d9b5a5b8ddc8d7e5a6795e9774d97faf1efea59b2caf7eaf9f8c5b32059df4',
confirmations: 6420635,
},
},
},
] as const;
2 changes: 2 additions & 0 deletions test/unit/tests/common.test.ts
@@ -1,5 +1,7 @@
import * as utils from '../../../src/utils/common';

jest.mock('@blockfrost/blockfrost-js');

describe('common utils', () => {
test('pagination', () => {
const input1 = [
Expand Down

0 comments on commit e3fbd89

Please sign in to comment.