From 3dd5351022ac600cc0095394140235e28f44bd07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bla=C5=BE=20Hrastnik?= Date: Wed, 19 Jan 2022 16:54:43 +0900 Subject: [PATCH] Fix tests by using the new query format --- contracts/tests/ocr2.spec.ts | 39 +++++++++--------------------------- 1 file changed, 9 insertions(+), 30 deletions(-) diff --git a/contracts/tests/ocr2.spec.ts b/contracts/tests/ocr2.spec.ts index cd4b86a46..9bcd6cf75 100644 --- a/contracts/tests/ocr2.spec.ts +++ b/contracts/tests/ocr2.spec.ts @@ -637,14 +637,14 @@ describe('ocr2', async () => { assert.ok(account.leftoverPayments.len == 0); }); + const roundSchema = new Map([[Round, { kind: 'struct', fields: [ + ['roundId', 'u32'], + // ['slot', 'u64'], + // ['timestamp', 'u32'], + ['timestamp', 'u64'], + ['answer', [16]], // i128 + ]}]]); it('Can call query', async () => { - const roundSchema = new Map([[Round, { kind: 'struct', fields: [ - ['roundId', 'u32'], - // ['slot', 'u64'], - // ['timestamp', 'u32'], - ['timestamp', 'u64'], - ['answer', [16]], // i128 - ]}]]); let round = await query(transmissions.publicKey, Scope.LatestRoundData, roundSchema, Round); console.log(round); @@ -665,29 +665,8 @@ describe('ocr2', async () => { for (let i = 3; i < 15; i++) { await transmit(i, i, new BN(i)); - let buffer = Keypair.generate(); - await workspace.Store.rpc.query( - Scope.LatestRoundData, - { - accounts: { - feed: transmissions.publicKey, - buffer: buffer.publicKey, - }, - preInstructions: [ - SystemProgram.createAccount({ - fromPubkey: provider.wallet.publicKey, - newAccountPubkey: buffer.publicKey, - lamports: await provider.connection.getMinimumBalanceForRentExemption(256), - space: 256, - programId: workspace.Store.programId, - }) - ], - signers: [buffer] - } - ); - - let account = await workspace.Store.account.round.fetch(buffer.publicKey); - assert.ok(account.answer.toNumber() == i) + let round = await query(transmissions.publicKey, Scope.LatestRoundData, roundSchema, Round); + assert.ok(new BN(round.answer, 10, 'le').toNumber() == i) } });