From d3cd1ffab6469954679a11aadc793edd8b8e67a5 Mon Sep 17 00:00:00 2001 From: Daniele Lisi <22307776+danielelisi@users.noreply.github.com> Date: Mon, 5 Dec 2022 16:54:46 -0800 Subject: [PATCH 1/2] Adapt integration tests to limanet box --- .github/workflows/main.yml | 50 ++++++++++++++++++- .../contract-drain-delegate-operation.spec.ts | 25 ++++++---- 2 files changed, 62 insertions(+), 13 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e832efe6e1..9cb1a012c4 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -59,7 +59,7 @@ jobs: version: 1.32.2 - run: npm -w integration-tests run test:${{ matrix.protocol }} -- --maxWorkers=8 - integration-tests-flextesa: + integration-tests-flextesa-kathmandu: runs-on: ubuntu-latest continue-on-error: true steps: @@ -70,7 +70,7 @@ jobs: - run: docker run --rm --name my-sandbox --detach -p 20000:20000 -e block_time=1 oxheadalpha/flextesa:latest kathmandubox start - run: npm ci - run: npm run build - - run: npm -w integration-tests run test:originate-known-contracts && npm -w integration-tests run test:kathmandunet-secret-key -- --testPathIgnorePatterns ledger-signer-failing-tests.spec.ts ledger-signer.spec.ts contract-estimation-tests.spec.ts rpc-get-protocol-constants.spec.ts + - run: npm -w integration-tests run test:originate-known-contracts && npm -w integration-tests run test:kathmandunet-secret-key -- --testPathIgnorePatterns contract-drain-delegate-operation.spec.ts ledger-signer-failing-tests.spec.ts ledger-signer.spec.ts contract-estimation-tests.spec.ts rpc-get-protocol-constants.spec.ts env: RUN_KATHMANDUNET_WITH_SECRET_KEY: true SECRET_KEY: edsk3RFgDiCt7tWB2oe96w1eRw72iYiiqZPLu9nnEY23MYRp2d8Kkx @@ -79,3 +79,49 @@ jobs: RPC_CACHE_MILLISECONDS: 0 TEZOS_BAKER: tz1VSUr8wwNhLAzempoch5d6hLRiTh8Cjcjb - run: docker kill my-sandbox + + integration-tests-flextesa-lima: + runs-on: ubuntu-latest + continue-on-error: true + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 16 + - run: |- + export flextesa_docker_image='oxheadalpha/flextesa:20221123' + + export alice="$(docker run --rm ${flextesa_docker_image} flextesa key alice)" + export bob="$(docker run --rm ${flextesa_docker_image} flextesa key bob)" + export charlie="$(docker run --rm ${flextesa_docker_image} flextesa key charlie)" + export donald="$(docker run --rm ${flextesa_docker_image} flextesa key donald)" + + docker run + --rm + --name my-sandbox + --detach + -p 20001:20000 + oxheadalpha/flextesa:latest + --root /tmp/mini-box --size 1 \ + --set-history-mode N000:archive \ + --number-of-b 1 \ + --balance-of-bootstrap-accounts tez:100_000_000 \ + --time-b 1 \ + --add-bootstrap-account="$alice@2_000_000_000_000" \ + --add-bootstrap-account="$bob@2_000_000_000_000" \ + --add-bootstrap-account="$charlie@2_000_000_000_000" \ + --add-bootstrap-account="$donald@2_000_000_000_000" \ + --no-daemons-for=donald \ + --until-level 200_000_000 \ + --protocol-kind Lima + - run: npm ci + - run: npm run build + - run: npm -w integration-tests run test:limanet-secret-key -- contract-drain-delegate-operation.spec.ts + env: + RUN_LIMANET_WITH_SECRET_KEY: true + SECRET_KEY: edsk3RFgDiCt7tWB2oe96w1eRw72iYiiqZPLu9nnEY23MYRp2d8Kkx + TEZOS_RPC_LIMANET: http://0.0.0.0:20001 + POLLING_INTERVAL_MILLISECONDS: 100 + RPC_CACHE_MILLISECONDS: 0 + TEZOS_BAKER: tz1VSUr8wwNhLAzempoch5d6hLRiTh8Cjcjb + - run: docker kill my-sandbox diff --git a/integration-tests/contract-drain-delegate-operation.spec.ts b/integration-tests/contract-drain-delegate-operation.spec.ts index 2757d09530..813dc28ffe 100644 --- a/integration-tests/contract-drain-delegate-operation.spec.ts +++ b/integration-tests/contract-drain-delegate-operation.spec.ts @@ -1,9 +1,12 @@ +import { InMemorySigner } from "@taquito/signer"; import { TezosToolkit } from "@taquito/taquito"; import { CONFIGS } from "./config"; CONFIGS().forEach(({ lib, rpc, setup, createAddress }) => { const Tezos = lib; - const flextesanet = (rpc === 'http://0.0.0.0:20000') ? it : it.skip + const signer = new InMemorySigner('edsk3RgWvbKKA1atEUcaGwivge7QtckHkTL9nQJUXQKY5r8WKp4pF4'); + Tezos.setSignerProvider(signer); + const flextesanet = (rpc === 'http://0.0.0.0:20001') ? it : it.skip describe(`Test drain delegate with defaul consensus key through contract api using: ${rpc}`, () => { let delegate: TezosToolkit @@ -13,12 +16,12 @@ CONFIGS().forEach(({ lib, rpc, setup, createAddress }) => { await setup(true) try { - delegate = await createAddress() - delegatePkh = await delegate.signer.publicKeyHash() - const fund = await Tezos.contract.transfer({ amount: 5, to: delegatePkh}) - await fund.confirmation(); - const register = await delegate.contract.registerDelegate({}) - await register.confirmation() + // delegate = await createAddress() + // delegatePkh = await delegate.signer.publicKeyHash() + // const fund = await Tezos.contract.transfer({ amount: 5, to: delegatePkh}) + // await fund.confirmation(); + // const register = await Tezos.contract.registerDelegate({}) + // await register.confirmation() const destination = await createAddress() destinationPkh = await destination.signer.publicKeyHash() @@ -31,13 +34,13 @@ CONFIGS().forEach(({ lib, rpc, setup, createAddress }) => { }) flextesanet('Verify that new Account can be created, registered as delegate and drained itself', async (done) => { - expect((await delegate.rpc.getBalance(delegatePkh)).toNumber()).toBeGreaterThan(0) - await delegate.contract.drainDelegate({ + expect((await Tezos.rpc.getBalance(await signer.publicKeyHash())).toNumber()).toBeGreaterThan(0) + await Tezos.contract.drainDelegate({ consensus_key: destinationPkh, - delegate: delegatePkh, + delegate: await signer.publicKeyHash(), destination: destinationPkh, }) - expect((await delegate.tz.getBalance(delegatePkh)).toNumber).toEqual(0) + expect((await delegate.tz.getBalance(await signer.publicKeyHash())).toNumber).toEqual(0) done(); }); }); From 7075fbd438c880fc168a946aa89443a22c46d37b Mon Sep 17 00:00:00 2001 From: Daniele Lisi <22307776+danielelisi@users.noreply.github.com> Date: Mon, 5 Dec 2022 16:57:14 -0800 Subject: [PATCH 2/2] Missing flextesa mini-net command --- .github/workflows/main.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9cb1a012c4..6f81525100 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -101,7 +101,8 @@ jobs: --name my-sandbox --detach -p 20001:20000 - oxheadalpha/flextesa:latest + oxheadalpha/flextesa:latest + flextesa mini-net --root /tmp/mini-box --size 1 \ --set-history-mode N000:archive \ --number-of-b 1 \