From d3ed53ee3f6588214002e90b4d139ded626974a1 Mon Sep 17 00:00:00 2001 From: Michael Danenberg <56533526+danenbm@users.noreply.github.com> Date: Mon, 13 May 2024 11:14:59 -0700 Subject: [PATCH] Add simple test to use new SDK to add Oracle plugin (#125) --- .../js/test/externalPlugins/oracle.test.ts | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/clients/js/test/externalPlugins/oracle.test.ts b/clients/js/test/externalPlugins/oracle.test.ts index 0c7f189d..bee3e1fa 100644 --- a/clients/js/test/externalPlugins/oracle.test.ts +++ b/clients/js/test/externalPlugins/oracle.test.ts @@ -343,6 +343,58 @@ test('it cannot create asset with oracle that has no lifecycle checks', async (t await t.throwsAsync(result, { name: 'RequiresLifecycleCheck' }); }); +test('it can add oracle that can reject to asset', async (t) => { + const umi = await createUmi(); + const account = generateSigner(umi); + const owner = generateSigner(umi); + + const asset = await createAsset(umi, { + owner, + }); + + await assertAsset(t, umi, { + ...DEFAULT_ASSET, + asset: asset.publicKey, + owner: owner.publicKey, + }); + + await addPlugin(umi, { + asset: asset.publicKey, + plugin: { + type: 'Oracle', + resultsOffset: { + type: 'Anchor', + }, + lifecycleChecks: { + transfer: [CheckResult.CAN_REJECT], + }, + baseAddress: account.publicKey, + }, + }).sendAndConfirm(umi); + + await assertAsset(t, umi, { + ...DEFAULT_ASSET, + asset: asset.publicKey, + owner: owner.publicKey, + oracles: [ + { + type: 'Oracle', + resultsOffset: { + type: 'Anchor', + }, + authority: { + type: 'UpdateAuthority', + }, + baseAddress: account.publicKey, + lifecycleChecks: { + transfer: [CheckResult.CAN_REJECT], + }, + baseAddressConfig: undefined, + }, + ], + }); +}); + test('it cannot add oracle with no lifecycle checks to asset', async (t) => { const umi = await createUmi(); const account = generateSigner(umi);