Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
7235e80
added: type block added
nunesinc Mar 24, 2022
fa44721
added: features correction array<any>
nunesinc Mar 24, 2022
ae6eaaf
added: skeleton blocks fetch
nunesinc Mar 24, 2022
33d7d5f
added: tests jest for block, function block types
nunesinc Mar 24, 2022
c1cd754
added: refactor code, clean code on blocks and test
nunesinc Mar 24, 2022
e42edbf
added: correction test
nunesinc Mar 24, 2022
facb61e
added: test ok form blockHeight()
nunesinc Mar 25, 2022
08eb422
added: average delay function, test case
nunesinc Mar 25, 2022
4ff1e9d
added: blockSeq function, test case jest
nunesinc Mar 25, 2022
fd9de60
added: blockLast function, test case
nunesinc Mar 25, 2022
9fb4fa0
added: blockChild function, test case
nunesinc Mar 25, 2022
b22959a
added: blockHeightEncoded function, test case
nunesinc Mar 25, 2022
18f70fb
added: correction test, blockHeightEncoded
nunesinc Mar 25, 2022
70bf8d2
added: blockAtHeaderOnly function and test
nunesinc Mar 25, 2022
b6c6f6c
added: blockSeqHeaderOnly test and test case
nunesinc Mar 25, 2022
1a61f01
added: blockLastHeaderOnly test and function
nunesinc Mar 25, 2022
0a21f80
added: blockFirst test and function
nunesinc Mar 25, 2022
ffefae5
added: blockAddress test and function
nunesinc Mar 25, 2022
7625e2b
added: run command prettier -w
nunesinc Mar 25, 2022
80f4f8f
added: blockbyHeight specified errors test
nunesinc Mar 31, 2022
c86698c
added: crash test because block.types
nunesinc Mar 31, 2022
54d7891
added: refactored block.types and added validation on function blockb…
nunesinc Mar 31, 2022
e6e6845
refactored: blockByHeight function, tests and type refactored
nunesinc Mar 31, 2022
65a9cc1
refactored: blockHeigh test case refactored
nunesinc Mar 31, 2022
cd9de7c
refactored: blockHeight function, tests refactor
nunesinc Mar 31, 2022
2804b11
added: blockAverageDelay function and test refactor
nunesinc Apr 1, 2022
fa01dce
added: blockSeq test and function refacator
nunesinc Apr 1, 2022
08d7abd
added: refactored blocklast function and test
nunesinc Apr 4, 2022
e1a27a2
added: blockChild test case and refactor function
nunesinc Apr 5, 2022
d638ece
added: blockHeightEncoded test and function with refactor
nunesinc Apr 5, 2022
404877d
added: blockAtHeaderOnly test 404 and function
nunesinc Apr 6, 2022
5518eb4
refactored: spaces and lines refactores of function
nunesinc Apr 6, 2022
0d273d4
added: blockSeqHeaderOnly test and function
nunesinc Apr 6, 2022
b2caad8
added: blockSignature test and function with refactor
nunesinc Apr 6, 2022
5ff00b6
added: blockFirst function and test added and refact
nunesinc Apr 7, 2022
58e434a
added: blockAddress test and function and refact
nunesinc Apr 7, 2022
976517a
refactored: yarn fmt
nunesinc Apr 7, 2022
4b9eb80
update: from main
Apr 19, 2022
2f63a26
update: package
Apr 19, 2022
279bed0
update: from main
Apr 19, 2022
c8d17a5
update: rename server to blokchcain
Apr 19, 2022
1bde93d
update: from main
Apr 19, 2022
93c0c47
update: blocks returns
Apr 19, 2022
568c611
update: from main
Apr 19, 2022
e032e3f
update: add jest RunIT extension
nunesinc Apr 20, 2022
61688bb
update: blochainError and blochainResponse update return in functions
nunesinc Apr 20, 2022
84e85b1
add: adding jsDoc for functions
nunesinc Apr 20, 2022
9a4a742
update: blockHeight function and test
nunesinc Apr 21, 2022
91bbe98
update: tet toMatchObject to ==> isSuccess
nunesinc Apr 21, 2022
4c2023f
add: bloqSeq job
nunesinc Apr 21, 2022
40fd60e
fix: block height
Apr 21, 2022
a55bd5f
update: function blochainHeight to actualHeigh rename, test jest
nunesinc Apr 21, 2022
6466325
update: blockAverageDelay test and function
nunesinc Apr 21, 2022
d8c6716
update: blockSeq test and function promise update
nunesinc Apr 21, 2022
d4fbde8
update blockLast function and test promise
nunesinc Apr 22, 2022
0a08368
update: blockLast jsdoc
nunesinc Apr 22, 2022
6008f02
update: blockChild test and function promise update
nunesinc Apr 22, 2022
0c2209a
update blockHeightEncoded test and function promise
nunesinc Apr 22, 2022
108ecd0
update: blockAtHeaderOnly test and function promises
nunesinc Apr 22, 2022
711bb1e
update: blockSeqHeaderOnly test and function promise updated
nunesinc Apr 22, 2022
8620046
update: blockLastHeaderOnly function and test promise updated
nunesinc Apr 22, 2022
cfd5f62
update: blockSignature test and function promises updated
nunesinc Apr 22, 2022
55a1350
update: blockFirst test and function promises updated
nunesinc Apr 22, 2022
6186f62
update: blockAddress function and test promises updated
nunesinc Apr 22, 2022
a42df3d
update: review by @olivmath
Apr 22, 2022
62744e3
update: byHeight function test and function promises #2
nunesinc Apr 22, 2022
f0ddefe
add: yarn fmt
nunesinc Apr 22, 2022
cbd5b18
update: actualHeigth test and function promises #2
nunesinc Apr 22, 2022
46845f1
update timeout test
nunesinc Apr 22, 2022
488beca
update testing jest
nunesinc Apr 22, 2022
b59540b
update: commet actualHeigh function
nunesinc Apr 22, 2022
58a108a
update: blockAverageDelay function and test #2
nunesinc Apr 23, 2022
fc3cce0
add: testing first function
nunesinc Apr 23, 2022
3fa2bca
add: testing suite
nunesinc Apr 23, 2022
6ee5138
add: testing #2 suite
nunesinc Apr 23, 2022
87100a7
add:testing delay and blocks with error
nunesinc May 12, 2022
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
3 changes: 2 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"esbenp.prettier-vscode",
"mhutchie.git-graph",
"Tyriar.sort-lines",
"eamodio.gitlens"
"eamodio.gitlens",
"vespa-dev-works.jestRunIt"
],
"postCreateCommand": "yarn install && yarn upgrade --latest"
}
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"editor.renderWhitespace": "trailing"
}
23 changes: 23 additions & 0 deletions junit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuites name="jest tests" tests="5" failures="1" errors="0" time="20.948">
<testsuite name="blockByHeight function- suite test block service" errors="0" failures="1" skipped="0" timestamp="2022-05-12T01:09:46" time="18.33" tests="5">
<testcase classname="blockByHeight function- suite test block service blockByHeight - block testing error, passing -1 number" name="blockByHeight function- suite test block service blockByHeight - block testing error, passing -1 number" time="0.009">
</testcase>
<testcase classname="blockByHeight function- suite test block service blockbyHeight - block testing error, passing i32Max " name="blockByHeight function- suite test block service blockbyHeight - block testing error, passing i32Max " time="0.002">
</testcase>
<testcase classname="blockByHeight function- suite test block service blockByHeight- receive number 10 param to get fetch" name="blockByHeight function- suite test block service blockByHeight- receive number 10 param to get fetch" time="1.28">
</testcase>
<testcase classname="blockAverageDelay function - suite test block service blockAverageDelay - see Average delay " name="blockAverageDelay function - suite test block service blockAverageDelay - see Average delay " time="1.084">
<failure>Error: expect(received).toEqual(expected) // deep equality

