-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added staking support in contract API, with unit and integration tests (
#2930) * added staking support in contract API, with unit and integration tests * updated ux to not require destination (for stake/unstake) and not require a param for finalize unstake * updated error message * addressed PR comments * remove wrong check * removed undefined check for a more general falsy check
- Loading branch information
Showing
13 changed files
with
1,455 additions
and
2 deletions.
There are no files selected for viewing
56 changes: 56 additions & 0 deletions
56
integration-tests/__tests__/contract/operations/staking.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,56 @@ | ||
import { CONFIGS } from "../../../config"; | ||
|
||
CONFIGS().forEach(({ lib, rpc, setup }) => { | ||
const Tezos = lib; | ||
|
||
describe(`Staking pseudo operations: ${rpc}`, () => { | ||
|
||
beforeAll(async () => { | ||
await setup(true); | ||
|
||
const delegateOp = await Tezos.contract.setDelegate({ | ||
delegate: 'tz1PZY3tEWmXGasYeehXYqwXuw2Z3iZ6QDnA', | ||
source: await Tezos.signer.publicKeyHash() | ||
}); | ||
|
||
await delegateOp.confirmation(); | ||
}); | ||
|
||
it('should throw an error when the destination specified is not the same as source', async () => { | ||
expect(async () => { | ||
const op = await Tezos.contract.stake({ | ||
amount: 0.1, | ||
to: 'tz1PZY3tEWmXGasYeehXYqwXuw2Z3iZ6QDnA' | ||
}); | ||
}).rejects.toThrow(); | ||
}); | ||
|
||
it('should be able to stake funds to a designated delegate', async () => { | ||
const op = await Tezos.contract.stake({ | ||
amount: 0.1 | ||
}); | ||
await op.confirmation(); | ||
|
||
expect(op.hash).toBeDefined(); | ||
expect(op.status).toEqual('applied'); | ||
}); | ||
|
||
it('should be able to unstake funds from a designated delegate', async () => { | ||
const op = await Tezos.contract.unstake({ | ||
amount: 0.1 | ||
}); | ||
await op.confirmation(); | ||
|
||
expect(op.hash).toBeDefined(); | ||
expect(op.status).toEqual('applied'); | ||
}); | ||
|
||
it('should be able to finalize_unstake funds from a designated delegate', async () => { | ||
const op = await Tezos.contract.finalizeUnstake({}); | ||
await op.confirmation(); | ||
|
||
expect(op.hash).toBeDefined(); | ||
expect(op.status).toEqual('applied'); | ||
}); | ||
}); | ||
}); |
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
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
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
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
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
Oops, something went wrong.