Add a method for get authorities and update tests #18

Merged
nabarun merged 7 commits from deep-stack/registry-sdk:iv-get-authorities into main 2024-08-05 07:53:14 +00:00
3 changed files with 31 additions and 16 deletions
Showing only changes of commit 37c2f5897f - Show all commits

View File

@ -61,6 +61,9 @@ const nameserviceExpiryTests = () => {
test('Wait for expiry duration', (done) => {
setTimeout(done, 60 * 1000);
// Wait some more time for block to be executed
setTimeout(done, 3 * 1000);
});
test('Check record expiry time', async () => {
@ -85,6 +88,9 @@ const nameserviceExpiryTests = () => {
test('Wait for expiry duration', (done) => {
setTimeout(done, 60 * 1000);
// Wait some more time for block to be executed
setTimeout(done, 3 * 1000);
});
test('Check record deleted without bond balance', async () => {

View File

@ -31,7 +31,7 @@ const namingTests = () => {
};
}[] = [];
let cosmosWallet: CosmosAccount;
let account: CosmosAccount;
beforeAll(async () => {
registry = new Registry(gqlEndpoint, rpcEndpoint, chainId);
@ -54,9 +54,8 @@ const namingTests = () => {
watcherId = result.id;
const account_pk = new Account(Buffer.from(privateKey, 'hex'));
const account = await DirectSecp256k1Wallet.fromKey(account_pk._privateKey, 'laconic');
[cosmosWallet] = await account.getAccounts();
const accountWallet = await DirectSecp256k1Wallet.fromKey(Buffer.from(privateKey, 'hex'), 'laconic');
[account] = await accountWallet.getAccounts();
const mnenonic1 = Account.generateMnemonic();
otherAccount1 = await Account.generateFromMnemonic(mnenonic1);
@ -70,7 +69,7 @@ const namingTests = () => {
reservedAuthorities.push({
name: authorityName,
entry: {
ownerAddress: cosmosWallet.address,
ownerAddress: account.address,
status: 'active'
}
});
@ -88,7 +87,7 @@ const namingTests = () => {
reservedAuthorities.push({
name: authorityName,
entry: {
ownerAddress: cosmosWallet.address,
ownerAddress: account.address,
status: 'active'
}
});
@ -119,7 +118,7 @@ const namingTests = () => {
reservedAuthorities.push({
name: subAuthority,
entry: {
ownerAddress: cosmosWallet.address,
ownerAddress: account.address,
status: 'active'
}
});
@ -169,17 +168,28 @@ const namingTests = () => {
});
test('List authorities.', async () => {
const authorities = await registry.getAuthorities();
const authorities = await registry.getAuthorities(undefined, true);
reservedAuthorities.sort((a, b) => a.name.localeCompare(b.name));
const expectedEntryKeys = [
'ownerAddress',
'ownerPublicKey',
'height',
'status',
'bondId',
'expiryTime',
'auction'
];
expect(authorities.length).toEqual(4);
authorities.forEach((authority: any, index: number) => {
expectedEntryKeys.forEach(key => {
authorities.forEach((authority: any) => {
expect(authority.entry).toHaveProperty(key);
});
});
authorities.forEach((authority: any, index: number) => {
expect(authority).toHaveProperty('name');
expect(authority.entry).toHaveProperty('ownerAddress');
expect(authority.entry).toHaveProperty('status');
});
expect(authority).toMatchObject(reservedAuthorities[index]);
});
});

View File

@ -25,9 +25,8 @@ const onboardingEnabledTests = () => {
const mnemonic = Account.generateMnemonic();
ethWallet = Wallet.fromMnemonic(mnemonic);
const account = new Account(Buffer.from(privateKey, 'hex'));
const cosmosAccount = await DirectSecp256k1Wallet.fromKey(account._privateKey, 'laconic');
[cosmosWallet] = await cosmosAccount.getAccounts();
const accountWallet = await DirectSecp256k1Wallet.fromKey(Buffer.from(privateKey, 'hex'), 'laconic');
[cosmosWallet] = await accountWallet.getAccounts();
expectedParticipants = [
{