Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add simple test to use new SDK to add Oracle plugin #125

Merged
merged 1 commit into from
May 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading