Skip to content

Commit

Permalink
Merge branch '2068-support-drain-delegate-operation-in-contract-api' …
Browse files Browse the repository at this point in the history
…of github.com:ecadlabs/taquito into 2068-support-drain-delegate-operation-in-contract-api
  • Loading branch information
hui-an-yang committed Dec 6, 2022
2 parents c9661fc + 7075fbd commit 3e483fa
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 13 deletions.
51 changes: 49 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand All @@ -79,3 +79,50 @@ 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
flextesa mini-net
--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
25 changes: 14 additions & 11 deletions integration-tests/contract-drain-delegate-operation.spec.ts
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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()
Expand All @@ -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();
});
});
Expand Down

0 comments on commit 3e483fa

Please sign in to comment.