Check for properties in returned authorities list

This commit is contained in:
IshaVenikar 2024-08-02 15:40:27 +05:30
parent 225aa2a6aa
commit 37c2f5897f
3 changed files with 31 additions and 16 deletions

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 = [
{