diff --git a/src/messages/aggregate/get.ts b/src/messages/aggregate/get.ts index 130a3a39..828f8cfc 100644 --- a/src/messages/aggregate/get.ts +++ b/src/messages/aggregate/get.ts @@ -10,6 +10,7 @@ type AggregateGetConfiguration = { APIServer?: string; address: string; keys?: Array; + limit?: number; }; /** @@ -18,20 +19,19 @@ type AggregateGetConfiguration = { * * @param configuration The configuration used to get the message, including the API endpoint. */ -export async function Get( - { APIServer = DEFAULT_API_V2, address = "", keys = [] }: AggregateGetConfiguration = { - APIServer: DEFAULT_API_V2, - address: "", - keys: [], - }, -): Promise { - const _keys = keys.length === 0 ? null : keys.join(","); +export async function Get({ + APIServer = DEFAULT_API_V2, + address = "", + keys = [], + limit = 50, +}: AggregateGetConfiguration): Promise { const response = await axios.get>( `${stripTrailingSlash(APIServer)}/api/v0/aggregates/${address}.json`, { socketPath: getSocketPath(), params: { - keys: _keys, + keys: keys.join(",") || undefined, + limit, }, }, ); diff --git a/src/messages/post/get.ts b/src/messages/post/get.ts index 2ce79de4..c2136ba9 100644 --- a/src/messages/post/get.ts +++ b/src/messages/post/get.ts @@ -65,21 +65,12 @@ export async function Get(configuration: PostGetConfiguration): Promise 0) { - params.refs = configuration.refs.join(","); - } - if (configuration.addresses?.length > 0) { - params.addresses = configuration.addresses.join(","); - } - if (configuration.tags?.length > 0) { - params.tags = configuration.tags.join(","); - } - if (configuration.hashes?.length > 0) { - params.hashes = configuration.hashes.join(","); - } - const response = await axios.get>( `${stripTrailingSlash(configuration.APIServer)}/api/v0/posts.json`, { diff --git a/tests/messages/aggregate/get.test.ts b/tests/messages/aggregate/get.test.ts index cb600d5d..961a6bab 100644 --- a/tests/messages/aggregate/get.test.ts +++ b/tests/messages/aggregate/get.test.ts @@ -2,62 +2,25 @@ import { aggregate } from "../../index"; import { DEFAULT_API_V2 } from "../../../src/global"; describe("Aggregate message retrieve test", () => { - it("should retrieve an existing aggregate message", async () => { - type T = { - satoshi: { - A: number; - }; - }; - const key = "satoshi"; - const address = "0x629fBDA22F485720617C8f1209692484C0359D43"; - - const message = await aggregate.Get({ - APIServer: DEFAULT_API_V2, - address: address, - keys: [key], - }); - - const expected = { - A: 1, - }; - - expect(message.satoshi).toStrictEqual(expected); + it("should failed to retrieve an aggregate message", async () => { + try { + await aggregate.Get({ + APIServer: DEFAULT_API_V2, + address: "0xa1B3bb7d2332383D96b7796B908fB7f7F3c2Be10", + keys: ["satoshi"], + }); + expect(true).toStrictEqual(false); + } catch (e: any) { + expect(e.request.res.statusCode).toStrictEqual(404); + } }); - it("should retrieve an existing aggregate message without specifies side params", async () => { - type T = { - satoshi: { - A: number; - }; - }; - const address = "0x629fBDA22F485720617C8f1209692484C0359D43"; - - const message = await aggregate.Get({ - address: address, + it("should print the CCN list correctly (testing #87)", async () => { + const message = await aggregate.Get({ + address: "0xa1B3bb7d2332383D96b7796B908fB7f7F3c2Be10", + keys: ["corechannel"], }); - const expected = { - A: 1, - }; - - expect(message.satoshi).toStrictEqual(expected); - }); - - it("should failed to retrieve an aggregate message", async () => { - type T = { - satoshi: { - A: number; - }; - }; - const key = "satoshi"; - const address = "0x629xBDA22F485720617C8f1209692484C0358D43"; - - await expect( - aggregate.Get({ - APIServer: DEFAULT_API_V2, - address: address, - keys: [key], - }), - ).rejects.toThrow(); + expect(message).toHaveProperty("corechannel"); }); }); diff --git a/tests/messages/aggregate/publish.test.ts b/tests/messages/aggregate/publish.test.ts index 8f7a718b..fb6ef00a 100644 --- a/tests/messages/aggregate/publish.test.ts +++ b/tests/messages/aggregate/publish.test.ts @@ -2,11 +2,9 @@ import { ItemType } from "../../../src/messages/message"; import { DEFAULT_API_V2 } from "../../../src/global"; import { aggregate, ethereum } from "../../index"; -const mnemonic = "exit canvas recycle vault excite battle short roof unlock limb attract device"; - describe("Aggregate message publish test", () => { it("should publish an aggregate message", async () => { - const account = ethereum.ImportAccountFromMnemonic(mnemonic); + const { account } = ethereum.NewAccount(); const key = "satoshi"; const content: { A: number } = {