-
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.
Merge branch 'paris' of https://github.com/ecadlabs/taquito into pari…
…sb-primitives
- Loading branch information
Showing
52 changed files
with
3,154 additions
and
665 deletions.
There are no files selected for viewing
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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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'); | ||
}); | ||
}); | ||
}); |
39 changes: 39 additions & 0 deletions
39
integration-tests/__tests__/pseudo-entrypoints-forging.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,39 @@ | ||
import { CONFIGS } from "../config"; | ||
import { DefaultContractType, UnitValue } from "@taquito/taquito"; | ||
import { LocalForger, ProtocolsHash } from '@taquito/local-forging' | ||
|
||
CONFIGS().forEach(({ rpc, protocol, setup, lib }) => { | ||
const Tezos = lib; | ||
|
||
describe(`Test forging pseudo entrypoints: ${rpc}`, () => { | ||
let contract: DefaultContractType | ||
// for every new protocol need to check https://tezos.gitlab.io/shell/p2p_api.html#alpha-entrypoint-determined-from-data-8-bit-tag for the latest entrypoints and corresponding tag | ||
let entrypoint = { 0: 'default', 1: 'root', 2: 'do', 3: 'set_delegate', 4: 'remove_delegate', 5: 'deposit', 6: 'stake', 7: 'unstake', 8: 'finalize_unstake', 9: 'set_delegate_parameters' } | ||
|
||
beforeAll(async () => { | ||
await setup(); | ||
try { | ||
// for every new entrypoint will need to modify the contract code to have new entrypoint covered | ||
let op = await Tezos.contract.originate({ | ||
code: [{ "prim": "parameter", "args": [{ "prim": "or", "args": [{ "prim": "unit", "annots": ["%default"] }, { "prim": "or", "args": [{ "prim": "unit", "annots": ["%root"] }, { "prim": "or", "args": [{ "prim": "unit", "annots": ["%do"] }, { "prim": "or", "args": [{ "prim": "unit", "annots": ["%set_delegate"] }, { "prim": "or", "args": [{ "prim": "unit", "annots": ["%remove_delegate"] }, { "prim": "or", "args": [{ "prim": "unit", "annots": ["%deposit"] }, { "prim": "or", "args": [{ "prim": "unit", "annots": ["%stake"] }, { "prim": "or", "args": [{ "prim": "unit", "annots": ["%unstake"] }, { "prim": "or", "args": [{ "prim": "unit", "annots": ["%finalize_unstake"] }, { "prim": "unit", "annots": ["%set_delegate_parameters"] }] }] }] }] }] }] }] }] }] }] }, { "prim": "storage", "args": [{ "prim": "string" }] }, { "prim": "code", "args": [[{ "prim": "CAR" }, { "prim": "IF_LEFT", "args": [[{ "prim": "DROP" }, { "prim": "PUSH", "args": [{ "prim": "string" }, { "string": "default" }] }], [{ "prim": "IF_LEFT", "args": [[{ "prim": "DROP" }, { "prim": "PUSH", "args": [{ "prim": "string" }, { "string": "root" }] }], [{ "prim": "IF_LEFT", "args": [[{ "prim": "DROP" }, { "prim": "PUSH", "args": [{ "prim": "string" }, { "string": "do" }] }], [{ "prim": "IF_LEFT", "args": [[{ "prim": "DROP" }, { "prim": "PUSH", "args": [{ "prim": "string" }, { "string": "set_delegate" }] }], [{ "prim": "IF_LEFT", "args": [[{ "prim": "DROP" }, { "prim": "PUSH", "args": [{ "prim": "string" }, { "string": "remove_delegate" }] }], [{ "prim": "IF_LEFT", "args": [[{ "prim": "DROP" }, { "prim": "PUSH", "args": [{ "prim": "string" }, { "string": "deposit" }] }], [{ "prim": "IF_LEFT", "args": [[{ "prim": "DROP" }, { "prim": "PUSH", "args": [{ "prim": "string" }, { "string": "stake" }] }], [{ "prim": "IF_LEFT", "args": [[{ "prim": "DROP" }, { "prim": "PUSH", "args": [{ "prim": "string" }, { "string": "unstake" }] }], [{ "prim": "IF_LEFT", "args": [[{ "prim": "DROP" }, { "prim": "PUSH", "args": [{ "prim": "string" }, { "string": "finalize_unstake" }] }], [{ "prim": "DROP" }, { "prim": "PUSH", "args": [{ "prim": "string" }, { "string": "set_delegate_parameters" }] }]] }]] }]] }]] }]] }]] }]] }]] }]] }, { "prim": "NIL", "args": [{ "prim": "operation" }] }, { "prim": "PAIR" }]] }], | ||
storage: 'init' | ||
}) | ||
await op.confirmation(); | ||
contract = await op.contract(); | ||
} catch(e) {console.log(e)} | ||
}) | ||
|
||
Object.values(entrypoint).forEach(name => { | ||
it(`Verify that local forge will return same result as for rpc forge for entrypoints name ${name}`, async () => { | ||
const localForger = new LocalForger(protocol as unknown as ProtocolsHash); | ||
const methodObject = await contract.methodsObject[name](UnitValue) | ||
const prepared = await Tezos.prepare.contractCall(methodObject) | ||
const operation = Tezos.prepare.toForge(prepared) | ||
const result = await localForger.forge(operation); | ||
const rpcResult = await Tezos.rpc.forgeOperations(operation); | ||
expect(result).toEqual(rpcResult); | ||
}); | ||
}) | ||
|
||
}); | ||
}); |
Oops, something went wrong.