Skip to content

Commit e02cc0b

Browse files
committed
Updating unit tests
1 parent 2ee49d4 commit e02cc0b

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
@@ -179,10 +179,10 @@ class AleoNetworkClient {
179179
* @param {number} params.startHeight - The height at which to start searching for unspent records
180180
* @param {number} [params.endHeight] - The height at which to stop searching for unspent records
181181
* @param {boolean} [params.unspent=false] - Whether to search for unspent records only
182-
* @param {string[]} [params.programs] - The program(s) to search for unspent records in
183-
* @param {number[]} [params.amounts] - The amounts (in microcredits) to search for (eg. [100, 200, 3000])
182+
* @param {string[]} [params.programs=[]] - The program(s) to search for unspent records in
183+
* @param {number[]} [params.amounts=[]] - The amounts (in microcredits) to search for (eg. [100, 200, 3000])
184184
* @param {number} [params.maxMicrocredits] - The maximum number of microcredits to search for
185-
* @param {string[]} [params.nonces] - The nonces of already found records to exclude from the search
185+
* @param {string[]} [params.nonces=[]] - The nonces of already found records to exclude from the search
186186
* @param {string | PrivateKey} [params.privateKey] - An optional private key to use to find unspent records.
187187
* @returns {Promise<Array<RecordPlaintext>>} An array of records belonging to the account configured in the network client.
188188
*
@@ -513,10 +513,10 @@ class AleoNetworkClient {
513513
* @param {Object} params
514514
* @param {number} params.startHeight - The height at which to start searching for unspent records
515515
* @param {number} [params.endHeight] - The height at which to stop searching for unspent records
516-
* @param {string[]} [params.programs] - The program(s) to search for unspent records in
517-
* @param {number[]} [params.amounts] - The amounts (in microcredits) to search for (eg. [100, 200, 3000])
516+
* @param {string[]} [params.programs=[]] - The program(s) to search for unspent records in
517+
* @param {number[]} [params.amounts=[]] - The amounts (in microcredits) to search for (eg. [100, 200, 3000])
518518
* @param {number} [params.maxMicrocredits] - The maximum number of microcredits to search for
519-
* @param {string[]} [params.nonces] - The nonces of already found records to exclude from the search
519+
* @param {string[]} [params.nonces=[]] - The nonces of already found records to exclude from the search
520520
* @param {string | PrivateKey} [params.privateKey] - An optional private key to use to find unspent records.
521521
* @returns {Promise<Array<RecordPlaintext>>} An array of unspent records belonging to the account configured in the network client.
522522
*

sdk/tests/network-client.test.ts

Lines changed: 33 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -383,63 +383,52 @@ describe("NodeConnection", () => {
383383
describe("findUnspentRecords", () => {
384384
it("should fail if block heights or private keys are incorrectly specified", async () => {
385385
await expectThrows(() =>
386-
connection.findUnspentRecords(
387-
5,
388-
0,
389-
[],
390-
undefined,
391-
undefined,
392-
[],
393-
beaconPrivateKeyString,
394-
),
386+
connection.findUnspentRecords({
387+
startHeight: 5,
388+
endHeight: 0,
389+
programs: [],
390+
nonces: [],
391+
privateKey: beaconPrivateKeyString,
392+
}),
395393
);
396394

397395
await expectThrows(() =>
398-
connection.findUnspentRecords(
399-
-5,
400-
5,
401-
[],
402-
undefined,
403-
undefined,
404-
[],
405-
beaconPrivateKeyString,
406-
),
396+
connection.findUnspentRecords({
397+
startHeight: -5,
398+
endHeight: 5,
399+
programs: [],
400+
nonces: [],
401+
privateKey: beaconPrivateKeyString,
402+
}),
407403
);
408404

409405
await expectThrows(() =>
410-
connection.findUnspentRecords(
411-
0,
412-
5,
413-
[],
414-
undefined,
415-
undefined,
416-
[],
417-
"definitelynotaprivatekey",
418-
),
406+
connection.findUnspentRecords({
407+
startHeight: 0,
408+
endHeight: 5,
409+
programs: [],
410+
nonces: [],
411+
privateKey: "definitelynotaprivatekey",
412+
}),
419413
);
420414

421415
await expectThrows(() =>
422-
connection.findUnspentRecords(
423-
0,
424-
5,
425-
undefined,
426-
undefined,
427-
undefined,
428-
[],
429-
),
416+
connection.findUnspentRecords({
417+
startHeight: 0,
418+
endHeight: 5,
419+
nonces: [],
420+
}),
430421
);
431422
});
432423

433424
it.skip("should search a range correctly and not find records where none exist", async () => {
434-
const records = await connection.findUnspentRecords(
435-
0,
436-
204,
437-
[],
438-
undefined,
439-
undefined,
440-
[],
441-
beaconPrivateKeyString,
442-
);
425+
const records = await connection.findUnspentRecords({
426+
startHeight: 0,
427+
endHeight: 204,
428+
programs: [],
429+
nonces: [],
430+
privateKey: beaconPrivateKeyString,
431+
});
443432
expect(Array.isArray(records)).equal(true);
444433
if (!(records instanceof Error)) {
445434
expect(records.length).equal(0);

0 commit comments

Comments
 (0)