Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integration test for singlesig delegate identifier #157

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions examples/integration-scripts/singlesig-dip.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import { CreateIdentiferArgs, SignifyClient } from 'signify-ts';
import {
getOrCreateClients,
getOrCreateContact,
getOrCreateIdentifier,
} from './utils/test-setup';
import { waitOperation } from './utils/test-util';
import { resolveEnvironment } from './utils/resolve-env';

let client1: SignifyClient, client2: SignifyClient;
let name1_id: string, name1_oobi: string;
let contact1_id: string;

Check warning on line 12 in examples/integration-scripts/singlesig-dip.test.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 18.12.1 and macOS-latest

'contact1_id' is assigned a value but never used

Check warning on line 12 in examples/integration-scripts/singlesig-dip.test.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 18.12.1 and ubuntu-latest

'contact1_id' is assigned a value but never used

beforeAll(async () => {
[client1, client2] = await getOrCreateClients(2);
});
beforeAll(async () => {
[name1_id, name1_oobi] = await getOrCreateIdentifier(client1, 'name1');
});
beforeAll(async () => {
contact1_id = await getOrCreateContact(client2, 'contact1', name1_oobi);
});

describe('singlesig-dip', () => {
test('delegate1a', async () => {
// delegate creates identifier without witnesses
let kargs: CreateIdentiferArgs = {

Check warning on line 27 in examples/integration-scripts/singlesig-dip.test.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 18.12.1 and macOS-latest

'kargs' is never reassigned. Use 'const' instead

Check warning on line 27 in examples/integration-scripts/singlesig-dip.test.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 18.12.1 and ubuntu-latest

'kargs' is never reassigned. Use 'const' instead
delpre: name1_id,
};
let result = await client2.identifiers().create('delegate1', kargs);

Check warning on line 30 in examples/integration-scripts/singlesig-dip.test.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 18.12.1 and macOS-latest

'result' is never reassigned. Use 'const' instead

Check warning on line 30 in examples/integration-scripts/singlesig-dip.test.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 18.12.1 and ubuntu-latest

'result' is never reassigned. Use 'const' instead
let op = await result.op();

Check warning on line 31 in examples/integration-scripts/singlesig-dip.test.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 18.12.1 and macOS-latest

'op' is never reassigned. Use 'const' instead

Check warning on line 31 in examples/integration-scripts/singlesig-dip.test.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 18.12.1 and ubuntu-latest

'op' is never reassigned. Use 'const' instead
let delegate1 = await client2.identifiers().get('delegate1');

Check warning on line 32 in examples/integration-scripts/singlesig-dip.test.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 18.12.1 and macOS-latest

'delegate1' is never reassigned. Use 'const' instead

Check warning on line 32 in examples/integration-scripts/singlesig-dip.test.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 18.12.1 and ubuntu-latest

'delegate1' is never reassigned. Use 'const' instead
expect(op.name).toEqual(`delegation.${delegate1.prefix}`);
});
test('delegator1', async () => {
// delegator approves delegate
let delegate1 = await client2.identifiers().get('delegate1');
let seal = {
i: delegate1.prefix,
s: '0',
d: delegate1.prefix,
};
let result = await client1.identifiers().interact('name1', seal);
let op = waitOperation(client1, await result.op());
});
test('delegate1b', async () => {
// delegate waits for completion
let delegate1 = await client2.identifiers().get('delegate1');
let op: any = { name: `delegation.${delegate1.prefix}` };
op = await waitOperation(client2, op);
expect(delegate1.prefix).toEqual(op.response.i);
});
test('delegate2a', async () => {
// delegate creates identifier with default witness config
let env = resolveEnvironment();
let kargs: CreateIdentiferArgs = {
delpre: name1_id,
toad: env.witnessIds.length,
wits: env.witnessIds,
};
let result = await client2.identifiers().create('delegate2', kargs);
let op = await result.op();
let delegate2 = await client2.identifiers().get('delegate2');
expect(op.name).toEqual(`delegation.${delegate2.prefix}`);
});
test('delegator2', async () => {
// delegator approves delegate
let delegate2 = await client2.identifiers().get('delegate2');
let seal = {
i: delegate2.prefix,
s: '0',
d: delegate2.prefix,
};
let result = await client1.identifiers().interact('name1', seal);
let op = waitOperation(client1, await result.op());
});
test('delegate2b', async () => {
// delegate waits for completion
let delegate2 = await client2.identifiers().get('delegate2');
let op: any = { name: `delegation.${delegate2.prefix}` };
op = await waitOperation(client2, op);
expect(delegate2.prefix).toEqual(op.response.i);
});
});
Loading