-
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.
feat: start support bytes conversion 2268 (#2316)
* feat: start support bytes conversion 2268 close #2268 * feat: add suport local-forging BYTES and NAT and tests' * chore: update test names --------- Co-authored-by: Zainen Suzuki <[email protected]>
- Loading branch information
Showing
10 changed files
with
123 additions
and
3 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
integration-tests/data/instructions-bytes-conversions-contracts.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,5 @@ | ||
import fs from 'fs'; | ||
import path from 'path'; | ||
|
||
export const bytesAndInt = fs.readFileSync(path.resolve(`${__dirname}/../../packages/taquito-michel-codec/test/contracts_016/opcodes/bytes_of_int.tz`)).toString(); | ||
export const bytesAndNat = fs.readFileSync(path.resolve(`${__dirname}/../../packages/taquito-michel-codec/test/contracts_016/opcodes/bytes_of_nat.tz`)).toString(); |
56 changes: 56 additions & 0 deletions
56
integration-tests/instructions-with-bytes-conversion.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"; | ||
import { Protocols } from "@taquito/taquito"; | ||
import { bytesAndInt, bytesAndNat } from "./data/instructions-bytes-conversions-contracts"; | ||
import { HttpResponseError } from "@taquito/http-utils"; | ||
|
||
CONFIGS().forEach(({ lib, protocol, setup }) => { | ||
const Tezos = lib; | ||
const limanet = protocol === Protocols.PtLimaPtL ? test : test.skip; | ||
const mumbaiAndAlpha = protocol === Protocols.PtMumbaii || protocol === Protocols.ProtoALpha ? test : test.skip; | ||
|
||
describe(`Test origination of contract with instructions now supporting bytes conversion`, () => { | ||
|
||
beforeEach(async (done) => { | ||
await setup(); | ||
done(); | ||
}); | ||
|
||
mumbaiAndAlpha(`Should be able to originate a contract with BYTES -> INT -> BYTES instructions`, async done => { | ||
const contract = await Tezos.contract.originate({ | ||
code: bytesAndInt, | ||
storage: 0 | ||
}); | ||
await contract.confirmation(); | ||
expect(contract).toBeDefined(); | ||
expect(contract.contractAddress).toContain("KT1"); | ||
expect(contract.status).toEqual('applied'); | ||
done(); | ||
}); | ||
|
||
mumbaiAndAlpha(`Should be able to originate a contract with BYTES -> NAT -> BYTES instructions`, async done => { | ||
const contract = await Tezos.contract.originate({ | ||
code: bytesAndNat, | ||
storage: 0 | ||
}); | ||
await contract.confirmation(); | ||
expect(contract).toBeDefined(); | ||
expect(contract.contractAddress).toContain("KT1"); | ||
expect(contract.status).toEqual('applied'); | ||
done(); | ||
}); | ||
|
||
limanet('Should fail with non-supported BYTES and NAT instructions', async (done) => { | ||
try { | ||
const contract = await Tezos.contract.originate({ | ||
code: bytesAndInt, | ||
storage: 0 | ||
}); | ||
await contract.confirmation(); | ||
} catch (err) { | ||
expect(err).toBeInstanceOf(HttpResponseError); | ||
} | ||
done(); | ||
}); | ||
|
||
}); | ||
}); |
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
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
25 changes: 25 additions & 0 deletions
25
packages/taquito-michel-codec/test/contracts_016/opcodes/bytes_of_int.tz
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,25 @@ | ||
parameter unit; | ||
storage unit; | ||
code { DROP; | ||
|
||
PUSH int 0; BYTES; PUSH bytes 0x; ASSERT_CMPEQ; | ||
PUSH int 1; BYTES; PUSH bytes 0x01; ASSERT_CMPEQ; | ||
PUSH int 1193046; BYTES; PUSH bytes 0x123456; ASSERT_CMPEQ; | ||
|
||
PUSH bytes 0x123456; INT; PUSH int 1193046; ASSERT_CMPEQ; | ||
PUSH bytes 0x0000123456; INT; PUSH int 1193046; ASSERT_CMPEQ; | ||
PUSH bytes 0x; INT; PUSH int 0; ASSERT_CMPEQ; | ||
PUSH bytes 0x0000; INT; PUSH int 0; ASSERT_CMPEQ; | ||
|
||
PUSH int -128; BYTES; PUSH bytes 0x80; ASSERT_CMPEQ; | ||
PUSH int -129; BYTES; PUSH bytes 0xff7f; ASSERT_CMPEQ; | ||
PUSH int -33024; BYTES; PUSH bytes 0xff7f00; ASSERT_CMPEQ; | ||
PUSH int -4294967296; BYTES; PUSH bytes 0xff00000000; ASSERT_CMPEQ; | ||
|
||
PUSH bytes 0x80; INT; PUSH int -128; ASSERT_CMPEQ; | ||
PUSH bytes 0xff7f; INT; PUSH int -129; ASSERT_CMPEQ; | ||
PUSH bytes 0xff7f00; INT; PUSH int -33024; ASSERT_CMPEQ; | ||
PUSH bytes 0xffffff7f00; INT; PUSH int -33024; ASSERT_CMPEQ; | ||
PUSH bytes 0xff00000000; INT; PUSH int -4294967296; ASSERT_CMPEQ; | ||
|
||
UNIT; NIL operation; PAIR; } |
14 changes: 14 additions & 0 deletions
14
packages/taquito-michel-codec/test/contracts_016/opcodes/bytes_of_nat.tz
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,14 @@ | ||
parameter unit; | ||
storage unit; | ||
code { DROP; | ||
|
||
PUSH nat 0; BYTES; PUSH bytes 0x; ASSERT_CMPEQ; | ||
PUSH nat 1; BYTES; PUSH bytes 0x01; ASSERT_CMPEQ; | ||
PUSH nat 1193046; BYTES; PUSH bytes 0x123456; ASSERT_CMPEQ; | ||
|
||
PUSH bytes 0x123456; NAT; PUSH nat 1193046; ASSERT_CMPEQ; | ||
PUSH bytes 0x0000123456; NAT; PUSH nat 1193046; ASSERT_CMPEQ; | ||
PUSH bytes 0x; NAT; PUSH nat 0; ASSERT_CMPEQ; | ||
PUSH bytes 0x0000; NAT; PUSH nat 0; ASSERT_CMPEQ; | ||
|
||
UNIT; NIL operation; PAIR; } |