-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: added integraiton test of drain_delegate
re #2068
- Loading branch information
1 parent
8d20a01
commit c9661fc
Showing
1 changed file
with
44 additions
and
0 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
integration-tests/contract-drain-delegate-operation.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}); | ||
}); | ||
}) |