diff --git a/clients/js/test/externalPlugins/oracle.test.ts b/clients/js/test/externalPlugins/oracle.test.ts index be1fd6ed..faa348ae 100644 --- a/clients/js/test/externalPlugins/oracle.test.ts +++ b/clients/js/test/externalPlugins/oracle.test.ts @@ -2390,7 +2390,7 @@ test('it can update oracle to different size external plugin', async (t) => { }); }); -test('create fails but does not panic when oracle account does not exist', async (t) => { +test('it create fails but does not panic when oracle account does not exist', async (t) => { const umi = await createUmi(); const oracleSigner = generateSigner(umi); @@ -2419,7 +2419,7 @@ test('create fails but does not panic when oracle account does not exist', async await t.throwsAsync(result, { name: 'InvalidOracleAccountData' }); }); -test('transfer fails but does not panic when oracle account does not exist', async (t) => { +test('it transfer fails but does not panic when oracle account does not exist', async (t) => { const umi = await createUmi(); const oracleSigner = generateSigner(umi); @@ -2469,7 +2469,7 @@ test('transfer fails but does not panic when oracle account does not exist', asy await t.throwsAsync(result, { name: 'InvalidOracleAccountData' }); }); -test('transfer fails but does not panic when oracle account is too small', async (t) => { +test('it transfer fails but does not panic when oracle account is too small', async (t) => { const umi = await createUmi(); const newAccount = generateSigner(umi); @@ -2526,3 +2526,61 @@ test('transfer fails but does not panic when oracle account is too small', async await t.throwsAsync(result, { name: 'InvalidOracleAccountData' }); }); + +test('it empty account does not default to valid oracle', async (t) => { + const umi = await createUmi(); + const newAccount = generateSigner(umi); + + // Create an invalid oracle account that is an account with 42 bytes. + await createAccount(umi, { + newAccount, + lamports: sol(0.1), + space: 42, + programId: umi.programs.get('mplCore').publicKey, + }).sendAndConfirm(umi); + + const asset = await createAsset(umi, { + plugins: [ + { + type: 'Oracle', + resultsOffset: { + type: 'NoOffset', + }, + lifecycleChecks: { + transfer: [CheckResult.CAN_REJECT], + }, + baseAddress: newAccount.publicKey, + }, + ], + }); + + await assertAsset(t, umi, { + ...DEFAULT_ASSET, + asset: asset.publicKey, + owner: umi.identity.publicKey, + oracles: [ + { + type: 'Oracle', + resultsOffset: { + type: 'NoOffset', + }, + authority: { + type: 'UpdateAuthority', + }, + baseAddress: newAccount.publicKey, + lifecycleChecks: { + transfer: [CheckResult.CAN_REJECT], + }, + pda: undefined, + }, + ], + }); + + const newOwner = generateSigner(umi); + const result = transfer(umi, { + asset, + newOwner: newOwner.publicKey, + }).sendAndConfirm(umi); + + await t.throwsAsync(result, { name: 'UninitializedOracleAccount' }); +});