Skip to content

Commit

Permalink
Add simple test to use new SDK to add Oracle plugin (#125)
Browse files Browse the repository at this point in the history
  • Loading branch information
danenbm authored May 13, 2024
1 parent e2ff79b commit d3ed53e
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions clients/js/test/externalPlugins/oracle.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit d3ed53e

Please sign in to comment.