Skip to content

Commit

Permalink
adds vdring/registry tests
Browse files Browse the repository at this point in the history
Signed-off-by: Kevin Griffin <[email protected]>
  • Loading branch information
m00sey committed Sep 29, 2023
1 parent 585678c commit e5bb3b3
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/keri/core/vdring.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace vdr {

export interface VDRInceptArgs {
pre: string,
toad: string | number | undefined
toad?: string | number | undefined
nonce?: string,
baks?: string[],
cnfg?: string[],
Expand All @@ -35,9 +35,11 @@ namespace vdr {

let _toad: number
if (toad === undefined) {
console.log("toad undefined");
if (baks.length === 0) {
_toad = 0
} else {
console.log("testing ample");
_toad = ample(baks.length);
}
} else {
Expand Down
22 changes: 22 additions & 0 deletions test/core/vdring.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,26 @@ describe('vdr', () => {
message: 'Invalid toad 1 for no baks',
});
});

it('should allow optional toad and no backers', async () => {
await libsodium.ready;
let actual = vdr.incept({ pre: "ECJIoBpEcCWMzvquk861dXP8JJZ-vbmJczlDR-NYcE3g", nonce: "AHSNDV3ABI6U8OIgKaj3aky91ZpNL54I5_7-qwtC6q2s" });

assert.equal(actual.pre, "EDAsrwU75uoh8sii7w-KN-Txy2d0dhHiUP34TQVBJiPS");
assert.equal(actual.code, "E");
assert.equal(actual.raw,
'{"v":"KERI10JSON00010f_","t":"vcp","d":"EDAsrwU75uoh8sii7w-KN-Txy2d0dhHiUP34TQVBJiPS","i":"EDAsrwU75uoh8sii7w-KN-Txy2d0dhHiUP34TQVBJiPS","ii":"ECJIoBpEcCWMzvquk861dXP8JJZ-vbmJczlDR-NYcE3g","s":"0","c":[],"bt":"0","b":[],"n":"AHSNDV3ABI6U8OIgKaj3aky91ZpNL54I5_7-qwtC6q2s"}');
assert.equal(actual.size, 271);
});

it('should allow optional toad and backers', async () => {
await libsodium.ready;
let actual = vdr.incept({ pre: "ECJIoBpEcCWMzvquk861dXP8JJZ-vbmJczlDR-NYcE3g", nonce: "AHSNDV3ABI6U8OIgKaj3aky91ZpNL54I5_7-qwtC6q2s", baks: ["a backer"]});

assert.equal(actual.pre, "ELdKGV_ojDYC47GVHBRakgib5LJQLKcA72oAMUF5Jsou");
assert.equal(actual.code, "E");
assert.equal(actual.raw,
'{"v":"KERI10JSON000119_","t":"vcp","d":"ELdKGV_ojDYC47GVHBRakgib5LJQLKcA72oAMUF5Jsou","i":"ELdKGV_ojDYC47GVHBRakgib5LJQLKcA72oAMUF5Jsou","ii":"ECJIoBpEcCWMzvquk861dXP8JJZ-vbmJczlDR-NYcE3g","s":"0","c":[],"bt":"0","b":["a backer"],"n":"AHSNDV3ABI6U8OIgKaj3aky91ZpNL54I5_7-qwtC6q2s"}');
assert.equal(actual.size, 281);
});
});

0 comments on commit e5bb3b3

Please sign in to comment.