Skip to content

Commit b29d9db

Browse files
committed
tests(integration): getMintAuthority and getMeltAuthority
1 parent e5af46a commit b29d9db

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

__tests__/integration/hathorwallet_facade.test.ts

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1736,6 +1736,57 @@ describe('sendManyOutputsTransaction', () => {
17361736
});
17371737
});
17381738

1739+
describe('authority utxo selection', () => {
1740+
afterEach(async () => {
1741+
await stopAllWallets();
1742+
await GenesisWalletHelper.clearListeners();
1743+
});
1744+
1745+
it('getMintAuthority', async () => {
1746+
// Setting up the custom token
1747+
const hWallet = await generateWalletHelper();
1748+
await GenesisWalletHelper.injectFunds(hWallet, await hWallet.getAddressAtIndex(0), 1);
1749+
const { hash: tokenUid } = await createTokenHelper(hWallet, 'Token to test', 'ATST', 100);
1750+
1751+
// Mark mint authority as selected_as_input
1752+
const [mintInput] = await hWallet.getMintAuthority(tokenUid, { many: false });
1753+
await hWallet.markUtxoSelected(mintInput.txId, mintInput.index, true);
1754+
1755+
// getMintAuthority should return even if the utxo is already selected_as_input
1756+
await expect(hWallet.getMintAuthority(tokenUid, { many: false })).resolves.toBe([mintInput]);
1757+
await expect(
1758+
hWallet.getMintAuthority(tokenUid, { many: false, only_available_utxos: false })
1759+
).resolves.toEqual([mintInput]);
1760+
1761+
// getMintAuthority should not return selected_as_input utxos if only_available_utxos is true
1762+
await expect(
1763+
hWallet.getMintAuthority(tokenUid, { many: false, only_available_utxos: true })
1764+
).resolves.toEqual([]);
1765+
});
1766+
1767+
it('getMeltAuthority', async () => {
1768+
// Setting up the custom token
1769+
const hWallet = await generateWalletHelper();
1770+
await GenesisWalletHelper.injectFunds(hWallet, await hWallet.getAddressAtIndex(0), 1);
1771+
const { hash: tokenUid } = await createTokenHelper(hWallet, 'Token to test', 'ATST', 100);
1772+
1773+
// Mark melt authority as selected_as_input
1774+
const [meltInput] = await hWallet.getMeltAuthority(tokenUid, { many: false });
1775+
await hWallet.markUtxoSelected(meltInput.txId, meltInput.index, true);
1776+
1777+
// getMeltAuthority should return even if the utxo is already selected_as_input
1778+
await expect(hWallet.getMeltAuthority(tokenUid, { many: false })).resolves.toBe([meltInput]);
1779+
await expect(
1780+
hWallet.getMeltAuthority(tokenUid, { many: false, only_available_utxos: false })
1781+
).resolves.toEqual([meltInput]);
1782+
1783+
// getMeltAuthority should not return selected_as_input utxos if only_available_utxos is true
1784+
await expect(
1785+
hWallet.getMeltAuthority(tokenUid, { many: false, only_available_utxos: true })
1786+
).resolves.toEqual([]);
1787+
});
1788+
});
1789+
17391790
describe('createNewToken', () => {
17401791
afterEach(async () => {
17411792
await stopAllWallets();

0 commit comments

Comments
 (0)