Expected: true
Received: false
at /workspaces/lunesjs/test/blockchain/blocks/blockOne.test.ts:99:34
at Generator.next (&lt;anonymous&gt;)
at fulfilled (/workspaces/lunesjs/test/blockchain/blocks/blockOne.test.ts:5:58)
at processTicksAndRejections (node:internal/process/task_queues:96:5)</failure>
</testcase>
<testcase classname="blockAverageDelay function - suite test block service blockAverageDelay - blockNum &gt;9 error " name="blockAverageDelay function - suite test block service blockAverageDelay - blockNum &gt;9 error " time="0.002">
</testcase>
</testsuite>
</testsuites>
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,22 @@
"author": "lunes-platform",
"license": "Apache-2.0",
"scripts": {
"deploy": "yarn build && yarn publish",
"fmt": "prettier -w .",
"fmtc": "prettier -c",
"test": "yarn jest",
"t": "yarn jest",
"build": "tsc"
},
"devDependencies": {
"@types/jest": "^27.0.3",
"jest": "^27.4.5",
"jest-junit": "^13.0.0",
"@types/jest": "^27.5.1",
"jest": "^28.1.0",
"jest-junit": "^13.2.0",
"prettier": "2.6.2",
"ts-jest": "^27.1.2",
"typescript": "^4.5.4"
"ts-jest": "^28.0.2",
"typescript": "^4.6.4"
},
"dependencies": {
"axios": "^0.26.1",
"axios": "^0.27.2",
"lunesrs": "^1.9.4"
}
}
93 changes: 93 additions & 0 deletions src/blockchain/blocks/block.types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import { AxiosResponse } from "axios"

interface INxtConsensus {
generationSignature: string
baseTarget: number
}
interface ITransaction {
senderPublicKey: string
timestamp: number
signature: string
recipient: string
feeAsset: string
assetId: string
amount: number
sender: string
type: number
fee: number
id: string
}

interface IHeader {
nxtConsensus: INxtConsensus
transactionCount: number
features: Array<number>
timestamp: number
reference: string
generator: string
signature: string
blocksize: number
version: number
height: number
fee: number
//delay: number //testando colocar delay não foi
}

export interface IBlock {
isSuccess: boolean
header: IHeader
body: Array<ITransaction>
}

export interface IBlockError {
isSuccess: boolean
response: {
codeError: number
message: string
}
}

export function mountBlock(
blockchainResponse: AxiosResponse<any, any>
): IBlock {
let block: IBlock = {
isSuccess: true,
header: {
nxtConsensus: {
baseTarget:
blockchainResponse.data["nxt-consensus"]["base-target"],
generationSignature:
blockchainResponse.data["nxt-consensus"][
"generation-signature"
]
},
transactionCount: blockchainResponse.data.transactionCount,
features:
blockchainResponse.data.features != undefined
? blockchainResponse.data.features
: [],
timestamp: blockchainResponse.data.timestamp,
reference: blockchainResponse.data.reference,
generator: blockchainResponse.data.generator,
signature: blockchainResponse.data.signature,
blocksize: blockchainResponse.data.blocksize,
version: blockchainResponse.data.version,
height: blockchainResponse.data.height,
fee: blockchainResponse.data.fee,
//delay: blockchainResponse.data.delay //testando colocar delay não foi
},
body: blockchainResponse.data.transactions
}

return block
}

export function mountErr(blockchainError: string): IBlockError {
return {
isSuccess: false,
response: {
codeError: 1,
message: blockchainError
}
}
}
Loading