From 05765a72cbc964a45ef54263c7188351afe7e6b4 Mon Sep 17 00:00:00 2001 From: Michael Danenberg <56533526+danenbm@users.noreply.github.com> Date: Fri, 8 Mar 2024 13:30:21 -0800 Subject: [PATCH] Fix JS tests --- clients/js/test/compress.test.ts | 7 +++-- clients/js/test/create.test.ts | 44 +++++++++++++++--------------- clients/js/test/decompress.test.ts | 7 +++-- clients/js/test/info.test.ts | 12 ++++++-- 4 files changed, 39 insertions(+), 31 deletions(-) diff --git a/clients/js/test/compress.test.ts b/clients/js/test/compress.test.ts index 4a3b3c51..23d6380c 100644 --- a/clients/js/test/compress.test.ts +++ b/clients/js/test/compress.test.ts @@ -1,4 +1,4 @@ -import { generateSigner } from '@metaplex-foundation/umi'; +import { generateSigner, publicKey } from '@metaplex-foundation/umi'; import test from 'ava'; import { Asset, @@ -44,7 +44,8 @@ test('it can compress an asset without any plugins as the owner', async (t) => { // And when we compress the asset. await compress(umi, { asset: assetAddress.publicKey, - owner: umi.identity, + authority: umi.identity, + logWrapper: publicKey('noopb9bkMVfRPU8AsbpTUg8AQkHtKwMYZiFUjNRtMmV'), }).sendAndConfirm(umi); // console.log('Compress signature: ', bs58.encode(tx.signature)); @@ -92,7 +93,7 @@ test('it cannot compress an asset if not the owner', async (t) => { const result = compress(umi, { asset: assetAddress.publicKey, - owner: attacker, + authority: attacker, }).sendAndConfirm(umi); await t.throwsAsync(result, { name: 'InvalidAuthority' }); diff --git a/clients/js/test/create.test.ts b/clients/js/test/create.test.ts index 5b601ee7..69e45f02 100644 --- a/clients/js/test/create.test.ts +++ b/clients/js/test/create.test.ts @@ -9,8 +9,6 @@ import { create, fetchAsset, fetchAssetWithPlugins, - fetchHashedAsset, - getAssetAccountDataSerializer, updateAuthority, } from '../src'; import { createUmi } from './_setup'; @@ -76,7 +74,7 @@ test('it can create a new asset in ledger state', async (t) => { const assetAddress = generateSigner(umi); // When we create a new account. - const txResult = await create(umi, { + const result = create(umi, { dataState: DataState.LedgerState, asset: assetAddress, name: 'Test Bread', @@ -85,27 +83,29 @@ test('it can create a new asset in ledger state', async (t) => { plugins: [], }).sendAndConfirm(umi); + await t.throwsAsync(result, { name: 'NotImplemented' }); + // Then an account was created with the correct data. - const asset = await fetchHashedAsset(umi, assetAddress.publicKey); + //const asset = await fetchHashedAsset(umi, assetAddress.publicKey); // console.log(asset); - t.like(asset, { - publicKey: assetAddress.publicKey, - }); - - const tx = await umi.rpc.getTransaction(txResult.signature); - if (tx && tx.meta.innerInstructions) { - // console.log(tx.meta.innerInstructions[0].instructions); - const { data } = tx.meta.innerInstructions[0].instructions[0]; - // console.log(base58.deserialize(data)); - const parsed = getAssetAccountDataSerializer().deserialize(data)[0]; - // console.log("Ledger State:", parsed); - t.like(parsed, { - updateAuthority: updateAuthority('Address', [umi.identity.publicKey]), - owner: umi.identity.publicKey, - name: 'Test Bread', - uri: 'https://example.com/bread', - }); - } + // t.like(asset, { + // publicKey: assetAddress.publicKey, + // }); + + // const tx = await umi.rpc.getTransaction(txResult.signature); + // if (tx && tx.meta.innerInstructions) { + // // console.log(tx.meta.innerInstructions[0].instructions); + // const { data } = tx.meta.innerInstructions[0].instructions[0]; + // // console.log(base58.deserialize(data)); + // const parsed = getAssetAccountDataSerializer().deserialize(data)[0]; + // // console.log("Ledger State:", parsed); + // t.like(parsed, { + // updateAuthority: updateAuthority('Address', [umi.identity.publicKey]), + // owner: umi.identity.publicKey, + // name: 'Test Bread', + // uri: 'https://example.com/bread', + // }); + // } }); test('it can create a new asset in account state with plugins', async (t) => { diff --git a/clients/js/test/decompress.test.ts b/clients/js/test/decompress.test.ts index 6b800948..c3c3f951 100644 --- a/clients/js/test/decompress.test.ts +++ b/clients/js/test/decompress.test.ts @@ -1,4 +1,4 @@ -import { generateSigner } from '@metaplex-foundation/umi'; +import { generateSigner, publicKey } from '@metaplex-foundation/umi'; import test from 'ava'; import { Asset, @@ -44,7 +44,8 @@ test('it can decompress a previously compressed asset as the owner', async (t) = // And when we compress the asset. await compress(umi, { asset: assetAddress.publicKey, - owner: umi.identity, + authority: umi.identity, + logWrapper: publicKey('noopb9bkMVfRPU8AsbpTUg8AQkHtKwMYZiFUjNRtMmV'), }).sendAndConfirm(umi); // And the asset is now compressed as a hashed asset. @@ -67,7 +68,7 @@ test('it can decompress a previously compressed asset as the owner', async (t) = // And when we decompress the asset. await decompress(umi, { asset: assetAddress.publicKey, - owner: umi.identity, + authority: umi.identity, compressionProof: { updateAuthority: updateAuthority('Address', [umi.identity.publicKey]), owner: umi.identity.publicKey, diff --git a/clients/js/test/info.test.ts b/clients/js/test/info.test.ts index 9ae35975..11d61696 100644 --- a/clients/js/test/info.test.ts +++ b/clients/js/test/info.test.ts @@ -1,6 +1,6 @@ import { generateSigner, publicKey } from '@metaplex-foundation/umi'; import test from 'ava'; -import { DataState, create /* fetchAsset, fetchHashedAsset */ } from '../src'; +import { DataState, create, compress /* fetchAsset, fetchHashedAsset */ } from '../src'; import { createUmi } from './_setup'; test('fetch account info for account state', async (t) => { @@ -30,14 +30,14 @@ test('fetch account info for account state', async (t) => { t.pass(); }); -test('fetch account info for ledger state', async (t) => { +test('HELLO EHLO HLEOOO fetch account info for ledger state', async (t) => { // Given a Umi instance and a new signer. const umi = await createUmi(); const assetAddress = generateSigner(umi); // When we create a new account. await create(umi, { - dataState: DataState.LedgerState, + dataState: DataState.AccountState, asset: assetAddress, name: 'Test Bread', uri: 'https://example.com/bread', @@ -45,6 +45,12 @@ test('fetch account info for ledger state', async (t) => { plugins: [], }).sendAndConfirm(umi); + // And when we compress the asset. + await compress(umi, { + asset: assetAddress.publicKey, + logWrapper: publicKey('noopb9bkMVfRPU8AsbpTUg8AQkHtKwMYZiFUjNRtMmV'), + }).sendAndConfirm(umi); + // Print the size of the account. const account = await umi.rpc.getAccount(assetAddress.publicKey); if (account.exists) {