Skip to content

Commit

Permalink
test: added integraiton test of drain_delegate
Browse files Browse the repository at this point in the history
  • Loading branch information
hui-an-yang committed Dec 6, 2022
1 parent 8d20a01 commit c9661fc
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions integration-tests/contract-drain-delegate-operation.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
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

describe(`Test drain delegate with defaul consensus key through contract api using: ${rpc}`, () => {
let delegate: TezosToolkit
let delegatePkh: string
let destinationPkh: string
beforeAll(async (done) => {
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()

const destination = await createAddress()
destinationPkh = await destination.signer.publicKeyHash()
const consensus = await delegate.contract.updateConsensusKey({pk: await destination.signer.publicKey()})
await consensus.confirmation()
} catch(e) {
console.log(JSON.stringify(e))
}
done();
})
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({
consensus_key: destinationPkh,
delegate: delegatePkh,
destination: destinationPkh,
})
expect((await delegate.tz.getBalance(delegatePkh)).toNumber).toEqual(0)
done();
});
});
})

0 comments on commit c9661fc

Please sign in to comment.