Skip to content

Commit b4ed8b2

Browse files
committed
Updating unit tests
1 parent cd6cf7a commit b4ed8b2

File tree

2 files changed

+39
-50
lines changed

2 files changed

+39
-50
lines changed

sdk/src/network-client.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -212,10 +212,10 @@ class AleoNetworkClient {
212212
* @param {number} params.startHeight - The height at which to start searching for unspent records
213213
* @param {number} [params.endHeight] - The height at which to stop searching for unspent records
214214
* @param {boolean} [params.unspent=false] - Whether to search for unspent records only
215-
* @param {string[]} [params.programs] - The program(s) to search for unspent records in
216-
* @param {number[]} [params.amounts] - The amounts (in microcredits) to search for (eg. [100, 200, 3000])
215+
* @param {string[]} [params.programs=[]] - The program(s) to search for unspent records in
216+
* @param {number[]} [params.amounts=[]] - The amounts (in microcredits) to search for (eg. [100, 200, 3000])
217217
* @param {number} [params.maxMicrocredits] - The maximum number of microcredits to search for
218-
* @param {string[]} [params.nonces] - The nonces of already found records to exclude from the search
218+
* @param {string[]} [params.nonces=[]] - The nonces of already found records to exclude from the search
219219
* @param {string | PrivateKey} [params.privateKey] - An optional private key to use to find unspent records.
220220
* @returns {Promise<Array<RecordPlaintext>>} An array of records belonging to the account configured in the network client.
221221
*
@@ -546,10 +546,10 @@ class AleoNetworkClient {
546546
* @param {Object} params
547547
* @param {number} params.startHeight - The height at which to start searching for unspent records
548548
* @param {number} [params.endHeight] - The height at which to stop searching for unspent records
549-
* @param {string[]} [params.programs] - The program(s) to search for unspent records in
550-
* @param {number[]} [params.amounts] - The amounts (in microcredits) to search for (eg. [100, 200, 3000])
549+
* @param {string[]} [params.programs=[]] - The program(s) to search for unspent records in
550+
* @param {number[]} [params.amounts=[]] - The amounts (in microcredits) to search for (eg. [100, 200, 3000])
551551
* @param {number} [params.maxMicrocredits] - The maximum number of microcredits to search for
552-
* @param {string[]} [params.nonces] - The nonces of already found records to exclude from the search
552+
* @param {string[]} [params.nonces=[]] - The nonces of already found records to exclude from the search
553553
* @param {string | PrivateKey} [params.privateKey] - An optional private key to use to find unspent records.
554554
* @returns {Promise<Array<RecordPlaintext>>} An array of unspent records belonging to the account configured in the network client.
555555
*

sdk/tests/network-client.test.ts

Lines changed: 33 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -387,63 +387,52 @@ describe("NodeConnection", () => {
387387
describe("findUnspentRecords", () => {
388388
it("should fail if block heights or private keys are incorrectly specified", async () => {
389389
await expectThrows(() =>
390-
connection.findUnspentRecords(
391-
5,
392-
0,
393-
[],
394-
undefined,
395-
undefined,
396-
[],
397-
beaconPrivateKeyString,
398-
),
390+
connection.findUnspentRecords({
391+
startHeight: 5,
392+
endHeight: 0,
393+
programs: [],
394+
nonces: [],
395+
privateKey: beaconPrivateKeyString,
396+
}),
399397
);
400398

401399
await expectThrows(() =>
402-
connection.findUnspentRecords(
403-
-5,
404-
5,
405-
[],
406-
undefined,
407-
undefined,
408-
[],
409-
beaconPrivateKeyString,
410-
),
400+
connection.findUnspentRecords({
401+
startHeight: -5,
402+
endHeight: 5,
403+
programs: [],
404+
nonces: [],
405+
privateKey: beaconPrivateKeyString,
406+
}),
411407
);
412408

413409
await expectThrows(() =>
414-
connection.findUnspentRecords(
415-
0,
416-
5,
417-
[],
418-
undefined,
419-
undefined,
420-
[],
421-
"definitelynotaprivatekey",
422-
),
410+
connection.findUnspentRecords({
411+
startHeight: 0,
412+
endHeight: 5,
413+
programs: [],
414+
nonces: [],
415+
privateKey: "definitelynotaprivatekey",
416+
}),
423417
);
424418

425419
await expectThrows(() =>
426-
connection.findUnspentRecords(
427-
0,
428-
5,
429-
undefined,
430-
undefined,
431-
undefined,
432-
[],
433-
),
420+
connection.findUnspentRecords({
421+
startHeight: 0,
422+
endHeight: 5,
423+
nonces: [],
424+
}),
434425
);
435426
});
436427

437428
it.skip("should search a range correctly and not find records where none exist", async () => {
438-
const records = await connection.findUnspentRecords(
439-
0,
440-
204,
441-
[],
442-
undefined,
443-
undefined,
444-
[],
445-
beaconPrivateKeyString,
446-
);
429+
const records = await connection.findUnspentRecords({
430+
startHeight: 0,
431+
endHeight: 204,
432+
programs: [],
433+
nonces: [],
434+
privateKey: beaconPrivateKeyString,
435+
});
447436
expect(Array.isArray(records)).equal(true);
448437
if (!(records instanceof Error)) {
449438
expect(records.length).equal(0);

0 commit comments

Comments
 (0)