From 6f9d037e58a02b020fe1718ce8dd2dd7e0eef598 Mon Sep 17 00:00:00 2001 From: Nhan Phan Date: Fri, 14 Jun 2024 13:36:20 -0700 Subject: [PATCH] add minor collect test --- clients/js/test/collect.test.ts | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/clients/js/test/collect.test.ts b/clients/js/test/collect.test.ts index 863ab495..d1d89679 100644 --- a/clients/js/test/collect.test.ts +++ b/clients/js/test/collect.test.ts @@ -1,6 +1,7 @@ import { PublicKey, Umi, + generateSigner, publicKey, sol, subtractAmounts, @@ -15,8 +16,9 @@ import { createPlugin, pluginAuthorityPair, removePluginV1, + transfer, } from '../src'; -import { createAsset, createUmi } from './_setupRaw'; +import { assertAsset, createAsset, createUmi } from './_setupRaw'; const recipient1 = publicKey('8AT6o8Qk5T9QnZvPThMrF9bcCQLTGkyGvVZZzHgCw11v'); const recipient2 = publicKey('MmHsqX4LxTfifxoH8BVRLUKrwDn1LPCac6YcCZTHhwt'); @@ -200,3 +202,28 @@ test.serial('it can collect multiple assets at once', async (t) => { t.deepEqual(subtractAmounts(balEnd1, balStart1), sol((0.0015 / 2) * 3)); t.deepEqual(subtractAmounts(balEnd2, balStart2), sol((0.0015 / 2) * 3)); }); + +test('it can transfer after collecting', async (t) => { + const umi = await createUmi(); + const asset = await createAsset(umi); + await collect(umi, {}) + .addRemainingAccounts({ + isSigner: false, + isWritable: true, + pubkey: asset.publicKey, + }) + .sendAndConfirm(umi); + t.is(await hasCollectAmount(umi, asset.publicKey), false); + const newOwner = generateSigner(umi); + + await transfer(umi, { + asset, + newOwner: newOwner.publicKey, + }).sendAndConfirm(umi); + + await assertAsset(t, umi, { + asset: asset.publicKey, + owner: newOwner.publicKey, + updateAuthority: { type: 'Address', address: umi.identity.publicKey }, + }); +});