From 3c2b442559c7757be1c2f4b7cdeab0eda2446a1b Mon Sep 17 00:00:00 2001 From: nunesinc Date: Sun, 17 Apr 2022 13:42:31 -0300 Subject: [PATCH 01/10] add: skeleton address --- package.json | 2 +- src/tx/address/service.address.ts | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 src/tx/address/service.address.ts diff --git a/package.json b/package.json index 7caece2..090372b 100644 --- a/package.json +++ b/package.json @@ -37,4 +37,4 @@ "axios": "^0.26.1", "lunesrs": "^1.9.1" } -} \ No newline at end of file +} diff --git a/src/tx/address/service.address.ts b/src/tx/address/service.address.ts new file mode 100644 index 0000000..73b6d88 --- /dev/null +++ b/src/tx/address/service.address.ts @@ -0,0 +1,4 @@ + +import axios from "axios" + +fsfs \ No newline at end of file From 175116a2d629a0842d862b7346a4cc8ad6928f23 Mon Sep 17 00:00:00 2001 From: nunesinc Date: Sun, 17 Apr 2022 15:45:42 -0300 Subject: [PATCH 02/10] add: skeleton mod blockchain --- src/{tx => blockchain}/address/service.address.ts | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/{tx => blockchain}/address/service.address.ts (100%) diff --git a/src/tx/address/service.address.ts b/src/blockchain/address/service.address.ts similarity index 100% rename from src/tx/address/service.address.ts rename to src/blockchain/address/service.address.ts From 4235db0457dd74a60b4b063db785596e992f4e2c Mon Sep 17 00:00:00 2001 From: nunesinc Date: Sun, 17 Apr 2022 17:03:26 -0300 Subject: [PATCH 03/10] add: test case skeleton --- test/blockchain/address/address.service.test.ts | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 test/blockchain/address/address.service.test.ts diff --git a/test/blockchain/address/address.service.test.ts b/test/blockchain/address/address.service.test.ts new file mode 100644 index 0000000..14d3940 --- /dev/null +++ b/test/blockchain/address/address.service.test.ts @@ -0,0 +1,8 @@ +import { validateAddr } from "../../../src/blockchain/address/service.address" + +describe("validateAddr function- suite test block service", () => { + it("validateAddr - validate address, passing true addrress", async () => { + const result = await validateAddr("37pU1WLv8vettr9UHGfPpTMWe1twne8FCBn") + expect(result).toStrictEqual("a") + }) +}) From f106429260645dfbd4f8993250d11a087d4862b7 Mon Sep 17 00:00:00 2001 From: nunesinc Date: Sun, 17 Apr 2022 17:04:17 -0300 Subject: [PATCH 04/10] add: yarn fmt --- src/blockchain/address/service.address.ts | 33 +++++++++++++++++++++-- src/tx/transfer/utils.ts | 3 +-- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/src/blockchain/address/service.address.ts b/src/blockchain/address/service.address.ts index 73b6d88..7dc0caf 100644 --- a/src/blockchain/address/service.address.ts +++ b/src/blockchain/address/service.address.ts @@ -1,4 +1,33 @@ - import axios from "axios" -fsfs \ No newline at end of file +const BASEURL = "https://lunesnode.lunes.io/addresses/" + +/* + * This function get wallet accounts addresses + * --- validation: {from} {to} + * + */ + +/* + * This function check whether address {address} is valid or not + * --- validation: {address} : string + * + */ + +export async function validateAddr(address: String): Promise { + const url = `${BASEURL}validate/${address}` + + const response = await axios.get(url) + return response.data +} + +/* + * This function check whether address {address} is valid or not + * --- validation: {address} : string + * + + +export async function validateAddr(address:String): Promise { + +} + */ diff --git a/src/tx/transfer/utils.ts b/src/tx/transfer/utils.ts index 79dac9e..112974e 100644 --- a/src/tx/transfer/utils.ts +++ b/src/tx/transfer/utils.ts @@ -64,7 +64,7 @@ export async function broadcastTransfer( } resolve(x) }) - .catch(erro => { + .catch((erro) => { resolve({ isSuccess: false, response: { @@ -100,4 +100,3 @@ type TransferFail = { message: string } } - From 3359a113b06a2e1f456c380f6869fb3dcf673bb3 Mon Sep 17 00:00:00 2001 From: nunesinc Date: Sun, 17 Apr 2022 17:52:42 -0300 Subject: [PATCH 05/10] add: test for validateAddr --- test/blockchain/address/address.service.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/blockchain/address/address.service.test.ts b/test/blockchain/address/address.service.test.ts index 14d3940..7795ab8 100644 --- a/test/blockchain/address/address.service.test.ts +++ b/test/blockchain/address/address.service.test.ts @@ -3,6 +3,6 @@ import { validateAddr } from "../../../src/blockchain/address/service.address" describe("validateAddr function- suite test block service", () => { it("validateAddr - validate address, passing true addrress", async () => { const result = await validateAddr("37pU1WLv8vettr9UHGfPpTMWe1twne8FCBn") - expect(result).toStrictEqual("a") + expect(result).toStrictEqual({"address": "37pU1WLv8vettr9UHGfPpTMWe1twne8FCBn", "valid": true}) }) }) From 20e64d48b69b037280d2f1732231fe297249f02c Mon Sep 17 00:00:00 2001 From: nunesinc Date: Sun, 17 Apr 2022 21:10:24 -0300 Subject: [PATCH 06/10] add: validadteAddr, test jest and address.types correct and refact --- src/blockchain/address/address.types.ts | 4 ++ src/blockchain/address/service.address.ts | 50 +++++++++++++++++-- .../address/address.service.test.ts | 13 ++++- 3 files changed, 62 insertions(+), 5 deletions(-) create mode 100644 src/blockchain/address/address.types.ts diff --git a/src/blockchain/address/address.types.ts b/src/blockchain/address/address.types.ts new file mode 100644 index 0000000..48e6208 --- /dev/null +++ b/src/blockchain/address/address.types.ts @@ -0,0 +1,4 @@ +export interface IAddressError { + status: string + message: string +} diff --git a/src/blockchain/address/service.address.ts b/src/blockchain/address/service.address.ts index 7dc0caf..f233d3f 100644 --- a/src/blockchain/address/service.address.ts +++ b/src/blockchain/address/service.address.ts @@ -1,5 +1,8 @@ +import { IAddressError } from "./address.types" + import axios from "axios" + const BASEURL = "https://lunesnode.lunes.io/addresses/" /* @@ -8,19 +11,58 @@ const BASEURL = "https://lunesnode.lunes.io/addresses/" * */ + + + /* * This function check whether address {address} is valid or not * --- validation: {address} : string - * + * https://lunesnode.lunes.io/addresses/validate/${address} */ -export async function validateAddr(address: String): Promise { +export async function validateAddr( + address: String +): Promise { const url = `${BASEURL}validate/${address}` - const response = await axios.get(url) - return response.data + if (typeof address !== "string") { + const error: IAddressError = { + status: `error`, + message: `the type of address cannot different of string` + } + return error + } else { + const response = await axios.get(url) + //return response.data + if ( + response.status === 404 || + response.status === 401 || + response.status === 403 || + response.status === 501 + ) { + const error: IAddressError = { + status: `error`, + message: `system error, come back later` + } + return error + } else if (response.data.valid === false){ + const error: IAddressError = { + status: `error`, + message: `address invalid` + } + return error + + } else if(response.status === 200) {return response.data} + + + } + + // const response = await axios.get(url) + // return response.data } + + /* * This function check whether address {address} is valid or not * --- validation: {address} : string diff --git a/test/blockchain/address/address.service.test.ts b/test/blockchain/address/address.service.test.ts index 7795ab8..8a83a37 100644 --- a/test/blockchain/address/address.service.test.ts +++ b/test/blockchain/address/address.service.test.ts @@ -3,6 +3,17 @@ import { validateAddr } from "../../../src/blockchain/address/service.address" describe("validateAddr function- suite test block service", () => { it("validateAddr - validate address, passing true addrress", async () => { const result = await validateAddr("37pU1WLv8vettr9UHGfPpTMWe1twne8FCBn") - expect(result).toStrictEqual({"address": "37pU1WLv8vettr9UHGfPpTMWe1twne8FCBn", "valid": true}) + expect(result).toStrictEqual({ + address: "37pU1WLv8vettr9UHGfPpTMWe1twne8FCBn", + valid: true + }) + }) + + it("validateAddr - incorrect address, testing response.data.valid=== false", async () => { + const result = await validateAddr("-1") + expect(result).toStrictEqual({ + message: "address invalid", + status: "error" + }) }) }) From 18f1dda2cd71c5e428e4d94e4643e02c003222ae Mon Sep 17 00:00:00 2001 From: nunesinc Date: Mon, 18 Apr 2022 15:17:51 -0300 Subject: [PATCH 07/10] add: address.types interface, test error and assetBalance function --- src/blockchain/address/address.types.ts | 64 ++++++++++++++ src/blockchain/address/service.address.ts | 85 ++++++++++++++++--- .../address/address.service.test.ts | 49 ++++++++++- 3 files changed, 183 insertions(+), 15 deletions(-) diff --git a/src/blockchain/address/address.types.ts b/src/blockchain/address/address.types.ts index 48e6208..d49e55c 100644 --- a/src/blockchain/address/address.types.ts +++ b/src/blockchain/address/address.types.ts @@ -1,3 +1,67 @@ +/* +{ + "address": "387LjpQ5fdBdcY4nRcfDU7gPYdesbc1Md4D", + "balances": [ + { + "assetId": "FJL6J61NFWmZksXh3KnZdbN4ZWwgkZkUswWQ1G9DLvUk", + "balance": 13140000, + "reissuable": true, + "quantity": 1000000000000000, + "issueTransaction": { + "type": 3, + "id": "FJL6J61NFWmZksXh3KnZdbN4ZWwgkZkUswWQ1G9DLvUk", + "sender": "37kGaGFGgzw5E6cr5thLVsxiXHoJSMuso92", + "senderPublicKey": "EkUV6ihoPtvXKX8q6KhkSasihjxWZcXivBuf4HpN4sRp", + "fee": 100000000, + "timestamp": 1529557133065, + "signature": "5uEUY5JgQ9756RAPCHNStsFNyLGU9pp1kv3q3N2MdwUnYAyzvU7wdtG5MTsKwNmYDvkTUwHP6fjaJqH6rzuCm7NP", + "assetId": "FJL6J61NFWmZksXh3KnZdbN4ZWwgkZkUswWQ1G9DLvUk", + "name": "NEO Token", + "description": "Reward Token for lunesrealnode.com Leasers", + "quantity": 1000000000000000, + "decimals": 8, + "reissuable": true + } + } + ] + } +*/ +interface IIssueTransaction { + type: number + id: string + sender: string + senderPublicKey: string + fee: number + timestamp: number + signature: string + assetId: string + name: string + description: string + quantity: number + decimals: number + reissuable: boolean +} + +interface IBalances { + assetId: string + balance: number + reissuable: boolean + quantity: number + issueTransaction: Array +} + +interface IHeader { + address: string +} + +export interface IAddress { + header: IHeader + body: Array +} + +/* + * IAddressError : error messages to Address functions + */ export interface IAddressError { status: string message: string diff --git a/src/blockchain/address/service.address.ts b/src/blockchain/address/service.address.ts index f233d3f..565dbd7 100644 --- a/src/blockchain/address/service.address.ts +++ b/src/blockchain/address/service.address.ts @@ -1,16 +1,22 @@ -import { IAddressError } from "./address.types" +import { IAddress, IAddressError } from "./address.types" import axios from "axios" - -const BASEURL = "https://lunesnode.lunes.io/addresses/" +const BASEURL = "https://lunesnode.lunes.io/" /* - * This function get wallet accounts addresses - * --- validation: {from} {to} - * - */ +/assets/{asset_id}/distribution +/assets/balance/{address} +assets/balance/{address}/{asset_id} + + +/leasing/active/{address} +/addresses +/addresses/alias/by-alias/{alias} +/addresses/balance/{address} +addresses/alias/by-address/{address} +/* @@ -23,7 +29,7 @@ const BASEURL = "https://lunesnode.lunes.io/addresses/" export async function validateAddr( address: String ): Promise { - const url = `${BASEURL}validate/${address}` + const url = `${BASEURL}addresses/validate/${address}` if (typeof address !== "string") { const error: IAddressError = { @@ -31,7 +37,7 @@ export async function validateAddr( message: `the type of address cannot different of string` } return error - } else { + } else { const response = await axios.get(url) //return response.data if ( @@ -45,23 +51,74 @@ export async function validateAddr( message: `system error, come back later` } return error - } else if (response.data.valid === false){ + } else if (response.data.valid === false) { const error: IAddressError = { status: `error`, message: `address invalid` } return error - - } else if(response.status === 200) {return response.data} - - + } else if (response.status === 200) { + return response.data + } } // const response = await axios.get(url) // return response.data } +/* + * This function check Account's balances for all assets + * --- validation: {address} : string + * GET /assets/balance/{address} + */ +export async function assetBalance(address: String): Promise { + + const url = `${BASEURL}assets/balance/${address}` + + if (typeof address !== "string") { + const error: IAddressError = { + status: `error`, + message: `the type of address cannot different of string` + } + return error + } else { + return new Promise(async (resolve, reject) => { + const response = await axios.get(url) + + if (response.status === 400) { + const error: IAddressError = { + status: `error`, + message: `invalid address` + } + return error + + } else if (response.status === 200) { + resolve(response.data) + } else { + reject(response.data) + } + }) + } + +} +//const response = await axios.get(url) +//return response.data + +/* + * This function check Account's balances for all assets + * --- validation: {address} : string + * GET /assets/balance/{address} + +export async function assetBalance(address: String): Promise { + +} + */ +/* +/assets/{asset_id}/distribution +/assets/balance/{address} +assets/balance/{address}/{asset_id} +*/ /* * This function check whether address {address} is valid or not diff --git a/test/blockchain/address/address.service.test.ts b/test/blockchain/address/address.service.test.ts index 8a83a37..4358a57 100644 --- a/test/blockchain/address/address.service.test.ts +++ b/test/blockchain/address/address.service.test.ts @@ -1,4 +1,7 @@ -import { validateAddr } from "../../../src/blockchain/address/service.address" +import { + validateAddr, + assetBalance +} from "../../../src/blockchain/address/service.address" describe("validateAddr function- suite test block service", () => { it("validateAddr - validate address, passing true addrress", async () => { @@ -17,3 +20,47 @@ describe("validateAddr function- suite test block service", () => { }) }) }) + +describe("ASSETS functions - suite test ASSETS service", () => { + it("assetBalance - check asset, passing true addrress", async () => { + const result = await assetBalance("387LjpQ5fdBdcY4nRcfDU7gPYdesbc1Md4D") + expect(result).toStrictEqual({ + address: "387LjpQ5fdBdcY4nRcfDU7gPYdesbc1Md4D", + balances: [ + { + assetId: "FJL6J61NFWmZksXh3KnZdbN4ZWwgkZkUswWQ1G9DLvUk", + balance: 13140000, + issueTransaction: { + assetId: "FJL6J61NFWmZksXh3KnZdbN4ZWwgkZkUswWQ1G9DLvUk", + decimals: 8, + description: + "Reward Token for lunesrealnode.com Leasers", + fee: 100000000, + id: "FJL6J61NFWmZksXh3KnZdbN4ZWwgkZkUswWQ1G9DLvUk", + name: "NEO Token", + quantity: 1000000000000000, + reissuable: true, + sender: "37kGaGFGgzw5E6cr5thLVsxiXHoJSMuso92", + senderPublicKey: + "EkUV6ihoPtvXKX8q6KhkSasihjxWZcXivBuf4HpN4sRp", + signature: + "5uEUY5JgQ9756RAPCHNStsFNyLGU9pp1kv3q3N2MdwUnYAyzvU7wdtG5MTsKwNmYDvkTUwHP6fjaJqH6rzuCm7NP", + timestamp: 1529557133065, + type: 3 + }, + quantity: 1000000000000000, + reissuable: true + } + ] + }) + }) + it("assetBalance temp - check asset, passing invalid addrress", async () => { + const result = await assetBalance("387LjpQ5fdBdcY4nRcfDU7gPYdesbc1Md4Dm") + expect(result).toStrictEqual("invalid address") + }) +}) + +/* +describe("validateAddr function- suite test block service", () => { + +})*/ From c8917cb0460cd4c37917e9324202d03156a4cfd0 Mon Sep 17 00:00:00 2001 From: nunesinc Date: Tue, 19 Apr 2022 12:23:28 -0300 Subject: [PATCH 08/10] add: refactored assetBalance test and function, interface functional --- src/blockchain/address/service.address.ts | 60 ++++++++++++------- .../address/address.service.test.ts | 22 ++++++- 2 files changed, 59 insertions(+), 23 deletions(-) diff --git a/src/blockchain/address/service.address.ts b/src/blockchain/address/service.address.ts index 565dbd7..b1263e5 100644 --- a/src/blockchain/address/service.address.ts +++ b/src/blockchain/address/service.address.ts @@ -64,43 +64,63 @@ export async function validateAddr( // const response = await axios.get(url) // return response.data -} +} /* * This function check Account's balances for all assets * --- validation: {address} : string * GET /assets/balance/{address} */ -export async function assetBalance(address: String): Promise { - +export async function assetBalance(address: string): Promise { const url = `${BASEURL}assets/balance/${address}` - + if (typeof address !== "string") { const error: IAddressError = { status: `error`, message: `the type of address cannot different of string` } return error - } else { - return new Promise(async (resolve, reject) => { - const response = await axios.get(url) - - if (response.status === 400) { - const error: IAddressError = { - status: `error`, - message: `invalid address` - } + } else { + const response = await axios.get(url) + // return response.data + if (typeof address !== "string") { + const error: IAddressError = { + status: `error`, + message: `the type of address cannot different of string` + } + return error + } else { + //const response = await axios.get(url) + //return response.data + if ( + response.status === 404 || + response.status === 401 || + response.status === 403 || + response.status === 501 + ) { + const error: IAddressError = { + status: `error`, + message: `system error, come back later` + } return error - - } else if (response.status === 200) { - resolve(response.data) - } else { - reject(response.data) + } else if (response.status === 400) { + const error: IAddressError = { + status: `error`, + message: `address invalid` } - }) + return error + } else (response.status === 200) + return response.data + } + } - } + + +///////teste + + + //const response = await axios.get(url) //return response.data diff --git a/test/blockchain/address/address.service.test.ts b/test/blockchain/address/address.service.test.ts index 4358a57..5c99af1 100644 --- a/test/blockchain/address/address.service.test.ts +++ b/test/blockchain/address/address.service.test.ts @@ -1,3 +1,4 @@ +//import { IAddress, IAddressError } from "../../../src/blockchain/address/address.types" import { validateAddr, assetBalance @@ -54,12 +55,27 @@ describe("ASSETS functions - suite test ASSETS service", () => { ] }) }) - it("assetBalance temp - check asset, passing invalid addrress", async () => { - const result = await assetBalance("387LjpQ5fdBdcY4nRcfDU7gPYdesbc1Md4Dm") - expect(result).toStrictEqual("invalid address") + + it("assetBalance -error 400 - check asset, passing invalid addrress", async () => { + + ///const result = await assetOne("387LjpQ5fdBdcY4nRcfDU7gPYdesbc1Md4Dm") + //expect(result).toStrictEqual("invalid address") + // expect(result()).rejects.toThrow() + + const result = async () => { await assetBalance("387LjpQ5fdBdcY4nRcfDU7gPYdesbc1Md4Dm")} + + expect(result()).rejects.toThrow() + }) + }) + + + + + + /* describe("validateAddr function- suite test block service", () => { From b968322d1418eddb9415a386c8020031499e42e3 Mon Sep 17 00:00:00 2001 From: nunesinc Date: Tue, 19 Apr 2022 13:26:38 -0300 Subject: [PATCH 09/10] add: yarn fmt and assetBalance function refactor --- src/blockchain/address/service.address.ts | 62 +++++++------------ .../address/address.service.test.ts | 17 ++--- 2 files changed, 29 insertions(+), 50 deletions(-) diff --git a/src/blockchain/address/service.address.ts b/src/blockchain/address/service.address.ts index b1263e5..c6ecdde 100644 --- a/src/blockchain/address/service.address.ts +++ b/src/blockchain/address/service.address.ts @@ -6,7 +6,7 @@ const BASEURL = "https://lunesnode.lunes.io/" /* /assets/{asset_id}/distribution -/assets/balance/{address} +/assets/balance/{address} [ok] assets/balance/{address}/{asset_id} @@ -64,32 +64,28 @@ export async function validateAddr( // const response = await axios.get(url) // return response.data -} +} /* * This function check Account's balances for all assets * --- validation: {address} : string * GET /assets/balance/{address} */ -export async function assetBalance(address: string): Promise { +export async function assetBalance( + address: string +): Promise { const url = `${BASEURL}assets/balance/${address}` - + if (typeof address !== "string") { - const error: IAddressError = { - status: `error`, - message: `the type of address cannot different of string` - } - return error - } else { - const response = await axios.get(url) - // return response.data - if (typeof address !== "string") { const error: IAddressError = { status: `error`, message: `the type of address cannot different of string` } return error } else { + const response = await axios.get(url) + // return response.data + //const response = await axios.get(url) //return response.data if ( @@ -109,44 +105,32 @@ export async function assetBalance(address: string): Promise { +export async function assetDistribution(assetId:String): Promise { + + const url = `${BASEURL}assets/{assetId}/distribution` + } */ -/* -/assets/{asset_id}/distribution -/assets/balance/{address} -assets/balance/{address}/{asset_id} -*/ +//const response = await axios.get(url) +//return response.data /* - * This function check whether address {address} is valid or not - * --- validation: {address} : string + * This function + * --- validation: * - - -export async function validateAddr(address:String): Promise { +export async function xxxx(address:String): Promise { } */ diff --git a/test/blockchain/address/address.service.test.ts b/test/blockchain/address/address.service.test.ts index 5c99af1..5037301 100644 --- a/test/blockchain/address/address.service.test.ts +++ b/test/blockchain/address/address.service.test.ts @@ -57,24 +57,19 @@ describe("ASSETS functions - suite test ASSETS service", () => { }) it("assetBalance -error 400 - check asset, passing invalid addrress", async () => { - ///const result = await assetOne("387LjpQ5fdBdcY4nRcfDU7gPYdesbc1Md4Dm") //expect(result).toStrictEqual("invalid address") - // expect(result()).rejects.toThrow() + // expect(result()).rejects.toThrow() - const result = async () => { await assetBalance("387LjpQ5fdBdcY4nRcfDU7gPYdesbc1Md4Dm")} + const result = async () => { + await assetBalance("387LjpQ5fdBdcY4nRcfDU7gPYdesbc1Md4Dm") + } - expect(result()).rejects.toThrow() - + expect(result()).rejects.toThrow() }) - }) - - - - - +//37qrqmmQ8jwJJB2aXMnXt98kiwezyzb5ww7 richlist com vários assets /* describe("validateAddr function- suite test block service", () => { From 3543a1da0a932dc820b9406baa24c9627b11d2d1 Mon Sep 17 00:00:00 2001 From: nunesinc Date: Tue, 19 Apr 2022 14:24:39 -0300 Subject: [PATCH 10/10] add: assetDistribution test and function --- src/blockchain/address/service.address.ts | 38 ++++++++++++++++--- .../address/address.service.test.ts | 21 +++++++++- 2 files changed, 53 insertions(+), 6 deletions(-) diff --git a/src/blockchain/address/service.address.ts b/src/blockchain/address/service.address.ts index c6ecdde..af0ae56 100644 --- a/src/blockchain/address/service.address.ts +++ b/src/blockchain/address/service.address.ts @@ -114,14 +114,42 @@ export async function assetBalance( * This function show Asset balance distribution by account * --- validation: {assetId} string * GET /assets/{assetId}/distribution + */ +export async function assetDistribution(assetId: String): Promise { -export async function assetDistribution(assetId:String): Promise { - - const url = `${BASEURL}assets/{assetId}/distribution` - + const url = `${BASEURL}assets/${assetId}/distribution` + if (typeof assetId !== "string") { + const error: IAddressError = { + status: `error`, + message: `the type of asset Id cannot different of string` + } + return error + } else { + return new Promise(async (resolve, reject) => { + const response = await axios.get(url) + + if ( + response.status === 404 || + response.status === 401 || + response.status === 403 || + response.status === 501) { + const error: IAddressError = { + status: `error`, + message: `system error, come back later` + } + return error + } else if (response.status === 200) { + resolve(response.data) + } else { + reject(response.data) + } return response.data + }) + + + } } - */ + //const response = await axios.get(url) //return response.data diff --git a/test/blockchain/address/address.service.test.ts b/test/blockchain/address/address.service.test.ts index 5037301..9192e3e 100644 --- a/test/blockchain/address/address.service.test.ts +++ b/test/blockchain/address/address.service.test.ts @@ -1,7 +1,7 @@ //import { IAddress, IAddressError } from "../../../src/blockchain/address/address.types" import { validateAddr, - assetBalance + assetBalance, assetDistribution } from "../../../src/blockchain/address/service.address" describe("validateAddr function- suite test block service", () => { @@ -69,6 +69,25 @@ describe("ASSETS functions - suite test ASSETS service", () => { }) }) + + +describe(" assetDistribution function- suite test ASSET DIST service", () => { + it("assetDistribution - check ASSET DIST, passing VALID assetID", async () => { + const result = await assetDistribution("4xxGB1BgeiegawpZnvFssacbKzFuPKoueGD7k7xjmJn8") + expect(result).toStrictEqual({ + "37rjJJQvE1g9qENxGTKubD3XkK5s5RAJS2f": 0, + "385ZRVhNfK7oZhPFeBRgpvChdZrzPhwjDZR": 1 + }) + + }) + + it("assetDistribution - check ASSET DIST, passing inexistent assetID", async () => { + const result = await assetDistribution("abracadabra") + expect(result).toStrictEqual({}) + + }) + +}) //37qrqmmQ8jwJJB2aXMnXt98kiwezyzb5ww7 richlist com vários assets /*