From 5ea696915d27e5f351a098d16e9f76a0d516777d Mon Sep 17 00:00:00 2001 From: huianyang Date: Fri, 29 Sep 2023 16:43:55 -0400 Subject: [PATCH] test: fixing oxfordbox failing_noop tests --- .../contract-failing-noop.spec.ts | 22 +++++++++++-------- integration-tests/wallet-failing-noop.spec.ts | 22 +++++++++++-------- 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/integration-tests/contract-failing-noop.spec.ts b/integration-tests/contract-failing-noop.spec.ts index b3b2b78e16..48a20d9c45 100644 --- a/integration-tests/contract-failing-noop.spec.ts +++ b/integration-tests/contract-failing-noop.spec.ts @@ -1,20 +1,22 @@ import { InMemorySigner } from "@taquito/signer"; -import { CONFIGS, defaultSecretKey } from "./config"; +import { CONFIGS, defaultSecretKey, isSandbox } from "./config"; import { OpKind, TezosToolkit } from "@taquito/taquito"; import { verifySignature } from "@taquito/utils"; -CONFIGS().forEach(({ setup }) => { - let rpc = 'https://mainnet-archive.ecadinfra.com/' - const Tezos = new TezosToolkit(rpc); - Tezos.setSignerProvider(new InMemorySigner(defaultSecretKey.secret_key)); +CONFIGS().forEach(({ setup, rpc, lib }) => { + const testnet = isSandbox({ rpc }) ? it.skip : it; + let Tezos: TezosToolkit + let signer = new InMemorySigner(defaultSecretKey.secret_key) - describe(`Test failing_noop through contract api, based on head, and secret_key using: ${rpc}`, () => { - beforeEach(async (done) => { + describe(`Test failing_noop through contract api, based on head, and secret_key`, () => { + beforeAll(async (done) => { await setup(); + Tezos = new TezosToolkit('https://mainnet-archive.ecadinfra.com/'); + Tezos.setSignerProvider(signer); done(); }); - it('Verify that the contract.failingNoop result is as expected when the block and secret key are kept constant', async (done) => { + testnet('Verify that the contract.failingNoop result is as expected when the block and secret key are kept constant', async (done) => { const signed = await Tezos.contract.failingNoop({ arbitrary: "48656C6C6F20576F726C64", // Hello World basedOnBlock: 0, @@ -36,8 +38,10 @@ CONFIGS().forEach(({ setup }) => { }); describe(`Test failing_noop through contract api using: ${rpc}`, () => { - beforeEach(async (done) => { + beforeAll(async (done) => { await setup(); + Tezos = lib + Tezos.setSignerProvider(signer); done(); }); diff --git a/integration-tests/wallet-failing-noop.spec.ts b/integration-tests/wallet-failing-noop.spec.ts index c4ee77dc2b..a5c0eabf18 100644 --- a/integration-tests/wallet-failing-noop.spec.ts +++ b/integration-tests/wallet-failing-noop.spec.ts @@ -1,20 +1,22 @@ import { InMemorySigner } from "@taquito/signer"; -import { CONFIGS, defaultSecretKey } from "./config"; +import { CONFIGS, defaultSecretKey, isSandbox } from "./config"; import { OpKind, TezosToolkit } from "@taquito/taquito"; import { verifySignature } from "@taquito/utils"; -CONFIGS().forEach(({ setup }) => { - let rpc = 'https://mainnet-archive.ecadinfra.com/' - const Tezos = new TezosToolkit(rpc); - Tezos.setSignerProvider(new InMemorySigner(defaultSecretKey.secret_key)); +CONFIGS().forEach(({ setup, rpc, lib }) => { + const testnet = isSandbox({ rpc }) ? it.skip : it; + let Tezos: TezosToolkit + let signer = new InMemorySigner(defaultSecretKey.secret_key) - describe(`Test failing_noop through wallet api, based on head, and secret_key using: ${rpc}`, () => { - beforeEach(async (done) => { + describe(`Test failing_noop through wallet api, based on head, and secret_key`, () => { + beforeAll(async (done) => { await setup(); + Tezos = new TezosToolkit('https://mainnet-archive.ecadinfra.com/'); + Tezos.setSignerProvider(signer); done(); }); - it('Verify that the wallet.signFailingNoop result is as expected when the block and private key are kept constant', async done => { + testnet('Verify that the wallet.signFailingNoop result is as expected when the block and private key are kept constant', async done => { const signed = await Tezos.wallet.signFailingNoop({ arbitrary: "48656C6C6F20576F726C64", // Hello World basedOnBlock: 0, @@ -37,8 +39,10 @@ CONFIGS().forEach(({ setup }) => { }); describe(`Test failing_noop through wallet api using: ${rpc}`, () => { - beforeEach(async (done) => { + beforeAll(async (done) => { await setup(); + Tezos = lib; + Tezos.setSignerProvider(signer); done(); });