Skip to content

Commit

Permalink
add test for authority reassignment of freeze
Browse files Browse the repository at this point in the history
  • Loading branch information
nhanphan committed Mar 13, 2024
1 parent e3aa643 commit 088d42f
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions clients/js/test/plugins/asset/freeze.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
addPlugin,
approvePluginAuthority,
authority,
getPubkeyAuthority,
plugin,
pluginAuthorityPair,
revokePluginAuthority,
Expand Down Expand Up @@ -119,3 +120,55 @@ test('owner cannot undelegate a freeze plugin with a delegate', async (t) => {

await t.throwsAsync(result, { name: 'InvalidAuthority' });
});

test('owner cannot approve to reassign authority back to owner if frozen', async (t) => {
// Given a Umi instance and a new signer.
const umi = await createUmi();
const delegateAddress = generateSigner(umi);

const asset = await createAsset(umi, {
plugins: [pluginAuthorityPair({ type: 'Freeze', data: { frozen: true } })],
});

await approvePluginAuthority(umi, {
asset: asset.publicKey,
pluginType: PluginType.Freeze,
newAuthority: getPubkeyAuthority(delegateAddress.publicKey),
}).sendAndConfirm(umi);

await assertAsset(t, umi, {
...DEFAULT_ASSET,
asset: asset.publicKey,
owner: umi.identity.publicKey,
updateAuthority: updateAuthority('Address', [umi.identity.publicKey]),
freeze: {
authority: {
type: 'Pubkey',
address: delegateAddress.publicKey,
},
frozen: true,
},
});

const result = approvePluginAuthority(umi, {
asset: asset.publicKey,
pluginType: PluginType.Freeze,
newAuthority: authority('Owner'),
}).sendAndConfirm(umi);

await t.throwsAsync(result, { name: 'InvalidAuthority' });

await assertAsset(t, umi, {
...DEFAULT_ASSET,
asset: asset.publicKey,
owner: umi.identity.publicKey,
updateAuthority: updateAuthority('Address', [umi.identity.publicKey]),
freeze: {
authority: {
type: 'Pubkey',
address: delegateAddress.publicKey,
},
frozen: true,
},
});
});

0 comments on commit 088d42f

Please sign in to comment.