Add test
This commit is contained in:
parent
a863916033
commit
e579ed6654
|
@ -68,7 +68,7 @@ describe('Aggregator Tests', () => {
|
||||||
jobAccount = jobAccount1;
|
jobAccount = jobAccount1;
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Adds and removes a job from an aggregator', async () => {
|
it("Adds job, updates it's weight, then removes it from aggregator", async () => {
|
||||||
const aggregatorKeypair = Keypair.generate();
|
const aggregatorKeypair = Keypair.generate();
|
||||||
const aggregatorAuthority = Keypair.generate();
|
const aggregatorAuthority = Keypair.generate();
|
||||||
|
|
||||||
|
@ -94,14 +94,10 @@ describe('Aggregator Tests', () => {
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
const [jobAccount] = await JobAccount.create(
|
const [jobAccount] = await JobAccount.create(ctx.program, {
|
||||||
ctx.program,
|
data: OracleJob.encodeDelimited(oracleJob).finish(),
|
||||||
|
name: 'Job1',
|
||||||
{
|
});
|
||||||
data: OracleJob.encodeDelimited(oracleJob).finish(),
|
|
||||||
name: 'Job1',
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
await aggregatorAccount.addJob({
|
await aggregatorAccount.addJob({
|
||||||
job: jobAccount,
|
job: jobAccount,
|
||||||
|
@ -117,6 +113,17 @@ describe('Aggregator Tests', () => {
|
||||||
throw new Error(`Failed to add job to aggregator`);
|
throw new Error(`Failed to add job to aggregator`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await aggregatorAccount.updateJobWeight({
|
||||||
|
job: jobAccount,
|
||||||
|
jobIdx: jobIdx,
|
||||||
|
weight: 2,
|
||||||
|
authority: aggregatorAuthority,
|
||||||
|
});
|
||||||
|
const postUpdateWeightAggregatorState = await aggregatorAccount.loadData();
|
||||||
|
if (postUpdateWeightAggregatorState.jobWeights[0] !== 2) {
|
||||||
|
throw new Error(`Failed to update job weight in aggregator`);
|
||||||
|
}
|
||||||
|
|
||||||
await aggregatorAccount.removeJob({
|
await aggregatorAccount.removeJob({
|
||||||
job: jobAccount,
|
job: jobAccount,
|
||||||
jobIdx: jobIdx,
|
jobIdx: jobIdx,
|
||||||
|
|
Loading…
Reference in New Issue