solana.js: fix test assertions

This commit is contained in:
Conner Gallagher 2023-01-12 15:21:08 -07:00
parent 0dc77a0bed
commit 60fa887a69
5 changed files with 28 additions and 47 deletions

View File

@ -12,6 +12,7 @@ const ignoreFiles = [
'./src/generated/types/SwitchboardDecimal.ts', // added toBig methods
'./src/generated/types/Lanes.ts', // anchor-client-gen struggles with dual exports
'./src/generated/types/index.ts', // TODO: Need a better way to handle this. anchor-client-gen adds multiple, broken exports (for VRF builder)
'./src/generated/errors/index.ts', // need to revert the program ID check
];
/**

View File

@ -1,3 +1,4 @@
import { SBV2_DEVNET_PID, SBV2_MAINNET_PID } from '../../SwitchboardProgram';
import { PROGRAM_ID } from '../programId';
import * as anchor from './anchor';
import * as custom from './custom';
@ -45,7 +46,10 @@ export function fromTxError(
}
const [programIdRaw, codeRaw] = firstMatch.slice(1);
if (programIdRaw !== PROGRAM_ID.toString()) {
if (
programIdRaw !== SBV2_DEVNET_PID.toString() &&
programIdRaw !== SBV2_MAINNET_PID.toString()
) {
return null;
}

View File

@ -137,13 +137,9 @@ describe('Crank Tests', () => {
// queueAuthority,
});
await assert.rejects(
async () => {
await crankAccount.push({ aggregatorAccount: newAggregatorAccount });
},
new RegExp(/custom program error: 0x1793/g)
// { code: 6035 } // PermissionDenied
);
await assert.rejects(async () => {
await crankAccount.push({ aggregatorAccount: newAggregatorAccount });
}, new RegExp(/PermissionDenied|6035|0x1793/g));
});
it('Fails to push a new aggregator onto a full crank', async () => {
@ -152,13 +148,9 @@ describe('Crank Tests', () => {
queueAuthority,
});
await assert.rejects(
async () => {
await crankAccount.push({ aggregatorAccount: newAggregatorAccount });
},
new RegExp(/custom program error: 0x1786/g)
// { code: 6022 } // CrankMaxCapacityError
);
await assert.rejects(async () => {
await crankAccount.push({ aggregatorAccount: newAggregatorAccount });
}, new RegExp(/CrankMaxCapacityError|6022|0x1786/g));
});
it('Crank pop tests', async () => {

View File

@ -114,13 +114,9 @@ describe('Open Round Tests', () => {
});
it('fails to call open round when aggregator lacks permissions', async () => {
await assert.rejects(
async () => {
await aggregatorAccount.openRound();
},
new RegExp(/custom program error: 0x1793/g)
// { code: 6035 } // PermissionDenied
);
await assert.rejects(async () => {
await aggregatorAccount.openRound();
}, new RegExp(/PermissionDenied|6035|0x1793/g));
});
it('sets aggregator permissions', async () => {
@ -140,23 +136,15 @@ describe('Open Round Tests', () => {
});
it('fails to call open round when not enough oracles are heartbeating', async () => {
await assert.rejects(
async () => {
await aggregatorAccount.openRound();
},
new RegExp(/custom program error: 0x17a4/g)
// { code: 6052 } // InsufficientOracleQueueError
);
await assert.rejects(async () => {
await aggregatorAccount.openRound();
}, new RegExp(/InsufficientOracleQueueError|6052|0x17a4/g));
// still fails when queueSize < batchSize
await oracleAccount1.heartbeat();
await assert.rejects(
async () => {
await aggregatorAccount.openRound();
},
new RegExp(/custom program error: 0x17a4/g)
// { code: 6052 } // InsufficientOracleQueueError
);
await assert.rejects(async () => {
await aggregatorAccount.openRound();
}, new RegExp(/InsufficientOracleQueueError|6052|0x17a4/g));
});
it('successfully calls open round', async () => {

View File

@ -121,17 +121,13 @@ describe('Queue Tests', () => {
const oracle = await oracleAccount.loadData();
await assert.rejects(
async () => {
await oracleAccount.heartbeat({
queueAccount,
tokenWallet: oracle.tokenAccount,
authority: oracleAuthority,
});
},
new RegExp(/custom program error: 0x1771/g)
// { code: 6001 } // QueueOperationError
);
await assert.rejects(async () => {
await oracleAccount.heartbeat({
queueAccount,
tokenWallet: oracle.tokenAccount,
authority: oracleAuthority,
});
}, new RegExp(/QueueOperationError|6001|0x1771/g));
});
it('Deposits into an oracle staking wallet', async () => {